mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 03:19:15 +00:00
[API] Add more annotations
This commit is contained in:
@@ -49,80 +49,294 @@ public interface ItemManager extends Reloadable {
|
||||
*/
|
||||
boolean unregisterItemLibrary(String identification);
|
||||
|
||||
/**
|
||||
* Get item's id by ItemStack
|
||||
* ItemsAdder: namespace:id
|
||||
* Oraxen: id
|
||||
* Vanilla: CAPITAL_ID
|
||||
* Other item libraries: LibraryID:ItemID
|
||||
*
|
||||
* @param itemStack item
|
||||
* @return ID
|
||||
*/
|
||||
String getItemID(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get item by ID
|
||||
* ItemsAdder: namespace:id
|
||||
* Oraxen: id
|
||||
* Vanilla: CAPITAL_ID
|
||||
* Other item libraries: LibraryID:ItemID
|
||||
*
|
||||
* @param player player
|
||||
* @param id id
|
||||
* @return item
|
||||
*/
|
||||
ItemStack getItemStack(Player player, String id);
|
||||
|
||||
/**
|
||||
* Place an item at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @param carrier carrier
|
||||
* @param id id
|
||||
*/
|
||||
void placeItem(Location location, ItemCarrier carrier, String id);
|
||||
|
||||
void placeItem(Location location, ItemCarrier carrier, String id, CRotation rotate);
|
||||
/**
|
||||
* Place an item at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @param carrier carrier
|
||||
* @param id id
|
||||
* @param rotation rotation
|
||||
*/
|
||||
void placeItem(Location location, ItemCarrier carrier, String id, CRotation rotation);
|
||||
|
||||
/**
|
||||
* Remove any block/entity from a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return the rotation of the removed entity
|
||||
*/
|
||||
CRotation removeAnythingAt(Location location);
|
||||
|
||||
/**
|
||||
* Get watering can config by ID
|
||||
*
|
||||
* @param id id
|
||||
* @return watering can config
|
||||
*/
|
||||
@Nullable
|
||||
WateringCan getWateringCanByID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get watering can config by item ID
|
||||
*
|
||||
* @param id item ID
|
||||
* @return watering can config
|
||||
*/
|
||||
@Nullable
|
||||
WateringCan getWateringCanByItemID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get watering can config by itemStack
|
||||
*
|
||||
* @param itemStack itemStack
|
||||
* @return watering can config
|
||||
*/
|
||||
@Nullable
|
||||
WateringCan getWateringCanByItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by ID
|
||||
*
|
||||
* @param id id
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerByID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by 3D item ID
|
||||
*
|
||||
* @param id 3D item ID
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerBy3DItemID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by 2D item ID
|
||||
*
|
||||
* @param id 2D item ID
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerBy2DItemID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by entity
|
||||
*
|
||||
* @param entity entity
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerByEntity(@NotNull Entity entity);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by block
|
||||
*
|
||||
* @param block block
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerByBlock(@NotNull Block block);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by 2D itemStack
|
||||
*
|
||||
* @param itemStack 2D itemStack
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerBy2DItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get sprinkler config by 3D itemStack
|
||||
*
|
||||
* @param itemStack 3D itemStack
|
||||
* @return sprinkler config
|
||||
*/
|
||||
@Nullable
|
||||
Sprinkler getSprinklerBy3DItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
@Nullable
|
||||
Sprinkler getSprinklerByItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get pot config by ID
|
||||
*
|
||||
* @param id id
|
||||
* @return pot config
|
||||
*/
|
||||
@Nullable
|
||||
Pot getPotByID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get pot config by block ID
|
||||
*
|
||||
* @param id block ID
|
||||
* @return pot config
|
||||
*/
|
||||
@Nullable
|
||||
Pot getPotByBlockID(@NotNull String id);
|
||||
|
||||
/**
|
||||
* Get pot config by block
|
||||
*
|
||||
* @param block block
|
||||
* @return pot config
|
||||
*/
|
||||
@Nullable
|
||||
Pot getPotByBlock(@NotNull Block block);
|
||||
|
||||
/**
|
||||
* Get pot config by block itemStack
|
||||
*
|
||||
* @param itemStack itemStack
|
||||
* @return pot config
|
||||
*/
|
||||
@Nullable
|
||||
Pot getPotByItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get fertilizer config by ID
|
||||
*
|
||||
* @param id id
|
||||
* @return fertilizer config
|
||||
*/
|
||||
@Nullable
|
||||
Fertilizer getFertilizerByID(String id);
|
||||
|
||||
/**
|
||||
* Get fertilizer config by item ID
|
||||
*
|
||||
* @param id item id
|
||||
* @return fertilizer config
|
||||
*/
|
||||
@Nullable
|
||||
Fertilizer getFertilizerByItemID(String id);
|
||||
|
||||
/**
|
||||
* Get fertilizer config by itemStack
|
||||
*
|
||||
* @param itemStack itemStack
|
||||
* @return fertilizer config
|
||||
*/
|
||||
@Nullable
|
||||
Fertilizer getFertilizerByItemStack(@NotNull ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get crop config by ID
|
||||
*
|
||||
* @param id id
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropByID(String id);
|
||||
|
||||
/**
|
||||
* Get crop config by seed ID
|
||||
*
|
||||
* @param id seed ID
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropBySeedID(String id);
|
||||
|
||||
/**
|
||||
* Get crop config by seed itemStack
|
||||
*
|
||||
* @param itemStack seed itemStack
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropBySeedItemStack(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get crop config by stage item ID
|
||||
*
|
||||
* @param id stage item ID
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropByStageID(String id);
|
||||
|
||||
/**
|
||||
* Get crop config by entity
|
||||
*
|
||||
* @param entity entity
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropByEntity(Entity entity);
|
||||
|
||||
/**
|
||||
* Get crop config by block
|
||||
*
|
||||
* @param block block
|
||||
* @return crop config
|
||||
*/
|
||||
@Nullable
|
||||
Crop getCropByBlock(Block block);
|
||||
|
||||
/**
|
||||
* Get crop stage config by stage ID
|
||||
*
|
||||
* @param id stage ID
|
||||
* @return crop stage config
|
||||
*/
|
||||
@Nullable
|
||||
Crop.Stage getCropStageByStageID(String id);
|
||||
|
||||
/**
|
||||
* Update a pot's block state
|
||||
*
|
||||
* @param location location
|
||||
* @param pot pot config
|
||||
* @param hasWater has water or not
|
||||
* @param fertilizer fertilizer
|
||||
*/
|
||||
void updatePotState(Location location, Pot pot, boolean hasWater, Fertilizer fertilizer);
|
||||
|
||||
/**
|
||||
* Get the pots that can be watered with a watering can
|
||||
*
|
||||
* @param baseLocation the clicked pot's location
|
||||
* @param width width of the working range
|
||||
* @param length length of the working range
|
||||
* @param yaw player's yaw
|
||||
* @param potID pot's ID
|
||||
* @return the pots that can be watered
|
||||
*/
|
||||
@NotNull
|
||||
Collection<Location> getPotInRange(Location baseLocation, int width, int length, float yaw, String potID);
|
||||
}
|
||||
|
||||
@@ -83,90 +83,327 @@ public interface WorldManager extends Reloadable {
|
||||
@NotNull
|
||||
Collection<? extends CustomCropsWorld> getCustomCropsWorlds();
|
||||
|
||||
/**
|
||||
* Get CustomCrops world by name
|
||||
*
|
||||
* @param name name
|
||||
* @return CustomCrops world
|
||||
*/
|
||||
@NotNull
|
||||
Optional<CustomCropsWorld> getCustomCropsWorld(@NotNull String name);
|
||||
|
||||
/**
|
||||
* Get CustomCrops world by Bukkit world
|
||||
*
|
||||
* @param world world
|
||||
* @return CustomCrops world
|
||||
*/
|
||||
@NotNull
|
||||
Optional<CustomCropsWorld> getCustomCropsWorld(@NotNull World world);
|
||||
|
||||
/**
|
||||
* Get sprinkler at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return sprinkler
|
||||
*/
|
||||
@NotNull
|
||||
Optional<WorldSprinkler> getSprinklerAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get pot at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return pot
|
||||
*/
|
||||
@NotNull
|
||||
Optional<WorldPot> getPotAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get crop at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return crop
|
||||
*/
|
||||
@NotNull
|
||||
Optional<WorldCrop> getCropAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get greenhouse glass at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return greenhouse glass
|
||||
*/
|
||||
@NotNull Optional<WorldGlass> getGlassAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get scarecrow at a certain location
|
||||
*
|
||||
* @param location location
|
||||
* @return scarecrow
|
||||
*/
|
||||
@NotNull Optional<WorldScarecrow> getScarecrowAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get any CustomCrops block at a certain location
|
||||
* The block can be crop, sprinkler and etc.
|
||||
*
|
||||
* @param location location
|
||||
* @return CustomCrops block
|
||||
*/
|
||||
Optional<CustomCropsBlock> getBlockAt(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Create crop data
|
||||
*
|
||||
* @param location location
|
||||
* @param crop crop config
|
||||
* @param point initial point
|
||||
* @return the crop data
|
||||
*/
|
||||
WorldCrop createCropData(SimpleLocation location, Crop crop, int point);
|
||||
|
||||
/**
|
||||
* Create crop data
|
||||
*
|
||||
* @param location location
|
||||
* @param crop crop config
|
||||
* @return the crop data
|
||||
*/
|
||||
default WorldCrop createCropData(SimpleLocation location, Crop crop) {
|
||||
return createCropData(location, crop, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create sprinkler data
|
||||
*
|
||||
* @param location location
|
||||
* @param sprinkler sprinkler config
|
||||
* @param water initial water
|
||||
* @return the sprinkler data
|
||||
*/
|
||||
WorldSprinkler createSprinklerData(SimpleLocation location, Sprinkler sprinkler, int water);
|
||||
|
||||
/**
|
||||
* Create sprinkler data
|
||||
*
|
||||
* @param location location
|
||||
* @param sprinkler sprinkler config
|
||||
* @return the sprinkler data
|
||||
*/
|
||||
default WorldSprinkler createSprinklerData(SimpleLocation location, Sprinkler sprinkler) {
|
||||
return createSprinklerData(location, sprinkler, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create pot data
|
||||
*
|
||||
* @param location location
|
||||
* @param pot pot config
|
||||
* @param water initial water
|
||||
* @param fertilizer fertilizer config
|
||||
* @param fertilizerTimes the remaining usages of the fertilizer
|
||||
* @return the pot data
|
||||
*/
|
||||
WorldPot createPotData(SimpleLocation location, Pot pot, int water, @Nullable Fertilizer fertilizer, int fertilizerTimes);
|
||||
|
||||
/**
|
||||
* Create pot data
|
||||
*
|
||||
* @param location location
|
||||
* @param pot pot config
|
||||
* @return the pot data
|
||||
*/
|
||||
default WorldPot createPotData(SimpleLocation location, Pot pot) {
|
||||
return createPotData(location, pot, 0, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Greenhouse glass data
|
||||
*
|
||||
* @param location location
|
||||
* @return the greenhouse glass data
|
||||
*/
|
||||
WorldGlass createGreenhouseGlassData(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Create scarecrow data
|
||||
*
|
||||
* @param location location
|
||||
* @return the scarecrow data
|
||||
*/
|
||||
WorldScarecrow createScarecrowData(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Add water to the sprinkler
|
||||
* This method would create new sprinkler data if the sprinkler data not exists in that place
|
||||
* This method would also update the sprinkler's model if it has models according to the water amount
|
||||
*
|
||||
* @param sprinkler sprinkler config
|
||||
* @param location location
|
||||
* @param amount amount of water
|
||||
*/
|
||||
void addWaterToSprinkler(@NotNull Sprinkler sprinkler, @NotNull SimpleLocation location, int amount);
|
||||
|
||||
/**
|
||||
* Add fertilizer to the pot
|
||||
* This method would create new pot data if the pot data not exists in that place
|
||||
* This method would update the pot's block state if it has appearance variations for different fertilizers
|
||||
*
|
||||
* @param pot pot config
|
||||
* @param fertilizer fertilizer config
|
||||
* @param location location
|
||||
*/
|
||||
void addFertilizerToPot(@NotNull Pot pot, @NotNull Fertilizer fertilizer, @NotNull SimpleLocation location);
|
||||
|
||||
void addWaterToPot(@NotNull Pot pot, @NotNull SimpleLocation location, int amount);
|
||||
/**
|
||||
* Add water to the pot
|
||||
* This method would create new pot data if the pot data not exists in that place
|
||||
* This method would update the pot's block state if it's dry
|
||||
*
|
||||
* @param pot pot config
|
||||
* @param amount amount of water
|
||||
* @param location location
|
||||
*/
|
||||
void addWaterToPot(@NotNull Pot pot, int amount, @NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Add points to a crop
|
||||
* This method would do nothing if the crop data not exists in that place
|
||||
* This method would change the stage of the crop and trigger the actions
|
||||
*
|
||||
* @param crop crop config
|
||||
* @param points points to add
|
||||
* @param location location
|
||||
*/
|
||||
void addPointToCrop(@NotNull Crop crop, int points, @NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Add greenhouse glass data
|
||||
*
|
||||
* @param glass glass data
|
||||
* @param location location
|
||||
*/
|
||||
void addGlassAt(@NotNull WorldGlass glass, @NotNull SimpleLocation location);
|
||||
|
||||
void addScarecrowAt(@NotNull WorldScarecrow scarecrow, @NotNull SimpleLocation location);
|
||||
|
||||
void removeSprinklerAt(@NotNull SimpleLocation location);
|
||||
|
||||
void removePotAt(@NotNull SimpleLocation location);
|
||||
|
||||
void removeCropAt(@NotNull SimpleLocation location);
|
||||
|
||||
boolean isReachLimit(SimpleLocation location, ItemType itemType);
|
||||
|
||||
/**
|
||||
* Add pot data
|
||||
*
|
||||
* @param pot pot data
|
||||
* @param location location
|
||||
*/
|
||||
void addPotAt(@NotNull WorldPot pot, @NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Add sprinkler data
|
||||
*
|
||||
* @param sprinkler sprinkler data
|
||||
* @param location location
|
||||
*/
|
||||
void addSprinklerAt(@NotNull WorldSprinkler sprinkler, @NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Add crop data
|
||||
*
|
||||
* @param crop crop data
|
||||
* @param location location
|
||||
*/
|
||||
void addCropAt(@NotNull WorldCrop crop, @NotNull SimpleLocation location);
|
||||
|
||||
void addPointToCrop(@NotNull Crop crop, @NotNull SimpleLocation location, int points);
|
||||
/**
|
||||
* Add scarecrow data
|
||||
*
|
||||
* @param scarecrow scarecrow data
|
||||
* @param location location
|
||||
*/
|
||||
void addScarecrowAt(@NotNull WorldScarecrow scarecrow, @NotNull SimpleLocation location);
|
||||
|
||||
void handleChunkLoad(Chunk bukkitChunk);
|
||||
/**
|
||||
* Remove sprinkler data from a certain location
|
||||
*
|
||||
* @param location location
|
||||
*/
|
||||
void removeSprinklerAt(@NotNull SimpleLocation location);
|
||||
|
||||
void handleChunkUnload(Chunk bukkitChunk);
|
||||
/**
|
||||
* Remove pot data from a certain location
|
||||
*
|
||||
* @param location location
|
||||
*/
|
||||
void removePotAt(@NotNull SimpleLocation location);
|
||||
|
||||
void saveChunkToCachedRegion(CustomCropsChunk chunk);
|
||||
|
||||
void saveRegionToFile(CustomCropsRegion region);
|
||||
/**
|
||||
* Remove crop data from a certain location
|
||||
*
|
||||
* @param location location
|
||||
*/
|
||||
void removeCropAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Remove greenhouse glass data from a certain location
|
||||
*
|
||||
* @param location location
|
||||
*/
|
||||
void removeGlassAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Remove scarecrow data from a certain location
|
||||
*
|
||||
* @param location location
|
||||
*/
|
||||
void removeScarecrowAt(@NotNull SimpleLocation location);
|
||||
|
||||
/**
|
||||
* If a certain type of item reached the limitation
|
||||
*
|
||||
* @param location location
|
||||
* @param itemType the type of the item
|
||||
* @return reached or not
|
||||
*/
|
||||
boolean isReachLimit(SimpleLocation location, ItemType itemType);
|
||||
|
||||
/**
|
||||
* Handle the load of a chunk
|
||||
* It's recommended to call world.getChunkAt(x,z), otherwise you have to manually control the load/unload process
|
||||
*
|
||||
* @param bukkitChunk chunk
|
||||
*/
|
||||
void handleChunkLoad(Chunk bukkitChunk);
|
||||
|
||||
/**
|
||||
* Handle the unload of a chunk
|
||||
*
|
||||
* @param bukkitChunk chunk
|
||||
*/
|
||||
void handleChunkUnload(Chunk bukkitChunk);
|
||||
|
||||
/**
|
||||
* Save a chunk to region (from memory to memory)
|
||||
*
|
||||
* @param chunk the chunk to save
|
||||
*/
|
||||
void saveChunkToCachedRegion(CustomCropsChunk chunk);
|
||||
|
||||
/**
|
||||
* Save a region to file (from memory to disk)
|
||||
*
|
||||
* @param region the region to save
|
||||
*/
|
||||
void saveRegionToFile(CustomCropsRegion region);
|
||||
|
||||
CustomCropsBlock removeAnythingAt(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* Get the world adaptor
|
||||
*
|
||||
* @return the world adaptor
|
||||
*/
|
||||
AbstractWorldAdaptor getWorldAdaptor();
|
||||
|
||||
/**
|
||||
* Save a world's season and date
|
||||
*
|
||||
* @param customCropsWorld the world to save
|
||||
*/
|
||||
void saveInfoData(CustomCropsWorld customCropsWorld);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user