mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 17:09:21 +00:00
Merge branch 'main' into dev
This commit is contained in:
@@ -20,7 +20,9 @@ package net.momirealms.customcrops.api.mechanic.world;
|
|||||||
import com.flowpowered.nbt.CompoundMap;
|
import com.flowpowered.nbt.CompoundMap;
|
||||||
import com.flowpowered.nbt.Tag;
|
import com.flowpowered.nbt.Tag;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.StringJoiner;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
@@ -64,4 +66,28 @@ public class SynchronizedCompoundMap {
|
|||||||
SynchronizedCompoundMap that = (SynchronizedCompoundMap) o;
|
SynchronizedCompoundMap that = (SynchronizedCompoundMap) o;
|
||||||
return Objects.equals(compoundMap, that.compoundMap);
|
return Objects.equals(compoundMap, that.compoundMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return compoundMapToString(compoundMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String compoundMapToString(CompoundMap compoundMap) {
|
||||||
|
StringJoiner joiner = new StringJoiner(", ");
|
||||||
|
for (Map.Entry<String, Tag<?>> entry : compoundMap.entrySet()) {
|
||||||
|
Tag<?> tag = entry.getValue();
|
||||||
|
String tagValue;
|
||||||
|
switch (tag.getType()) {
|
||||||
|
case TAG_STRING, TAG_BYTE, TAG_DOUBLE, TAG_FLOAT, TAG_INT, TAG_INT_ARRAY, TAG_LONG, TAG_SHORT, TAG_SHORT_ARRAY, TAG_LONG_ARRAY, TAG_BYTE_ARRAY ->
|
||||||
|
tagValue = tag.getValue().toString();
|
||||||
|
case TAG_COMPOUND -> tagValue = compoundMapToString(tag.getAsCompoundTag().get().getValue());
|
||||||
|
case TAG_LIST -> tagValue = tag.getAsListTag().get().getValue().toString();
|
||||||
|
default -> {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
joiner.add("\"" + entry.getKey() + "\":\"" + tagValue + "\"");
|
||||||
|
}
|
||||||
|
return "{" + joiner + "}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ plugins {
|
|||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
project.group = "net.momirealms"
|
project.group = "net.momirealms"
|
||||||
project.version = "3.5.4"
|
project.version = "3.5.7"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ dependencies {
|
|||||||
|
|
||||||
compileOnly("net.Indyuce:MMOCore-API:1.12-SNAPSHOT")
|
compileOnly("net.Indyuce:MMOCore-API:1.12-SNAPSHOT")
|
||||||
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.23")
|
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.23")
|
||||||
|
|
||||||
compileOnly("com.github.Zrips:Jobs:v4.17.2")
|
compileOnly("com.github.Zrips:Jobs:v4.17.2")
|
||||||
compileOnly("dev.aurelium:auraskills-api-bukkit:2.0.0-SNAPSHOT")
|
compileOnly("dev.aurelium:auraskills-api-bukkit:2.1.2")
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.2-beta-r3-b")
|
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.2-beta-r3-b")
|
||||||
@@ -52,12 +53,12 @@ dependencies {
|
|||||||
implementation(project(":oraxen-j21"))
|
implementation(project(":oraxen-j21"))
|
||||||
implementation(project(":legacy-api"))
|
implementation(project(":legacy-api"))
|
||||||
|
|
||||||
implementation(files("libs/Sparrow-Heart-0.17.jar"))
|
implementation(files("libs/Sparrow-Heart-0.19.jar"))
|
||||||
implementation("net.kyori:adventure-api:4.17.0")
|
implementation("net.kyori:adventure-api:4.17.0")
|
||||||
implementation("net.kyori:adventure-platform-bukkit:4.3.3")
|
implementation("net.kyori:adventure-platform-bukkit:4.3.3")
|
||||||
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
implementation("net.kyori:adventure-text-minimessage:4.17.0")
|
||||||
implementation("net.kyori:adventure-text-serializer-legacy:4.17.0")
|
implementation("net.kyori:adventure-text-serializer-legacy:4.17.0")
|
||||||
implementation("com.github.Xiao-MoMi:AntiGriefLib:0.11")
|
implementation("com.github.Xiao-MoMi:AntiGriefLib:0.12")
|
||||||
// implementation("com.github.Xiao-MoMi:Sparrow-Heart:0.16")
|
// implementation("com.github.Xiao-MoMi:Sparrow-Heart:0.16")
|
||||||
implementation("com.flowpowered:flow-nbt:2.0.2")
|
implementation("com.flowpowered:flow-nbt:2.0.2")
|
||||||
implementation("com.saicone.rtag:rtag:1.5.4")
|
implementation("com.saicone.rtag:rtag:1.5.4")
|
||||||
|
|||||||
Binary file not shown.
BIN
plugin/libs/Sparrow-Heart-0.19.jar
Normal file
BIN
plugin/libs/Sparrow-Heart-0.19.jar
Normal file
Binary file not shown.
@@ -30,6 +30,7 @@ import net.momirealms.customcrops.api.manager.MessageManager;
|
|||||||
import net.momirealms.customcrops.api.mechanic.item.ItemType;
|
import net.momirealms.customcrops.api.mechanic.item.ItemType;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.ChunkPos;
|
import net.momirealms.customcrops.api.mechanic.world.ChunkPos;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||||
|
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
|
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsSection;
|
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsSection;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsWorld;
|
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsWorld;
|
||||||
@@ -37,6 +38,7 @@ import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
|||||||
import net.momirealms.customcrops.compatibility.season.InBuiltSeason;
|
import net.momirealms.customcrops.compatibility.season.InBuiltSeason;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.generator.WorldInfo;
|
import org.bukkit.generator.WorldInfo;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -88,7 +90,7 @@ public class CommandManager implements Initable {
|
|||||||
return new CommandAPICommand("unsafe")
|
return new CommandAPICommand("unsafe")
|
||||||
.withSubcommands(
|
.withSubcommands(
|
||||||
new CommandAPICommand("delete-chunk-data").executesPlayer((player, args) -> {
|
new CommandAPICommand("delete-chunk-data").executesPlayer((player, args) -> {
|
||||||
CustomCropsPlugin.get().getWorldManager().getCustomCropsWorld(player.getWorld()).ifPresent(customCropsWorld -> {
|
plugin.getWorldManager().getCustomCropsWorld(player.getWorld()).ifPresent(customCropsWorld -> {
|
||||||
var optionalChunk = customCropsWorld.getLoadedChunkAt(ChunkPos.getByBukkitChunk(player.getChunk()));
|
var optionalChunk = customCropsWorld.getLoadedChunkAt(ChunkPos.getByBukkitChunk(player.getChunk()));
|
||||||
if (optionalChunk.isEmpty()) {
|
if (optionalChunk.isEmpty()) {
|
||||||
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>This chunk doesn't have any data.");
|
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>This chunk doesn't have any data.");
|
||||||
@@ -97,6 +99,17 @@ public class CommandManager implements Initable {
|
|||||||
customCropsWorld.deleteChunk(ChunkPos.getByBukkitChunk(player.getChunk()));
|
customCropsWorld.deleteChunk(ChunkPos.getByBukkitChunk(player.getChunk()));
|
||||||
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>Done.");
|
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>Done.");
|
||||||
});
|
});
|
||||||
|
}),
|
||||||
|
new CommandAPICommand("check-data").executesPlayer((player, args) -> {
|
||||||
|
Block block = player.getTargetBlockExact(10);
|
||||||
|
if (block != null) {
|
||||||
|
Optional<CustomCropsBlock> customCropsBlock = plugin.getWorldManager().getBlockAt(SimpleLocation.of(block.getLocation()));
|
||||||
|
if (customCropsBlock.isPresent()) {
|
||||||
|
AdventureManager.getInstance().sendMessageWithPrefix(player, customCropsBlock.get().getType() + ":" + customCropsBlock.get().getCompoundMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AdventureManager.getInstance().sendMessageWithPrefix(player, "Data not found");
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import net.momirealms.customcrops.api.util.LogUtils;
|
|||||||
import net.momirealms.customcrops.compatibility.VaultHook;
|
import net.momirealms.customcrops.compatibility.VaultHook;
|
||||||
import net.momirealms.customcrops.manager.AdventureManagerImpl;
|
import net.momirealms.customcrops.manager.AdventureManagerImpl;
|
||||||
import net.momirealms.customcrops.manager.HologramManager;
|
import net.momirealms.customcrops.manager.HologramManager;
|
||||||
import net.momirealms.customcrops.manager.PacketManager;
|
|
||||||
import net.momirealms.customcrops.mechanic.item.impl.VariationCrop;
|
import net.momirealms.customcrops.mechanic.item.impl.VariationCrop;
|
||||||
import net.momirealms.customcrops.mechanic.misc.TempFakeItem;
|
import net.momirealms.customcrops.mechanic.misc.TempFakeItem;
|
||||||
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
||||||
@@ -61,7 +60,7 @@ import net.momirealms.customcrops.util.ClassUtils;
|
|||||||
import net.momirealms.customcrops.util.ConfigUtils;
|
import net.momirealms.customcrops.util.ConfigUtils;
|
||||||
import net.momirealms.customcrops.util.ItemUtils;
|
import net.momirealms.customcrops.util.ItemUtils;
|
||||||
import net.momirealms.sparrow.heart.SparrowHeart;
|
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||||
import net.momirealms.sparrow.heart.argument.HandSlot;
|
import net.momirealms.sparrow.heart.feature.inventory.HandSlot;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@@ -828,7 +827,8 @@ public class ActionManagerImpl implements ActionManager {
|
|||||||
return state -> {
|
return state -> {
|
||||||
if (Math.random() > chance) return;
|
if (Math.random() > chance) return;
|
||||||
ItemStack itemStack = state.getItemInHand();
|
ItemStack itemStack = state.getItemInHand();
|
||||||
|
if (itemStack.getItemMeta() == null)
|
||||||
|
return;
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
ItemUtils.increaseDurability(itemStack, amount);
|
ItemUtils.increaseDurability(itemStack, amount);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public class ConditionManagerImpl implements ConditionManager {
|
|||||||
this.registerPotCondition();
|
this.registerPotCondition();
|
||||||
this.registerLightCondition();
|
this.registerLightCondition();
|
||||||
this.registerPointCondition();
|
this.registerPointCondition();
|
||||||
|
this.registerWorldRequirement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -199,6 +200,17 @@ public class ConditionManagerImpl implements ConditionManager {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerWorldRequirement() {
|
||||||
|
registerCondition("world", (args) -> {
|
||||||
|
HashSet<String> worlds = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||||
|
return (block, offline) -> worlds.contains(block.getLocation().getWorldName());
|
||||||
|
});
|
||||||
|
registerCondition("!world", (args) -> {
|
||||||
|
HashSet<String> worlds = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||||
|
return (block, offline) -> !worlds.contains(block.getLocation().getWorldName());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void registerBiomeRequirement() {
|
private void registerBiomeRequirement() {
|
||||||
registerCondition("biome", (args) -> {
|
registerCondition("biome", (args) -> {
|
||||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
oraxenListenerConstructor.setAccessible(true);
|
oraxenListenerConstructor.setAccessible(true);
|
||||||
this.listener = (AbstractCustomListener) oraxenListenerConstructor.newInstance(this);
|
this.listener = (AbstractCustomListener) oraxenListenerConstructor.newInstance(this);
|
||||||
Class<?> oraxenProviderClass = Class.forName("net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider");
|
Class<?> oraxenProviderClass = Class.forName("net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider");
|
||||||
Constructor<?> oraxenProviderConstructor = oraxenProviderClass.getDeclaredConstructor(ItemManager.class);
|
Constructor<?> oraxenProviderConstructor = oraxenProviderClass.getDeclaredConstructor();
|
||||||
oraxenProviderConstructor.setAccessible(true);
|
oraxenProviderConstructor.setAccessible(true);
|
||||||
this.customProvider = (CustomProvider) oraxenProviderConstructor.newInstance();
|
this.customProvider = (CustomProvider) oraxenProviderConstructor.newInstance();
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
@@ -2660,6 +2660,9 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
Pot currentPot = getPotByBlock(block);
|
Pot currentPot = getPotByBlock(block);
|
||||||
if (currentPot != pot) {
|
if (currentPot != pot) {
|
||||||
plugin.getWorldManager().removePotAt(SimpleLocation.of(location));
|
plugin.getWorldManager().removePotAt(SimpleLocation.of(location));
|
||||||
|
if (currentPot != null) {
|
||||||
|
plugin.getWorldManager().addPotAt(new MemoryPot(SimpleLocation.of(location), currentPot.getKey()), SimpleLocation.of(location));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pot.isVanillaBlock()) {
|
if (pot.isVanillaBlock()) {
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ public class ItemsAdderProvider implements CustomProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFurniture(Entity entity) {
|
public boolean isFurniture(Entity entity) {
|
||||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
try {
|
||||||
|
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class ItemUtils {
|
|||||||
public static void increaseDurability(ItemStack itemStack, int amount) {
|
public static void increaseDurability(ItemStack itemStack, int amount) {
|
||||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack);
|
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack.clone());
|
||||||
int damage = Math.max(item.damage().orElse(0) - amount, 0);
|
int damage = Math.max(item.damage().orElse(0) - amount, 0);
|
||||||
item.damage(damage);
|
item.damage(damage);
|
||||||
itemStack.setItemMeta(item.load().getItemMeta());
|
itemStack.setItemMeta(item.load().getItemMeta());
|
||||||
@@ -104,7 +104,7 @@ public class ItemUtils {
|
|||||||
if (Math.random() > (double) 1 / (unBreakingLevel + 1)) {
|
if (Math.random() > (double) 1 / (unBreakingLevel + 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack);
|
Item<ItemStack> item = BukkitItemFactory.getInstance().wrap(itemStack.clone());
|
||||||
int damage = item.damage().orElse(0) + amount;
|
int damage = item.damage().orElse(0) + amount;
|
||||||
if (damage > item.maxDamage().orElse((int) itemStack.getType().getMaxDurability())) {
|
if (damage > item.maxDamage().orElse((int) itemStack.getType().getMaxDurability())) {
|
||||||
itemStack.setAmount(0);
|
itemStack.setAmount(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user