mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 00:19:24 +00:00
2.0-r3
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '2.0-r1-hotfix'
|
||||
version = '2.0-r3'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -77,6 +77,7 @@ public class ConfigUtil {
|
||||
if (CustomCrops.plugin.getCropManager() != null) {
|
||||
CustomCrops.plugin.getCropManager().loadMode();
|
||||
CustomCrops.plugin.getCropManager().loadSeason();
|
||||
CustomCrops.plugin.getCropManager().loadPacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,14 @@ public class MainConfig {
|
||||
public static boolean autoBackUp;
|
||||
public static boolean needSkyLight;
|
||||
public static int skyLightLevel;
|
||||
public static boolean enableWaterCanLore;
|
||||
public static boolean enablePacketLore;
|
||||
public static List<String> waterCanLore;
|
||||
public static String waterBarLeft;
|
||||
public static String waterBarFull;
|
||||
public static String waterBarEmpty;
|
||||
public static String waterBarRight;
|
||||
public static boolean topOrBottom;
|
||||
|
||||
public static void load() {
|
||||
ConfigUtil.update("config.yml");
|
||||
@@ -105,12 +113,15 @@ public class MainConfig {
|
||||
worlds[i] = Bukkit.getWorld(worldsName.get(i));
|
||||
}
|
||||
}
|
||||
if (worlds != null) {
|
||||
worldList = List.of(worlds);
|
||||
}
|
||||
else {
|
||||
|
||||
worldList = new ArrayList<>();
|
||||
for (World world : worlds) {
|
||||
if (world == null) continue;
|
||||
worldList.add(world);
|
||||
}
|
||||
|
||||
worlds = worldList.toArray(new World[0]);
|
||||
|
||||
cropMode = config.getString("mechanics.crops-mode", "tripwire").equals("tripwire");
|
||||
limitation = config.getBoolean("optimization.limitation.enable", true);
|
||||
wireAmount = config.getInt("optimization.limitation.tripwire-amount", 64);
|
||||
@@ -132,8 +143,8 @@ public class MainConfig {
|
||||
preventInWrongSeason = config.getBoolean("mechanics.prevent-plant-if-wrong-season", true);
|
||||
notifyInWrongSeason = config.getBoolean("mechanics.should-notify-if-wrong-season", true);
|
||||
|
||||
enableBoneMeal = config.getBoolean("mechanics.bone-meal", true);
|
||||
boneMealChance = config.getDouble("mechanics.chance", 0.5);
|
||||
enableBoneMeal = config.getBoolean("mechanics.bone-meal.enable", true);
|
||||
boneMealChance = config.getDouble("mechanics.bone-meal.chance", 0.5);
|
||||
|
||||
syncSeason = config.getBoolean("mechanics.season.sync-seasons.enable", false);
|
||||
syncWorld = Bukkit.getWorld(config.getString("mechanics.season.sync-seasons.world", "world"));
|
||||
@@ -144,7 +155,7 @@ public class MainConfig {
|
||||
enableAnimations = !config.getBoolean("optimization.disable-sprinkler-animation", false);
|
||||
|
||||
try {
|
||||
boneMealSuccess = Particle.valueOf(config.getString("mechanics.success-particle", "VILLAGER_HAPPY"));
|
||||
boneMealSuccess = Particle.valueOf(config.getString("mechanics.bone-meal.success-particle", "VILLAGER_HAPPY"));
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomCrops] Illegal Particle Argument for Bone Meal</red>");
|
||||
@@ -184,44 +195,53 @@ public class MainConfig {
|
||||
fertilizerInfoDuration = config.getInt("hologram.fertilizer-info.duration", 1);
|
||||
fertilizerInfo = config.getString("hologram.fertilizer-info.text", "<font:customcrops:default>{fertilizer}</font> <white>{times}<gray>/<white>{max_times}");
|
||||
|
||||
enableWaterCanLore = config.getBoolean("watering-can-lore.enable", true);
|
||||
enablePacketLore = config.getBoolean("watering-can-lore.packets.enable", true);
|
||||
topOrBottom = config.getBoolean("watering-can-lore.packets.top-or-bottom", true);
|
||||
waterCanLore = config.getStringList("watering-can-lore.lore");
|
||||
waterBarLeft = config.getString("watering-can-lore.water-bar.left", "<font:customcrops:default>뀂");
|
||||
waterBarFull = config.getString("watering-can-lore.water-bar.full", "뀁뀃");
|
||||
waterBarEmpty = config.getString("watering-can-lore.water-bar.empty", "뀁뀄");
|
||||
waterBarRight = config.getString("watering-can-lore.water-bar.right", "뀁뀅</font>");
|
||||
|
||||
antiGriefs = new ArrayList<>();
|
||||
if (config.getBoolean("config.integration.Residence",false)){
|
||||
if (config.getBoolean("integration.Residence",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Residence") == null) Log.warn("Failed to initialize Residence!");
|
||||
else {antiGriefs.add(new ResidenceHook());hookMessage("Residence");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.Kingdoms",false)){
|
||||
if (config.getBoolean("integration.Kingdoms",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Kingdoms") == null) Log.warn("Failed to initialize Kingdoms!");
|
||||
else {antiGriefs.add(new KingdomsXHook());hookMessage("Kingdoms");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.WorldGuard",false)){
|
||||
if (config.getBoolean("integration.WorldGuard",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) Log.warn("Failed to initialize WorldGuard!");
|
||||
else {antiGriefs.add(new WorldGuardHook());hookMessage("WorldGuard");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.GriefDefender",false)){
|
||||
if (config.getBoolean("integration.GriefDefender",false)){
|
||||
if(Bukkit.getPluginManager().getPlugin("GriefDefender") == null) Log.warn("Failed to initialize GriefDefender!");
|
||||
else {antiGriefs.add(new GriefDefenderHook());hookMessage("GriefDefender");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.PlotSquared",false)){
|
||||
if (config.getBoolean("integration.PlotSquared",false)){
|
||||
if(Bukkit.getPluginManager().getPlugin("PlotSquared") == null) Log.warn("Failed to initialize PlotSquared!");
|
||||
else {antiGriefs.add(new PlotSquaredHook());hookMessage("PlotSquared");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.Towny",false)){
|
||||
if (config.getBoolean("integration.Towny",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Towny") == null) Log.warn("Failed to initialize Towny!");
|
||||
else {antiGriefs.add(new TownyHook());hookMessage("Towny");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.Lands",false)){
|
||||
if (config.getBoolean("integration.Lands",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("Lands") == null) Log.warn("Failed to initialize Lands!");
|
||||
else {antiGriefs.add(new LandsHook());hookMessage("Lands");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.GriefPrevention",false)){
|
||||
if (config.getBoolean("integration.GriefPrevention",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("GriefPrevention") == null) Log.warn("Failed to initialize GriefPrevention!");
|
||||
else {antiGriefs.add(new GriefPreventionHook());hookMessage("GriefPrevention");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.CrashClaim",false)){
|
||||
if (config.getBoolean("integration.CrashClaim",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("CrashClaim") == null) Log.warn("Failed to initialize CrashClaim!");
|
||||
else {antiGriefs.add(new CrashClaimHook());hookMessage("CrashClaim");}
|
||||
}
|
||||
if (config.getBoolean("config.integration.BentoBox",false)){
|
||||
if (config.getBoolean("integration.BentoBox",false)){
|
||||
if (Bukkit.getPluginManager().getPlugin("BentoBox") == null) Log.warn("Failed to initialize BentoBox!");
|
||||
else {antiGriefs.add(new BentoBoxHook());hookMessage("BentoBox");}
|
||||
}
|
||||
@@ -276,6 +296,6 @@ public class MainConfig {
|
||||
}
|
||||
|
||||
private static void hookMessage(String plugin){
|
||||
AdventureUtil.consoleMessage("[CustomCrops] <gold>" + plugin + " <color:#FFEBCD>Hooked!");
|
||||
AdventureUtil.consoleMessage("[CustomCrops] <white>" + plugin + " Hooked!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
package net.momirealms.customcrops.integrations.customplugin;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.Function;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -74,6 +77,13 @@ public abstract class HandlerP extends Function {
|
||||
//null
|
||||
}
|
||||
|
||||
public boolean coolDownJudge(Player player) {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - 50)) < 50) return false;
|
||||
coolDown.put(player, time);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onInteractSprinkler(Location location, Player player, @Nullable ItemStack itemStack, Sprinkler config) {
|
||||
|
||||
CustomWorld customWorld = cropManager.getCustomWorld(location.getWorld());
|
||||
@@ -110,6 +120,11 @@ public abstract class HandlerP extends Function {
|
||||
}
|
||||
}
|
||||
else if (itemStack.getType() != Material.AIR) {
|
||||
|
||||
String canID = customInterface.getItemID(itemStack);
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(canID);
|
||||
if (canConfig != null) {
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
int canWater = nbtItem.getInteger("WaterAmount");
|
||||
if (canWater > 0) {
|
||||
@@ -121,7 +136,7 @@ public abstract class HandlerP extends Function {
|
||||
}
|
||||
|
||||
nbtItem.setInteger("WaterAmount", --canWater);
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
|
||||
int water = sprinkler.getWater() + MainConfig.wateringCanToSprinkler;
|
||||
if (water > config.getWater()) water = config.getWater();
|
||||
sprinkler.setWater(water);
|
||||
@@ -136,10 +151,6 @@ public abstract class HandlerP extends Function {
|
||||
}
|
||||
|
||||
if (MainConfig.enableActionBar) {
|
||||
String canID = customInterface.getItemID(itemStack);
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(canID);
|
||||
if (canConfig == null) return;
|
||||
|
||||
AdventureUtil.playerActionbar(
|
||||
player,
|
||||
(MainConfig.actionBarLeft +
|
||||
@@ -150,6 +161,17 @@ public abstract class HandlerP extends Function {
|
||||
.replace("{water}", String.valueOf(canWater))
|
||||
);
|
||||
}
|
||||
|
||||
if (MainConfig.enableWaterCanLore && !MainConfig.enablePacketLore) {
|
||||
addWaterLore(nbtItem, canConfig, canWater);
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
|
||||
if (MainConfig.enableWaterCanLore && MainConfig.enablePacketLore) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,7 +339,7 @@ public abstract class HandlerP extends Function {
|
||||
water += MainConfig.waterToWaterCan;
|
||||
if (water > config.getMax()) water = config.getMax();
|
||||
nbtItem.setInteger("WaterAmount", water);
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
|
||||
|
||||
if (SoundConfig.addWaterToCan.isEnable()) {
|
||||
AdventureUtil.playerSound(
|
||||
@@ -332,7 +354,17 @@ public abstract class HandlerP extends Function {
|
||||
player.getWorld().spawnParticle(Particle.WATER_SPLASH, block.getLocation().add(0.5,1, 0.5),10,0.1,0.1,0.1);
|
||||
}
|
||||
|
||||
if (MainConfig.enableWaterCanLore && !MainConfig.enablePacketLore) {
|
||||
addWaterLore(nbtItem, config, water);
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
|
||||
if (MainConfig.enableWaterCanLore && MainConfig.enablePacketLore) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -353,6 +385,24 @@ public abstract class HandlerP extends Function {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void addWaterLore(NBTItem nbtItem, WaterCan config, int water) {
|
||||
NBTCompound display = nbtItem.getCompound("display");
|
||||
List<String> lore = display.getStringList("Lore");
|
||||
lore.clear();
|
||||
for (String text : MainConfig.waterCanLore) {
|
||||
lore.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(
|
||||
text.replace("{water_bar}",
|
||||
MainConfig.waterBarLeft +
|
||||
MainConfig.waterBarFull.repeat(water) +
|
||||
MainConfig.waterBarEmpty.repeat(config.getMax() - water) +
|
||||
MainConfig.waterBarRight
|
||||
)
|
||||
.replace("{water}", String.valueOf(water))
|
||||
.replace("{max_water}", String.valueOf(config.getMax()))
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean useFertilizer(Location potLoc, String id, Player player, ItemStack itemStack) {
|
||||
Fertilizer fertilizer = FertilizerConfig.FERTILIZERS.get(id);
|
||||
if (fertilizer == null) return false;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.managers;
|
||||
package net.momirealms.customcrops.integrations.customplugin.itemsadder;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -23,6 +23,8 @@ import net.momirealms.customcrops.config.BasicItemConfig;
|
||||
import net.momirealms.customcrops.config.CropConfig;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.managers.CropModeInterface;
|
||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Gigantic;
|
||||
@@ -138,9 +138,9 @@ public abstract class ItemsAdderHandler extends HandlerP {
|
||||
}
|
||||
|
||||
private boolean useWateringCan(Location potLoc, String namespacedID, Player player, @NotNull CustomStack can) {
|
||||
WaterCan waterCan = WaterCanConfig.CANS.get(namespacedID);
|
||||
|
||||
if (waterCan == null) return false;
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(namespacedID);
|
||||
if (canConfig == null) return false;
|
||||
|
||||
ItemStack itemStack = can.getItemStack();
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
@@ -180,10 +180,6 @@ public abstract class ItemsAdderHandler extends HandlerP {
|
||||
}
|
||||
|
||||
if (MainConfig.enableActionBar) {
|
||||
String canID = customInterface.getItemID(itemStack);
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(canID);
|
||||
if (canConfig == null) return true;
|
||||
|
||||
AdventureUtil.playerActionbar(
|
||||
player,
|
||||
(MainConfig.actionBarLeft +
|
||||
@@ -195,8 +191,17 @@ public abstract class ItemsAdderHandler extends HandlerP {
|
||||
);
|
||||
}
|
||||
|
||||
if (MainConfig.enableWaterCanLore && !MainConfig.enablePacketLore) {
|
||||
addWaterLore(nbtItem, canConfig, water);
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
super.waterPot(waterCan.getWidth(), waterCan.getLength(), potLoc, player.getLocation().getYaw());
|
||||
|
||||
if (MainConfig.enableWaterCanLore && MainConfig.enablePacketLore) {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
super.waterPot(canConfig.getWidth(), canConfig.getLength(), potLoc, player.getLocation().getYaw());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.managers;
|
||||
package net.momirealms.customcrops.integrations.customplugin.itemsadder;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -23,6 +23,8 @@ import net.momirealms.customcrops.config.BasicItemConfig;
|
||||
import net.momirealms.customcrops.config.CropConfig;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.managers.CropModeInterface;
|
||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Gigantic;
|
||||
@@ -31,7 +33,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class ItemsAdderWireCropImpl implements CropModeInterface{
|
||||
public class ItemsAdderWireCropImpl implements CropModeInterface {
|
||||
|
||||
private final CropManager cropManager;
|
||||
private final CustomInterface customInterface;
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.managers;
|
||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -23,7 +23,8 @@ import net.momirealms.customcrops.config.BasicItemConfig;
|
||||
import net.momirealms.customcrops.config.CropConfig;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHook;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.managers.CropModeInterface;
|
||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Gigantic;
|
||||
@@ -136,8 +136,9 @@ public abstract class OraxenHandler extends HandlerP {
|
||||
}
|
||||
|
||||
private boolean useWateringCan(Location potLoc, String id, Player player, @NotNull ItemStack can) {
|
||||
WaterCan waterCan = WaterCanConfig.CANS.get(id);
|
||||
if (waterCan == null) return false;
|
||||
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(id);
|
||||
if (canConfig == null) return false;
|
||||
|
||||
NBTItem nbtItem = new NBTItem(can);
|
||||
int water = nbtItem.getInteger("WaterAmount");
|
||||
@@ -160,10 +161,6 @@ public abstract class OraxenHandler extends HandlerP {
|
||||
}
|
||||
|
||||
if (MainConfig.enableActionBar) {
|
||||
String canID = customInterface.getItemID(can);
|
||||
WaterCan canConfig = WaterCanConfig.CANS.get(canID);
|
||||
if (canConfig == null) return true;
|
||||
|
||||
AdventureUtil.playerActionbar(
|
||||
player,
|
||||
(MainConfig.actionBarLeft +
|
||||
@@ -175,8 +172,17 @@ public abstract class OraxenHandler extends HandlerP {
|
||||
);
|
||||
}
|
||||
|
||||
if (MainConfig.enableWaterCanLore && !MainConfig.enablePacketLore) {
|
||||
addWaterLore(nbtItem, canConfig, water);
|
||||
}
|
||||
|
||||
can.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
super.waterPot(waterCan.getWidth(), waterCan.getLength(), potLoc, player.getLocation().getYaw());
|
||||
|
||||
if (MainConfig.enableWaterCanLore && MainConfig.enablePacketLore) {
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
super.waterPot(canConfig.getWidth(), canConfig.getLength(), potLoc, player.getLocation().getYaw());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.managers;
|
||||
package net.momirealms.customcrops.integrations.customplugin.oraxen;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.crop.Crop;
|
||||
@@ -23,6 +23,8 @@ import net.momirealms.customcrops.config.BasicItemConfig;
|
||||
import net.momirealms.customcrops.config.CropConfig;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.managers.CropModeInterface;
|
||||
import net.momirealms.customcrops.objects.GiganticCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Gigantic;
|
||||
@@ -31,7 +33,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class OraxenWireCropImpl implements CropModeInterface{
|
||||
public class OraxenWireCropImpl implements CropModeInterface {
|
||||
|
||||
private final CropManager cropManager;
|
||||
private final CustomInterface customInterface;
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.integrations.skill;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.momirealms.customcrops.integrations.SkillXP;
|
||||
@@ -25,7 +26,7 @@ import org.bukkit.entity.Player;
|
||||
public class MMOCoreHook implements SkillXP {
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
Profession profession = net.Indyuce.mmocore.MMOCore.plugin.professionManager.get("farming");
|
||||
profession.giveExperience(net.Indyuce.mmocore.MMOCore.plugin.dataProvider.getDataManager().get(player), amount, null ,EXPSource.OTHER);
|
||||
Profession profession = MMOCore.plugin.professionManager.get("farming");
|
||||
profession.giveExperience(MMOCore.plugin.dataProvider.getDataManager().get(player), amount, null ,EXPSource.OTHER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,13 @@ import net.momirealms.customcrops.config.SeasonConfig;
|
||||
import net.momirealms.customcrops.config.SoundConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.ItemsAdderFrameHandler;
|
||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.ItemsAdderHook;
|
||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.ItemsAdderWireHandler;
|
||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenFrameHandler;
|
||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHook;
|
||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenWireHandler;
|
||||
import net.momirealms.customcrops.integrations.customplugin.itemsadder.*;
|
||||
import net.momirealms.customcrops.integrations.customplugin.oraxen.*;
|
||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
||||
import net.momirealms.customcrops.integrations.season.InternalSeason;
|
||||
import net.momirealms.customcrops.integrations.season.RealisticSeasonsHook;
|
||||
import net.momirealms.customcrops.integrations.season.SeasonInterface;
|
||||
import net.momirealms.customcrops.managers.listener.ItemSpawnListener;
|
||||
import net.momirealms.customcrops.managers.listener.WorldListener;
|
||||
import net.momirealms.customcrops.managers.listener.*;
|
||||
import net.momirealms.customcrops.managers.timer.CrowTask;
|
||||
import net.momirealms.customcrops.managers.timer.TimerTask;
|
||||
import net.momirealms.customcrops.objects.OtherLoot;
|
||||
@@ -75,6 +70,9 @@ public class CropManager extends Function {
|
||||
private SeasonInterface seasonInterface;
|
||||
private CustomInterface customInterface;
|
||||
private ArmorStandUtil armorStandUtil;
|
||||
private ContainerListener containerListener;
|
||||
private PlayerModeListener playerModeListener;
|
||||
private PlayerContainerListener playerContainerListener;
|
||||
private HandlerP handler;
|
||||
|
||||
public CropManager() {
|
||||
@@ -91,6 +89,7 @@ public class CropManager extends Function {
|
||||
|
||||
loadMode();
|
||||
loadSeason();
|
||||
loadPacket();
|
||||
|
||||
//load Worlds
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
@@ -149,6 +148,28 @@ public class CropManager extends Function {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadPacket() {
|
||||
if (this.containerListener != null) {
|
||||
CustomCrops.protocolManager.removePacketListener(containerListener);
|
||||
this.containerListener = null;
|
||||
}
|
||||
if (this.playerModeListener != null) {
|
||||
HandlerList.unregisterAll(playerModeListener);
|
||||
this.playerModeListener = null;
|
||||
}
|
||||
if (this.playerContainerListener != null) {
|
||||
CustomCrops.protocolManager.removePacketListener(playerContainerListener);
|
||||
this.playerContainerListener = null;
|
||||
}
|
||||
if (!MainConfig.enableWaterCanLore || !MainConfig.enablePacketLore) return;
|
||||
containerListener = new ContainerListener(this);
|
||||
CustomCrops.protocolManager.addPacketListener(containerListener);
|
||||
playerContainerListener = new PlayerContainerListener(handler);
|
||||
CustomCrops.protocolManager.addPacketListener(playerContainerListener);
|
||||
playerModeListener = new PlayerModeListener();
|
||||
Bukkit.getPluginManager().registerEvents(playerModeListener, CustomCrops.plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
super.unload();
|
||||
@@ -161,6 +182,7 @@ public class CropManager extends Function {
|
||||
}
|
||||
customWorlds.clear();
|
||||
if (this.seasonInterface != null) seasonInterface.unload();
|
||||
if (this.containerListener != null) CustomCrops.protocolManager.removePacketListener(containerListener);
|
||||
}
|
||||
|
||||
public void onItemSpawn(Item item) {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.momirealms.customcrops.managers.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.config.MainConfig;
|
||||
import net.momirealms.customcrops.config.WaterCanConfig;
|
||||
import net.momirealms.customcrops.integrations.customplugin.CustomInterface;
|
||||
import net.momirealms.customcrops.managers.CropManager;
|
||||
import net.momirealms.customcrops.objects.WaterCan;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContainerListener extends PacketAdapter {
|
||||
|
||||
private final CustomInterface customInterface;
|
||||
|
||||
public ContainerListener(CropManager cropManager) {
|
||||
super(CustomCrops.plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.WINDOW_ITEMS);
|
||||
this.customInterface = cropManager.getCustomInterface();
|
||||
}
|
||||
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
List<ItemStack> itemStacks = packet.getItemListModifier().read(0);
|
||||
List<ItemStack> itemStacksClone = new ArrayList<>();
|
||||
for (ItemStack itemStack : itemStacks) {
|
||||
ItemStack fake = itemStack.clone();
|
||||
itemStacksClone.add(fake);
|
||||
if (fake.getType() == Material.AIR) continue;
|
||||
String id = customInterface.getItemID(fake);
|
||||
WaterCan config = WaterCanConfig.CANS.get(id);
|
||||
if (config == null) continue;
|
||||
NBTItem nbtItem = new NBTItem(fake);
|
||||
int water = nbtItem.getInteger("WaterAmount");
|
||||
NBTCompound display = nbtItem.getCompound("display");
|
||||
if (display == null) continue;
|
||||
List<String> lore = display.getStringList("Lore");
|
||||
if (MainConfig.topOrBottom) lore.addAll(0, getLore(config.getMax(), water));
|
||||
else lore.addAll(getLore(config.getMax(), water));
|
||||
fake.setItemMeta(nbtItem.getItem().getItemMeta());
|
||||
}
|
||||
packet.getItemListModifier().write(0, itemStacksClone);
|
||||
}
|
||||
|
||||
private List<String> getLore(int max, int water) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String text : MainConfig.waterCanLore) {
|
||||
lore.add(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(
|
||||
text.replace("{water_bar}",
|
||||
MainConfig.waterBarLeft +
|
||||
MainConfig.waterBarFull.repeat(water) +
|
||||
MainConfig.waterBarEmpty.repeat(max - water) +
|
||||
MainConfig.waterBarRight
|
||||
)
|
||||
.replace("{water}", String.valueOf(water))
|
||||
.replace("{max_water}", String.valueOf(max))
|
||||
)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.momirealms.customcrops.managers.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.integrations.customplugin.HandlerP;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerContainerListener extends PacketAdapter {
|
||||
|
||||
private final HandlerP handlerP;
|
||||
|
||||
public PlayerContainerListener(HandlerP handlerP) {
|
||||
super(CustomCrops.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.WINDOW_CLICK);
|
||||
this.handlerP = handlerP;
|
||||
}
|
||||
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (handlerP.coolDownJudge(player)) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.momirealms.customcrops.managers.listener;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
|
||||
public class PlayerModeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onModeChange(PlayerGameModeChangeEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(CustomCrops.plugin, () -> {
|
||||
event.getPlayer().updateInventory();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.objects;
|
||||
|
||||
public class ScareCow {
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#Don't change
|
||||
config-version: '10'
|
||||
config-version: '11'
|
||||
|
||||
# lang: english / spanish / chinese
|
||||
lang: english
|
||||
@@ -165,20 +165,20 @@ sounds:
|
||||
type: player
|
||||
|
||||
|
||||
#Hologram information
|
||||
# Hologram information
|
||||
hologram:
|
||||
#Pot infomation
|
||||
# Pot infomation
|
||||
fertilizer-info:
|
||||
enable: true
|
||||
y-offset: 0.8
|
||||
duration: 1
|
||||
text: '<font:customcrops:default>{fertilizer} </font><white>{times}<gray>/<white>{max_times}'
|
||||
#Sprinkler infomation
|
||||
# Sprinkler infomation
|
||||
sprinkler-info:
|
||||
enable: true
|
||||
y-offset: 0.8
|
||||
duration: 1
|
||||
#available variables {water} {max_water}
|
||||
# available variables {water} {max_water}
|
||||
left: '<font:customcrops:default>뀂'
|
||||
full: '뀁뀃'
|
||||
empty: '뀁뀄'
|
||||
@@ -187,9 +187,33 @@ hologram:
|
||||
|
||||
|
||||
actionbar:
|
||||
#Should actionbar be sent when using watering-can
|
||||
# Should actionbar be sent when using watering-can
|
||||
enable: true
|
||||
#available variables {water} {max_water}
|
||||
# Available variables {water} {max_water}
|
||||
left: '<font:customcrops:default>뀂'
|
||||
full: '뀁뀃'
|
||||
empty: '뀁뀄'
|
||||
right: '뀁뀅</font>'
|
||||
|
||||
|
||||
|
||||
watering-can-lore:
|
||||
# Should watering-can has dynamic lore according to the water amount
|
||||
enable: true
|
||||
# Only packets can remain the former lore, otherwise the lore would be replaced
|
||||
packets:
|
||||
# Should watering-can's lore be sent by packets
|
||||
# Wouldn't work in creative mode for safety
|
||||
enable: true
|
||||
# true: top / false: bottom
|
||||
top-or-bottom: true
|
||||
# Lore format
|
||||
# Available variables: {water_bar}
|
||||
# {water}current water {max_water}max storage
|
||||
lore:
|
||||
- '<italic:false><white>{water_bar}'
|
||||
- '<italic:false><gray>Right click water to add water to the can.'
|
||||
water-bar:
|
||||
left: '<font:customcrops:default>뀂'
|
||||
full: '뀁뀃'
|
||||
empty: '뀁뀄'
|
||||
|
||||
Reference in New Issue
Block a user