Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48b3955add | ||
|
|
50bb40d701 | ||
|
|
5cd86f3850 | ||
|
|
4fb73836f3 | ||
|
|
6015933000 | ||
|
|
395037cba5 | ||
|
|
c307386645 | ||
|
|
e5ea0c1ae2 | ||
|
|
8f3565dd95 | ||
|
|
61873f6dd7 | ||
|
|
44f3226838 | ||
|
|
71203206d1 | ||
|
|
d1dcc34708 | ||
|
|
ac8744c0f3 | ||
|
|
89af1d872c | ||
|
|
c270c8b45d | ||
|
|
14556e7afa | ||
|
|
c885fc87da | ||
|
|
cdea9cfa7f | ||
|
|
05fbf78034 | ||
|
|
79a8f6a09f | ||
|
|
1640b45041 | ||
|
|
0b111d48bf | ||
|
|
db70651bb6 | ||
|
|
d66027cb9b | ||
|
|
fabd2de076 | ||
|
|
0a431430bd | ||
|
|
bb779badf5 | ||
|
|
f9068c71d9 |
No files matched your search
@@ -22,3 +22,5 @@ gradle-app.setting
|
|||||||
|
|
||||||
run
|
run
|
||||||
.idea
|
.idea
|
||||||
|
.gradle
|
||||||
|
build
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
<img src="https://i.imgur.com/AxYMos8.png)https://i.imgur.com/AxYMos8.png"></img>
|
# NoDropX
|
||||||
|
Give no drop items!
|
||||||
|
=======
|
||||||
|
<img src="https://i.imgur.com/PMxKZEP.png"></img>
|
||||||
|
|
||||||
# NoDropX
|
# NoDropX
|
||||||
**Give no drop items!**
|
**Give no drop items!**
|
||||||
|
|
||||||
@@ -6,16 +10,20 @@ The plugin will allow you to create items that will not drop out of your invento
|
|||||||
|
|
||||||
Give an no drop item: `/nodrop give [player] [item] (count)` <br>
|
Give an no drop item: `/nodrop give [player] [item] (count)` <br>
|
||||||
Check all plugin commands: https://github.com/iRedTea/NoDropX/wiki/Commands <br>
|
Check all plugin commands: https://github.com/iRedTea/NoDropX/wiki/Commands <br>
|
||||||
Plugin wiki: https://github.com/iRedTea/NoDropX/wiki
|
Plugin wiki: https://github.com/iRedTea/NoDropX/wiki <br>
|
||||||
|
SpigotMC resource: https://www.spigotmc.org/resources/nodropx.111485/
|
||||||
|
|
||||||
**Features**
|
**Features**
|
||||||
- Supports HEX Colors (MiniMessages and MD5 ChatColor)
|
- Supports HEX Colors (MiniMessages and MD5 ChatColor)
|
||||||
- Supports all versions from 1.12.2 to 1.20.1 (Spigot/Paper)
|
- Supports all versions from 1.12.2 to 1.20.1 (Spigot/Paper/Folia)
|
||||||
- No drop items storage: `/nodrop gui`
|
- No drop items storage: `/nodrop gui`
|
||||||
- Fully customization
|
- Fully customization
|
||||||
- Items that protect other slots from death
|
- Items that protect other slots from death
|
||||||
- Developer API
|
- Developer API
|
||||||
- Mods support (tested on Arclight 1.16.5)
|
- Mods support (tested on Arclight 1.16.5)
|
||||||
- ItemsAdder support
|
- ItemsAdder support
|
||||||
|
- Folia support
|
||||||
|
- Items thats protect all items in inventory from death
|
||||||
|
|
||||||
<img src="https://i.imgur.com/7DdnANr.png"></img>
|
|
||||||
|
This plugin uses <a href="https://github.com/iRedTea/CarcadeX">CarcadeX</a> library
|
||||||
+28
-13
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'me.redtea'
|
group = 'me.redtea'
|
||||||
version = '1.0.1-SNAPSHOT'
|
version = '1.1.1-STABLE'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -17,6 +17,10 @@ repositories {
|
|||||||
name = "sonatype"
|
name = "sonatype"
|
||||||
url = "https://oss.sonatype.org/content/groups/public/"
|
url = "https://oss.sonatype.org/content/groups/public/"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "CodeMC"
|
name = "CodeMC"
|
||||||
url = uri("https://repo.codemc.io/repository/maven-public/")
|
url = uri("https://repo.codemc.io/repository/maven-public/")
|
||||||
@@ -25,19 +29,30 @@ repositories {
|
|||||||
name = "papermc-repo"
|
name = "papermc-repo"
|
||||||
url = "https://repo.papermc.io/repository/maven-public/"
|
url = "https://repo.papermc.io/repository/maven-public/"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url 'https://jitpack.io'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url = "https://repo.triumphteam.dev/snapshots/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.jetbrains:annotations:24.0.0'
|
implementation "org.jetbrains:annotations:24.0.0"
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.26'
|
compileOnly "org.projectlombok:lombok:1.18.26"
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
annotationProcessor 'org.projectlombok:lombok:1.18.26'
|
||||||
compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
|
compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"
|
||||||
implementation "me.mattstudios.utils:matt-framework:1.4"
|
// implementation "tech.carcadex:kotlinbukkitkit-commands:1.0.0.4b-SNAPSHOT"
|
||||||
implementation 'de.tr7zw:item-nbt-api:2.11.3'
|
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 "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.2"
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 8
|
def targetJavaVersion = 8
|
||||||
@@ -56,6 +71,8 @@ tasks.withType(JavaCompile).configureEach {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
def props = [version: version]
|
def props = [version: version]
|
||||||
inputs.properties props
|
inputs.properties props
|
||||||
@@ -67,10 +84,8 @@ processResources {
|
|||||||
|
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate 'de.tr7zw.changeme.nbtapi', 'me.redtea.nodropx.libs.tr7zw.nbt'
|
relocate 'de.tr7zw', 'me.redtea.nodropx.libs.tr7zw'
|
||||||
relocate 'de.tr7zw.annotations', 'me.redtea.nodropx.libs.tr7zw.annotations'
|
relocate 'dev.triumphteam', 'me.redtea.nodropx.libs.triumphteam'
|
||||||
relocate 'me.mattstudios.mf', 'me.redtea.nodropx.libs.commands'
|
|
||||||
relocate 'dev.triumphteam', 'me.redtea.nodropx.libs.gui'
|
|
||||||
relocate 'org.checkerframework', 'me.redtea.nodropx.libs.message.oskarsmc.libs.checker'
|
relocate 'org.checkerframework', 'me.redtea.nodropx.libs.message.oskarsmc.libs.checker'
|
||||||
relocate 'org.intellij', 'me.redtea.nodropx.libs.intellij'
|
relocate 'org.intellij', 'me.redtea.nodropx.libs.intellij'
|
||||||
relocate 'org.jetbrains', 'me.redtea.nodropx.libs.jetbrains'}
|
relocate 'org.jetbrains', 'me.redtea.nodropx.libs.jetbrains'}
|
||||||
@@ -78,6 +93,6 @@ shadowJar {
|
|||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.16.5")
|
minecraftVersion("1.12.2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,13 @@
|
|||||||
package me.redtea.nodropx;
|
package me.redtea.nodropx;
|
||||||
|
|
||||||
|
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 lombok.Getter;
|
||||||
import me.mattstudios.mf.base.CommandManager;
|
|
||||||
import me.redtea.nodropx.api.facade.NoDropAPI;
|
import me.redtea.nodropx.api.facade.NoDropAPI;
|
||||||
import me.redtea.nodropx.api.facade.impl.NoDropXFacade;
|
import me.redtea.nodropx.api.facade.impl.NoDropXFacade;
|
||||||
import me.redtea.nodropx.command.NoDropCommand;
|
import me.redtea.nodropx.command.NoDropCommand;
|
||||||
@@ -10,23 +16,44 @@ import me.redtea.nodropx.factory.item.impl.NoDropItemFactoryImpl;
|
|||||||
import me.redtea.nodropx.factory.text.TextContext;
|
import me.redtea.nodropx.factory.text.TextContext;
|
||||||
import me.redtea.nodropx.factory.text.TextServicesFactory;
|
import me.redtea.nodropx.factory.text.TextServicesFactory;
|
||||||
import me.redtea.nodropx.factory.text.impl.TextServicesFactoryImpl;
|
import me.redtea.nodropx.factory.text.impl.TextServicesFactoryImpl;
|
||||||
import me.redtea.nodropx.gui.facade.GuiFacade;
|
import me.redtea.nodropx.folia.FoliaSupporter;
|
||||||
import me.redtea.nodropx.gui.facade.impl.GuiFacadeImpl;
|
|
||||||
import me.redtea.nodropx.gui.pages.StorageGui;
|
|
||||||
import me.redtea.nodropx.libs.bstats.Metrics;
|
import me.redtea.nodropx.libs.bstats.Metrics;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.impl.yaml.YamlRepo;
|
|
||||||
import me.redtea.nodropx.libs.message.container.Messages;
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
|
import me.redtea.nodropx.libs.message.verifier.impl.FileMessageVerifier;
|
||||||
|
import me.redtea.nodropx.listener.ConfirmDropHandler;
|
||||||
import me.redtea.nodropx.listener.InventoryHandler;
|
import me.redtea.nodropx.listener.InventoryHandler;
|
||||||
import me.redtea.nodropx.listener.PlayerHandler;
|
import me.redtea.nodropx.listener.PlayerHandler;
|
||||||
|
import me.redtea.nodropx.listener.menu.SinglePageGuiHandler;
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
|
import me.redtea.nodropx.menu.Menu;
|
||||||
|
import me.redtea.nodropx.menu.dropconfirm.DropConfirmMFGui;
|
||||||
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
|
import me.redtea.nodropx.menu.facade.impl.MenuFacadeImpl;
|
||||||
|
import me.redtea.nodropx.menu.facade.impl.NullMenuFacadeImpl;
|
||||||
|
import me.redtea.nodropx.menu.storage.pages.MFPageGui;
|
||||||
|
import me.redtea.nodropx.menu.storage.singlepage.SinglePageController;
|
||||||
|
import me.redtea.nodropx.menu.storage.singlepage.SinglePageGui;
|
||||||
import me.redtea.nodropx.model.cosmetic.impl.DisplayNameCosmetic;
|
import me.redtea.nodropx.model.cosmetic.impl.DisplayNameCosmetic;
|
||||||
|
import me.redtea.nodropx.model.materialprovider.impl.ItemStackProviderDefault;
|
||||||
|
import me.redtea.nodropx.model.materialprovider.impl.ItemsAdderProvider;
|
||||||
import me.redtea.nodropx.schema.ItemStackListSchema;
|
import me.redtea.nodropx.schema.ItemStackListSchema;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.AllNoDropService;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.impl.AllNoDropServiceImpl;
|
||||||
|
import me.redtea.nodropx.service.capasity.CapacityService;
|
||||||
|
import me.redtea.nodropx.service.capasity.impl.CapacityServiceImpl;
|
||||||
import me.redtea.nodropx.service.cosmetic.CosmeticService;
|
import me.redtea.nodropx.service.cosmetic.CosmeticService;
|
||||||
import me.redtea.nodropx.service.cosmetic.impl.CosmeticServiceImpl;
|
import me.redtea.nodropx.service.cosmetic.impl.CosmeticServiceImpl;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.impl.DropConfirmNull;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.impl.DropConfirmServiceImpl;
|
||||||
import me.redtea.nodropx.service.event.EventService;
|
import me.redtea.nodropx.service.event.EventService;
|
||||||
import me.redtea.nodropx.service.event.impl.EventServiceImpl;
|
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.NBTService;
|
||||||
|
import me.redtea.nodropx.service.nbt.impl.FastNBTServiceImpl;
|
||||||
import me.redtea.nodropx.service.nbt.impl.Tr7zwNBTServiceImpl;
|
import me.redtea.nodropx.service.nbt.impl.Tr7zwNBTServiceImpl;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.service.nodrop.impl.NoDropServiceImpl;
|
import me.redtea.nodropx.service.nodrop.impl.NoDropServiceImpl;
|
||||||
@@ -34,116 +61,204 @@ import me.redtea.nodropx.service.respawn.RespawnService;
|
|||||||
import me.redtea.nodropx.service.respawn.impl.RespawnServiceImpl;
|
import me.redtea.nodropx.service.respawn.impl.RespawnServiceImpl;
|
||||||
import me.redtea.nodropx.service.storage.StorageService;
|
import me.redtea.nodropx.service.storage.StorageService;
|
||||||
import me.redtea.nodropx.service.storage.impl.StorageServiceImpl;
|
import me.redtea.nodropx.service.storage.impl.StorageServiceImpl;
|
||||||
|
import me.redtea.nodropx.util.ConfigVerifier;
|
||||||
|
import me.redtea.nodropx.util.FoliaSupportedUtils;
|
||||||
import me.redtea.nodropx.util.UpdateChecker;
|
import me.redtea.nodropx.util.UpdateChecker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public final class NoDropX extends JavaPlugin {
|
public final class NoDropX extends JavaPlugin {
|
||||||
private static NoDropAPI noDropAPIInstance;
|
private static NoDropAPI noDropAPIInstance;
|
||||||
@Getter
|
@Getter
|
||||||
private static NoDropX instance;
|
private static NoDropX instance;
|
||||||
|
@Getter
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
private CosmeticService cosmeticService;
|
private CosmeticService noDropCosmeticService;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean supportHEX;
|
private boolean supportHEX;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean supportKyoriLore;
|
private boolean supportKyoriLore;
|
||||||
private MutableRepo<UUID, List<ItemStack>> pagesRepo;
|
@Getter
|
||||||
private Repo<String, List<Integer>> capacity;
|
private boolean supportItemsAdder;
|
||||||
|
private MutableRepo<UUID, List<ItemStack>> personalStorageRepo;
|
||||||
|
private CapacityService capacityService;
|
||||||
|
private MenuFacade menuFacade;
|
||||||
|
private NoDropService noDropService;
|
||||||
|
private ItemStackService itemStackService;
|
||||||
|
private DropConfirmService dropConfirmService;
|
||||||
|
private FoliaSupportedUtils foliaSupportedUtils;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
saveDefaultConfig();
|
new ConfigVerifier().verifyDefaults(this);
|
||||||
|
|
||||||
|
foliaSupportedUtils = new FoliaSupportedUtils(this);
|
||||||
|
|
||||||
TextServicesFactory textServicesFactory = new TextServicesFactoryImpl();
|
TextServicesFactory textServicesFactory = new TextServicesFactoryImpl();
|
||||||
TextContext textContext = textServicesFactory.create(this);
|
TextContext textContext = textServicesFactory.create(this);
|
||||||
supportHEX = textContext.isSupportHex();
|
supportHEX = textContext.isSupportHex();
|
||||||
supportKyoriLore = textContext.isSupportKyori();
|
supportKyoriLore = textContext.isSupportKyori();
|
||||||
messages = supportKyoriLore ? Messages.of(textContext.getMessages()) : Messages.legacy(textContext.getMessages());
|
messages = supportKyoriLore ? Messages.of(textContext.getMessages()) : Messages.legacy(textContext.getMessages());
|
||||||
|
messages.setVerifier(new FileMessageVerifier(getResource(textContext.getPath()), YamlConfiguration.loadConfiguration(textContext.getMessages()), textContext.getMessages()));
|
||||||
|
|
||||||
cosmeticService = new CosmeticServiceImpl();
|
noDropCosmeticService = new CosmeticServiceImpl();
|
||||||
cosmeticService.add(new DisplayNameCosmetic());
|
noDropCosmeticService.add(new DisplayNameCosmetic());
|
||||||
cosmeticService.add(textContext.getLoreStrategy());
|
noDropCosmeticService.add(textContext.getLoreStrategy());
|
||||||
cosmeticService.load(YamlConfiguration.loadConfiguration(textContext.getCosmetics()));
|
noDropCosmeticService.load(YamlConfiguration.loadConfiguration(textContext.getCosmetics()));
|
||||||
|
|
||||||
capacity = new YamlRepo<>(
|
dropConfirmService = getConfig().getBoolean("confirmThrowNoDropItem") ? new DropConfirmServiceImpl() : new DropConfirmNull();
|
||||||
new File(getDataFolder(), "capacity.yml").toPath(),
|
NBTService nbtService = new FastNBTServiceImpl();
|
||||||
this,
|
noDropService = new NoDropServiceImpl(nbtService, noDropCosmeticService);
|
||||||
conf -> conf.getKeys(false).stream().collect(Collectors.toMap(
|
|
||||||
value -> value,
|
|
||||||
conf::getIntegerList))
|
|
||||||
);
|
|
||||||
|
|
||||||
NBTService nbtService = new Tr7zwNBTServiceImpl();
|
|
||||||
NoDropService noDropService = new NoDropServiceImpl(nbtService, cosmeticService);
|
|
||||||
NoDropItemFactory noDropItemFactory = new NoDropItemFactoryImpl(noDropService);
|
NoDropItemFactory noDropItemFactory = new NoDropItemFactoryImpl(noDropService);
|
||||||
EventService eventService = new EventServiceImpl(noDropService);
|
EventService eventService = new EventServiceImpl(noDropService);
|
||||||
RespawnService respawnService = new RespawnServiceImpl(noDropService, capacity);
|
capacityService = new CapacityServiceImpl(this);
|
||||||
pagesRepo = Repo.<UUID, List<ItemStack>>builder()
|
AllNoDropService allNoDropService = new AllNoDropServiceImpl(nbtService);
|
||||||
|
RespawnService respawnService = new RespawnServiceImpl(noDropService, allNoDropService, capacityService);
|
||||||
|
|
||||||
|
//EXPERIMENTAL! Folia support!
|
||||||
|
FoliaSupporter foliaSupporter = new FoliaSupporter();
|
||||||
|
foliaSupporter.run(respawnService, this);
|
||||||
|
|
||||||
|
personalStorageRepo = Repo.<UUID, List<ItemStack>>builder()
|
||||||
.autoSave(1000 * 60 * 15L)
|
.autoSave(1000 * 60 * 15L)
|
||||||
.schema(new ItemStackListSchema(new File(getDataFolder(), "storage")))
|
.schema(new ItemStackListSchema(new File(getDataFolder(), "storage")))
|
||||||
.plugin(this)
|
.plugin(this)
|
||||||
.build();
|
.build();
|
||||||
|
itemStackService = initItemStackService();
|
||||||
|
|
||||||
|
|
||||||
GuiFacade guiFacade = new GuiFacadeImpl(
|
menuFacade = initMenus();
|
||||||
new StorageGui(messages, pagesRepo, noDropService, this)
|
StorageService storageService = new StorageServiceImpl(menuFacade, personalStorageRepo, noDropService);
|
||||||
);
|
|
||||||
StorageService storageService = new StorageServiceImpl(guiFacade, pagesRepo, noDropService);
|
|
||||||
|
|
||||||
NoDropAPI noDropAPI = new NoDropXFacade(noDropService, noDropItemFactory, storageService, capacity);
|
|
||||||
|
|
||||||
|
NoDropAPI noDropAPI = new NoDropXFacade(noDropService, noDropItemFactory, storageService, capacityService,
|
||||||
|
itemStackService, allNoDropService);
|
||||||
noDropAPIInstance = noDropAPI;
|
noDropAPIInstance = noDropAPI;
|
||||||
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(
|
Bukkit.getPluginManager().registerEvents(new InventoryHandler(eventService, noDropService, dropConfirmService), this);
|
||||||
new InventoryHandler(eventService),
|
Bukkit.getPluginManager().registerEvents(new PlayerHandler(respawnService, eventService, menuFacade), this);
|
||||||
this
|
Bukkit.getPluginManager().registerEvents(new ConfirmDropHandler(dropConfirmService, menuFacade), this);
|
||||||
);
|
|
||||||
Bukkit.getPluginManager().registerEvents(
|
|
||||||
new PlayerHandler(respawnService, eventService, guiFacade),
|
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
Bukkit.getServicesManager().register(NoDropAPI.class,
|
Bukkit.getServicesManager().register(NoDropAPI.class,
|
||||||
noDropAPI, this, ServicePriority.Normal);
|
noDropAPI, this, ServicePriority.Normal);
|
||||||
|
|
||||||
CommandManager commandManager = new CommandManager(this);
|
// CommandManager commandManager = CommandManager.get(this);
|
||||||
commandManager.getMessageHandler().register("cmd.no.permission", sender -> messages.get("noPerms").send(sender));
|
// commandManager.message("#no-perm", sender -> {
|
||||||
commandManager.getMessageHandler().register("cmd.no.console", sender -> messages.get("noConsole").send(sender));
|
// messages.get("noPerms").send(sender);
|
||||||
commandManager.getMessageHandler().register("cmd.no.exists", sender -> messages.get("noExists").send(sender));
|
// return Unit.INSTANCE;
|
||||||
commandManager.getMessageHandler().register("cmd.wrong.usage", sender -> messages.get("usage").send(sender));
|
// });
|
||||||
commandManager.getCompletionHandler().register("#materials", input -> Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList()));
|
// commandManager.message("#for-players-only", sender -> {
|
||||||
commandManager.register(new NoDropCommand(messages, noDropAPI, guiFacade, this));
|
// messages.get("noConsole").send(sender);
|
||||||
|
// return Unit.INSTANCE;
|
||||||
|
// });
|
||||||
|
// commandManager.message("#no-such-player", sender -> {
|
||||||
|
// messages.get("noExists").send(sender);
|
||||||
|
// return Unit.INSTANCE;
|
||||||
|
// });
|
||||||
|
// commandManager.message("#no-such-player", sender -> {
|
||||||
|
// messages.get("usage").send(sender);
|
||||||
|
// return Unit.INSTANCE;
|
||||||
|
// });
|
||||||
|
// commandManager.tabComplete("#materials", input -> itemStackService.allMaterials());
|
||||||
|
// commandManager.register(new NoDropCommand(messages, noDropAPI, menuFacade, this,
|
||||||
|
// itemStackService, dropConfirmService, eventService, allNoDropService));
|
||||||
|
final BukkitCommandManager<CommandSender> commandManager = BukkitCommandManager.create(this, builder -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
commandManager.registerSuggestion(SuggestionKey.of("allmaterials"),
|
||||||
|
new SuggestionResolver.Simple<CommandSender>() {
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> resolve(@NotNull SuggestionContext<CommandSender> context) {
|
||||||
|
return itemStackService.allMaterials();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
commandManager.registerMessage(MessageKey.TOO_MANY_ARGUMENTS, (sender, context) -> {
|
||||||
|
messages.get("usage").send(sender);
|
||||||
|
});
|
||||||
|
commandManager.registerMessage(MessageKey.UNKNOWN_COMMAND, (sender, context) -> {
|
||||||
|
messages.get("usage").send(sender);
|
||||||
|
});
|
||||||
|
commandManager.registerMessage(MessageKey.NOT_ENOUGH_ARGUMENTS, (sender, context) -> {
|
||||||
|
messages.get("usage").send(sender);
|
||||||
|
});
|
||||||
|
commandManager.registerMessage(MessageKey.INVALID_ARGUMENT, (sender, context) -> {
|
||||||
|
messages.get("error").send(sender);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
commandManager.registerCommand(new NoDropCommand(messages, noDropAPI, menuFacade, this,
|
||||||
|
itemStackService, dropConfirmService, eventService, allNoDropService));
|
||||||
bStatsInit();
|
bStatsInit();
|
||||||
printCredits();
|
printCredits();
|
||||||
checkUpdates();
|
checkUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MenuFacade initMenus() {
|
||||||
|
try {
|
||||||
|
CachedMenu personalStorageCachedMenu;
|
||||||
|
if (Objects.requireNonNull(getConfig().getString("personalStorageType")).equalsIgnoreCase("SINGLE_PAGE")) {
|
||||||
|
SinglePageGui singlePageGui = new SinglePageGui(messages, personalStorageRepo);
|
||||||
|
personalStorageCachedMenu = singlePageGui;
|
||||||
|
Bukkit.getPluginManager().registerEvents(new SinglePageGuiHandler(new SinglePageController(noDropService,
|
||||||
|
singlePageGui, personalStorageRepo, foliaSupportedUtils), singlePageGui), this);
|
||||||
|
} else
|
||||||
|
personalStorageCachedMenu = new MFPageGui(messages, personalStorageRepo, noDropService, itemStackService, this);
|
||||||
|
|
||||||
|
Menu confirmMenu = new DropConfirmMFGui(messages, dropConfirmService, this);
|
||||||
|
return new MenuFacadeImpl(personalStorageCachedMenu, confirmMenu);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Bukkit.getLogger().severe(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
printConsoleLine("&4Can not use menus on this server!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NullMenuFacadeImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStackService initItemStackService() {
|
||||||
|
ItemStackService result = new ItemStackServiceImpl();
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("ItemsAdder") != null) {
|
||||||
|
supportItemsAdder = true;
|
||||||
|
printConsoleLine("ItemsAdder found! Registering a CustomStack provider for it.");
|
||||||
|
result.registerProvider(new ItemsAdderProvider());
|
||||||
|
}
|
||||||
|
result.registerProvider(new ItemStackProviderDefault());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void checkUpdates() {
|
private void checkUpdates() {
|
||||||
if(!(getConfig().contains("checkForUpdates") && getConfig().getBoolean("checkForUpdates"))) {
|
if (!getConfig().getBoolean("checkForUpdates")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new UpdateChecker(this, 111485).getVersion(version -> {
|
new UpdateChecker(this, 111485, foliaSupportedUtils).getVersion(version -> {
|
||||||
if (this.getDescription().getVersion().equals(version)) {
|
if (this.getDescription().getVersion().equals(version)) {
|
||||||
getLogger().info("There is not a new update available.");
|
printConsoleLine("There is not a new update available.");
|
||||||
} else {
|
} else {
|
||||||
getLogger().info("There is a new update available: " + version);
|
printConsoleLine("&eThere is a new update available: " + ChatColor.GOLD + version);
|
||||||
getLogger().info(". Download it from https://www.spigotmc.org/resources/nodropx.111485/");
|
printConsoleLine("&eDownload it from " + ChatColor.GOLD + "https://www.spigotmc.org/resources/nodropx.111485/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -156,25 +271,35 @@ public final class NoDropX extends JavaPlugin {
|
|||||||
|
|
||||||
|
|
||||||
private void printCredits() {
|
private void printCredits() {
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "************************************************************");
|
printCreditLine("&a************************************************************");
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "* " + ChatColor.YELLOW + "NoDropX version " + ChatColor.GOLD + getDescription().getVersion() + ChatColor.GRAY + " (uses CarcadeX v. 1.0.7)");
|
printCreditLine("&a* &2&lNoDrop&a&lX&e version &6" + getDescription().getVersion());
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "* " + ChatColor.YELLOW + "By " + ChatColor.RED + "itzRedTea");
|
printCreditLine("&a* &eBy &citzRedTea");
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "* "+ ChatColor.YELLOW + "Detected bukkit version " + ChatColor.GOLD + Bukkit.getBukkitVersion());
|
printCreditLine("&a* &eDetected bukkit version &6" + Bukkit.getBukkitVersion());
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "* "+ ChatColor.YELLOW + "support HEX colors " + (supportHEX ? ChatColor.DARK_GREEN + "YES" : ChatColor.DARK_RED + "NO"));
|
printCreditLine("&a* &esupport HEX colors " + (supportHEX ? "&2YES" : "&4NO"));
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "* "+ ChatColor.YELLOW + "support Kyori as lore " + (supportKyoriLore ? ChatColor.DARK_GREEN + "YES" : ChatColor.DARK_RED + "NO"));
|
printCreditLine("&a* &esupport Kyori as lore " + (supportKyoriLore ? "&2YES" : "&4NO"));
|
||||||
Bukkit.getLogger().info(ChatColor.GREEN + "************************************************************");
|
printCreditLine("&a************************************************************");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printConsoleLine(String s) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||||
|
"&e[&2&lNoDrop&a&lX&e] &f" + s));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printCreditLine(String s) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onReload() {
|
public void onReload() {
|
||||||
pagesRepo.saveAll();
|
personalStorageRepo.saveAll();
|
||||||
capacity.reload();
|
menuFacade.clearAllCache();
|
||||||
|
capacityService.reload();
|
||||||
messages.reload(YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml")));
|
messages.reload(YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml")));
|
||||||
cosmeticService.load(YamlConfiguration.loadConfiguration(new File(getDataFolder(), "cosmetics.yml")));
|
noDropCosmeticService.load(YamlConfiguration.loadConfiguration(new File(getDataFolder(), "cosmetics.yml")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
pagesRepo.saveAll();
|
personalStorageRepo.saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NoDropAPI getAPI() {
|
public static NoDropAPI getAPI() {
|
||||||
|
|||||||
+6
-3
@@ -11,10 +11,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* This event is called when item changes no drop status
|
* This event is called when item changes no drop status
|
||||||
*/
|
*/
|
||||||
public class ChangeNoDropEvent extends PlayerEvent implements Cancellable {
|
public class PlayerChangeNoDropEvent extends PlayerEvent implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final boolean newValue;
|
private final boolean newValue;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -23,7 +23,7 @@ public class ChangeNoDropEvent extends PlayerEvent implements Cancellable {
|
|||||||
|
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
|
|
||||||
public ChangeNoDropEvent(@NotNull Player who, boolean newValue, @NotNull ItemStack item) {
|
public PlayerChangeNoDropEvent(@NotNull Player who, boolean newValue, @NotNull ItemStack item) {
|
||||||
super(who);
|
super(who);
|
||||||
this.newValue = newValue;
|
this.newValue = newValue;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
@@ -48,4 +48,7 @@ public class ChangeNoDropEvent extends PlayerEvent implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getNewValue() {
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.redtea.nodropx.api.facade;
|
package me.redtea.nodropx.api.facade;
|
||||||
|
|
||||||
|
import lombok.val;
|
||||||
import me.redtea.nodropx.api.facade.manipulator.StorageManipulator;
|
import me.redtea.nodropx.api.facade.manipulator.StorageManipulator;
|
||||||
import me.redtea.nodropx.util.MaterialUtils;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@@ -22,7 +22,7 @@ public interface NoDropAPI {
|
|||||||
* @author redtea
|
* @author redtea
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
void setNoDrop(@NotNull ItemStack item, boolean isNoDrop);
|
ItemStack setNoDrop(@NotNull ItemStack item, boolean isNoDrop);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if item is no drop item
|
* Check if item is no drop item
|
||||||
@@ -41,8 +41,20 @@ public interface NoDropAPI {
|
|||||||
* @author redtea
|
* @author redtea
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
ItemStack getNoDrop(@NotNull Material material, int amount);
|
default ItemStack getNoDrop(@NotNull Material material, int amount) {
|
||||||
|
val item = new ItemStack(material, amount);
|
||||||
|
setNoDrop(item, true);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives the entity no drop item
|
||||||
|
* @param entity who will get no drop item
|
||||||
|
* @param item no drop item
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
void giveNoDrop(@NotNull HumanEntity entity, @NotNull ItemStack item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives the entity no drop item
|
* Gives the entity no drop item
|
||||||
@@ -52,7 +64,9 @@ public interface NoDropAPI {
|
|||||||
* @author redtea
|
* @author redtea
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
void giveNoDrop(@NotNull HumanEntity entity, @NotNull Material material, int amount);
|
default void giveNoDrop(@NotNull HumanEntity entity, @NotNull Material material, int amount) {
|
||||||
|
giveNoDrop(entity, getNoDrop(material, amount));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns an object for accessing the storage of a player with UUID playerUniqueId
|
* returns an object for accessing the storage of a player with UUID playerUniqueId
|
||||||
@@ -64,7 +78,16 @@ public interface NoDropAPI {
|
|||||||
@NotNull StorageManipulator getStorageManipulator(@NotNull UUID playerUniqueId);
|
@NotNull StorageManipulator getStorageManipulator(@NotNull UUID playerUniqueId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the slot numbers that an no drop item with this material saves at death
|
* returns the slot numbers that no drop item with this itemStack saves at death
|
||||||
|
* @param itemStack itemStack to check
|
||||||
|
* @return numbers of saved slots
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.3
|
||||||
|
*/
|
||||||
|
@NotNull Collection<Integer> getCapacitySlots(ItemStack itemStack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the slot numbers that no drop item with this material saves at death
|
||||||
* @param material material to check
|
* @param material material to check
|
||||||
* @return numbers of saved slots
|
* @return numbers of saved slots
|
||||||
* @author redtea
|
* @author redtea
|
||||||
@@ -75,9 +98,7 @@ public interface NoDropAPI {
|
|||||||
/**
|
/**
|
||||||
* @see NoDropAPI#getCapacitySlots(Material)
|
* @see NoDropAPI#getCapacitySlots(Material)
|
||||||
*/
|
*/
|
||||||
default @NotNull Collection<Integer> getCapacitySlots(String material) {
|
@NotNull Collection<Integer> getCapacitySlots(String material);
|
||||||
return getCapacitySlots(MaterialUtils.getMaterialFromString(material));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NoDropAPI#getStorageManipulator(UUID)
|
* @see NoDropAPI#getStorageManipulator(UUID)
|
||||||
@@ -89,9 +110,7 @@ public interface NoDropAPI {
|
|||||||
/**
|
/**
|
||||||
* @see NoDropAPI#giveNoDrop(HumanEntity, Material, int)
|
* @see NoDropAPI#giveNoDrop(HumanEntity, Material, int)
|
||||||
*/
|
*/
|
||||||
default void giveNoDrop(@NotNull HumanEntity entity, @NotNull String material, int amount) {
|
void giveNoDrop(@NotNull HumanEntity entity, @NotNull String material, int amount);
|
||||||
giveNoDrop(entity, MaterialUtils.getMaterialFromString(material), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NoDropAPI#giveNoDrop(HumanEntity, Material, int)
|
* @see NoDropAPI#giveNoDrop(HumanEntity, Material, int)
|
||||||
@@ -110,9 +129,7 @@ public interface NoDropAPI {
|
|||||||
/**
|
/**
|
||||||
* @see NoDropAPI#getNoDrop(Material, int)
|
* @see NoDropAPI#getNoDrop(Material, int)
|
||||||
*/
|
*/
|
||||||
default @NotNull ItemStack getNoDrop(@NotNull String material, int amount) {
|
@NotNull ItemStack getNoDrop(@NotNull String material, int amount);
|
||||||
return getNoDrop(MaterialUtils.getMaterialFromString(material), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NoDropAPI#getNoDrop(Material, int)
|
* @see NoDropAPI#getNoDrop(Material, int)
|
||||||
@@ -127,4 +144,55 @@ public interface NoDropAPI {
|
|||||||
default @NotNull ItemStack getNoDrop(@NotNull String material) {
|
default @NotNull ItemStack getNoDrop(@NotNull String material) {
|
||||||
return getNoDrop(material, 1);
|
return getNoDrop(material, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set AllNoDrop
|
||||||
|
* @param item the item who's AllNoDrop property are changing
|
||||||
|
* @param isAllNoDrop will the item save all items in player's inventory from death?
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
ItemStack setAllNoDrop(@NotNull ItemStack item, boolean isAllNoDrop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if item is AllNoDrop
|
||||||
|
* @param item the item being checked
|
||||||
|
* @return true if the item save all items in player's inventory from death
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
boolean isAllNoDrop(@NotNull ItemStack item);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate new nodropall item by material and amount
|
||||||
|
* @param material material of item
|
||||||
|
* @param amount count of item
|
||||||
|
* @return nodropall item
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
default ItemStack getAllNoDrop(@NotNull Material material, int amount) {
|
||||||
|
val item = new ItemStack(material, amount);
|
||||||
|
setAllNoDrop(item, true);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate new nodropall item by material and amount
|
||||||
|
* @param material material of item
|
||||||
|
* @param amount count of item
|
||||||
|
* @return nodropall item
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see NoDropAPI#getAllNoDrop(Material, int)
|
||||||
|
*/
|
||||||
|
ItemStack getAllNoDrop(@NotNull String material, int amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see NoDropAPI#getAllNoDrop(Material, int)
|
||||||
|
*/
|
||||||
|
void giveAllNoDrop(HumanEntity entity, @NotNull String material, int amount);
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,9 @@ import me.redtea.nodropx.api.facade.manipulator.StorageManipulator;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.redtea.nodropx.factory.item.NoDropItemFactory;
|
import me.redtea.nodropx.factory.item.NoDropItemFactory;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.AllNoDropService;
|
||||||
|
import me.redtea.nodropx.service.capasity.CapacityService;
|
||||||
|
import me.redtea.nodropx.service.material.ItemStackService;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.service.storage.StorageService;
|
import me.redtea.nodropx.service.storage.StorageService;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -23,11 +26,14 @@ public class NoDropXFacade implements NoDropAPI {
|
|||||||
private final NoDropService noDropService;
|
private final NoDropService noDropService;
|
||||||
private final NoDropItemFactory itemFactory;
|
private final NoDropItemFactory itemFactory;
|
||||||
private final StorageService storageService;
|
private final StorageService storageService;
|
||||||
private final Repo<String, List<Integer>> capacity;
|
private final CapacityService capacityService;
|
||||||
|
private final ItemStackService itemStackService;
|
||||||
|
private final AllNoDropService allNoDropService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNoDrop(@NotNull ItemStack item, boolean isNoDrop) {
|
public ItemStack setNoDrop(@NotNull ItemStack item, boolean isNoDrop) {
|
||||||
noDropService.setNoDrop(item, isNoDrop);
|
noDropService.setNoDrop(item, isNoDrop);
|
||||||
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,6 +47,11 @@ public class NoDropXFacade implements NoDropAPI {
|
|||||||
return itemFactory.createNoDrop(material, amount);
|
return itemFactory.createNoDrop(material, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveNoDrop(@NotNull HumanEntity entity, @NotNull ItemStack item) {
|
||||||
|
entity.getInventory().addItem(setNoDrop(item, true));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveNoDrop(@NotNull HumanEntity entity, @NotNull Material material, int amount) {
|
public void giveNoDrop(@NotNull HumanEntity entity, @NotNull Material material, int amount) {
|
||||||
entity.getInventory().addItem(getNoDrop(material, amount));
|
entity.getInventory().addItem(getNoDrop(material, amount));
|
||||||
@@ -66,8 +77,49 @@ public class NoDropXFacade implements NoDropAPI {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Collection<Integer> getCapacitySlots(ItemStack itemStack) {
|
||||||
|
return capacityService.get(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Collection<Integer> getCapacitySlots(Material material) {
|
public @NotNull Collection<Integer> getCapacitySlots(Material material) {
|
||||||
return capacity.get(material.name()).orElse(new ArrayList<>());
|
return capacityService.get(material);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Collection<Integer> getCapacitySlots(String material) {
|
||||||
|
return getCapacitySlots(itemStackService.get(material, 1).getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveNoDrop(@NotNull HumanEntity entity, @NotNull String material, int amount) {
|
||||||
|
giveNoDrop(entity, itemStackService.get(material, amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ItemStack getNoDrop(@NotNull String material, int amount) {
|
||||||
|
return setNoDrop(itemStackService.get(material, amount), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack setAllNoDrop(@NotNull ItemStack item, boolean isAllNoDrop) {
|
||||||
|
allNoDropService.setAllNoDrop(item, isAllNoDrop);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllNoDrop(@NotNull ItemStack item) {
|
||||||
|
return allNoDropService.isAllNoDrop(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getAllNoDrop(@NotNull String material, int amount) {
|
||||||
|
return setAllNoDrop(itemStackService.get(material, amount), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void giveAllNoDrop(HumanEntity entity, @NotNull String material, int amount) {
|
||||||
|
entity.getInventory().addItem(getAllNoDrop(material, amount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,32 @@
|
|||||||
package me.redtea.nodropx.command;
|
package me.redtea.nodropx.command;
|
||||||
|
|
||||||
|
import dev.triumphteam.cmd.bukkit.annotation.Permission;
|
||||||
|
import dev.triumphteam.cmd.core.annotations.Command;
|
||||||
|
import dev.triumphteam.cmd.core.annotations.NamedArguments;
|
||||||
|
import dev.triumphteam.cmd.core.annotations.Optional;
|
||||||
|
import dev.triumphteam.cmd.core.annotations.Suggestion;
|
||||||
|
import dev.triumphteam.cmd.core.suggestion.SuggestionContext;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.mattstudios.mf.annotations.*;
|
import lombok.val;
|
||||||
import me.mattstudios.mf.base.CommandBase;
|
|
||||||
import me.redtea.nodropx.NoDropX;
|
import me.redtea.nodropx.NoDropX;
|
||||||
import me.redtea.nodropx.api.facade.NoDropAPI;
|
import me.redtea.nodropx.api.facade.NoDropAPI;
|
||||||
import me.redtea.nodropx.gui.facade.GuiFacade;
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
import me.redtea.nodropx.libs.message.container.Messages;
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.AllNoDropService;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import me.redtea.nodropx.service.event.EventService;
|
||||||
|
import me.redtea.nodropx.service.material.ItemStackService;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main command of plugin
|
* Main command of plugin
|
||||||
@@ -19,38 +35,46 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
@Command("nodrop")
|
@Command("nodrop")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class NoDropCommand extends CommandBase {
|
public class NoDropCommand {
|
||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
private final NoDropAPI noDropAPI;
|
private final NoDropAPI noDropAPI;
|
||||||
private final GuiFacade guiFacade;
|
private final MenuFacade menuFacade;
|
||||||
private final NoDropX plugin;
|
private final NoDropX plugin;
|
||||||
|
private final ItemStackService itemStackService;
|
||||||
|
private final DropConfirmService confirmService;
|
||||||
|
private final EventService eventService;
|
||||||
|
private final AllNoDropService allNoDropService;
|
||||||
|
|
||||||
@Default
|
@Command
|
||||||
public void onDefault(final CommandSender sender) {
|
public void onDefault(final CommandSender sender) {
|
||||||
messages.get("usage").send(sender);
|
messages.get("usage").send(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand("give")
|
|
||||||
@Permission("R")
|
|
||||||
@Completion({"#players", "#materials", "#range:1-64"})
|
@Command("give")
|
||||||
|
@Permission("nodropx.give")
|
||||||
|
@NamedArguments("query-parameters")
|
||||||
|
//@TabComplete(complete = {"#players", "#materials", "#range:1-64"})
|
||||||
public void onGive(final CommandSender sender,
|
public void onGive(final CommandSender sender,
|
||||||
final Player player,
|
final Player player,
|
||||||
final String material,
|
@Suggestion("allmaterials") final String material,
|
||||||
@Optional final Integer amount) {
|
@Optional final Integer amount) {
|
||||||
try {
|
try {
|
||||||
noDropAPI.giveNoDrop(player, material, amount == null ? 1 : amount);
|
noDropAPI.giveNoDrop(player, material, amount == null || amount == 0 ? 1 : amount);
|
||||||
messages.get("give.success")
|
messages.get("give.success")
|
||||||
.replaceAll("%item%", material)
|
.replaceAll("%item%", material)
|
||||||
.replaceAll("%player%", player.getName())
|
.replaceAll("%player%", player.getName())
|
||||||
.replaceAll("%amount%", amount == null ? "0" : amount.toString())
|
.replaceAll("%amount%", amount == null ? "1" : amount.toString())
|
||||||
.send(sender);
|
.send(sender);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
messages.get("give.fail").send(sender);
|
messages.get("give.fail").send(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand("reload")
|
@Command("reload")
|
||||||
@Permission("nodropx.reload")
|
@Permission("nodropx.reload")
|
||||||
public void onReload(final CommandSender sender) {
|
public void onReload(final CommandSender sender) {
|
||||||
long time = new Date().getTime();
|
long time = new Date().getTime();
|
||||||
@@ -58,9 +82,130 @@ public class NoDropCommand extends CommandBase {
|
|||||||
messages.get("reload").replaceAll("%time%", String.valueOf(new Date().getTime() - time)).send(sender);
|
messages.get("reload").replaceAll("%time%", String.valueOf(new Date().getTime() - time)).send(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubCommand("gui")
|
@Command("givestorage")
|
||||||
|
@Permission("nodropx.giveStorage")
|
||||||
|
@NamedArguments("query-parameters")
|
||||||
|
//@TabComplete(complete = {"#players", "#materials", "#range:1-64"})
|
||||||
|
public void onGiveStorage(final CommandSender sender,
|
||||||
|
final String playerName,
|
||||||
|
final String material,
|
||||||
|
@Optional final Integer amount) {
|
||||||
|
try {
|
||||||
|
val item = noDropAPI.setNoDrop(itemStackService.get(material, amount == null || amount == 0 ? 1 : amount), true);
|
||||||
|
val player = getOfflinePlayer(playerName);
|
||||||
|
if(player == null) {
|
||||||
|
messages.get("noExists").send(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
noDropAPI.getStorageManipulator(player).add(item);
|
||||||
|
messages.get("giveToStorage.success")
|
||||||
|
.replaceAll("%item%", material)
|
||||||
|
.replaceAll("%player%", playerName)
|
||||||
|
.replaceAll("%amount%", amount == null ? "1" : amount.toString())
|
||||||
|
.send(sender);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
messages.get("giveToStorage.fail").send(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command("ignoreconfirm")
|
||||||
|
@Permission("nodropx.ignoreConfirm")
|
||||||
|
public void onIgnoreConfirm(final CommandSender sender, @Optional Player target) {
|
||||||
|
if(target == null) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
messages.get("error").send(sender);
|
||||||
|
} else {
|
||||||
|
messages.get("ignoreConfirm.on").send(sender);
|
||||||
|
confirmService.forceConfirm((Player) sender);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
confirmService.forceConfirm(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command("ignoreconfirmtimed")
|
||||||
|
@Permission("nodropx.ignoreConfirm.timed")
|
||||||
|
public void onIgnoreConfirmTimed(final CommandSender sender, Integer sec, @Optional Player target) {
|
||||||
|
if(target == null) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
messages.get("error").send(sender);
|
||||||
|
} else {
|
||||||
|
confirmService.forceConfirm((Player) sender);
|
||||||
|
try {
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin,() -> confirmService.removeForceConfirm((Player) sender),20L*sec);
|
||||||
|
messages.get("ignoreConfirm.on").send(sender);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "This operation didn't supports on your environment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
confirmService.forceConfirm(target);
|
||||||
|
try {
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin,() -> confirmService.removeForceConfirm(target),20L*sec);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "This operation didn't supports on your environment");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command("noignoreconfirm")
|
||||||
|
@Permission("nodropx.noIgnoreConfirm")
|
||||||
|
public void onNoIgnoreConfirm(final CommandSender sender, @Optional Player target) {
|
||||||
|
if(target == null) {
|
||||||
|
if(!(sender instanceof Player)) {
|
||||||
|
messages.get("error").send(sender);
|
||||||
|
} else {
|
||||||
|
confirmService.removeForceConfirm((Player) sender);
|
||||||
|
messages.get("ignoreConfirm.off").send(sender);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
confirmService.removeForceConfirm(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Command("applyhand")
|
||||||
|
@Permission("nodropx.applyhand")
|
||||||
|
public void onApplyHand(final Player sender) {
|
||||||
|
try {
|
||||||
|
val event = eventService.callPlayerChangeNoDropEvent(sender, sender.getInventory().getItemInMainHand(), true);
|
||||||
|
noDropAPI.setNoDrop(sender.getInventory().getItemInMainHand(), event.getNewValue());
|
||||||
|
messages.get("applyHand.success").send(sender);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
messages.get("applyHand.fail").send(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(value = "gui", alias = "storage")
|
||||||
@Permission("nodropx.gui")
|
@Permission("nodropx.gui")
|
||||||
public void onGui(final Player sender) {
|
public void onGui(final Player sender) {
|
||||||
guiFacade.openNoDropStorage(sender);
|
menuFacade.openPersonalStorage(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private OfflinePlayer getOfflinePlayer(final String name) {
|
||||||
|
for(OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if(player.getName() != null && player.getName().equalsIgnoreCase(name)) return player;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command("giveallnodrop")
|
||||||
|
@Permission("nodropx.giveallnodrop")
|
||||||
|
@NamedArguments("query-parameters")
|
||||||
|
// @TabComplete(complete = {"#players", "#materials", "#range:1-64"})
|
||||||
|
public void onGiveAllNoDrop(final CommandSender sender,
|
||||||
|
final Player player,
|
||||||
|
final String material,
|
||||||
|
@Optional final Integer amount) {
|
||||||
|
try {
|
||||||
|
noDropAPI.giveAllNoDrop(player, material, amount == null || amount == 0 ? 1 : amount);
|
||||||
|
messages.get("give.success")
|
||||||
|
.replaceAll("%item%", material)
|
||||||
|
.replaceAll("%player%", player.getName())
|
||||||
|
.replaceAll("%amount%", amount == null ? "1" : amount.toString())
|
||||||
|
.send(sender);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
messages.get("give.fail").send(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,4 +12,5 @@ public class TextContext {
|
|||||||
private final File cosmetics;
|
private final File cosmetics;
|
||||||
private final boolean supportHex;
|
private final boolean supportHex;
|
||||||
private final boolean supportKyori;
|
private final boolean supportKyori;
|
||||||
|
private final String path;
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ public class TextServicesFactoryImpl implements TextServicesFactory {
|
|||||||
cosmeticStrategy = new LoreMD5Cosmetics();
|
cosmeticStrategy = new LoreMD5Cosmetics();
|
||||||
} else cosmeticStrategy = new LoreKyoriCosmetic();
|
} else cosmeticStrategy = new LoreKyoriCosmetic();
|
||||||
|
|
||||||
return new TextContext(cosmeticStrategy, messages, cosmetics, isSupportHEX, isSupportKyoriLore);
|
return new TextContext(cosmeticStrategy, messages, cosmetics, isSupportHEX, isSupportKyoriLore, "text/" + folder + "/messages.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package me.redtea.nodropx.folia;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import me.redtea.nodropx.service.respawn.RespawnService;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
|
//Experimental. Must be refactored in the future.
|
||||||
|
public class FoliaSupporter {
|
||||||
|
private RespawnService respawnService;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static boolean runningOnFolia = false;
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public void run(RespawnService respawnService, Plugin plugin) {
|
||||||
|
try {
|
||||||
|
boolean isFolia = false;
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||||
|
isFolia = true;
|
||||||
|
} catch (ClassNotFoundException ignored) {}
|
||||||
|
String version = ((JsonObject) new JsonParser().parse(new FileReader("version_history.json"))).get("currentVersion").getAsString();
|
||||||
|
if(!isFolia && !version.toLowerCase().contains("folia") && !plugin.getConfig().getBoolean("forceUseFoliaPatches")
|
||||||
|
&& !(Bukkit.getName().toLowerCase().contains("folia"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
runningOnFolia = true;
|
||||||
|
plugin.getLogger().info("Found Folia! Applying patches for this...");
|
||||||
|
this.respawnService = respawnService;
|
||||||
|
Bukkit.getPluginManager().registerEvents(new FoliaDeathListener(), plugin);
|
||||||
|
plugin.getLogger().info("Patches for Folia successfully applied!");
|
||||||
|
} catch (Throwable ignored) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
temp fix when folia not called respawn event
|
||||||
|
*/
|
||||||
|
class FoliaDeathListener implements Listener {
|
||||||
|
private final Set<Player> toRespawn = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
|
public FoliaDeathListener() {
|
||||||
|
new Thread(() -> {
|
||||||
|
while (true) {
|
||||||
|
for(Player player : toRespawn) {
|
||||||
|
if(!player.isDead()) {
|
||||||
|
onRespawn(player);
|
||||||
|
toRespawn.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRespawn(Player player) {
|
||||||
|
respawnService.giveSavedItems(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDeath(PlayerDeathEvent event) {
|
||||||
|
toRespawn.add(event.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package me.redtea.nodropx.gui.facade;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface GuiFacade {
|
|
||||||
void openNoDropStorage(Player player);
|
|
||||||
void clearCache(Player player);
|
|
||||||
void clearAllCache();
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package me.redtea.nodropx.gui.facade.impl;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import me.redtea.nodropx.gui.facade.GuiFacade;
|
|
||||||
import me.redtea.nodropx.gui.pages.StorageGui;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class GuiFacadeImpl implements GuiFacade {
|
|
||||||
private final StorageGui storageGui;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openNoDropStorage(Player player) {
|
|
||||||
storageGui.open(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearCache(Player player) {
|
|
||||||
storageGui.clearCache(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearAllCache() {
|
|
||||||
storageGui.clearAllCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,6 +5,7 @@ import me.redtea.nodropx.libs.message.factory.MessageFactory;
|
|||||||
import me.redtea.nodropx.libs.message.factory.impl.LegacyFactoryImpl;
|
import me.redtea.nodropx.libs.message.factory.impl.LegacyFactoryImpl;
|
||||||
import me.redtea.nodropx.libs.message.model.Message;
|
import me.redtea.nodropx.libs.message.model.Message;
|
||||||
import me.redtea.nodropx.libs.message.model.impl.NullMessage;
|
import me.redtea.nodropx.libs.message.model.impl.NullMessage;
|
||||||
|
import me.redtea.nodropx.libs.message.verifier.MessageVerifier;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@@ -119,7 +120,11 @@ public interface Messages {
|
|||||||
/**
|
/**
|
||||||
* <h1>Sets custom message parse factory.</h1>
|
* <h1>Sets custom message parse factory.</h1>
|
||||||
*/
|
*/
|
||||||
void factory(MessageFactory messageFactory);
|
Messages factory(MessageFactory messageFactory);
|
||||||
|
|
||||||
|
Messages init();
|
||||||
|
|
||||||
|
void setVerifier(MessageVerifier verifier);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>Create container using configuration section</h1>
|
* <h1>Create container using configuration section</h1>
|
||||||
@@ -134,7 +139,7 @@ public interface Messages {
|
|||||||
* @return container with messages
|
* @return container with messages
|
||||||
*/
|
*/
|
||||||
static Messages of(ConfigurationSection section) {
|
static Messages of(ConfigurationSection section) {
|
||||||
return new MessagesImpl(section);
|
return new MessagesImpl(section).init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +173,7 @@ public interface Messages {
|
|||||||
* @return container with messages
|
* @return container with messages
|
||||||
*/
|
*/
|
||||||
static Messages of(Plugin plugin) {
|
static Messages of(Plugin plugin) {
|
||||||
return of(plugin, "text/legacy/messages.yml");
|
return of(plugin, "messages.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,28 +207,24 @@ public interface Messages {
|
|||||||
* @return container with messages
|
* @return container with messages
|
||||||
*/
|
*/
|
||||||
static Messages legacy(ConfigurationSection section) {
|
static Messages legacy(ConfigurationSection section) {
|
||||||
return asLegacy(of(section));
|
return new MessagesImpl(section).factory(new LegacyFactoryImpl()).init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Messages#legacy(ConfigurationSection) */
|
/** @see Messages#legacy(ConfigurationSection) */
|
||||||
static Messages legacy(Plugin plugin, String fileName) {
|
static Messages legacy(Plugin plugin, String fileName) {
|
||||||
return asLegacy(of(plugin, fileName));
|
File file = new File(plugin.getDataFolder(), fileName);
|
||||||
|
if(!file.exists()) plugin.saveResource(fileName, false);
|
||||||
|
return new MessagesImpl(file).factory(new LegacyFactoryImpl()).init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Messages#legacy(ConfigurationSection) */
|
/** @see Messages#legacy(ConfigurationSection) */
|
||||||
static Messages legacy(Plugin plugin) {
|
static Messages legacy(Plugin plugin) {
|
||||||
return asLegacy(of(plugin));
|
return legacy(plugin, "messages.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see Messages#legacy(ConfigurationSection) */
|
/** @see Messages#legacy(ConfigurationSection) */
|
||||||
static Messages legacy(File file) {
|
static Messages legacy(File file) {
|
||||||
return asLegacy(of(file));
|
return new MessagesImpl(file).factory(new LegacyFactoryImpl()).init();
|
||||||
}
|
|
||||||
|
|
||||||
/** @see Messages#legacy(ConfigurationSection) */
|
|
||||||
static Messages asLegacy(Messages messages) {
|
|
||||||
messages.factory(new LegacyFactoryImpl());
|
|
||||||
return messages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.redtea.nodropx.libs.message.container.impl;
|
package me.redtea.nodropx.libs.message.container.impl;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.redtea.nodropx.libs.message.verifier.MessageVerifier;
|
||||||
import me.redtea.nodropx.libs.message.container.Messages;
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
import me.redtea.nodropx.libs.message.factory.MessageFactory;
|
import me.redtea.nodropx.libs.message.factory.MessageFactory;
|
||||||
import me.redtea.nodropx.libs.message.model.Message;
|
import me.redtea.nodropx.libs.message.model.Message;
|
||||||
@@ -8,9 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class MessagesImpl implements Messages {
|
public class MessagesImpl implements Messages {
|
||||||
private Map<String, Message> messages;
|
private Map<String, Message> messages;
|
||||||
@@ -19,25 +19,52 @@ public class MessagesImpl implements Messages {
|
|||||||
|
|
||||||
private final Message NULL_MESSAGE = factory.nullMessage();
|
private final Message NULL_MESSAGE = factory.nullMessage();
|
||||||
|
|
||||||
|
private ConfigurationSection section;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private MessageVerifier verifier;
|
||||||
|
|
||||||
public MessagesImpl() {
|
public MessagesImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagesImpl(@NotNull ConfigurationSection section) {
|
public MessagesImpl(@NotNull ConfigurationSection section) {
|
||||||
messages = fromConfigurationToMap(section);
|
this.section = section;
|
||||||
|
}
|
||||||
|
public MessagesImpl(@NotNull ConfigurationSection section, MessageVerifier verifier) {
|
||||||
|
this.section = section;
|
||||||
|
this.verifier = verifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagesImpl(@NotNull File file) {
|
public MessagesImpl(@NotNull File file) {
|
||||||
this(YamlConfiguration.loadConfiguration(file));
|
this(YamlConfiguration.loadConfiguration(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessagesImpl(@NotNull File file, MessageVerifier verifier) {
|
||||||
|
this(YamlConfiguration.loadConfiguration(file));
|
||||||
|
this.verifier = verifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message get(String key) {
|
public Message get(String key) {
|
||||||
|
if(!has(key)) {
|
||||||
|
if(verifier != null) {
|
||||||
|
Optional<Object> def = verifier.fromDefault(key);
|
||||||
|
if(def.isPresent()) {
|
||||||
|
if(def.get() instanceof List) messages.put(key, factory.message((List<String>) def.get()));
|
||||||
|
else messages.put(key, factory.message((def.get().toString())));
|
||||||
return messages.get(key);
|
return messages.get(key);
|
||||||
}
|
}
|
||||||
|
return NULL_MESSAGE;
|
||||||
|
}
|
||||||
|
return NULL_MESSAGE;
|
||||||
|
}
|
||||||
|
return messages.get(key) == null ? NULL_MESSAGE : messages.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message put(String key, Message message) {
|
public Message put(String key, Message message) {
|
||||||
if(!has(key)) return NULL_MESSAGE;
|
|
||||||
return messages.put(key, message);
|
return messages.put(key, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +79,15 @@ public class MessagesImpl implements Messages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void factory(MessageFactory messageFactory) {
|
public Messages factory(MessageFactory messageFactory) {
|
||||||
this.factory = messageFactory;
|
this.factory = messageFactory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Messages init() {
|
||||||
|
messages = fromConfigurationToMap(section);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Message> fromConfigurationToMap(@NotNull ConfigurationSection section) {
|
private Map<String, Message> fromConfigurationToMap(@NotNull ConfigurationSection section) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ public abstract class AbstractMessage implements Message {
|
|||||||
parse();
|
parse();
|
||||||
Audience audience = adventure.sender(sender);
|
Audience audience = adventure.sender(sender);
|
||||||
parsed.forEach(audience::sendMessage);
|
parsed.forEach(audience::sendMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component cacheComponent = null;
|
private Component cacheComponent = null;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package me.redtea.nodropx.libs.message.model;
|
package me.redtea.nodropx.libs.message.model;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.util.MaterialUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -60,4 +62,8 @@ public interface Message extends ComponentLike {
|
|||||||
default Message replaceAll(@NotNull Object from, @NotNull Object to) {
|
default Message replaceAll(@NotNull Object from, @NotNull Object to) {
|
||||||
return replaceAll(String.valueOf(from), String.valueOf(to));
|
return replaceAll(String.valueOf(from), String.valueOf(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Material toMaterial() {
|
||||||
|
return Material.matchMaterial(asUnparsedString()) == null ? Material.STONE : Material.matchMaterial(asUnparsedString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ComponentMessage extends AbstractMessage {
|
public class ComponentMessage extends AbstractMessage {
|
||||||
private final MiniMessage mm = MiniMessage.get();
|
private final MiniMessage mm = MiniMessage.builder().build();
|
||||||
|
|
||||||
public ComponentMessage(List<String> unparsed) {
|
public ComponentMessage(List<String> unparsed) {
|
||||||
super(unparsed);
|
super(unparsed);
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package me.redtea.nodropx.libs.message.verifier;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface MessageVerifier {
|
||||||
|
Optional<Object> fromDefault(String key);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package me.redtea.nodropx.libs.message.verifier.impl;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import me.redtea.nodropx.libs.message.verifier.MessageVerifier;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class FileMessageVerifier implements MessageVerifier {
|
||||||
|
private ConfigurationSection defaultSection;
|
||||||
|
|
||||||
|
private final FileConfiguration toSaveSection;
|
||||||
|
private final File toSaveFile;
|
||||||
|
|
||||||
|
public FileMessageVerifier(InputStream defaultResource, FileConfiguration toSaveSection, File toSaveFile) {
|
||||||
|
defaultSection = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultResource));
|
||||||
|
this.toSaveSection = toSaveSection;
|
||||||
|
this.toSaveFile = toSaveFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Object> fromDefault(String key) {
|
||||||
|
Optional<Object> o = Optional.ofNullable(defaultSection.get(key));
|
||||||
|
o.ifPresent(s -> saveToMain(key, s));
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public void saveToMain(String path, Object obj) {
|
||||||
|
toSaveSection.set(path, obj);
|
||||||
|
toSaveSection.save(toSaveFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package me.redtea.nodropx.listener;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
||||||
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ConfirmDropHandler implements Listener {
|
||||||
|
private final DropConfirmService confirmService;
|
||||||
|
private final MenuFacade menuFacade;
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDrop(NoDropItemThrownEvent event) {
|
||||||
|
if(!confirmService.isConfirmed(event.getPlayer()) && event.getReason() == NoDropItemThrownEvent.Reason.DROP_BY_PLAYER) {
|
||||||
|
menuFacade.openConfirmDrop(event.getPlayer());
|
||||||
|
event.setCancelled(true);
|
||||||
|
} else confirmService.resetConfirm(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
package me.redtea.nodropx.listener;
|
package me.redtea.nodropx.listener;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.impl.DropConfirmNull;
|
||||||
import me.redtea.nodropx.service.event.EventService;
|
import me.redtea.nodropx.service.event.EventService;
|
||||||
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -10,22 +14,32 @@ import org.bukkit.event.inventory.InventoryAction;
|
|||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class InventoryHandler implements Listener {
|
public class InventoryHandler implements Listener {
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
|
private final NoDropService noDropService;
|
||||||
|
private final DropConfirmService dropConfirmService;
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(InventoryClickEvent event) {
|
public void onMove(InventoryClickEvent event) {
|
||||||
if(event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)) {
|
if(event.getAction().name().startsWith("DROP")
|
||||||
|
&& (noDropService.isNoDrop(event.getCursor()) || noDropService.isNoDrop(event.getCurrentItem()))
|
||||||
|
&& !(dropConfirmService instanceof DropConfirmNull)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) && !event.getInventory().equals(event.getClickedInventory())) {
|
||||||
call(event, event.getCurrentItem());
|
call(event, event.getCurrentItem());
|
||||||
} else if(event.getAction().equals(InventoryAction.PLACE_ALL)
|
} else if(event.getAction().equals(InventoryAction.PLACE_ALL)
|
||||||
|| event.getAction().equals(InventoryAction.PLACE_ONE)
|
|| event.getAction().equals(InventoryAction.PLACE_ONE)
|
||||||
|| event.getAction().equals(InventoryAction.PLACE_SOME)) {
|
|| event.getAction().equals(InventoryAction.PLACE_SOME)) {
|
||||||
call(event, event.getCursor());
|
call(event, event.getCursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void call(InventoryClickEvent event, ItemStack item) {
|
private void call(InventoryClickEvent event, ItemStack item) {
|
||||||
|
|||||||
@@ -2,26 +2,31 @@ package me.redtea.nodropx.listener;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
||||||
import me.redtea.nodropx.gui.facade.GuiFacade;
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
import me.redtea.nodropx.service.event.EventService;
|
import me.redtea.nodropx.service.event.EventService;
|
||||||
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.service.respawn.RespawnService;
|
import me.redtea.nodropx.service.respawn.RespawnService;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PlayerHandler implements Listener {
|
public class PlayerHandler implements Listener {
|
||||||
private final RespawnService respawnService;
|
private final RespawnService respawnService;
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
private final GuiFacade guiFacade;
|
private final MenuFacade menuFacade;
|
||||||
|
|
||||||
//TODO check for armor
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDrop(PlayerDropItemEvent event) {
|
public void onDrop(PlayerDropItemEvent event) {
|
||||||
eventService.callThrownEvent(
|
eventService.callThrownEvent(
|
||||||
@@ -42,9 +47,14 @@ public class PlayerHandler implements Listener {
|
|||||||
respawnService.giveSavedItems(event.getPlayer());
|
respawnService.giveSavedItems(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
respawnService.giveSavedItems(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event) {
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
guiFacade.clearCache(event.getPlayer());
|
menuFacade.clearCache(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package me.redtea.nodropx.listener.menu;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.menu.storage.singlepage.SinglePageController;
|
||||||
|
import me.redtea.nodropx.menu.storage.singlepage.SinglePageGui;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
|
|
||||||
|
public class SinglePageGuiHandler implements Listener {
|
||||||
|
private final SinglePageController controller;
|
||||||
|
private final SinglePageGui gui;
|
||||||
|
|
||||||
|
public SinglePageGuiHandler(SinglePageController controller, SinglePageGui gui) {
|
||||||
|
this.controller = controller;
|
||||||
|
this.gui = gui;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDrag(InventoryDragEvent event) {
|
||||||
|
if(gui.isStorageGui(event.getInventory())) {
|
||||||
|
controller.onDrag(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(InventoryClickEvent event) {
|
||||||
|
if(gui.isStorageGui(event.getInventory())) {
|
||||||
|
if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) controller.onClick(event);
|
||||||
|
}
|
||||||
|
if(gui.isStorageGui(event.getClickedInventory()) && event.getWhoClicked() instanceof Player) {
|
||||||
|
controller.onClick(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClose(InventoryCloseEvent event) {
|
||||||
|
if(gui.isStorageGui(event.getInventory()) && event.getPlayer() instanceof Player) {
|
||||||
|
controller.onClose(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package me.redtea.nodropx.menu;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface CachedMenu extends Menu {
|
||||||
|
void clearCache(Player player);
|
||||||
|
void clearAllCache();
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package me.redtea.nodropx.menu;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface Menu {
|
||||||
|
void open(Player player);
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package me.redtea.nodropx.menu.dropconfirm;
|
||||||
|
|
||||||
|
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||||
|
import dev.triumphteam.gui.guis.Gui;
|
||||||
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
|
import me.redtea.nodropx.menu.Menu;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DropConfirmMFGui implements Menu {
|
||||||
|
private final Gui gui;
|
||||||
|
private final Set<UUID> inMenu = new HashSet<>();
|
||||||
|
private final DropConfirmService dropConfirmService;
|
||||||
|
private final Plugin plugin;
|
||||||
|
public DropConfirmMFGui(Messages messages, DropConfirmService dropConfirmService, Plugin plugin) {
|
||||||
|
gui = Gui.gui()
|
||||||
|
.rows(1)
|
||||||
|
.title(messages.get("gui.confirm.title").asComponent())
|
||||||
|
.disableAllInteractions()
|
||||||
|
.create();
|
||||||
|
this.plugin = plugin;
|
||||||
|
gui.setItem(1, ItemBuilder.from(messages.get("gui.confirm.yesButton.material").toMaterial())
|
||||||
|
.name(messages.get("gui.confirm.yesButton.name").asComponent())
|
||||||
|
.lore(messages.get("gui.confirm.yesButton.lore").asComponent())
|
||||||
|
.asGuiItem((event -> {
|
||||||
|
dropConfirmService.confirm((Player) event.getWhoClicked());
|
||||||
|
event.getWhoClicked().dropItem(true);
|
||||||
|
event.getWhoClicked().closeInventory();
|
||||||
|
})));
|
||||||
|
gui.setItem(7, ItemBuilder.from(messages.get("gui.confirm.noButton.material").toMaterial())
|
||||||
|
.name(messages.get("gui.confirm.noButton.name").asComponent())
|
||||||
|
.lore(messages.get("gui.confirm.noButton.lore").asComponent())
|
||||||
|
.asGuiItem((event -> event.getWhoClicked().closeInventory())));
|
||||||
|
gui.setCloseGuiAction((e) -> {
|
||||||
|
inMenu.remove(e.getPlayer().getUniqueId());
|
||||||
|
});
|
||||||
|
this.dropConfirmService = dropConfirmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player) {
|
||||||
|
if(inMenu.contains(player.getUniqueId())) {
|
||||||
|
dropConfirmService.forceConfirm(player);
|
||||||
|
player.closeInventory();
|
||||||
|
try {
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin,
|
||||||
|
() -> dropConfirmService.removeForceConfirm(player),
|
||||||
|
20*15L);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
plugin.getLogger().severe("Can not start task. Maybe will bugs. Do you run on Folia?");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inMenu.add(player.getUniqueId());
|
||||||
|
gui.open(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package me.redtea.nodropx.menu.facade;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface MenuFacade {
|
||||||
|
CachedMenu noDropStorage();
|
||||||
|
void openPersonalStorage(Player player);
|
||||||
|
void openConfirmDrop(Player player);
|
||||||
|
void clearCache(Player player);
|
||||||
|
void clearAllCache();
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package me.redtea.nodropx.menu.facade.impl;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
|
import me.redtea.nodropx.menu.Menu;
|
||||||
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MenuFacadeImpl implements MenuFacade {
|
||||||
|
private final CachedMenu personalStorageCachedMenu;
|
||||||
|
private final Menu confirmDropMenu;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CachedMenu noDropStorage() {
|
||||||
|
return personalStorageCachedMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openPersonalStorage(Player player) {
|
||||||
|
personalStorageCachedMenu.open(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openConfirmDrop(Player player) {
|
||||||
|
confirmDropMenu.open(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearCache(Player player) {
|
||||||
|
personalStorageCachedMenu.clearCache(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAllCache() {
|
||||||
|
personalStorageCachedMenu.clearAllCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package me.redtea.nodropx.menu.facade.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class NullMenuFacadeImpl implements MenuFacade {
|
||||||
|
@Override
|
||||||
|
public CachedMenu noDropStorage() {
|
||||||
|
return new CachedMenu() {
|
||||||
|
@Override
|
||||||
|
public void clearCache(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAllCache() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openPersonalStorage(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openConfirmDrop(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearCache(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAllCache() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
-15
@@ -1,14 +1,16 @@
|
|||||||
package me.redtea.nodropx.gui.pages;
|
package me.redtea.nodropx.menu.storage.pages;
|
||||||
|
|
||||||
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
import dev.triumphteam.gui.builder.item.ItemBuilder;
|
||||||
import dev.triumphteam.gui.guis.Gui;
|
import dev.triumphteam.gui.guis.Gui;
|
||||||
import dev.triumphteam.gui.guis.GuiItem;
|
import dev.triumphteam.gui.guis.GuiItem;
|
||||||
import dev.triumphteam.gui.guis.ScrollingGui;
|
import dev.triumphteam.gui.guis.ScrollingGui;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
||||||
import me.redtea.nodropx.libs.message.container.Messages;
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
|
import me.redtea.nodropx.service.material.ItemStackService;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.util.MaterialUtils;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
@@ -21,13 +23,15 @@ import java.util.*;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class StorageGui {
|
public class MFPageGui implements CachedMenu {
|
||||||
private final Map<UUID, ScrollingGui> cache = new HashMap<>();
|
|
||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
private final MutableRepo<UUID, List<ItemStack>> pagesRepo;
|
private final MutableRepo<UUID, List<ItemStack>> personalStorageRepo;
|
||||||
private final NoDropService noDropService;
|
private final NoDropService noDropService;
|
||||||
|
private final ItemStackService itemStackService;
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
private final Map<UUID, ScrollingGui> cache = new HashMap<>();
|
||||||
|
|
||||||
public void open(Player player) {
|
public void open(Player player) {
|
||||||
if(cache.containsKey(player.getUniqueId())) {
|
if(cache.containsKey(player.getUniqueId())) {
|
||||||
cache.get(player.getUniqueId()).open(player);
|
cache.get(player.getUniqueId()).open(player);
|
||||||
@@ -35,7 +39,7 @@ public class StorageGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScrollingGui gui = Gui.scrolling()
|
ScrollingGui gui = Gui.scrolling()
|
||||||
.title(messages.get("gui.title").asComponent())
|
.title(messages.get("gui.personalStorage.title").asComponent())
|
||||||
.rows(6)
|
.rows(6)
|
||||||
.pageSize(45)
|
.pageSize(45)
|
||||||
.disableAllInteractions()
|
.disableAllInteractions()
|
||||||
@@ -44,16 +48,16 @@ public class StorageGui {
|
|||||||
setButtons(gui);
|
setButtons(gui);
|
||||||
setAction(gui);
|
setAction(gui);
|
||||||
setOnClose(gui);
|
setOnClose(gui);
|
||||||
for(ItemStack item : pagesRepo.get(player.getUniqueId()).orElse(new ArrayList<>())) {
|
for(ItemStack item : personalStorageRepo.get(player.getUniqueId()).orElse(new ArrayList<>())) {
|
||||||
gui.addItem(ItemBuilder.from(item).asGuiItem());
|
gui.addItem(ItemBuilder.from(item).asGuiItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.open(player);
|
|
||||||
cache.put(player.getUniqueId(), gui);
|
cache.put(player.getUniqueId(), gui);
|
||||||
|
gui.open(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOnClose(ScrollingGui gui) {
|
private void setOnClose(ScrollingGui gui) {
|
||||||
gui.setCloseGuiAction(event -> pagesRepo.update(event.getPlayer().getUniqueId(), gui.getPageItems().stream()
|
gui.setCloseGuiAction(event -> personalStorageRepo.update(event.getPlayer().getUniqueId(), gui.getPageItems().stream()
|
||||||
.map(GuiItem::getItemStack)
|
.map(GuiItem::getItemStack)
|
||||||
.collect(Collectors.toList())));
|
.collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
@@ -108,21 +112,21 @@ public class StorageGui {
|
|||||||
private void setFrame(ScrollingGui gui) {
|
private void setFrame(ScrollingGui gui) {
|
||||||
for(int i = 1; i < 10; ++i) {
|
for(int i = 1; i < 10; ++i) {
|
||||||
gui.setItem(6, i, ItemBuilder.from(
|
gui.setItem(6, i, ItemBuilder.from(
|
||||||
MaterialUtils.getMaterialFromString(messages.get("gui.frame.material").asUnparsedString())
|
itemStackService.get(messages.get("gui.personalStorage.frame.material").asUnparsedString(), 1)
|
||||||
).name(messages.get("gui.frame.name").asComponent()).asGuiItem(event -> event.setCancelled(true)));
|
).name(messages.get("gui.personalStorage.frame.name").asComponent()).asGuiItem(event -> event.setCancelled(true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setButtons(ScrollingGui gui) {
|
private void setButtons(ScrollingGui gui) {
|
||||||
gui.setItem(6, 3, ItemBuilder.from(
|
gui.setItem(6, 3, ItemBuilder.from(
|
||||||
MaterialUtils.getMaterialFromString(messages.get("gui.prev.material").asUnparsedString())
|
itemStackService.get(messages.get("gui.personalStorage.prev.material").asUnparsedString(), 1)
|
||||||
).name(messages.get("gui.prev.name").asComponent()).asGuiItem(event -> {
|
).name(messages.get("gui.personalStorage.prev.name").asComponent()).asGuiItem(event -> {
|
||||||
gui.previous();
|
gui.previous();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}));
|
}));
|
||||||
gui.setItem(6, 7, ItemBuilder.from(
|
gui.setItem(6, 7, ItemBuilder.from(
|
||||||
MaterialUtils.getMaterialFromString(messages.get("gui.next.material").asUnparsedString())
|
itemStackService.get(messages.get("gui.personalStorage.next.material").asUnparsedString(), 1)
|
||||||
).name(messages.get("gui.next.name").asComponent()).asGuiItem(event -> {
|
).name(messages.get("gui.personalStorage.next.name").asComponent()).asGuiItem(event -> {
|
||||||
gui.next();
|
gui.next();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}));
|
}));
|
||||||
@@ -133,6 +137,10 @@ public class StorageGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllCache() {
|
public void clearAllCache() {
|
||||||
|
cache.forEach((k, v) -> {
|
||||||
|
Player player = Bukkit.getPlayer(k);
|
||||||
|
if(player != null) v.close(player);
|
||||||
|
});
|
||||||
cache.clear();
|
cache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package me.redtea.nodropx.menu.storage.singlepage;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
||||||
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
|
import me.redtea.nodropx.util.FoliaSupportedUtils;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.*;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SinglePageController {
|
||||||
|
private final NoDropService noDropService;
|
||||||
|
private final SinglePageGui singlePageGui;
|
||||||
|
private final MutableRepo<UUID, List<ItemStack>> personalStorageRepo;
|
||||||
|
private final FoliaSupportedUtils foliaSupportedUtils;
|
||||||
|
|
||||||
|
private final List<InventoryAction> clickActions = Lists.newArrayList(InventoryAction.MOVE_TO_OTHER_INVENTORY, InventoryAction.PLACE_ALL, InventoryAction.PLACE_ONE, InventoryAction.PLACE_SOME,
|
||||||
|
InventoryAction.SWAP_WITH_CURSOR, InventoryAction.NOTHING, InventoryAction.COLLECT_TO_CURSOR, InventoryAction.HOTBAR_MOVE_AND_READD, InventoryAction.UNKNOWN);
|
||||||
|
|
||||||
|
|
||||||
|
public void onClick(InventoryClickEvent event) {
|
||||||
|
if(clickActions.contains(event.getAction()) && !(noDropService.isNoDrop(event.getCurrentItem()))) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
foliaCheck(event.getInventory(), event.getWhoClicked(), event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDrag(InventoryDragEvent event) {
|
||||||
|
if((event.getNewItems().entrySet().stream().anyMatch(it -> !noDropService.isNoDrop(it.getValue())))) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
foliaCheck(event.getInventory(), event.getWhoClicked(), event);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void foliaCheck(Inventory inventory, HumanEntity whoClicked, InventoryEvent event) {
|
||||||
|
foliaSupportedUtils.runTask(() -> {
|
||||||
|
for(ItemStack itemStack : inventory) {
|
||||||
|
if (itemStack != null && !noDropService.isNoDrop(itemStack)) {
|
||||||
|
whoClicked.getInventory().addItem(itemStack);
|
||||||
|
inventory.remove(itemStack);
|
||||||
|
((Player) whoClicked).updateInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClose(InventoryCloseEvent event) {
|
||||||
|
Player player = (Player) event.getPlayer();
|
||||||
|
personalStorageRepo.update(event.getPlayer().getUniqueId(),
|
||||||
|
Arrays.asList(singlePageGui.getCache().get(player.getUniqueId()).getContents()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package me.redtea.nodropx.menu.storage.singlepage;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
||||||
|
import me.redtea.nodropx.libs.message.container.Messages;
|
||||||
|
import me.redtea.nodropx.menu.CachedMenu;
|
||||||
|
import me.redtea.nodropx.util.MD5ColorUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SinglePageGui implements CachedMenu {
|
||||||
|
private final Messages messages;
|
||||||
|
private final MutableRepo<UUID, List<ItemStack>> personalStorageRepo;
|
||||||
|
@Getter
|
||||||
|
private final Map<UUID, Inventory> cache = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void open(Player player) {
|
||||||
|
if(cache.containsKey(player.getUniqueId())) {
|
||||||
|
player.openInventory(cache.get(player.getUniqueId()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Inventory gui;
|
||||||
|
try {
|
||||||
|
gui = Bukkit.createInventory(null, 54, messages.get("gui.personalStorage.title").asComponent());
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
gui = Bukkit.createInventory(null, 54, MD5ColorUtils.translateHexColorCodes(messages.get("gui.personalStorage.title").asUnparsedString()));
|
||||||
|
}
|
||||||
|
for(ItemStack item : personalStorageRepo.get(player.getUniqueId()).orElse(new ArrayList<>())) if(item != null) gui.addItem(item);
|
||||||
|
|
||||||
|
cache.put(player.getUniqueId(), gui);
|
||||||
|
player.openInventory(gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCache(Player player) {
|
||||||
|
cache.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAllCache() {
|
||||||
|
cache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStorageGui(Inventory inventory) {
|
||||||
|
return cache.containsValue(inventory);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class LoreKyoriCosmetic implements CosmeticStrategy {
|
public class LoreKyoriCosmetic implements CosmeticStrategy {
|
||||||
private List<Component> lore;
|
private List<Component> lore;
|
||||||
private final MiniMessage mm = MiniMessage.get();
|
private final MiniMessage mm = MiniMessage.builder().build();
|
||||||
@Override
|
@Override
|
||||||
public void apply(ItemStack itemStack) {
|
public void apply(ItemStack itemStack) {
|
||||||
List<Component> lore = itemStack.lore();
|
List<Component> lore = itemStack.lore();
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package me.redtea.nodropx.model.materialprovider;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ItemStackProvider {
|
||||||
|
ItemStack get(String s);
|
||||||
|
List<String> allMaterials();
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package me.redtea.nodropx.model.materialprovider.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.model.materialprovider.ItemStackProvider;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ItemStackProviderDefault implements ItemStackProvider {
|
||||||
|
@Override
|
||||||
|
public ItemStack get(String s) {
|
||||||
|
if(s == null || s.equals("")) return new ItemStack(Material.AIR);
|
||||||
|
Material material = Material.matchMaterial(s);
|
||||||
|
if(material != null) return new ItemStack(material);
|
||||||
|
|
||||||
|
String[] spl = s.split(":");
|
||||||
|
|
||||||
|
if (spl[0].equals("minecraft")) {
|
||||||
|
material = Material.matchMaterial(spl[1]);
|
||||||
|
} else {
|
||||||
|
if(spl.length < 2) {
|
||||||
|
material = Material.matchMaterial(spl[0]);
|
||||||
|
} else {
|
||||||
|
material = Material.matchMaterial(spl[0]+"_"+spl[1]);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ItemStack(material == null ? Material.AIR : material);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> allMaterials() {
|
||||||
|
return Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package me.redtea.nodropx.model.materialprovider.impl;
|
||||||
|
|
||||||
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
|
import dev.lone.itemsadder.api.ItemsAdder;
|
||||||
|
import me.redtea.nodropx.model.materialprovider.ItemStackProvider;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ItemsAdderProvider implements ItemStackProvider {
|
||||||
|
@Override
|
||||||
|
public ItemStack get(String s) {
|
||||||
|
CustomStack stack = CustomStack.getInstance(s);
|
||||||
|
return (stack != null) ? stack.getItemStack() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> allMaterials() {
|
||||||
|
if((ItemsAdder.getAllItems() == null) || ItemsAdder.getAllItems().isEmpty()) return Collections.emptyList();
|
||||||
|
return ItemsAdder.getAllItems().stream().map(CustomStack::getNamespacedID).filter(s -> !s.startsWith("_iainternal")).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package me.redtea.nodropx.service.allnodrop;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for checking all no drop items
|
||||||
|
* @since 1.0.4
|
||||||
|
* @author redtea
|
||||||
|
*/
|
||||||
|
public interface AllNoDropService {
|
||||||
|
/**
|
||||||
|
* Set no drop to item
|
||||||
|
* @param item the item who's no drop property are changing
|
||||||
|
* @param isAllNoDrop will the item can drop from inventory on death?
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
void setAllNoDrop(ItemStack item, boolean isAllNoDrop);
|
||||||
|
/**
|
||||||
|
* Check if item is NoDropAll
|
||||||
|
* @param item the item being checked
|
||||||
|
* @return true if item is NoDropAll
|
||||||
|
* @author redtea
|
||||||
|
* @since 1.0.4
|
||||||
|
*/
|
||||||
|
boolean isAllNoDrop(ItemStack item);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package me.redtea.nodropx.service.allnodrop.impl;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.AllNoDropService;
|
||||||
|
import me.redtea.nodropx.service.nbt.NBTService;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AllNoDropServiceImpl implements AllNoDropService {
|
||||||
|
private final NBTService nbtService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAllNoDrop(ItemStack item, boolean isAllNoDrop) {
|
||||||
|
nbtService.setBoolTag(item, "isAllNoDrop", isAllNoDrop);
|
||||||
|
nbtService.setBoolTag(item, "isNoDrop", isAllNoDrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllNoDrop(ItemStack item) {
|
||||||
|
return nbtService.getBoolTag(item, "isAllNoDrop");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package me.redtea.nodropx.service.capasity;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.impl.yaml.YamlRepo;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public interface CapacityService {
|
||||||
|
|
||||||
|
|
||||||
|
List<Integer> get(ItemStack item);
|
||||||
|
void reload();
|
||||||
|
|
||||||
|
default List<Integer> get(Material material) {
|
||||||
|
return get(new ItemStack(material));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package me.redtea.nodropx.service.capasity.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
||||||
|
import me.redtea.nodropx.libs.carcadex.repo.impl.yaml.YamlRepo;
|
||||||
|
import me.redtea.nodropx.service.capasity.CapacityService;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CapacityServiceImpl implements CapacityService {
|
||||||
|
private final Repo<String, List<Integer>> capacityRepo;
|
||||||
|
public CapacityServiceImpl(Plugin plugin) {
|
||||||
|
capacityRepo = new YamlRepo<>(
|
||||||
|
new File(plugin.getDataFolder(), "capacity.yml").toPath(),
|
||||||
|
plugin,
|
||||||
|
conf -> conf.getKeys(false).stream().collect(Collectors.toMap(
|
||||||
|
value -> value,
|
||||||
|
conf::getIntegerList))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
return result.orElse(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reload() {
|
||||||
|
capacityRepo.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package me.redtea.nodropx.service.dropconfirm;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface DropConfirmService {
|
||||||
|
boolean isConfirmed(Player player);
|
||||||
|
void confirm(Player player);
|
||||||
|
void resetConfirm(Player player);
|
||||||
|
|
||||||
|
void forceConfirm(Player player);
|
||||||
|
void removeForceConfirm(Player player);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package me.redtea.nodropx.service.dropconfirm.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DropConfirmNull implements DropConfirmService {
|
||||||
|
@Override
|
||||||
|
public boolean isConfirmed(Player player) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirm(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetConfirm(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forceConfirm(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeForceConfirm(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package me.redtea.nodropx.service.dropconfirm.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DropConfirmServiceImpl implements DropConfirmService {
|
||||||
|
private Set<UUID> confirmed = new HashSet<>();
|
||||||
|
private Set<UUID> force = new HashSet<>();
|
||||||
|
@Override
|
||||||
|
public boolean isConfirmed(Player player) {
|
||||||
|
if(force.contains(player.getUniqueId()) || player.isDead()) return true;
|
||||||
|
return confirmed.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirm(Player player) {
|
||||||
|
confirmed.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetConfirm(Player player) {
|
||||||
|
confirmed.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forceConfirm(Player player) {
|
||||||
|
force.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeForceConfirm(Player player) {
|
||||||
|
force.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
package me.redtea.nodropx.service.event;
|
package me.redtea.nodropx.service.event;
|
||||||
|
|
||||||
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
||||||
|
import me.redtea.nodropx.api.event.PlayerChangeNoDropEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface EventService {
|
public interface EventService {
|
||||||
void callThrownEvent(Player who, ItemStack item, NoDropItemThrownEvent.Reason reason, Optional<Cancellable> rootEvent);
|
PlayerChangeNoDropEvent callPlayerChangeNoDropEvent(Player who, ItemStack item, boolean value);
|
||||||
|
@Nullable
|
||||||
|
NoDropItemThrownEvent callThrownEvent(Player who, ItemStack item, NoDropItemThrownEvent.Reason reason, Optional<Cancellable> rootEvent);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package me.redtea.nodropx.service.event.impl;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
import me.redtea.nodropx.api.event.NoDropItemThrownEvent;
|
||||||
|
import me.redtea.nodropx.api.event.PlayerChangeNoDropEvent;
|
||||||
import me.redtea.nodropx.service.event.EventService;
|
import me.redtea.nodropx.service.event.EventService;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -16,8 +17,15 @@ public class EventServiceImpl implements EventService {
|
|||||||
private final NoDropService noDropService;
|
private final NoDropService noDropService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void callThrownEvent(Player who, ItemStack item, NoDropItemThrownEvent.Reason reason, Optional<Cancellable> rootEvent) {
|
public PlayerChangeNoDropEvent callPlayerChangeNoDropEvent(Player who, ItemStack item, boolean value) {
|
||||||
if(!noDropService.isNoDrop(item)) return;
|
PlayerChangeNoDropEvent callingEvent = new PlayerChangeNoDropEvent(who, value, item);
|
||||||
|
Bukkit.getPluginManager().callEvent(callingEvent);
|
||||||
|
return callingEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NoDropItemThrownEvent callThrownEvent(Player who, ItemStack item, NoDropItemThrownEvent.Reason reason, Optional<Cancellable> rootEvent) {
|
||||||
|
if(!noDropService.isNoDrop(item)) return null;
|
||||||
NoDropItemThrownEvent callingEvent = new NoDropItemThrownEvent(
|
NoDropItemThrownEvent callingEvent = new NoDropItemThrownEvent(
|
||||||
who,
|
who,
|
||||||
reason,
|
reason,
|
||||||
@@ -25,5 +33,6 @@ public class EventServiceImpl implements EventService {
|
|||||||
);
|
);
|
||||||
Bukkit.getPluginManager().callEvent(callingEvent);
|
Bukkit.getPluginManager().callEvent(callingEvent);
|
||||||
rootEvent.ifPresent(cancellable -> cancellable.setCancelled(callingEvent.isCancelled()));
|
rootEvent.ifPresent(cancellable -> cancellable.setCancelled(callingEvent.isCancelled()));
|
||||||
|
return callingEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package me.redtea.nodropx.service.material;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.model.materialprovider.ItemStackProvider;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ItemStackService {
|
||||||
|
@NotNull
|
||||||
|
ItemStack get(String s, int amount);
|
||||||
|
|
||||||
|
void registerProvider(ItemStackProvider provider);
|
||||||
|
|
||||||
|
List<String> allMaterials();
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package me.redtea.nodropx.service.material.impl;
|
||||||
|
|
||||||
|
import lombok.val;
|
||||||
|
import me.redtea.nodropx.model.materialprovider.ItemStackProvider;
|
||||||
|
import me.redtea.nodropx.service.material.ItemStackService;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ItemStackServiceImpl implements ItemStackService {
|
||||||
|
private final List<ItemStackProvider> providers = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ItemStack get(String s, int amount) {
|
||||||
|
ItemStack result = new ItemStack(Material.AIR);
|
||||||
|
for(ItemStackProvider provider : providers) {
|
||||||
|
val i = provider.get(s);
|
||||||
|
if(i != null && i.getType() != Material.AIR) {
|
||||||
|
result = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.setAmount(amount);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerProvider(ItemStackProvider provider) {
|
||||||
|
providers.add(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> materials = null;
|
||||||
|
@Override
|
||||||
|
public List<String> allMaterials() {
|
||||||
|
if(materials == null) materials = providers.stream().map(ItemStackProvider::allMaterials).flatMap(List::stream).collect(Collectors.toList());
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,18 +9,20 @@ public interface NBTService {
|
|||||||
/**
|
/**
|
||||||
* Sets the NBT tag "isNoDrop", which indicates that the item is no drop
|
* Sets the NBT tag "isNoDrop", which indicates that the item is no drop
|
||||||
* @param item editable item
|
* @param item editable item
|
||||||
* @param isNoDrop tag value
|
* @param tag nbt tag
|
||||||
* @since 1.0.0
|
* @param value tag value
|
||||||
|
* @since 1.0.4
|
||||||
* @author redtea
|
* @author redtea
|
||||||
*/
|
*/
|
||||||
void setNoDropTag(ItemStack item, boolean isNoDrop);
|
void setBoolTag(ItemStack item, String tag, boolean value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the "isNoDrop" tag, which indicates that the item is no drop
|
* Gets the value of the "isNoDrop" tag, which indicates that the item is no drop
|
||||||
* @param item checking item
|
* @param item checking item
|
||||||
|
* @param tag nbt tag
|
||||||
* @return tag value
|
* @return tag value
|
||||||
* @since 1.0.0
|
* @since 1.0.4
|
||||||
* @author redtea
|
* @author redtea
|
||||||
*/
|
*/
|
||||||
boolean getNoDropTag(ItemStack item);
|
boolean getBoolTag(ItemStack item, String tag);
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,17 +6,19 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Tr7zwNBTServiceImpl implements NBTService {
|
public class Tr7zwNBTServiceImpl implements NBTService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNoDropTag(ItemStack item, boolean isNoDrop) {
|
public void setBoolTag(ItemStack item, String tag, boolean value) {
|
||||||
NBTItem nbtItem = new NBTItem(item);
|
NBTItem nbtItem = new NBTItem(item);
|
||||||
nbtItem.setBoolean("isNoDrop", true);
|
nbtItem.setBoolean(tag, value);
|
||||||
nbtItem.applyNBT(item);
|
nbtItem.applyNBT(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getNoDropTag(ItemStack item) {
|
public boolean getBoolTag(ItemStack item, String tag) {
|
||||||
if(item == null || item.getType() == Material.AIR) return false;
|
if(item == null || item.getType() == Material.AIR) return false;
|
||||||
NBTItem nbtItem = new NBTItem(item);
|
NBTItem nbtItem = new NBTItem(item);
|
||||||
return nbtItem.hasTag("isNoDrop") && nbtItem.getBoolean("isNoDrop");
|
return nbtItem.hasTag(tag) && nbtItem.getBoolean(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,13 +13,13 @@ public class NoDropServiceImpl implements NoDropService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNoDrop(ItemStack item, boolean isNoDrop) {
|
public void setNoDrop(ItemStack item, boolean isNoDrop) {
|
||||||
nbtService.setNoDropTag(item, isNoDrop);
|
nbtService.setBoolTag(item, "isNoDrop", true);
|
||||||
cosmeticService.applyAll(item);
|
cosmeticService.applyAll(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNoDrop(ItemStack item) {
|
public boolean isNoDrop(ItemStack item) {
|
||||||
if(item == null) return false;
|
if(item == null) return false;
|
||||||
return nbtService.getNoDropTag(item);
|
return nbtService.getBoolTag(item, "isNoDrop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package me.redtea.nodropx.service.respawn.impl;
|
||||||
|
|
||||||
|
import me.redtea.nodropx.service.respawn.RespawnService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
|
public class NullRespawnService implements RespawnService {
|
||||||
|
@Override
|
||||||
|
public void giveSavedItems(Player player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveItemsBeforeDeath(PlayerDeathEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
package me.redtea.nodropx.service.respawn.impl;
|
package me.redtea.nodropx.service.respawn.impl;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
import me.redtea.nodropx.api.event.NoDropItemDropOnDeathEvent;
|
import me.redtea.nodropx.api.event.NoDropItemDropOnDeathEvent;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
import me.redtea.nodropx.libs.carcadex.repo.Repo;
|
||||||
|
import me.redtea.nodropx.service.allnodrop.AllNoDropService;
|
||||||
|
import me.redtea.nodropx.service.capasity.CapacityService;
|
||||||
|
import me.redtea.nodropx.service.dropconfirm.DropConfirmService;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.service.respawn.RespawnService;
|
import me.redtea.nodropx.service.respawn.RespawnService;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RespawnServiceImpl implements RespawnService {
|
public class RespawnServiceImpl implements RespawnService {
|
||||||
private final NoDropService noDropService;
|
private final NoDropService noDropService;
|
||||||
|
private final AllNoDropService allNoDropService;
|
||||||
private final Map<String, Pair[]> toRespawn = new HashMap<>();
|
private final Map<String, Pair[]> toRespawn = new HashMap<>();
|
||||||
private final Repo<String, List<Integer>> capacity;
|
private final CapacityService capacityService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -25,6 +33,8 @@ public class RespawnServiceImpl implements RespawnService {
|
|||||||
if(toRespawn.containsKey(player.getName())) {
|
if(toRespawn.containsKey(player.getName())) {
|
||||||
Pair[] pairs = toRespawn.get(player.getName());
|
Pair[] pairs = toRespawn.get(player.getName());
|
||||||
for(Pair pair : pairs) player.getInventory().setItem(pair.slot, pair.item);
|
for(Pair pair : pairs) player.getInventory().setItem(pair.slot, pair.item);
|
||||||
|
toRespawn.remove(player.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +42,11 @@ public class RespawnServiceImpl implements RespawnService {
|
|||||||
public void saveItemsBeforeDeath(PlayerDeathEvent event) {
|
public void saveItemsBeforeDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getEntity();
|
||||||
Set<Integer> noDropSlots = new HashSet<>();
|
Set<Integer> noDropSlots = new HashSet<>();
|
||||||
|
boolean isHasAllNoDropItem = event.getDrops().stream().anyMatch(allNoDropService::isAllNoDrop);
|
||||||
for(int i = 0; i < player.getInventory().getSize(); ++i) {
|
for(int i = 0; i < player.getInventory().getSize(); ++i) {
|
||||||
ItemStack item = player.getInventory().getItem(i);
|
ItemStack item = player.getInventory().getItem(i);
|
||||||
if(!noDropService.isNoDrop(item)) continue;
|
if(!(noDropService.isNoDrop(item) || isHasAllNoDropItem) || item == null ||
|
||||||
|
item.getType() == Material.AIR) continue;
|
||||||
NoDropItemDropOnDeathEvent callingEvent = new NoDropItemDropOnDeathEvent(
|
NoDropItemDropOnDeathEvent callingEvent = new NoDropItemDropOnDeathEvent(
|
||||||
player,
|
player,
|
||||||
item
|
item
|
||||||
@@ -59,12 +71,13 @@ public class RespawnServiceImpl implements RespawnService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
static class Pair {
|
static class Pair {
|
||||||
int slot;
|
int slot;
|
||||||
ItemStack item;
|
ItemStack item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> getProtectedSlots(ItemStack i) {
|
private List<Integer> getProtectedSlots(ItemStack i) {
|
||||||
return capacity.get(i.getType().name()).orElse(new ArrayList<>());
|
return capacityService.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package me.redtea.nodropx.service.storage.impl;
|
package me.redtea.nodropx.service.storage.impl;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.redtea.nodropx.gui.facade.GuiFacade;
|
import me.redtea.nodropx.menu.facade.MenuFacade;
|
||||||
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
import me.redtea.nodropx.libs.carcadex.repo.MutableRepo;
|
||||||
import me.redtea.nodropx.service.nodrop.NoDropService;
|
import me.redtea.nodropx.service.nodrop.NoDropService;
|
||||||
import me.redtea.nodropx.service.storage.StorageService;
|
import me.redtea.nodropx.service.storage.StorageService;
|
||||||
@@ -14,17 +14,17 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class StorageServiceImpl implements StorageService {
|
public class StorageServiceImpl implements StorageService {
|
||||||
private final GuiFacade guiFacade;
|
private final MenuFacade menuFacade;
|
||||||
private final MutableRepo<UUID, List<ItemStack>> pagesRepo;
|
private final MutableRepo<UUID, List<ItemStack>> pagesRepo;
|
||||||
private final NoDropService noDropService;
|
private final NoDropService noDropService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addItem(UUID playerId, ItemStack item) {
|
public void addItem(UUID playerId, ItemStack item) {
|
||||||
List<ItemStack> items = pagesRepo.get(playerId).orElse(new ArrayList<>());
|
List<ItemStack> items = new ArrayList<>(pagesRepo.get(playerId).orElse(new ArrayList<>()));
|
||||||
if(!noDropService.isNoDrop(item)) throw new IllegalArgumentException("Item must be no drop!");
|
if(!noDropService.isNoDrop(item)) throw new IllegalArgumentException("Item must be no drop!");
|
||||||
items.add(item);
|
items.add(item);
|
||||||
pagesRepo.update(playerId, items);
|
pagesRepo.update(playerId, items);
|
||||||
guiFacade.clearCache(Bukkit.getPlayer(playerId));
|
menuFacade.clearCache(Bukkit.getPlayer(playerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -33,7 +33,7 @@ public class StorageServiceImpl implements StorageService {
|
|||||||
if(items == null) return;
|
if(items == null) return;
|
||||||
items.remove(item);
|
items.remove(item);
|
||||||
pagesRepo.update(playerId, items);
|
pagesRepo.update(playerId, items);
|
||||||
guiFacade.clearCache(Bukkit.getPlayer(playerId));
|
menuFacade.clearCache(Bukkit.getPlayer(playerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package me.redtea.nodropx.util;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.Configuration;
|
||||||
|
import org.bukkit.configuration.MemoryConfiguration;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Verify for versions:
|
||||||
|
- 1.0.2
|
||||||
|
- 1.0.3
|
||||||
|
*/
|
||||||
|
public class ConfigVerifier {
|
||||||
|
public void verifyDefaults(Plugin plugin) {
|
||||||
|
Map<String, Object> properties = new HashMap<String, Object>(){{
|
||||||
|
put("forceUseLegacy", false);
|
||||||
|
put("forceUseMD5Colors", false);
|
||||||
|
|
||||||
|
//1.0.3
|
||||||
|
put("checkForUpdates", true);
|
||||||
|
put("personalStorageType", "SINGLE_PAGE");
|
||||||
|
put("confirmThrowNoDropItem", true);
|
||||||
|
put("forceUseFoliaPatches", false);
|
||||||
|
}};
|
||||||
|
|
||||||
|
plugin.saveDefaultConfig();
|
||||||
|
FileConfiguration config = plugin.getConfig();
|
||||||
|
for(Map.Entry<String, Object> entry : properties.entrySet()) {
|
||||||
|
if(!config.contains(entry.getKey(), true))
|
||||||
|
plugin.getConfig().set(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package me.redtea.nodropx.util;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class FoliaSupportedUtils {
|
||||||
|
private final Plugin plugin;
|
||||||
|
|
||||||
|
public void runTask(Runnable runnable) {
|
||||||
|
try {
|
||||||
|
Bukkit.getScheduler().runTask(plugin, runnable);
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
new Thread(runnable).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,28 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class MaterialUtils {
|
public class MaterialUtils {
|
||||||
@NotNull
|
public static void remove(Inventory inventory, Material type, int amount) {
|
||||||
public static Material getMaterialFromString(String s) {
|
|
||||||
if(s == null || s.equals("")) return Material.AIR;
|
|
||||||
Material material = Material.matchMaterial(s);
|
|
||||||
if(material != null) return material;
|
|
||||||
|
|
||||||
String[] spl = s.split(":");
|
|
||||||
|
|
||||||
if (spl[0].equals("minecraft")) {
|
|
||||||
material = Material.matchMaterial(spl[1]);
|
|
||||||
} else {
|
|
||||||
if(spl.length < 2) {
|
|
||||||
material = Material.matchMaterial(spl[0]);
|
|
||||||
} else {
|
|
||||||
material = Material.matchMaterial(spl[0]+"_"+spl[1]);;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return material == null ? Material.AIR : material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Inventory inventory, Material type, int amount) {
|
|
||||||
if (amount <= 0) return;
|
if (amount <= 0) return;
|
||||||
int size = inventory.getSize();
|
int size = inventory.getSize();
|
||||||
for (int slot = 0; slot < size; slot++) {
|
for (int slot = 0; slot < size; slot++) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package me.redtea.nodropx.util;
|
package me.redtea.nodropx.util;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -12,14 +11,19 @@ import java.util.function.Consumer;
|
|||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private final int resourceId;
|
private final int resourceId;
|
||||||
|
private final FoliaSupportedUtils foliaSupportedUtils;
|
||||||
|
|
||||||
public UpdateChecker(JavaPlugin plugin, int resourceId) {
|
|
||||||
|
public UpdateChecker(JavaPlugin plugin, int resourceId, FoliaSupportedUtils foliaSupportedUtils) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
|
|
||||||
|
this.foliaSupportedUtils = foliaSupportedUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getVersion(final Consumer<String> consumer) {
|
public void getVersion(final Consumer<String> consumer) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
foliaSupportedUtils.runTask(() -> {
|
||||||
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scann = new Scanner(is)) {
|
try (InputStream is = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scann = new Scanner(is)) {
|
||||||
if (scann.hasNext()) {
|
if (scann.hasNext()) {
|
||||||
consumer.accept(scann.next());
|
consumer.accept(scann.next());
|
||||||
@@ -28,5 +32,7 @@ public class UpdateChecker {
|
|||||||
plugin.getLogger().info("Unable to check for updates: " + e.getMessage());
|
plugin.getLogger().info("Unable to check for updates: " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1 +1,3 @@
|
|||||||
CHAINMAIL_HELMET: [ 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
|
CHAINMAIL_HELMET: [ 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
|
||||||
|
#MATERIAL->CUSTOM_MODEL_DATA
|
||||||
|
DIAMOND_HELMET->1000: [ 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
|
||||||
@@ -1,3 +1,14 @@
|
|||||||
|
# Dev's discord tag - itzredtea
|
||||||
|
|
||||||
forceUseLegacy: false
|
forceUseLegacy: false
|
||||||
forceUseMD5Colors: false
|
forceUseMD5Colors: false
|
||||||
|
forceUseFoliaPatches: false
|
||||||
|
|
||||||
checkForUpdates: true
|
checkForUpdates: true
|
||||||
|
|
||||||
|
# Not recommended on Forge servers!
|
||||||
|
# Use it on your own risk
|
||||||
|
confirmThrowNoDropItem: false
|
||||||
|
|
||||||
|
#Can be SINGLE_PAGE or MULTI_PAGES (Use MULTI_PAGES on your own risk)
|
||||||
|
personalStorageType: SINGLE_PAGE
|
||||||
@@ -5,12 +5,21 @@ api-version: '1.13'
|
|||||||
description: Set no drop status to your items
|
description: Set no drop status to your items
|
||||||
author: itzRedTea
|
author: itzRedTea
|
||||||
authors: [itzRedTea]
|
authors: [itzRedTea]
|
||||||
|
softdepend: [ItemsAdder]
|
||||||
|
folia-supported: true
|
||||||
|
website: https://github.com/iRedTea/NoDropX
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
nodropx.give:
|
nodropx.give:
|
||||||
description: "Allows give no drop items"
|
description: "Allows give no drop items"
|
||||||
|
nodropx.giveallnodrop:
|
||||||
|
description: "Allows give allnodrop items"
|
||||||
nodropx.reload:
|
nodropx.reload:
|
||||||
description: "Allows reload the plugin"
|
description: "Allows reload the plugin"
|
||||||
nodropx.gui:
|
nodropx.gui:
|
||||||
escription: "Allows open no drop gui"
|
description: "Allows open no drop gui"
|
||||||
default: true
|
default: true
|
||||||
|
nodropx.giveStorage:
|
||||||
|
description: "Allows give to storage"
|
||||||
|
nodropx.applyhand:
|
||||||
|
description: "Allows apply no drop to item in main hand"
|
||||||
@@ -1,16 +1,45 @@
|
|||||||
usage:
|
usage:
|
||||||
- "&7[ &aUsage of command &e/nodrop &7]"
|
- "&7[ &aUsage of command &e/nodrop &7]"
|
||||||
- "&7| &a/give [player] [item] (amount) &e- give no drop item"
|
- "&7| &a/nodrop give [player] [item] (amount) &e- give no drop item"
|
||||||
|
- "&7| &a/nodrop storage &e- open no drop items storage"
|
||||||
|
- "&7| &a/nodrop giveStorage [player] [material] (amount) &e- Gives nodrop item to the player's personal storage"
|
||||||
|
- "&7| &a/nodrop giveallnodrop [player] [material] (amount) &e- Gives allnodrop item to player"
|
||||||
|
- "&7| &a/nodrop ignoreconfirm &e- Ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "&7| &a/nodrop ignoreconfirmtimed [seconds] &e- Timed ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "&7| &a/nodrop noIgnoreConfirm &e- Drop ignore confirm setting (only if confirm enabled)"
|
||||||
give:
|
give:
|
||||||
fail: "&4[!] &cFail! Check item type for valid."
|
fail: "&4[!] &cFail! Check item type for valid."
|
||||||
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a!"
|
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a!"
|
||||||
reload: "&aPlugin successfully reloaded at %time% ms"
|
reload: "&aPlugin successfully reloaded at %time% ms"
|
||||||
|
applyHand:
|
||||||
|
fail: "&4&l[!] &cFailed to apply no drop!"
|
||||||
|
success: "&2&l[!] &aSuccessfully applied no drop status to your item!"
|
||||||
|
giveToStorage:
|
||||||
|
fail: "&4[!] &cFail! Check item type for valid."
|
||||||
|
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a to storage!"
|
||||||
|
ignoreConfirm:
|
||||||
|
on: "&2&l[!] &aNow you are ignore confirm menu!"
|
||||||
|
off: "&2&l[!] &aNow you are not ignore confirm menu!"
|
||||||
|
|
||||||
noPerms: "&4&l[!] &cNo perms for this!"
|
noPerms: "&4&l[!] &cNo perms for this!"
|
||||||
noConsole: "&4&l[!] &cOnly players can use it!"
|
noConsole: "&4&l[!] &cOnly players can use it!"
|
||||||
noExists: "&4&l[!] &cThis player doesnt exists!"
|
noExists: "&4&l[!] &cThis player doesnt exists!"
|
||||||
|
error: "&4&l[!] &cAn error occurred during the execution of the command!"
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
|
confirm:
|
||||||
|
title: "&lConfirm drop"
|
||||||
|
yesButton:
|
||||||
|
name: "&aYES"
|
||||||
|
lore:
|
||||||
|
- "&7Confirm throw no drop item"
|
||||||
|
material: ARROW
|
||||||
|
noButton:
|
||||||
|
name: "&cNO"
|
||||||
|
lore:
|
||||||
|
- "&7Cancel throw no drop item"
|
||||||
|
material: ARROW
|
||||||
|
personalStorage:
|
||||||
title: "&lPersonal storage"
|
title: "&lPersonal storage"
|
||||||
frame:
|
frame:
|
||||||
name: "&7"
|
name: "&7"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
#name: "No drop"
|
#name: "No drop"
|
||||||
lore:
|
lore:
|
||||||
- "&7[&a✔&7] Dcf0cNcd41fo fd932dIdd46rMe259obe76cp eec7fiRf192tVf5a6eYfab9mdffcc!!"
|
- "&7[&a✔&7] Dcf0cNcd41fo fd932dIdd46rMe259obe76cp eec7fiRf192tVf5a6eYfab9mdffcc!!"
|
||||||
|
|
||||||
@@ -1,16 +1,45 @@
|
|||||||
usage:
|
usage:
|
||||||
- "&7[ &aUsage of command &e/nodrop &7]"
|
- "&7[ &aUsage of command &e/nodrop &7]"
|
||||||
- "&7| &a/give [player] [item] (amount) &e- give no drop item"
|
- "&7| &a/nodrop give [player] [item] (amount) &e- give no drop item"
|
||||||
|
- "&7| &a/nodrop storage &e- open no drop items storage"
|
||||||
|
- "&7| &a/nodrop giveStorage [player] [material] (amount) &e- Gives nodrop item to the player's personal storage"
|
||||||
|
- "&7| &a/nodrop giveAllNoDrop [player] [material] (amount) &e- Gives allnodrop item to player"
|
||||||
|
- "&7| &a/nodrop ignoreConfirm &e- Ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "&7| &a/nodrop ignoreConfirmTimed [seconds] &e- Timed ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "&7| &a/nodrop noIgnoreConfirm &e- Drop ignore confirm setting (only if confirm enabled)"
|
||||||
give:
|
give:
|
||||||
fail: "&4[!] &cFail! Check item type for valid."
|
fail: "&4[!] &cFail! Check item type for valid."
|
||||||
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a!"
|
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a!"
|
||||||
reload: "&aPlugin successfully reloaded at %time% ms"
|
reload: "&aPlugin successfully reloaded at %time% ms"
|
||||||
|
applyHand:
|
||||||
|
fail: "&4&l[!] &cFailed to apply no drop!"
|
||||||
|
success: "&2&l[!] &aSuccessfully applied no drop status to your item!"
|
||||||
|
giveToStorage:
|
||||||
|
fail: "&4[!] &cFail! Check item type for valid."
|
||||||
|
success: "&2&l[!] &aGived &e%item%&a to &e%player%&a amount &e%amount%&a to storage!"
|
||||||
|
ignoreConfirm:
|
||||||
|
on: "&2&l[!] &aNow you are ignore confirm menu!"
|
||||||
|
off: "&2&l[!] &aNow you are not ignore confirm menu!"
|
||||||
|
|
||||||
noPerms: "&4&l[!] &cNo perms for this!"
|
noPerms: "&4&l[!] &cNo perms for this!"
|
||||||
noConsole: "&4&l[!] &cOnly players can use it!"
|
noConsole: "&4&l[!] &cOnly players can use it!"
|
||||||
noExists: "&4&l[!] &cThis player doesnt exists!"
|
noExists: "&4&l[!] &cThis player doesnt exists!"
|
||||||
|
error: "&4&l[!] &cAn error occurred during the execution of the command!"
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
|
confirm:
|
||||||
|
title: "&lConfirm drop"
|
||||||
|
yesButton:
|
||||||
|
name: "&aYES"
|
||||||
|
lore:
|
||||||
|
- "&7Confirm throw no drop item"
|
||||||
|
material: GREEN_WOOL
|
||||||
|
noButton:
|
||||||
|
name: "&cNO"
|
||||||
|
lore:
|
||||||
|
- "&7Cancel throw no drop item"
|
||||||
|
material: RED_WOOL
|
||||||
|
personalStorage:
|
||||||
title: "&lPersonal storage"
|
title: "&lPersonal storage"
|
||||||
frame:
|
frame:
|
||||||
name: "&7"
|
name: "&7"
|
||||||
|
|||||||
@@ -1,17 +1,45 @@
|
|||||||
usage:
|
usage:
|
||||||
- "<gray>[ <green>Usage of command <yellow>/nodrop <gray>]"
|
- "<gray>[ <green>Usage of command <yellow>/nodrop <gray>]"
|
||||||
- "<gray>| <green>/give [player] [item] (amount) <yellow>- give no drop item"
|
- "<gray>| <green>/nodrop give [player] [item] (amount) <yellow>- give no drop item"
|
||||||
|
- "<gray>| <green>/nodrop storage <yellow>- open no drop items storage"
|
||||||
|
- "<gray>| <green>/nodrop giveStorage [player] [material] (amount) <yellow>- Gives nodrop item to the player's personal storage"
|
||||||
|
- "<gray>| <green>/nodrop giveallnodrop [player] [material] (amount) <yellow>- Gives allnodrop item to player"
|
||||||
|
- "<gray>| <green>/nodrop ignoreConfirm <yellow>- Ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "<gray>| <green>/nodrop ignoreConfirmTimed [seconds] <yellow>- Timed ignore confirm gui (only if confirm enabled)"
|
||||||
|
- "<gray>| <green>/nodrop noIgnoreConfirm <yellow>- Drop ignore confirm setting (only if confirm enabled)"
|
||||||
give:
|
give:
|
||||||
fail: "<dark_red><bold>[!] <red>Fail! Check item type for valid."
|
fail: "<dark_red><bold>[!] <red>Fail! Check item type for valid."
|
||||||
success: "<green><bold>[!] <reset><green>Gived <yellow>%item%<green> to <yellow>%player%<green> amount <yellow>%amount%<green>!"
|
success: "<green><bold>[!] <reset><green>Gived <yellow>%item%<green> to <yellow>%player%<green> amount <yellow>%amount%<green>!"
|
||||||
reload: "<green>Plugin successfully reloaded at %time% ms"
|
reload: "<green>Plugin successfully reloaded at %time% ms"
|
||||||
|
applyHand:
|
||||||
|
fail: "<dark_red><bold>[!] <red>Failed to apply no drop!"
|
||||||
|
success: "<green><bold>[!] <reset><green>Successfully applied no drop status to your item!"
|
||||||
|
giveToStorage:
|
||||||
|
fail: "<dark_red><bold>[!] <red>Fail! Check item type for valid."
|
||||||
|
success: "<green><bold>[!] <reset><green>Gived <yellow>%item%<green> to <yellow>%player%<green> amount <yellow>%amount%<green> to storage!"
|
||||||
|
ignoreConfirm:
|
||||||
|
on: "<green><bold>[!] <reset><green>Now you are ignore confirm menu!"
|
||||||
|
off: "<green><bold>[!] <reset><green>Now you are not ignore confirm menu!"
|
||||||
|
|
||||||
noPerms: "<dark_red><bold>[!] <red>No perms for this!"
|
noPerms: "<dark_red><bold>[!] <red>No perms for this!"
|
||||||
noConsole: "<dark_red><bold>[!] <red>Only players can use it!"
|
noConsole: "<dark_red><bold>[!] <red>Only players can use it!"
|
||||||
noExists: "<dark_red><bold>[!] <red>This player doesnt exists!"
|
noExists: "<dark_red><bold>[!] <red>This player doesnt exists!"
|
||||||
|
error: "<dark_red><bold>[!] <red>An error occurred during the execution of the command!"
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
|
confirm:
|
||||||
|
title: "<bold>Confirm throw"
|
||||||
|
yesButton:
|
||||||
|
name: "<green>YES"
|
||||||
|
lore:
|
||||||
|
- "<gray>Confirm throw no drop item"
|
||||||
|
material: GREEN_WOOL
|
||||||
|
noButton:
|
||||||
|
name: "<red>NO"
|
||||||
|
lore:
|
||||||
|
- "<gray>Cancel throw no drop item"
|
||||||
|
material: RED_WOOL
|
||||||
|
personalStorage:
|
||||||
title: "<bold>Personal storage"
|
title: "<bold>Personal storage"
|
||||||
frame:
|
frame:
|
||||||
name: "<gray>"
|
name: "<gray>"
|
||||||
|
|||||||
Reference in new issue
Block a user