mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-19 15:09:25 +00:00
3.5.6
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.Tag;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -64,4 +66,28 @@ public class SynchronizedCompoundMap {
|
||||
SynchronizedCompoundMap that = (SynchronizedCompoundMap) o;
|
||||
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 {
|
||||
|
||||
project.group = "net.momirealms"
|
||||
project.version = "3.5.5"
|
||||
project.version = "3.5.6"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -26,7 +26,7 @@ dependencies {
|
||||
compileOnly("net.Indyuce:MMOCore-API:1.12-SNAPSHOT")
|
||||
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.3.23")
|
||||
compileOnly("com.github.Zrips:Jobs:4.17.2")
|
||||
compileOnly("dev.aurelium:auraskills-api-bukkit:2.0.0-SNAPSHOT")
|
||||
compileOnly("dev.aurelium:auraskills-api-bukkit:2.1.2")
|
||||
|
||||
// Items
|
||||
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.2-beta-r3-b")
|
||||
|
||||
@@ -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.world.ChunkPos;
|
||||
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.CustomCropsSection;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -88,7 +90,7 @@ public class CommandManager implements Initable {
|
||||
return new CommandAPICommand("unsafe")
|
||||
.withSubcommands(
|
||||
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()));
|
||||
if (optionalChunk.isEmpty()) {
|
||||
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()));
|
||||
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");
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class ConditionManagerImpl implements ConditionManager {
|
||||
this.registerPotCondition();
|
||||
this.registerLightCondition();
|
||||
this.registerPointCondition();
|
||||
this.registerWorldRequirement();
|
||||
}
|
||||
|
||||
@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() {
|
||||
registerCondition("biome", (args) -> {
|
||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
oraxenListenerConstructor.setAccessible(true);
|
||||
this.listener = (AbstractCustomListener) oraxenListenerConstructor.newInstance(this);
|
||||
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);
|
||||
this.customProvider = (CustomProvider) oraxenProviderConstructor.newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
|
||||
@@ -106,6 +106,10 @@ public class ItemsAdderProvider implements CustomProvider {
|
||||
|
||||
@Override
|
||||
public boolean isFurniture(Entity entity) {
|
||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||
try {
|
||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user