mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 18:39:17 +00:00
3.2.3.3
This commit is contained in:
@@ -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<Chunk> asyncGetChunk = location.getWorld().getChunkAtAsync(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
if (itemMode == ItemMode.ITEM_FRAME || itemMode == ItemMode.ITEM_DISPLAY) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user