2.5.19 | Add UseItem World Protection and Change and minor code changes
This commit is contained in:
parent
b212b68f67
commit
89030215a1
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>CommandGUI_V2</artifactId>
|
||||
<version>2.5.18</version>
|
||||
<version>2.5.19</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandGUI</name>
|
||||
|
@ -28,11 +28,21 @@ public class ItemChange {
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeProtection) {
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
if (SelectConfig.UseItemGameModeRemoveItemWhenItIsDisabled) removeItem(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SelectConfig.UseItemWorldProtection) {
|
||||
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
|
||||
if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
|
||||
if (SelectConfig.UseItemWorldRemoveItemWhenItIsDisabled)removeItem(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
||||
import de.jatitv.commandguiv2.api.CGuiAPI;
|
||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -110,6 +112,20 @@ public class Events implements Listener {
|
||||
}.runTaskLater(Main.plugin, SelectConfig.UseItemGameModeChangeDelayInTicks * 1L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerChangedWorldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!SelectConfig.UseItemWorldChangeEnable) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
}.runTaskLater(Main.plugin, SelectConfig.UseItemWorldChangeDelayInTicks * 1L);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
@ -118,29 +134,22 @@ public class Events implements Listener {
|
||||
if (SelectConfig.UseItem_PlayerHead_Enable) {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == ItemVersion.getHead()) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
e.setCancelled(true);
|
||||
if (p.isSneaking()) {
|
||||
Commands.info(p);
|
||||
return;
|
||||
}
|
||||
if (!legacy()) {
|
||||
if (!topInventoryIsEmpty(p)) return;
|
||||
}
|
||||
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
|
||||
OpenGUI.openGUI(p, Main.guiHashMap.get(SelectConfig.UseItem_OpenGUI), SelectConfig.UseItem_OpenGUI);
|
||||
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
||||
p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
|
||||
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
|
||||
}
|
||||
openGUI(e, p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(SelectConfig.UseItem_Material)) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
openGUI(e, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void openGUI(PlayerInteractEvent e, Player p) {
|
||||
e.setCancelled(true);
|
||||
|
||||
if (p.isSneaking()) {
|
||||
Commands.info(p);
|
||||
return;
|
||||
@ -148,6 +157,32 @@ public class Events implements Listener {
|
||||
if (!legacy()) {
|
||||
if (!topInventoryIsEmpty(p)) return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeProtection) {
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) {
|
||||
e.setCancelled(true);
|
||||
send.player(p,SelectMessages.UseItemDisabledInGameMode);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(p.getGameMode().toString())) {
|
||||
e.setCancelled(true);
|
||||
send.player(p,SelectMessages.UseItemDisabledInGameMode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
send.debugmsg(Main.plugin,SelectConfig.UseItemWorldList.toString());
|
||||
send.debugmsg(Main.plugin,p.getWorld().getName());
|
||||
if (SelectConfig.UseItemWorldProtection) {
|
||||
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) {
|
||||
e.setCancelled(true);
|
||||
send.player(p,SelectMessages.UseItemDisabledInWorld);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemWorldList.contains(p.getWorld().getName())) {
|
||||
e.setCancelled(true);
|
||||
send.player(p,SelectMessages.UseItemDisabledInWorld);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
|
||||
OpenGUI.openGUI(p, Main.guiHashMap.get(SelectConfig.UseItem_OpenGUI), SelectConfig.UseItem_OpenGUI);
|
||||
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
|
||||
@ -158,10 +193,6 @@ public class Events implements Listener {
|
||||
.replace("[gui]", SelectConfig.UseItem_OpenGUI));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onItemMoveEvent(InventoryMoveItemEvent e) {
|
||||
|
@ -14,7 +14,7 @@ import java.util.Arrays;
|
||||
|
||||
public class ConfigCreate {
|
||||
|
||||
public static Integer ConfigVersion = 3;
|
||||
public static Integer ConfigVersion = 4;
|
||||
|
||||
public static void configCreate() {
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
@ -25,7 +25,7 @@ public class ConfigCreate {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion) {
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < ConfigVersion && new File(Main.getPath(), "config.yml").exists()) {
|
||||
send.console(Util.getPrefix() +" §4----------------------");
|
||||
send.console(Util.getPrefix() +" ");
|
||||
send.console(Util.getPrefix() +" §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
@ -99,9 +99,17 @@ public class ConfigCreate {
|
||||
Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
|
||||
|
||||
Config.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
|
||||
|
||||
Config.set("Sound.Enable", true, yamlConfiguration);
|
||||
|
||||
Config.set("Sound.OpenInventory.Enable", true, yamlConfiguration);
|
||||
|
@ -43,14 +43,19 @@ public class SelectConfig {
|
||||
public static Boolean UseItem_Permission;
|
||||
public static Boolean UseItem_KeepAtCommandClear;
|
||||
|
||||
|
||||
|
||||
public static Boolean UseItemGameModeChangeEnable;
|
||||
public static int UseItemGameModeChangeDelayInTicks;
|
||||
public static Boolean UseItemGameModeProtection;
|
||||
public static Boolean UseItemGameModeRemoveItemWhenItIsDisabled;
|
||||
public static String UseItemGameModeMode;
|
||||
public static List<String> UseItemGameModeList;
|
||||
|
||||
public static Boolean UseItemWorldChangeEnable;
|
||||
public static int UseItemWorldChangeDelayInTicks;
|
||||
public static Boolean UseItemWorldProtection;
|
||||
public static Boolean UseItemWorldRemoveItemWhenItIsDisabled;
|
||||
public static String UseItemWorldMode;
|
||||
public static List<String> UseItemWorldList;
|
||||
|
||||
public static Boolean UseItem_InventorySlot_FreeSlot;
|
||||
public static Integer UseItem_InventorySlot;
|
||||
@ -64,8 +69,6 @@ public class SelectConfig {
|
||||
public static String UseItem_Name;
|
||||
public static List<String> UseItem_Lore;
|
||||
|
||||
|
||||
|
||||
public static Boolean Sound_Enable = true;
|
||||
|
||||
public static Boolean Sound_OpenInventory_Enable = true;
|
||||
@ -80,7 +83,6 @@ public class SelectConfig {
|
||||
public static Sound Sound_NoMoney;
|
||||
public static String Sound_NoMoney_input;
|
||||
|
||||
|
||||
public static Boolean Sound_NoInventorySpace_Enable = true;
|
||||
public static Sound Sound_NoInventorySpace;
|
||||
public static String Sound_NoInventorySpace_input;
|
||||
@ -149,6 +151,7 @@ public class SelectConfig {
|
||||
UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable");
|
||||
UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks");
|
||||
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
|
||||
UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
|
||||
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode");
|
||||
List<String> gml = new ArrayList<>();
|
||||
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")){
|
||||
@ -156,7 +159,12 @@ public class SelectConfig {
|
||||
}
|
||||
UseItemGameModeList = gml;
|
||||
|
||||
|
||||
UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable");
|
||||
UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks");
|
||||
UseItemWorldProtection = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.Enable");
|
||||
UseItemWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
|
||||
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
|
||||
UseItemWorldList =yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
|
||||
|
||||
Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable");
|
||||
Sound_OpenInventory_Enable = yamlConfiguration.getBoolean("Sound.OpenInventory.Enable");
|
||||
@ -172,7 +180,6 @@ public class SelectConfig {
|
||||
Sound_Give_input = (yamlConfiguration.getString("Sound.Give.Sound").toUpperCase().replace(".", "_"));
|
||||
Sound_PlayerNotFound_Enable = yamlConfiguration.getBoolean("Sound.PlayerNotFound.Enable");
|
||||
Sound_PlayerNotFound_input = (yamlConfiguration.getString("Sound.PlayerNotFound.Sound").toUpperCase().replace(".", "_"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,6 +42,8 @@ public class LanguagesCreate {
|
||||
set("UseItem.SlotNotEmpty", MSG.EN_ItemSlotNotEmpty, yamlConfigurationEN);
|
||||
set("UseItem.SlotAlreadySet", MSG.EN_ItemSlotAlreadySet, yamlConfigurationEN);
|
||||
set("UseItem.ItemSlot_wrongValue", MSG.EN_ItemSlot_wrongValue, yamlConfigurationEN);
|
||||
set("UseItem.DisabledInGameMode", MSG.EN_UseItemDisabledInGameMode, yamlConfigurationEN);
|
||||
set("UseItem.DisabledInWorld", MSG.EN_UseItemDisabledInWorld, yamlConfigurationEN);
|
||||
|
||||
set("Cost.Buy_msg", MSG.EN_Buy_msg, yamlConfigurationEN);
|
||||
set("Cost.No_money", MSG.EN_No_money, yamlConfigurationEN);
|
||||
@ -104,6 +106,8 @@ public class LanguagesCreate {
|
||||
set("UseItem.SlotNotEmpty", MSG.DE_ItemSlotNotEmpty, yamlConfigurationDE);
|
||||
set("UseItem.SlotAlreadySet", MSG.DE_ItemSlotAlreadySet, yamlConfigurationDE);
|
||||
set("UseItem.ItemSlot_wrongValue", MSG.DE_ItemSlot_wrongValue, yamlConfigurationDE);
|
||||
set("UseItem.DisabledInGameMode", MSG.DE_UseItemDisabledInGameMode, yamlConfigurationDE);
|
||||
set("UseItem.DisabledInWorld", MSG.DE_UseItemDisabledInWorld, yamlConfigurationDE);
|
||||
|
||||
set("Cost.Buy_msg", MSG.DE_Buy_msg, yamlConfigurationDE);
|
||||
set("Cost.No_money", MSG.DE_No_money, yamlConfigurationDE);
|
||||
@ -167,6 +171,8 @@ public class LanguagesCreate {
|
||||
set("UseItem.SlotNotEmpty", MSG.NO_ItemSlotNotEmpty, yamlConfigurationNO);
|
||||
set("UseItem.SlotAlreadySet", MSG.NO_ItemSlotAlreadySet, yamlConfigurationNO);
|
||||
set("UseItem.ItemSlot_wrongValue", MSG.NO_ItemSlot_wrongValue, yamlConfigurationNO);
|
||||
set("UseItem.DisabledInGameMode", MSG.NO_UseItemDisabledInGameMode, yamlConfigurationNO);
|
||||
set("UseItem.DisabledInWorld", MSG.NO_UseItemDisabledInWorld, yamlConfigurationNO);
|
||||
|
||||
set("Cost.Buy_msg", MSG.NO_Buy_msg, yamlConfigurationNO);
|
||||
set("Cost.No_money", MSG.NO_No_money, yamlConfigurationNO);
|
||||
|
@ -38,6 +38,8 @@ public class MSG {
|
||||
public static String EN_ItemSlotNotEmpty = "[prefix] &6The slot &e[slot] &6is currently occupied!";
|
||||
public static String EN_ItemSlotAlreadySet = "[prefix] &6The slot §e[slot] §6is already set!";
|
||||
public static String EN_ItemSlot_wrongValue = "[prefix] &cThe specified slot must be between 1 and 9!";
|
||||
public static String EN_UseItemDisabledInGameMode = "[prefix] &cThe UseItem is disabled in this GameMode!";
|
||||
public static String EN_UseItemDisabledInWorld = "[prefix] &cThe UseItem is disabled in this World!";
|
||||
|
||||
public static String EN_GUInotFound = "[prefix] &cThe GUI chosen by the does not exist.";
|
||||
public static String EN_GUIisDisabled = "[prefix] &cThe GUI [gui] &cis currently Disabled!";
|
||||
@ -79,6 +81,8 @@ public class MSG {
|
||||
public static String DE_ItemSlotNotEmpty = "[prefix] &6Der Slot §e[slot] §6ist derzeit belegt!.";
|
||||
public static String DE_ItemSlotAlreadySet = "[prefix] &6Der Slot §e[slot] §6ist bereits eingestellt!";
|
||||
public static String DE_ItemSlot_wrongValue = "[prefix] &cDer angegebene Slot muss sich zwischen 1 und 9 befinden!";
|
||||
public static String DE_UseItemDisabledInGameMode = "[prefix] &cDas UseItem ist in diesem GameMode deaktiviert!";
|
||||
public static String DE_UseItemDisabledInWorld = "[prefix] &cDas UseItem ist in dieser Welt deaktiviert!";
|
||||
|
||||
public static String DE_Buy_msg = "[prefix] &2Du hast dir [itemname] &2f[ue]r &6[price] &2gekauft.";
|
||||
public static String DE_No_money = "[prefix] &cDu hast nicht gen[ue]gend Geld!";
|
||||
@ -130,6 +134,8 @@ public class MSG {
|
||||
public static String NO_ItemSlotNotEmpty = "[prefix] &6Plassen &e[slot] &6er opptatt for øyeblikket!";
|
||||
public static String NO_ItemSlotAlreadySet = "[prefix] &6Plassen §e[slot] §6er allerede satt!";
|
||||
public static String NO_ItemSlot_wrongValue = "[prefix] &cDen spesifiserte plassen må være mellom 1 og 9!";
|
||||
public static String NO_UseItemDisabledInGameMode = "[prefix] &cBrukselementet er deaktivert i denne spillmodusen!!";
|
||||
public static String NO_UseItemDisabledInWorld = "[prefix] &cUseItem er deaktivert i denne verden!";
|
||||
|
||||
public static String NO_Buy_msg = "[prefix] &2Du kjøpte [itemname] &2for &6[price]&2.";
|
||||
public static String NO_No_money = "[prefix] &cDu har ikke nok penger!";
|
||||
|
@ -32,6 +32,8 @@ public class SelectMessages {
|
||||
public static String ItemSlotNotEmpty;
|
||||
public static String ItemSlotAlreadySet;
|
||||
public static String ItemSlot_wrongValue;
|
||||
public static String UseItemDisabledInGameMode;
|
||||
public static String UseItemDisabledInWorld;
|
||||
|
||||
public static String Buy_msg;
|
||||
public static String No_money;
|
||||
@ -97,6 +99,8 @@ public class SelectMessages {
|
||||
ItemSlotNotEmpty = select("UseItem.SlotNotEmpty", yamlConfiguration_msg);
|
||||
ItemSlotAlreadySet = select("UseItem.SlotAlreadySet", yamlConfiguration_msg);
|
||||
ItemSlot_wrongValue = select("UseItem.ItemSlot_wrongValue", yamlConfiguration_msg);
|
||||
UseItemDisabledInGameMode =select("UseItem.DisabledInGameMode",yamlConfiguration_msg);
|
||||
UseItemDisabledInWorld =select("UseItem.DisabledInWorld",yamlConfiguration_msg);
|
||||
|
||||
Buy_msg = select("Cost.Buy_msg", yamlConfiguration_msg);
|
||||
No_money = select("Cost.No_money", yamlConfiguration_msg);
|
||||
|
Loading…
Reference in New Issue
Block a user