mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
1.5.22
This commit is contained in:
@@ -133,12 +133,12 @@ public class SprinklerManager {
|
||||
String[] split = StringUtils.split(chunk,",");
|
||||
if (world.isChunkLoaded(Integer.parseInt(split[0]), Integer.parseInt(split[1]))) {
|
||||
data.getConfigurationSection(worldName + "." + chunk).getValues(false).forEach((key, value) -> {
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
if (value instanceof MemorySection map){
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
bukkitScheduler.runTask(CustomCrops.instance, ()->{
|
||||
int water = (int) map.get("water");
|
||||
int range = (int) map.get("range");
|
||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||
if(!IAFurniture.getFromLocation(location, world)){
|
||||
data.set(worldName + "." + chunk + "." + key, null);
|
||||
return;
|
||||
@@ -196,7 +196,7 @@ public class SprinklerManager {
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
bukkitScheduler.callSyncMethod(CustomCrops.instance, ()->{
|
||||
int water = (int) map.get("water");
|
||||
int range = (int) map.get("range");
|
||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||
if (water > 0){
|
||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
||||
@@ -241,11 +241,11 @@ public class SprinklerManager {
|
||||
String[] split = StringUtils.split(chunk,",");
|
||||
if (world.isChunkLoaded(Integer.parseInt(split[0]), Integer.parseInt(split[1]))) {
|
||||
data.getConfigurationSection(worldName + "." + chunk).getValues(false).forEach((key, value) -> {
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
if (value instanceof MemorySection map){
|
||||
int water = (int) map.get("water");
|
||||
int range = (int) map.get("range");
|
||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
bukkitScheduler.runTask(CustomCrops.instance, ()->{
|
||||
if(!IAFurniture.getFromLocation(location, world)){
|
||||
data.set(worldName + "." + chunk + "." + key, null);
|
||||
@@ -275,11 +275,11 @@ public class SprinklerManager {
|
||||
return;
|
||||
}
|
||||
if (!players.contains(player)) return;
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
int water = (int) map.get("water");
|
||||
int range = (int) map.get("range");
|
||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||
if (water > 0){
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
||||
for(int i = -range; i <= range; i++){
|
||||
@@ -319,12 +319,12 @@ public class SprinklerManager {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
data.getConfigurationSection(worldName).getKeys(false).forEach(chunk ->{
|
||||
data.getConfigurationSection(worldName + "." + chunk).getValues(false).forEach((key, value) -> {
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
if (value instanceof MemorySection map){
|
||||
int water = (int) map.get("water");
|
||||
int range = (int) map.get("range");
|
||||
int range = (int) Optional.ofNullable(map.get("range")).orElse(0);
|
||||
if (water > 0){
|
||||
String[] coordinate = StringUtils.split(key, ",");
|
||||
Location location = new Location(world,Double.parseDouble(coordinate[0])+0.5,Double.parseDouble(coordinate[1])+0.5,Double.parseDouble(coordinate[2])+0.5);
|
||||
data.set(worldName + "." + chunk + "." + key + ".water", water - 1);
|
||||
bukkitScheduler.runTaskLater(CustomCrops.instance, ()-> {
|
||||
for(int i = -range; i <= range; i++){
|
||||
@@ -348,6 +348,7 @@ public class SprinklerManager {
|
||||
if(ConfigReader.Config.logTime) AdventureManager.consoleMessage("性能监测: 洒水器数据保存" + (time4-time3) + "ms");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 所有世界的洒水器工作
|
||||
*/
|
||||
|
||||
@@ -82,13 +82,14 @@ public class InteractEntity implements Listener {
|
||||
}
|
||||
sprinkler.setWater(currentWater);
|
||||
}else {
|
||||
String path = world + "." + x / 16 + "," + z / 16 + "." + x + "," + location.getBlockY() + "," + z + ".water";
|
||||
currentWater = plugin.getSprinklerManager().data.getInt(path);
|
||||
String path = world + "." + x / 16 + "," + z / 16 + "." + x + "," + location.getBlockY() + "," + z ;
|
||||
currentWater = plugin.getSprinklerManager().data.getInt(path+ ".water");
|
||||
currentWater += ConfigReader.Config.sprinklerRefill;
|
||||
if (currentWater > maxWater){
|
||||
currentWater = maxWater;
|
||||
}
|
||||
plugin.getSprinklerManager().data.set(path, currentWater);
|
||||
plugin.getSprinklerManager().data.set(path + ".water", currentWater);
|
||||
plugin.getSprinklerManager().data.set(path + ".range", config.getRange());
|
||||
}
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.addWaterToSprinklerSource, ConfigReader.Sounds.addWaterToSprinklerKey);
|
||||
}
|
||||
|
||||
@@ -130,14 +130,16 @@ public class RightClick implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(location.getBlock().getType() != Material.AIR){
|
||||
if (location.getBlock().getType() != Material.AIR){
|
||||
return;
|
||||
}
|
||||
if(CropsPerChunk.isLimited(location)){
|
||||
if (CropsPerChunk.isLimited(location)){
|
||||
AdventureManager.playerMessage(player,ConfigReader.Message.prefix + ConfigReader.Message.crop_limit.replace("{max}", String.valueOf(ConfigReader.Config.cropLimit)));
|
||||
return;
|
||||
}
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
CropManager.Cache.put(location, player.getName());
|
||||
CustomBlock.place((nbtCompound.getString("namespace") + ":" + cropName + "_stage_1"), location);
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.plantSeedSource, ConfigReader.Sounds.plantSeedKey);
|
||||
@@ -244,18 +246,24 @@ public class RightClick implements Listener {
|
||||
AdventureManager.playerMessage(player, ConfigReader.Message.prefix + ConfigReader.Message.beforePlant);
|
||||
return;
|
||||
}else {
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
|
||||
addFertilizer(fertilizerConfig, block.getLocation());
|
||||
}
|
||||
}else {
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
|
||||
addFertilizer(fertilizerConfig, block.getLocation());
|
||||
}
|
||||
}else if (namespacedID.contains("_stage_")){
|
||||
if (!fertilizerConfig.isBefore()){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
addFertilizer(fertilizerConfig, block.getLocation().subtract(0,1,0));
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.useFertilizerSource, ConfigReader.Sounds.useFertilizerKey);
|
||||
}else {
|
||||
@@ -280,7 +288,9 @@ public class RightClick implements Listener {
|
||||
}
|
||||
Sprinkler sprinklerData = new Sprinkler(sprinkler.getRange(), 0);
|
||||
sprinklerData.setPlayer(player.getName());
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
SimpleLocation simpleLocation = SimpleLocation.fromLocation(location.add(0,1,0));
|
||||
SprinklerManager.Cache.put(simpleLocation, sprinklerData);
|
||||
SprinklerManager.RemoveCache.remove(simpleLocation);
|
||||
@@ -334,7 +344,9 @@ public class RightClick implements Listener {
|
||||
String next = StringUtils.chop(namespacedID) + nextStage;
|
||||
if (CustomBlock.getInstance(next) != null){
|
||||
Location location = block.getLocation();
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (player.getGameMode() != GameMode.CREATIVE){
|
||||
itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
}
|
||||
AdventureManager.playerSound(player, ConfigReader.Sounds.boneMealSource, ConfigReader.Sounds.boneMealKey);
|
||||
if (Math.random() < ConfigReader.Config.boneMealChance){
|
||||
CustomBlock.remove(location);
|
||||
|
||||
Reference in New Issue
Block a user