UseItem Config

This commit is contained in:
JaTiTV 2023-01-04 12:36:23 +01:00
parent 2abdcdd3ad
commit 33fbe74818
4 changed files with 232 additions and 35 deletions

View File

@ -1,19 +1,11 @@
package net.t2code.commandguiv2.Spigot.config.useItems;
import net.t2code.commandguiv2.Spigot.Main;
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV6;
import net.t2code.commandguiv2.Spigot.enums.EcoEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
import net.t2code.commandguiv2.Spigot.objects.UseItemObject;
import net.t2code.commandguiv2.Util;
import net.t2code.commandguiv2.cache.Cache;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.IOException;
@ -21,12 +13,7 @@ import java.util.List;
public class UseItemSelect {
public UseItemSelect(){
create();
onSelectFunction();
}
private void create(){
public static void create() {
File config = new File(Main.getPath(), "/UseItems/default.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
@ -41,7 +28,8 @@ public class UseItemSelect {
e.printStackTrace();
}
}
private void onSelectFunction() {
public static void onSelect() {
Cache.useItemHash.clear();
File f = new File(Main.getPath() + "/UseItems/");
File[] fileArray = f.listFiles();
@ -53,13 +41,65 @@ public class UseItemSelect {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
String key = config.getName().replace(".yml", "");
Boolean enable = yamlConfiguration.getBoolean("useItem.enable");
String openGui = yamlConfiguration.getString("useItem.openGUI");
Boolean allowToggle = yamlConfiguration.getBoolean("useItem.allowToggle");
Boolean allowSetBlock = yamlConfiguration.getBoolean("useItem.allowSetSlot");
Boolean blockMoveAndDrop = yamlConfiguration.getBoolean("useItem.blockMoveAndDrop");
Boolean permBecomeNeeded = yamlConfiguration.getBoolean("useItem.permission.become.needed");
String permBecome = yamlConfiguration.getString("useItem.permission.become.permission");
PermissionDefault permBecomeDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.become.default"));
Boolean permUseNeeded = yamlConfiguration.getBoolean("useItem.permission.use.needed");
String permUse = yamlConfiguration.getString("useItem.permission.use.permission");
PermissionDefault permUseDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.use.default"));
Boolean permToggleNeeded = yamlConfiguration.getBoolean("useItem.permission.toggle.needed");
String permToggle = yamlConfiguration.getString("useItem.permission.toggle.permission");
PermissionDefault permToggleDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.toggle.default"));
Boolean permSetSlotNeeded = yamlConfiguration.getBoolean("useItem.permission.setSlot.needed");
String permSetSlot = yamlConfiguration.getString("useItem.permission.setSlot.permission");
PermissionDefault permSetSlotDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.setSlot.default"));
Boolean keepAtCommandClear = yamlConfiguration.getBoolean("useItem.keepAtCommandClear");
Integer invSlotSlot = yamlConfiguration.getInt("useItem.inventorySlot.slot");
Boolean invSlotEnforce = yamlConfiguration.getBoolean("useItem.inventorySlot.slotEnforce");
Boolean invFreeSlot = yamlConfiguration.getBoolean("useItem.inventorySlot.freeSlot");
String itemMaterial = yamlConfiguration.getString("useItem.item.material");
String itemName = yamlConfiguration.getString("useItem.item.name");
List<String> itemLore = yamlConfiguration.getStringList("useItem.item.lore");
Boolean itemPlayerHeadEnable = yamlConfiguration.getBoolean("useItem.item.playerHead.enable");
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("useItem.item.playerHead.playerWhoHasOpenedTheGUI");
String itemPlayerHeadPlayerName = yamlConfiguration.getString("useItem.item.playerHead.playerName");
Boolean itemPlayerHeadBase64Enable = yamlConfiguration.getBoolean("useItem.item.playerHead.base64.enable");
String itemPlayerHeadBase64Value = yamlConfiguration.getString("useItem.item.playerHead.base64.base64Value");
Boolean joinGiveOnEveryJoin = yamlConfiguration.getBoolean("useItem.join.giveOnEveryJoin");
Boolean joinGiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("useItem.join.giveOnlyOnFirstJoin");
Boolean quitRemoveOnQuit = yamlConfiguration.getBoolean("useItem.quit.removeOnQuit");
Boolean protectGameModeEnable = yamlConfiguration.getBoolean("useItem.protection.gameMode.enable");
Boolean protectGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.gameMode.removeItemWhenItIsDisabled");
String protectGameModeMode = yamlConfiguration.getString("useItem.protection.gameMode.mode");
List<String> protectGameModeList = yamlConfiguration.getStringList("useItem.protection.gameMode.list");
Boolean protectWorldEnable = yamlConfiguration.getBoolean("useItem.protection.world.enable");
Boolean protectWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.world.removeItemWhenItIsDisabled");
String protectWorldMode = yamlConfiguration.getString("useItem.protection.world.mode");
List<String> protectWorldList = yamlConfiguration.getStringList("useItem.protection.world.list");
UseItemObject useItem = new UseItemObject(key);
UseItemObject useItem = new UseItemObject(key, enable, openGui, allowToggle, allowSetBlock, blockMoveAndDrop, permBecomeNeeded, permBecome, permBecomeDefault,
permUseNeeded, permUse, permUseDefault, permToggleNeeded, permToggle, permToggleDefault, permSetSlotNeeded, permSetSlot, permSetSlotDefault, keepAtCommandClear,
invSlotSlot, invSlotEnforce, invFreeSlot, itemMaterial, itemName, itemLore, itemPlayerHeadEnable, itemPlayerHeadPlayerWhoHasOpenedTheGUI,
itemPlayerHeadPlayerName, itemPlayerHeadBase64Enable, itemPlayerHeadBase64Value, joinGiveOnEveryJoin, joinGiveOnlyOnFirstJoin, quitRemoveOnQuit,
protectGameModeEnable, protectGameModeRemoveItemWhenItIsDisabled, protectGameModeMode, protectGameModeList, protectWorldEnable,
protectWorldRemoveItemWhenItIsDisabled, protectWorldMode, protectWorldList);
Cache.useItemHash.put(key, useItem);
try {
@ -70,5 +110,4 @@ public class UseItemSelect {
}
}
}
}

View File

@ -1,4 +1,145 @@
package net.t2code.commandguiv2.Spigot.objects;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class UseItemObject {
public String key;
public Boolean enable;
public String openGui;
public Boolean allowToggle;
public Boolean allowSetBlock;
public Boolean blockMoveAndDrop;
public Boolean permBecomeNeeded;
public String permBecome;
public PermissionDefault permBecomeDefault;
public Boolean permUseNeeded;
public String permUse;
public PermissionDefault permUseDefault;
public Boolean permToggleNeeded;
public String permToggle;
public PermissionDefault permToggleDefault;
public Boolean permSetSlotNeeded;
public String permSetSlot;
public PermissionDefault permSetSlotDefault;
public Boolean keepAtCommandClear;
public Integer invSlotSlot;
public Boolean invSlotEnforce;
public Boolean invFreeSlot;
public String itemMaterial;
public String itemName;
public List<String> itemLore;
public Boolean itemPlayerHeadEnable;
public Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI;
public String itemPlayerHeadPlayerName;
public Boolean itemPlayerHeadBase64Enable;
public String itemPlayerHeadBase64Value;
public Boolean joinGiveOnEveryJoin;
public Boolean joinGiveOnlyOnFirstJoin;
public Boolean quitRemoveOnQuit;
public Boolean protectGameModeEnable;
public Boolean protectGameModeRemoveItemWhenItIsDisabled;
public String protectGameModeMode;
public List<String> protectGameModeList;
public Boolean protectWorldEnable;
public Boolean protectWorldRemoveItemWhenItIsDisabled;
public String protectWorldMode;
public List<String> protectWorldList;
public UseItemObject(String key,
Boolean enable,
String openGui,
Boolean allowToggle,
Boolean allowSetBlock,
Boolean blockMoveAndDrop,
Boolean permBecomeNeeded,
String permBecome,
PermissionDefault permBecomeDefault,
Boolean permUseNeeded,
String permUse,
PermissionDefault permUseDefault,
Boolean permToggleNeeded,
String permToggle,
PermissionDefault permToggleDefault,
Boolean permSetSlotNeeded,
String permSetSlot,
PermissionDefault permSetSlotDefault,
Boolean keepAtCommandClear,
Integer invSlotSlot,
Boolean invSlotEnforce,
Boolean invFreeSlot,
String itemMaterial,
String itemName,
List<String> itemLore,
Boolean itemPlayerHeadEnable,
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI,
String itemPlayerHeadPlayerName,
Boolean itemPlayerHeadBase64Enable,
String itemPlayerHeadBase64Value,
Boolean joinGiveOnEveryJoin,
Boolean joinGiveOnlyOnFirstJoin,
Boolean quitRemoveOnQuit,
Boolean protectGameModeEnable,
Boolean protectGameModeRemoveItemWhenItIsDisabled,
String protectGameModeMode,
List<String> protectGameModeList,
Boolean protectWorldEnable,
Boolean protectWorldRemoveItemWhenItIsDisabled,
String protectWorldMode,
List<String> protectWorldList) {
this.key = key;
this.enable = enable;
this.openGui = openGui;
this.allowToggle = allowToggle;
this.allowSetBlock = allowSetBlock;
this.blockMoveAndDrop = blockMoveAndDrop;
this.permBecomeNeeded = permBecomeNeeded;
this.permBecome = permBecome;
this.permBecomeDefault = permBecomeDefault;
this.permUseNeeded = permUseNeeded;
this.permUse = permUse;
this.permUseDefault = permUseDefault;
this.permToggleNeeded = permToggleNeeded;
this.permToggle = permToggle;
this.permToggleDefault = permToggleDefault;
this.permSetSlotNeeded = permSetSlotNeeded;
this.permSetSlot = permSetSlot;
this.permSetSlotDefault = permSetSlotDefault;
this.keepAtCommandClear = keepAtCommandClear;
this.invSlotSlot = invSlotSlot;
this.invSlotEnforce = invSlotEnforce;
this.invFreeSlot = invFreeSlot;
this.itemMaterial = itemMaterial;
this.itemName = itemName;
this.itemLore = itemLore;
this.itemPlayerHeadEnable = itemPlayerHeadEnable;
this.itemPlayerHeadPlayerWhoHasOpenedTheGUI = itemPlayerHeadPlayerWhoHasOpenedTheGUI;
this.itemPlayerHeadPlayerName = itemPlayerHeadPlayerName;
this.itemPlayerHeadBase64Enable = itemPlayerHeadBase64Enable;
this.itemPlayerHeadBase64Value = itemPlayerHeadBase64Value;
this.joinGiveOnEveryJoin = joinGiveOnEveryJoin;
this.joinGiveOnlyOnFirstJoin = joinGiveOnlyOnFirstJoin;
this.quitRemoveOnQuit = quitRemoveOnQuit;
this.protectGameModeEnable = protectGameModeEnable;
this.protectGameModeRemoveItemWhenItIsDisabled = protectGameModeRemoveItemWhenItIsDisabled;
this.protectGameModeMode = protectGameModeMode;
this.protectGameModeList = protectGameModeList;
this.protectWorldEnable = protectWorldEnable;
this.protectWorldRemoveItemWhenItIsDisabled = protectWorldRemoveItemWhenItIsDisabled;
this.protectWorldMode = protectWorldMode;
this.protectWorldList = protectWorldList;
}
}

View File

@ -5,6 +5,7 @@ import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
import net.t2code.commandguiv2.Spigot.config.useItems.UseItemSelect;
import net.t2code.commandguiv2.Spigot.function.gui.GUIListener;
import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
import net.t2code.commandguiv2.Spigot.function.useItem.EventsFrom110;
@ -69,6 +70,12 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
try {
UseItemSelect.create();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
@ -91,6 +98,11 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
try {
plugin.saveResource("UseItems/useItemDeclaration.yml", true);
} catch (Exception e) {
e.printStackTrace();
}
if (T2CLibConfig.getBungee()) {
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "t2c:bcmd")) {
@ -122,6 +134,11 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
try {
UseItemSelect.onSelect();
} catch (Exception e) {
e.printStackTrace();
}
try {
SelectMessages.onSelect(prefix);

View File

@ -56,25 +56,25 @@ useItem:
item:
# material: Set here which material should be used as UseItem
material: paper
playerHead:
# enable: This specifies whether a PlayerHead is to be used as a UseItem. If this is set to true, the 'material' option is ignored.
enable: false
base64:
# enable: Set here if a Base64 PlayerHead should be used as UseItem
enable: false
# base64Value: Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com.
base64Value: ''
# playerWhoHasOpenedTheGUI: Here you can set whether the player head should be used as a UseItem by the player
playerWhoHasOpenedTheGUI: false
# playerName: Here you can set a player name whose head should be used as UseItem
playerName: ''
# name: Set the DisplayName of the UseItem here
name: '&6GUI UseItem'
# lore: Set the lore of the UseItem here
lore:
- 'Lore line 1'
- 'Lore line 2'
playerHead:
# enable: This specifies whether a PlayerHead is to be used as a UseItem. If this is set to true, the 'material' option is ignored.
enable: false
# playerWhoHasOpenedTheGUI: Here you can set whether the player head should be used as a UseItem by the player
playerWhoHasOpenedTheGUI: false
# playerName: Here you can set a player name whose head should be used as UseItem
playerName: ''
base64:
# enable: Set here if a Base64 PlayerHead should be used as UseItem
enable: false
# base64Value: Here you can set the Base64 Value.
# You can find the Base64 Value for example on https://minecraft-heads.com.
base64Value: ''
join:
# giveOnEveryJoin: Set here if the UseItem should be given at every server join