mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-21 07:59:16 +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.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.5"
|
project.version = "3.5.6"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ 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:4.17.2")
|
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
|
// 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")
|
||||||
|
|||||||
@@ -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");
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ public class ItemsAdderProvider implements CustomProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFurniture(Entity entity) {
|
public boolean isFurniture(Entity entity) {
|
||||||
|
try {
|
||||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user