Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48b3955add |
No files matched your search
+4
-3
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'me.redtea'
|
||||
version = '1.1.0-STABLE'
|
||||
version = '1.1.1-STABLE'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -44,11 +44,12 @@ dependencies {
|
||||
compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
|
||||
// implementation "tech.carcadex:kotlinbukkitkit-commands:1.0.0.4b-SNAPSHOT"
|
||||
implementation "de.tr7zw:item-nbt-api:2.15.3"
|
||||
implementation "net.kyori:adventure-api:4.14.0"
|
||||
implementation "net.kyori:adventure-api:4.25.0"
|
||||
implementation "net.kyori:adventure-platform-bukkit:4.3.0"
|
||||
implementation files("libs/MiniMessages.jar")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.25.0")
|
||||
implementation "dev.triumphteam:triumph-gui:3.1.13"
|
||||
implementation "dev.triumphteam:triumph-cmd-bukkit:2.0.0-BETA-4"
|
||||
implementation("beer.devs:FastNbt-jar:1.4.15")
|
||||
|
||||
compileOnly "com.github.LoneDev6:API-ItemsAdder:3.6.1"
|
||||
compileOnly files("libs/nodropxforgebridge-1.4.jar")
|
||||
|
||||
@@ -4,7 +4,9 @@ import dev.triumphteam.cmd.bukkit.BukkitCommandManager;
|
||||
import dev.triumphteam.cmd.core.argument.keyed.Argument;
|
||||
import dev.triumphteam.cmd.core.argument.keyed.ArgumentKey;
|
||||
import dev.triumphteam.cmd.core.message.MessageKey;
|
||||
import dev.triumphteam.cmd.core.suggestion.SuggestionContext;
|
||||
import dev.triumphteam.cmd.core.suggestion.SuggestionKey;
|
||||
import dev.triumphteam.cmd.core.suggestion.SuggestionResolver;
|
||||
import lombok.Getter;
|
||||
import me.redtea.nodropx.api.facade.NoDropAPI;
|
||||
import me.redtea.nodropx.api.facade.impl.NoDropXFacade;
|
||||
@@ -51,6 +53,7 @@ import me.redtea.nodropx.service.event.impl.EventServiceImpl;
|
||||
import me.redtea.nodropx.service.material.ItemStackService;
|
||||
import me.redtea.nodropx.service.material.impl.ItemStackServiceImpl;
|
||||
import me.redtea.nodropx.service.nbt.NBTService;
|
||||
import me.redtea.nodropx.service.nbt.impl.FastNBTServiceImpl;
|
||||
import me.redtea.nodropx.service.nbt.impl.Tr7zwNBTServiceImpl;
|
||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||
import me.redtea.nodropx.service.nodrop.impl.NoDropServiceImpl;
|
||||
@@ -70,8 +73,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
@@ -117,7 +122,7 @@ public final class NoDropX extends JavaPlugin {
|
||||
noDropCosmeticService.load(YamlConfiguration.loadConfiguration(textContext.getCosmetics()));
|
||||
|
||||
dropConfirmService = getConfig().getBoolean("confirmThrowNoDropItem") ? new DropConfirmServiceImpl() : new DropConfirmNull();
|
||||
NBTService nbtService = new Tr7zwNBTServiceImpl();
|
||||
NBTService nbtService = new FastNBTServiceImpl();
|
||||
noDropService = new NoDropServiceImpl(nbtService, noDropCosmeticService);
|
||||
NoDropItemFactory noDropItemFactory = new NoDropItemFactoryImpl(noDropService);
|
||||
EventService eventService = new EventServiceImpl(noDropService);
|
||||
@@ -178,23 +183,15 @@ public final class NoDropX extends JavaPlugin {
|
||||
|
||||
});
|
||||
|
||||
commandManager.registerNamedArguments(
|
||||
ArgumentKey.of("query-parameters"),
|
||||
Argument.forBoolean().name("rev").longName("reversed").build(),
|
||||
Argument.forInt().name("r").longName("radius").suggestion(SuggestionKey.of("radius")).build(),
|
||||
Argument.forString().name("since").build(),
|
||||
Argument.forString().name("before").build(),
|
||||
Argument.forString().name("cause").build(),
|
||||
Argument.forString().name("at").build(),
|
||||
Argument.forType(Material.class).name("material").build(),
|
||||
Argument.forString().name("bounds").build(),
|
||||
Argument.forType(Material.class).name("ma").build(),
|
||||
Argument.listOf(String.class).name("a").build(),
|
||||
Argument.listOf(Material.class).name("m").build(),
|
||||
Argument.listOf(Player.class).name("p").build()
|
||||
);
|
||||
|
||||
commandManager.registerStaticSuggestion(SuggestionKey.of("allmaterials"), itemStackService.allMaterials());
|
||||
|
||||
commandManager.registerSuggestion(SuggestionKey.of("allmaterials"),
|
||||
new SuggestionResolver.Simple<CommandSender>() {
|
||||
@Override
|
||||
public @NotNull List<String> resolve(@NotNull SuggestionContext<CommandSender> context) {
|
||||
return itemStackService.allMaterials();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,19 +12,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class CapacityServiceImpl implements CapacityService {
|
||||
private final Repo<String, List<Integer>> capacityRepo;
|
||||
private final Map<String, Integer> customModelDataRequired = new HashMap<>();
|
||||
public CapacityServiceImpl(Plugin plugin) {
|
||||
capacityRepo = new YamlRepo<>(
|
||||
new File(plugin.getDataFolder(), "capacity.yml").toPath(),
|
||||
plugin,
|
||||
conf -> conf.getKeys(false).stream().collect(Collectors.toMap(
|
||||
value -> {
|
||||
if(value.contains("->")) {
|
||||
String[] args = value.split("->");
|
||||
customModelDataRequired.put(args[0], Integer.parseInt(args[1]));
|
||||
return args[0];
|
||||
} else return value;
|
||||
},
|
||||
value -> value,
|
||||
conf::getIntegerList))
|
||||
);
|
||||
}
|
||||
@@ -32,17 +25,11 @@ public class CapacityServiceImpl implements CapacityService {
|
||||
@Override
|
||||
public List<Integer> get(ItemStack item) {
|
||||
String key = item.getType().name();
|
||||
if(item.hasItemMeta() && item.getItemMeta().hasCustomModelData()) {
|
||||
key += "->" + item.getItemMeta().getCustomModelData();
|
||||
}
|
||||
Optional<List<Integer>> result = capacityRepo.get(key);
|
||||
if(!result.isPresent()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if(customModelDataRequired.containsKey(key)) {
|
||||
int cmi = customModelDataRequired.get(key);
|
||||
if(!item.getItemMeta().hasCustomModelData() || item.getItemMeta().getCustomModelData() != cmi) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
return result.get();
|
||||
return result.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.redtea.nodropx.service.nbt.impl;
|
||||
|
||||
import beer.devs.fastnbt.nms.nbt.NItem;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import me.redtea.nodropx.service.nbt.NBTService;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class FastNBTServiceImpl implements NBTService {
|
||||
|
||||
|
||||
@Override
|
||||
public void setBoolTag(ItemStack item, String tag, boolean value) {
|
||||
NItem nbtItem = new NItem(item);
|
||||
nbtItem.setBoolean(tag, value);
|
||||
nbtItem.merge(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolTag(ItemStack item, String tag) {
|
||||
if(item == null || item.getType() == Material.AIR) return false;
|
||||
NItem nbtItem = new NItem(item);
|
||||
return nbtItem.hasKey(tag) && nbtItem.getBoolean(tag);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user