This commit is contained in:
JaTiTV 2022-04-28 19:40:41 +02:00
parent f3feddd317
commit b6347c8fad
5 changed files with 23 additions and 21 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.7.0_Snapshot-6</version>
<version>2.7.0</version>
<packaging>jar</packaging>
<name>CommandGUI</name>
@ -67,7 +67,7 @@
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
@ -85,7 +85,7 @@
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>11.4</version>
<version>11.6</version>
</dependency>
<dependency>
<groupId>net.t2code</groupId>

View File

@ -36,23 +36,24 @@ public class Events implements Listener {
public static HashMap<Player, Boolean> useItemHashMap = new HashMap<>();
public static HashMap<Player, Integer> useItemSlotHashMap = new HashMap<>();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
if (SelectDatabase.selectItemStatus(e.getPlayer())){
if (SelectDatabase.selectItemStatus(e.getPlayer())) {
useItemHashMap.put(e.getPlayer(), true);
} else useItemHashMap.put(e.getPlayer(), false);
useItemSlotHashMap.put(e.getPlayer(), SelectDatabase.selectSlot(e.getPlayer()));
if (CGuiAPI.JoinDisable) {
send.debug(Main.plugin,"JoinDisable");
send.debug(Main.plugin, "JoinDisable");
return;
}
if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) {
new BukkitRunnable() {
@Override
public void run() {
send.debug(Main.plugin,"itemChange: " + e.getPlayer().getName());
send.debug(Main.plugin, "itemChange: " + e.getPlayer().getName());
ItemChange.itemChange(e.getPlayer(), true);
}
}.runTaskLater(Main.plugin, 20L * 1);
@ -159,14 +160,17 @@ public class Events implements Listener {
private static void openGUI(PlayerInteractEvent e, Player player) {
e.setCancelled(true);
if (player.isSneaking()) {
if (SelectConfig.disableInfoBySneak && player.isSneaking()) {
Commands.info(player);
return;
}
if (!legacy()) {
if (!topInventoryIsEmpty(player)) return;
}
if (UseItem.protection(player, true)) return;
if (SelectConfig.UseItemGameModeProtection) {
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
e.setCancelled(true);
@ -179,6 +183,7 @@ public class Events implements Listener {
return;
}
}
if (SelectConfig.UseItemWorldProtection) {
if (SelectConfig.UseItemWorldMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemWorldList.contains(player.getWorld().getName())) {
e.setCancelled(true);
@ -191,6 +196,7 @@ public class Events implements Listener {
return;
}
}
if (!SelectConfig.UseItem_Permission || player.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(player, SelectConfig.UseItem_OpenGUI, true);
} else {
@ -213,6 +219,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryDragEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getWhoClicked() instanceof Player) {
Player p = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
@ -234,7 +241,6 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemMove(InventoryClickEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
Player player = (Player) e.getWhoClicked();
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
@ -244,13 +250,13 @@ public class Events implements Listener {
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemMove(InventoryPickupItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItem() != null && e.getItem().getItemStack() != null) {
ItemStack item = e.getItem().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
@ -263,6 +269,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
e.setCancelled(true);
@ -272,6 +279,7 @@ public class Events implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onDrop(PlayerDropItemEvent e) {
if (!SelectConfig.UseItem_BlockMoveAndDrop || !SelectConfig.UseItem_Enable) return;
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
ItemStack item = e.getItemDrop().getItemStack();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
@ -282,7 +290,7 @@ public class Events implements Listener {
}
private static boolean legacy() {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15|| NMSVersion.v1_16_R1) {
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
return true;
} else return false;
}

View File

@ -26,8 +26,6 @@ public class ConfigCreate {
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
Config.set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
Config.set("Plugin.Debug", false, yamlConfiguration);
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
Config.set("Plugin.language", "english", yamlConfiguration);
@ -102,7 +100,6 @@ public class ConfigCreate {
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);

View File

@ -22,9 +22,6 @@ public class SelectConfig {
private static final File config = new File(Main.getPath(), "config.yml");
private static final YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
public static Boolean DisableUpdateChecker;
public static Boolean UpdateCheckOnJoin;
public static Boolean Debug;
public static Boolean HelpAlias;
public static String language;
@ -64,6 +61,8 @@ public class SelectConfig {
public static String UseItemWorldMode;
public static List<String> UseItemWorldList;
public static Boolean disableInfoBySneak;
public static Boolean UseItem_InventorySlot_FreeSlot;
public static Integer UseItem_InventorySlot;
public static Boolean UseItem_InventorySlotEnforce;
@ -129,10 +128,6 @@ public class SelectConfig {
}
}
if (yamlConfiguration.get("Plugin.DisableUpdateChecker") == null) {
DisableUpdateChecker = false;
} else DisableUpdateChecker = yamlConfiguration.getBoolean("Plugin.DisableUpdateChecker");
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias");
language = yamlConfiguration.getString("Plugin.language");
@ -194,6 +189,9 @@ public class SelectConfig {
UseItemWorldMode = yamlConfiguration.getString("Advanced.UseItem.World.Protection.Mode");
UseItemWorldList = yamlConfiguration.getStringList("Advanced.UseItem.World.Protection.List");
if (yamlConfiguration.get("Advanced.UseItem.DisableInfoBySneak") != null){
disableInfoBySneak = yamlConfiguration.getBoolean("Advanced.UseItem.DisableInfoBySneak");
}
toggleItemOnOrYesBase64 = yamlConfiguration.getBoolean("Toggle.Items.OnOrYes.Item.Base64.Enable");
toggleItemOnOrYesBase64Value = yamlConfiguration.getString("Toggle.Items.OnOrYes.Item.Base64.Base64Value");

View File

@ -36,7 +36,6 @@ public class Metrics {
public static void Bstats() {
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics(Main.plugin, pluginId);
metrics.addCustomChart(new Metrics.SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin)));
metrics.addCustomChart(new DrilldownPie("storage_type_mysql", () -> {
Map<String, Map<String, Integer>> map = new HashMap<>();
String storage = SelectDatabase.getStorage().toString();