mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-27 10:59:20 +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);
|
||||
}
|
||||
|
||||
@@ -409,6 +409,11 @@ public class ItemManagerImpl implements ItemManager {
|
||||
return Optional.ofNullable(customProvider.getEntityID(entity)).map(threeDItem2SprinklerMap::get).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprinkler getSprinklerByBlock(@NotNull Block block) {
|
||||
return Optional.ofNullable(customProvider.getBlockID(block)).map(threeDItem2SprinklerMap::get).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprinkler getSprinklerBy2DItemStack(@NotNull ItemStack itemStack) {
|
||||
return getSprinklerBy2DItemID(getItemID(itemStack));
|
||||
@@ -439,13 +444,6 @@ public class ItemManagerImpl implements ItemManager {
|
||||
return getPotByBlockID(getItemID(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprinkler getSprinklerByItemStack(@NotNull ItemStack itemStack) {
|
||||
if (itemStack.getType() == Material.AIR)
|
||||
return null;
|
||||
return getSprinklerBy2DItemID(getItemID(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fertilizer getFertilizerByID(@NotNull String id) {
|
||||
return id2FertilizerMap.get(id);
|
||||
@@ -566,7 +564,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
method.trigger(potState);
|
||||
pot.trigger(ActionTrigger.ADD_WATER, potState);
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(potLocation), method.getAmount());
|
||||
plugin.getWorldManager().addWaterToPot(pot, method.getAmount(), SimpleLocation.of(potLocation));
|
||||
} else {
|
||||
pot.trigger(ActionTrigger.FULL, potState);
|
||||
}
|
||||
@@ -607,7 +605,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
method.trigger(potState);
|
||||
pot.trigger(ActionTrigger.ADD_WATER, potState);
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(potLocation), method.getAmount());
|
||||
plugin.getWorldManager().addWaterToPot(pot, method.getAmount(), SimpleLocation.of(potLocation));
|
||||
} else {
|
||||
pot.trigger(ActionTrigger.FULL, potState);
|
||||
}
|
||||
@@ -873,7 +871,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
wateringCan.trigger(ActionTrigger.CONSUME_WATER, state);
|
||||
|
||||
for (Location location : waterEvent.getLocation()) {
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(location), wateringCan.getWater());
|
||||
plugin.getWorldManager().addWaterToPot(pot, wateringCan.getWater(), SimpleLocation.of(location));
|
||||
pot.trigger(ActionTrigger.ADD_WATER, new State(player, itemStack, location));
|
||||
}
|
||||
} else {
|
||||
@@ -955,7 +953,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
wateringCan.trigger(ActionTrigger.CONSUME_WATER, state);
|
||||
|
||||
for (Location location : waterEvent.getLocation()) {
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(location), wateringCan.getWater());
|
||||
plugin.getWorldManager().addWaterToPot(pot, wateringCan.getWater(), SimpleLocation.of(location));
|
||||
pot.trigger(ActionTrigger.ADD_WATER, new State(player, itemStack, location));
|
||||
}
|
||||
} else {
|
||||
@@ -1037,7 +1035,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
wateringCan.trigger(ActionTrigger.CONSUME_WATER, state);
|
||||
|
||||
for (Location location : waterEvent.getLocation()) {
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(location), wateringCan.getWater());
|
||||
plugin.getWorldManager().addWaterToPot(pot, wateringCan.getWater(), SimpleLocation.of(location));
|
||||
pot.trigger(ActionTrigger.ADD_WATER, new State(player, itemStack, location));
|
||||
}
|
||||
} else {
|
||||
@@ -1655,7 +1653,6 @@ public class ItemManagerImpl implements ItemManager {
|
||||
|
||||
// add data
|
||||
plugin.getWorldManager().addFertilizerToPot(pot, fertilizer, simpleLocation);
|
||||
updatePotState(location, pot, hasWater, fertilizer);
|
||||
if (interactBlockWrapper.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
}
|
||||
@@ -1723,7 +1720,6 @@ public class ItemManagerImpl implements ItemManager {
|
||||
|
||||
// add data
|
||||
plugin.getWorldManager().addFertilizerToPot(pot, fertilizer, simpleLocation);
|
||||
updatePotState(potLocation, pot, hasWater, fertilizer);
|
||||
if (interactBlockWrapper.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
}
|
||||
@@ -1783,7 +1779,6 @@ public class ItemManagerImpl implements ItemManager {
|
||||
|
||||
// add data
|
||||
plugin.getWorldManager().addFertilizerToPot(pot, fertilizer, simpleLocation);
|
||||
updatePotState(potLocation, pot, hasWater, fertilizer);
|
||||
if (furnitureWrapper.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||
itemInHand.setAmount(itemInHand.getAmount() - 1);
|
||||
}
|
||||
@@ -1962,7 +1957,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
method.trigger(potState);
|
||||
pot.trigger(ActionTrigger.ADD_WATER, potState);
|
||||
plugin.getWorldManager().addWaterToPot(pot, SimpleLocation.of(potLocation), method.getAmount());
|
||||
plugin.getWorldManager().addWaterToPot(pot, method.getAmount(), SimpleLocation.of(potLocation));
|
||||
} else {
|
||||
pot.trigger(ActionTrigger.FULL, potState);
|
||||
}
|
||||
@@ -1989,7 +1984,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
}
|
||||
boneMeal.trigger(cropState);
|
||||
plugin.getWorldManager().addPointToCrop(crop, SimpleLocation.of(cropLocation), boneMeal.getPoint());
|
||||
plugin.getWorldManager().addPointToCrop(crop, boneMeal.getPoint(), SimpleLocation.of(cropLocation));
|
||||
return FunctionResult.RETURN;
|
||||
}
|
||||
}
|
||||
@@ -2145,7 +2140,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
}
|
||||
method.trigger(state);
|
||||
pot.trigger(ActionTrigger.ADD_WATER, state);
|
||||
plugin.getWorldManager().addWaterToPot(pot, simpleLocation, method.getAmount());
|
||||
plugin.getWorldManager().addWaterToPot(pot, method.getAmount(), simpleLocation);
|
||||
} else {
|
||||
pot.trigger(ActionTrigger.FULL, state);
|
||||
return FunctionResult.CANCEL_EVENT_AND_RETURN;
|
||||
|
||||
@@ -294,7 +294,7 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
if (id.equals(itemID)) {
|
||||
storage.setAmount(storage.getAmount() - 1);
|
||||
boneMeal.trigger(new State(null, itemStack, location));
|
||||
CustomCropsPlugin.get().getWorldManager().addPointToCrop(config, simpleLocation, boneMeal.getPoint());
|
||||
CustomCropsPlugin.get().getWorldManager().addPointToCrop(config, boneMeal.getPoint(), simpleLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,8 +306,10 @@ public class CChunk implements CustomCropsChunk {
|
||||
memoryPot.setFertilizer(fertilizer);
|
||||
addBlockAt(memoryPot, location);
|
||||
CustomCropsPlugin.get().debug("When adding fertilizer to pot at " + location + ", the pot data doesn't exist.");
|
||||
CustomCropsPlugin.get().getItemManager().updatePotState(location.getBukkitLocation(), pot, false, fertilizer);
|
||||
} else {
|
||||
optionalWorldPot.get().setFertilizer(fertilizer);
|
||||
CustomCropsPlugin.get().getItemManager().updatePotState(location.getBukkitLocation(), pot, optionalWorldPot.get().getWater() > 0, fertilizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ public class CWorld implements CustomCropsWorld {
|
||||
if (chunk.isPresent()) {
|
||||
chunk.get().addPointToCrop(crop, location, points);
|
||||
} else {
|
||||
LogUtils.warn("Invalid operation: Adding points to crop in a not generated chunk");
|
||||
LogUtils.warn("Invalid operation: Adding point to crop in a not generated chunk");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,7 +335,8 @@ public class WorldManagerImpl implements WorldManager, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWaterToPot(@NotNull Pot pot, @NotNull SimpleLocation location, int amount) {
|
||||
public void addWaterToPot(@NotNull Pot pot, int amount, @NotNull SimpleLocation location) {
|
||||
if (amount <= 0) return;
|
||||
CWorld cWorld = loadedWorlds.get(location.getWorldName());
|
||||
if (cWorld == null) {
|
||||
LogUtils.warn("Unsupported operation: Adding water to pot in unloaded world " + location);
|
||||
@@ -375,7 +376,7 @@ public class WorldManagerImpl implements WorldManager, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPointToCrop(@NotNull Crop crop, @NotNull SimpleLocation location, int points) {
|
||||
public void addPointToCrop(@NotNull Crop crop, int points, @NotNull SimpleLocation location) {
|
||||
CWorld cWorld = loadedWorlds.get(location.getWorldName());
|
||||
if (cWorld == null) {
|
||||
LogUtils.warn("Unsupported operation: Adding point to crop in unloaded world " + location);
|
||||
|
||||
Reference in New Issue
Block a user