From b383cc6140901f3f2b0a2fa9925bf9b53d908719 Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Sun, 4 Jun 2023 23:27:17 +0800 Subject: [PATCH] 3.2.3.3 --- build.gradle | 14 +---------- .../api/object/action/ReplantImpl.java | 23 ++++++++----------- .../api/object/action/SoundActionImpl.java | 4 +++- .../api/object/crop/CropManager.java | 3 ++- .../object/fertilizer/FertilizerManager.java | 3 ++- .../api/object/pot/PotManager.java | 5 ++-- .../object/sprinkler/SprinklerManager.java | 7 +++--- .../wateringcan/WateringCanManager.java | 3 ++- .../customcrops/api/util/ConfigUtils.java | 18 +++++++-------- .../command/subcmd/ConvertCommand.java | 3 ++- .../command/subcmd/SetSeasonCommand.java | 3 ++- .../integration/item/MMOItemsItemImpl.java | 4 +++- src/main/resources/config.yml | 2 +- 13 files changed, 43 insertions(+), 49 deletions(-) diff --git a/build.gradle b/build.gradle index f7b38cb..d329615 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '3.2.3.2' +version = '3.2.3.3' repositories { mavenCentral() @@ -25,7 +25,6 @@ repositories { dependencies { compileOnly ('dev.dejvokep:boosted-yaml:1.3') - compileOnly ('com.github.Archy-X:AureliumSkills:Beta1.3.18') compileOnly ('commons-io:commons-io:2.11.0') compileOnly ('dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT') compileOnly ('io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT') @@ -47,16 +46,6 @@ dependencies { implementation fileTree (dir:'libs',includes:['BiomeAPI.jar','ProtectionLib.jar']) } -def targetJavaVersion = 17 -java { - def javaVersion = JavaVersion.toVersion(targetJavaVersion) - sourceCompatibility = javaVersion - targetCompatibility = javaVersion - if (JavaVersion.current() < javaVersion) { - toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) - } -} - processResources { def props = [version: version] inputs.properties props @@ -68,7 +57,6 @@ processResources { tasks.withType(JavaCompile).configureEach { options.encoding = "UTF-8" - options.release = targetJavaVersion } shadowJar { diff --git a/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java b/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java index 919f26d..3f076f4 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/action/ReplantImpl.java @@ -59,20 +59,15 @@ public class ReplantImpl implements Action { return; } if (player != null) { - // Though the task is executed on main thread - // But it still needs slight delay to prevent crop loots from doubled when clicking with both left and right click - // It's still unsure how it happens - CustomCrops.getInstance().getScheduler().runTask(() -> { - CropPlantEvent cropPlantEvent = new CropPlantEvent(player, player.getInventory().getItemInMainHand(), location, crop, point, model); - Bukkit.getPluginManager().callEvent(cropPlantEvent); - if (cropPlantEvent.isCancelled()) { - return; - } - if (!CustomCrops.getInstance().getPlatformInterface().detectAnyThing(location)) { - CustomCrops.getInstance().getPlatformInterface().placeCustomItem(location, model, newCMode); - CustomCrops.getInstance().getWorldDataManager().addCropData(cropLoc, new GrowingCrop(crop, point), true); - } - }); + CropPlantEvent cropPlantEvent = new CropPlantEvent(player, player.getInventory().getItemInMainHand(), location, crop, point, model); + Bukkit.getPluginManager().callEvent(cropPlantEvent); + if (cropPlantEvent.isCancelled()) { + return; + } + if (!CustomCrops.getInstance().getPlatformInterface().detectAnyThing(location)) { + CustomCrops.getInstance().getPlatformInterface().placeCustomItem(location, model, newCMode); + CustomCrops.getInstance().getWorldDataManager().addCropData(cropLoc, new GrowingCrop(crop, point), true); + } } else { CompletableFuture asyncGetChunk = location.getWorld().getChunkAtAsync(location.getBlockX() >> 4, location.getBlockZ() >> 4); if (itemMode == ItemMode.ITEM_FRAME || itemMode == ItemMode.ITEM_DISPLAY) { diff --git a/src/main/java/net/momirealms/customcrops/api/object/action/SoundActionImpl.java b/src/main/java/net/momirealms/customcrops/api/object/action/SoundActionImpl.java index a995bfa..e44b76e 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/action/SoundActionImpl.java +++ b/src/main/java/net/momirealms/customcrops/api/object/action/SoundActionImpl.java @@ -25,11 +25,13 @@ import net.momirealms.customcrops.api.util.AdventureUtils; import org.bukkit.entity.Player; import org.jetbrains.annotations.Nullable; +import java.util.Locale; + public record SoundActionImpl(String source, String sound, float volume, float pitch) implements Action { @Override public void doOn(@Nullable Player player, @Nullable SimpleLocation cropLoc, ItemMode itemMode) { if (player == null) return; - AdventureUtils.playerSound(player, Sound.Source.valueOf(source.toUpperCase()), Key.key(sound), volume, pitch); + AdventureUtils.playerSound(player, Sound.Source.valueOf(source.toUpperCase(Locale.ENGLISH)), Key.key(sound), volume, pitch); } } diff --git a/src/main/java/net/momirealms/customcrops/api/object/crop/CropManager.java b/src/main/java/net/momirealms/customcrops/api/object/crop/CropManager.java index c353d35..fdd1590 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/crop/CropManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/crop/CropManager.java @@ -42,6 +42,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.HashMap; import java.util.HashSet; +import java.util.Locale; public class CropManager extends Function implements Listener { @@ -91,7 +92,7 @@ public class CropManager extends Function implements Listener { for (String key : config.getKeys(false)) { ConfigurationSection cropSec = config.getConfigurationSection(key); if (cropSec == null) continue; - ItemMode itemMode = ItemMode.valueOf(cropSec.getString("type", "TripWire").toUpperCase()); + ItemMode itemMode = ItemMode.valueOf(cropSec.getString("type", "TripWire").toUpperCase(Locale.ENGLISH)); if (itemMode == ItemMode.TRIPWIRE && !hasCheckedTripwire) { checkTripwire(); } diff --git a/src/main/java/net/momirealms/customcrops/api/object/fertilizer/FertilizerManager.java b/src/main/java/net/momirealms/customcrops/api/object/fertilizer/FertilizerManager.java index c445716..9f58644 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/fertilizer/FertilizerManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/fertilizer/FertilizerManager.java @@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.Locale; public class FertilizerManager extends Function { @@ -93,7 +94,7 @@ public class FertilizerManager extends Function { ConfigurationSection fertilizerSec = config.getConfigurationSection(key); if (fertilizerSec == null) continue; FertilizerConfig fertilizerConfig; - FertilizerType fertilizerType = FertilizerType.valueOf(fertilizerSec.getString("type", "SPEED_GROW").toUpperCase()); + FertilizerType fertilizerType = FertilizerType.valueOf(fertilizerSec.getString("type", "SPEED_GROW").toUpperCase(Locale.ENGLISH)); String[] pot_whitelist = fertilizerSec.contains("pot-whitelist") ? fertilizerSec.getStringList("pot-whitelist").toArray(new String[0]) : null; boolean beforePlant = fertilizerSec.getBoolean("before-plant", false); int times = fertilizerSec.getInt("times", 14); diff --git a/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java b/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java index c1c991d..5031a6b 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/pot/PotManager.java @@ -33,6 +33,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.HashMap; +import java.util.Locale; public class PotManager extends Function { @@ -96,7 +97,7 @@ public class PotManager extends Function { section.getBoolean("hologram.fertilizer.enable", false) ? new FertilizerHologram( section.getString("hologram.fertilizer.content", ""), section.getDouble("hologram.fertilizer.vertical-offset"), - HologramManager.Mode.valueOf(section.getString("hologram.type", "ARMOR_STAND").toUpperCase()), + HologramManager.Mode.valueOf(section.getString("hologram.type", "ARMOR_STAND").toUpperCase(Locale.ENGLISH)), section.getInt("hologram.duration"), new TextDisplayMeta( section.getBoolean("hologram.text-display-options.has-shadow", false), @@ -109,7 +110,7 @@ public class PotManager extends Function { section.getBoolean("hologram.water.enable", false) ? new WaterAmountHologram( section.getString("hologram.water.content", ""), section.getDouble("hologram.water.vertical-offset"), - HologramManager.Mode.valueOf(section.getString("hologram.type", "ARMOR_STAND").toUpperCase()), + HologramManager.Mode.valueOf(section.getString("hologram.type", "ARMOR_STAND").toUpperCase(Locale.ENGLISH)), section.getInt("hologram.duration"), section.getString("hologram.water.water-bar.left"), section.getString("hologram.water.water-bar.full"), diff --git a/src/main/java/net/momirealms/customcrops/api/object/sprinkler/SprinklerManager.java b/src/main/java/net/momirealms/customcrops/api/object/sprinkler/SprinklerManager.java index d218fc3..5a9c50d 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/sprinkler/SprinklerManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/sprinkler/SprinklerManager.java @@ -42,6 +42,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.HashMap; +import java.util.Locale; public class SprinklerManager extends Function implements Listener { @@ -94,7 +95,7 @@ public class SprinklerManager extends Function implements Listener { } @Subst("namespace:key") String soundKey = sprinklerSec.getString("place-sound", "minecraft:block.bone_block.place"); Sound sound = sprinklerSec.contains("place-sound") ? Sound.sound(Key.key(soundKey), Sound.Source.PLAYER, 1, 1) : null; - ItemMode itemMode = ItemMode.valueOf(sprinklerSec.getString("type","ITEM_FRAME").toUpperCase()); + ItemMode itemMode = ItemMode.valueOf(sprinklerSec.getString("type","ITEM_FRAME").toUpperCase(Locale.ENGLISH)); SprinklerConfig sprinklerConfig = new SprinklerConfig( key, sprinklerSec.getInt("storage", 3), @@ -109,7 +110,7 @@ public class SprinklerManager extends Function implements Listener { sprinklerSec.getBoolean("hologram.enable") ? new WaterAmountHologram( sprinklerSec.getString("hologram.content",""), sprinklerSec.getDouble("hologram.vertical-offset"), - HologramManager.Mode.valueOf(sprinklerSec.getString("hologram.type", "ARMOR_STAND").toUpperCase()), + HologramManager.Mode.valueOf(sprinklerSec.getString("hologram.type", "ARMOR_STAND").toUpperCase(Locale.ENGLISH)), sprinklerSec.getInt("hologram.duration"), sprinklerSec.getString("hologram.water-bar.left"), sprinklerSec.getString("hologram.water-bar.full"), @@ -127,7 +128,7 @@ public class SprinklerManager extends Function implements Listener { sprinklerSec.getInt("animation.duration"), sprinklerSec.getString("animation.item"), sprinklerSec.getDouble("animation.vertical-offset"), - ItemMode.valueOf(sprinklerSec.getString("animation.type", "ARMOR_STAND").toUpperCase()) + ItemMode.valueOf(sprinklerSec.getString("animation.type", "ARMOR_STAND").toUpperCase(Locale.ENGLISH)) ) : null ); this.itemToKey.put(threeD, key); diff --git a/src/main/java/net/momirealms/customcrops/api/object/wateringcan/WateringCanManager.java b/src/main/java/net/momirealms/customcrops/api/object/wateringcan/WateringCanManager.java index e04e161..7b84b71 100644 --- a/src/main/java/net/momirealms/customcrops/api/object/wateringcan/WateringCanManager.java +++ b/src/main/java/net/momirealms/customcrops/api/object/wateringcan/WateringCanManager.java @@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.HashMap; import java.util.List; +import java.util.Locale; public class WateringCanManager extends Function { @@ -98,7 +99,7 @@ public class WateringCanManager extends Function { canSec.contains("pot-whitelist") ? canSec.getStringList("pot-whitelist").toArray(new String[0]) : null, canSec.contains("sprinkler-whitelist") ? canSec.getStringList("sprinkler-whitelist").toArray(new String[0]) : null, sound, - canSec.contains("particle") ? Particle.valueOf(canSec.getString("particle", "WATER_SPLASH").toUpperCase()) : null, + canSec.contains("particle") ? Particle.valueOf(canSec.getString("particle", "WATER_SPLASH").toUpperCase(Locale.ENGLISH)) : null, methods ); wateringCanConfigMap.put(canSec.getString("item"), wateringCanConfig); diff --git a/src/main/java/net/momirealms/customcrops/api/util/ConfigUtils.java b/src/main/java/net/momirealms/customcrops/api/util/ConfigUtils.java index 531b19d..60f2edc 100644 --- a/src/main/java/net/momirealms/customcrops/api/util/ConfigUtils.java +++ b/src/main/java/net/momirealms/customcrops/api/util/ConfigUtils.java @@ -179,11 +179,11 @@ public class ConfigUtils { case "water_more_than" -> conditions.add(new WaterMoreThan(map2.getInt("value"))); case "unsuitable_season" -> { if (!ConfigManager.enableSeason) return; - conditions.add(new WrongSeason(map2.getStringList("value").stream().map(s -> CCSeason.valueOf(s.toUpperCase())).toList().toArray(new CCSeason[0]))); + conditions.add(new WrongSeason(map2.getStringList("value").stream().map(s -> CCSeason.valueOf(s.toUpperCase(Locale.ENGLISH))).toList().toArray(new CCSeason[0]))); } case "suitable_season" -> { if (!ConfigManager.enableSeason) return; - conditions.add(new RightSeason(map2.getStringList("value").stream().map(s -> CCSeason.valueOf(s.toUpperCase())).toList().toArray(new CCSeason[0]))); + conditions.add(new RightSeason(map2.getStringList("value").stream().map(s -> CCSeason.valueOf(s.toUpperCase(Locale.ENGLISH))).toList().toArray(new CCSeason[0]))); } case "crow_attack" -> conditions.add(new CrowAttack(map2.getDouble("value.chance"), map2.getString("value.fly-model"), map2.getString("value.stand-model"))); case "random" -> conditions.add(new Random(map2.getDouble("value"))); @@ -211,7 +211,7 @@ public class ConfigUtils { case "ypos" -> requirements.add(new YPosImpl(msg, innerSec.getStringList("value"))); case "season" -> { if (!ConfigManager.enableSeason) continue; - requirements.add(new SeasonImpl(msg, innerSec.getStringList("value").stream().map(str -> CCSeason.valueOf(str.toUpperCase())).collect(Collectors.toList()))); + requirements.add(new SeasonImpl(msg, innerSec.getStringList("value").stream().map(str -> CCSeason.valueOf(str.toUpperCase(Locale.ENGLISH))).collect(Collectors.toList()))); } case "world" -> requirements.add(new WorldImpl(msg, innerSec.getStringList("value"))); case "permission" -> requirements.add(new PermissionImpl(msg, innerSec.getString("value"))); @@ -272,12 +272,12 @@ public class ConfigUtils { (float) actionSec.getDouble("value.pitch")) ); case "particle" -> actions.add(new ParticleImpl( - Particle.valueOf(actionSec.getString("value.particle", "FLAME").toUpperCase()), + Particle.valueOf(actionSec.getString("value.particle", "FLAME").toUpperCase(Locale.ENGLISH)), actionSec.getInt("value.amount"), actionSec.getDouble("value.offset")) ); case "potion-effect" -> { - PotionEffectType potionEffectType = PotionEffectType.getByName(actionSec.getString("value.type", "BLINDNESS").toUpperCase()); + PotionEffectType potionEffectType = PotionEffectType.getByName(actionSec.getString("value.type", "BLINDNESS").toUpperCase(Locale.ENGLISH)); PotionEffect potionEffect = new PotionEffect( potionEffectType == null ? PotionEffectType.LUCK : potionEffectType, actionSec.getInt("value.duration"), @@ -329,7 +329,7 @@ public class ConfigUtils { for (String inner_key : variationSec.getKeys(false)) { VariationCrop variationCrop = new VariationCrop( variationSec.getString(inner_key + ".item"), - ItemMode.valueOf(variationSec.getString(inner_key + ".type", "TripWire").toUpperCase()), + ItemMode.valueOf(variationSec.getString(inner_key + ".type", "TripWire").toUpperCase(Locale.ENGLISH)), variationSec.getDouble(inner_key + ".chance") ); variationCrops.add(variationCrop); @@ -365,7 +365,7 @@ public class ConfigUtils { methodSec.getString("item"), methodSec.getString("return"), methodSec.getInt("amount", 1), - methodSec.contains("particle") ? Particle.valueOf(methodSec.getString("particle", "WATER_SPLASH").toUpperCase()) : null, + methodSec.contains("particle") ? Particle.valueOf(methodSec.getString("particle", "WATER_SPLASH").toUpperCase(Locale.ENGLISH)) : null, sound ); passiveFillMethods.add(passiveFillMethod); @@ -420,7 +420,7 @@ public class ConfigUtils { boneMealSec.getString("return"), pairs, sound, - boneMealSec.contains("particle") ? Particle.valueOf(boneMealSec.getString("particle", "WATER_SPLASH").toUpperCase()) : null + boneMealSec.contains("particle") ? Particle.valueOf(boneMealSec.getString("particle", "WATER_SPLASH").toUpperCase(Locale.ENGLISH)) : null ); boneMeals.add(boneMeal); } @@ -440,7 +440,7 @@ public class ConfigUtils { PositiveFillMethod method = new PositiveFillMethod( id, methodSec.getInt("amount"), - methodSec.contains("particle") ? Particle.valueOf(methodSec.getString("particle", "WATER_SPLASH").toUpperCase()) : null, + methodSec.contains("particle") ? Particle.valueOf(methodSec.getString("particle", "WATER_SPLASH").toUpperCase(Locale.ENGLISH)) : null, sound ); methods.add(method); diff --git a/src/main/java/net/momirealms/customcrops/command/subcmd/ConvertCommand.java b/src/main/java/net/momirealms/customcrops/command/subcmd/ConvertCommand.java index 5329011..470105e 100644 --- a/src/main/java/net/momirealms/customcrops/command/subcmd/ConvertCommand.java +++ b/src/main/java/net/momirealms/customcrops/command/subcmd/ConvertCommand.java @@ -11,6 +11,7 @@ import java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.List; +import java.util.Locale; public class ConvertCommand extends AbstractSubCommand { @@ -35,7 +36,7 @@ public class ConvertCommand extends AbstractSubCommand { confirm.remove(sender.getName()); - String mode = args.get(0).toUpperCase(); + String mode = args.get(0).toUpperCase(Locale.ENGLISH); String platform = CustomCrops.getInstance().getPlatform().name().toLowerCase(); YamlConfiguration oldConfig = YamlConfiguration.loadConfiguration(new File(CustomCrops.getInstance().getDataFolder(), "crops_" + platform + ".yml")); diff --git a/src/main/java/net/momirealms/customcrops/command/subcmd/SetSeasonCommand.java b/src/main/java/net/momirealms/customcrops/command/subcmd/SetSeasonCommand.java index 9f47e40..5bc67d6 100644 --- a/src/main/java/net/momirealms/customcrops/command/subcmd/SetSeasonCommand.java +++ b/src/main/java/net/momirealms/customcrops/command/subcmd/SetSeasonCommand.java @@ -29,6 +29,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.generator.WorldInfo; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; public class SetSeasonCommand extends AbstractSubCommand { @@ -48,7 +49,7 @@ public class SetSeasonCommand extends AbstractSubCommand { return true; } try { - CCSeason ccSeason = CCSeason.valueOf(args.get(1).toUpperCase()); + CCSeason ccSeason = CCSeason.valueOf(args.get(1).toUpperCase(Locale.ENGLISH)); SeasonData seasonData = CustomCrops.getInstance().getSeasonManager().unloadSeasonData(args.get(0)); if (seasonData == null) { AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.noSeason); diff --git a/src/main/java/net/momirealms/customcrops/integration/item/MMOItemsItemImpl.java b/src/main/java/net/momirealms/customcrops/integration/item/MMOItemsItemImpl.java index a862d6c..81064ea 100644 --- a/src/main/java/net/momirealms/customcrops/integration/item/MMOItemsItemImpl.java +++ b/src/main/java/net/momirealms/customcrops/integration/item/MMOItemsItemImpl.java @@ -24,6 +24,8 @@ import net.momirealms.customcrops.integration.ItemInterface; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Locale; + public class MMOItemsItemImpl implements ItemInterface { @Nullable @@ -32,7 +34,7 @@ public class MMOItemsItemImpl implements ItemInterface { if (!material.startsWith("MMOItems:")) return null; material = material.substring(9); String[] split = material.split(":", 2); - MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1].toUpperCase()); + MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1].toUpperCase(Locale.ENGLISH)); return mmoItem == null ? null : mmoItem.newBuilder().build(); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 29c6b65..d22bd07 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -120,6 +120,6 @@ other-settings: # MMOCore职业名 MMOCore-profession-name: 'farmer' # Enable corruption fixer - enable-corruption-fixer: true + enable-corruption-fixer: false # Fixed corrupted pots when interacting corrupt-fix-range: 4 \ No newline at end of file