Changes
- If the option Join.Cursor.ToGUIItem.OnLogin was set to true the cursor was set to the UseItem even if the GameMode was changed, this was fixed. - Protection was completed
This commit is contained in:
parent
8377667f55
commit
75ab60bbaa
@ -5,7 +5,6 @@ import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class BMain extends Plugin {
|
||||
@ -86,7 +85,6 @@ public final class BMain extends Plugin {
|
||||
}
|
||||
|
||||
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) {
|
||||
|
||||
if (ProxyServer.getInstance().getPluginManager().getPlugin(pl) == null) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ItemChange {
|
||||
public static void itemChange(Player player) {
|
||||
public static void itemChange(Player player, Boolean setCursor) {
|
||||
Integer slot;
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce){
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce) {
|
||||
slot = SelectConfig.UseItem_InventorySlot;
|
||||
} else {
|
||||
if (Select_Database.selectSlot(player) == null) {
|
||||
@ -26,6 +26,16 @@ public class ItemChange {
|
||||
if (!SelectConfig.UseItem_Enable) {
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeProtection) {
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
|
||||
if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
@ -42,42 +52,18 @@ public class ItemChange {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItem_GiveOnEveryJoin) {
|
||||
if (!SelectConfig.UseItem_GiveOnEveryJoin) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
||||
ItemStack itm = player.getInventory().getItem(iam);
|
||||
if (itm != null) {
|
||||
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
||||
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
player.getInventory().remove(itm);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeItem(player);
|
||||
if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
|
||||
if (SelectConfig.UseItem_InventorySlotEnforce || player.getInventory().getItem(slot - 1) == null) {
|
||||
Give_UseItem.onGive(player);
|
||||
if (SelectConfig.Cursor_ToGUIItem_OnLogin) {
|
||||
if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
}
|
||||
} else {
|
||||
if (SelectConfig.Bungee) {
|
||||
if (SelectConfig.UseItem_ServerChange) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
} else {
|
||||
if (Main.bungeejoinplayers.contains(player.getName())) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
Main.bungeejoinplayers.remove(player.getName());
|
||||
}
|
||||
}
|
||||
} else player.getInventory().setHeldItemSlot(slot - 1);
|
||||
}
|
||||
if (setCursor) {
|
||||
setCursor(player, slot);
|
||||
}
|
||||
} else if (SelectConfig.UseItem_InventorySlot_FreeSlot) {
|
||||
boolean empty = false;
|
||||
@ -94,6 +80,46 @@ public class ItemChange {
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 1L * 1);
|
||||
|
||||
}
|
||||
|
||||
private static void setCursor(Player player, int slot) {
|
||||
if (!SelectConfig.Cursor_ToGUIItem_OnLogin) {
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.Cursor_ToGUIItem_OnlyOnFirstLogin) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!SelectConfig.Bungee) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItem_ServerChange) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
return;
|
||||
}
|
||||
if (Main.bungeejoinplayers.contains(player.getName())) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
Main.bungeejoinplayers.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeItem(Player player) {
|
||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
||||
ItemStack itm = player.getInventory().getItem(iam);
|
||||
if (itm != null) {
|
||||
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
||||
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
player.getInventory().remove(itm);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,6 @@ public class PluginEvent implements Listener {
|
||||
}
|
||||
|
||||
private static void clearGive(Player player) {
|
||||
ItemChange.itemChange(player);
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ public class Events implements Listener {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ItemChange.itemChange(e.getPlayer());
|
||||
ItemChange.itemChange(e.getPlayer(), true);
|
||||
}
|
||||
}.runTaskLater(Main.plugin, 20L * 1);
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class Events implements Listener {
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (SelectConfig.UseItem_Enable) {
|
||||
ItemChange.itemChange(player);
|
||||
ItemChange.itemChange(player, false);
|
||||
//if (!SelectConfig.UseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
|
||||
// if (SelectConfig.UseItem_GiveOnlyOnFirstJoin) {
|
||||
// if (!player.hasPlayedBefore()) {
|
||||
@ -99,38 +99,17 @@ public class Events implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onGameModeChange(PlayerGameModeChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!SelectConfig.UseItemGameModeChangeEnable) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (SelectConfig.UseItemGameModeChangeEnable) {
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("blacklist") && SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.UseItemGameModeMode.equalsIgnoreCase("whitelist") && !SelectConfig.UseItemGameModeList.contains(player.getGameMode().toString())) {
|
||||
removeItem(player);
|
||||
return;
|
||||
}
|
||||
ItemChange.itemChange(player);
|
||||
}
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
}.runTaskLater(Main.plugin, SelectConfig.UseItemGameModeChangeDelayInTicks * 1L);
|
||||
}
|
||||
|
||||
private static void removeItem(Player player) {
|
||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
||||
ItemStack itm = player.getInventory().getItem(iam);
|
||||
if (itm != null) {
|
||||
if (itm.getType() == Material.valueOf(SelectConfig.UseItem_Material) || itm.getType() == ItemVersion.getHead()) {
|
||||
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
player.getInventory().remove(itm);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
@ -204,14 +183,14 @@ public class Events implements Listener {
|
||||
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
ItemChange.itemChange(p);
|
||||
ItemChange.itemChange(p, false);
|
||||
}
|
||||
|
||||
if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName()
|
||||
&& e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.UseItem_Name)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
ItemChange.itemChange(p);
|
||||
ItemChange.itemChange(p, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,11 +96,11 @@ public class ConfigCreate {
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration);
|
||||
|
||||
Config.set("Advanced.UseItem.GameModeChange.Enable", true, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameModeChange.DelayInTicks", 1, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameModeChange.Protection.Enable", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameModeChange.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameModeChange.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
|
||||
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.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
|
||||
|
||||
Config.set("Sound.Enable", true, yamlConfiguration);
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SelectConfig {
|
||||
@ -145,11 +146,16 @@ public class SelectConfig {
|
||||
Cursor_ToGUIItem_OnlyOnFirstLogin = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
|
||||
UseItem_ServerChange = yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
|
||||
|
||||
UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Enable");
|
||||
UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameModeChange.DelayInTicks");
|
||||
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameModeChange.Protection.Enable");
|
||||
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameModeChange.Protection.Mode");
|
||||
UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameModeChange.Protection.List");
|
||||
UseItemGameModeChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Change.Enable");
|
||||
UseItemGameModeChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.GameMode.Change.DelayInTicks");
|
||||
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
|
||||
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode");
|
||||
List<String> gml = new ArrayList<>();
|
||||
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")){
|
||||
gml.add(gm.toUpperCase());
|
||||
}
|
||||
UseItemGameModeList = gml;
|
||||
|
||||
|
||||
|
||||
Sound_Enable = yamlConfiguration.getBoolean("Sound.Enable");
|
||||
|
@ -14,7 +14,10 @@ public class CGuiAPI {
|
||||
public static Boolean JoinDisable = false;
|
||||
|
||||
public static void onItemChange(Player player) {
|
||||
ItemChange.itemChange(player);
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
public static void onItemChange(Player player, Boolean setCursor) {
|
||||
ItemChange.itemChange(player, setCursor);
|
||||
}
|
||||
|
||||
public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) {
|
||||
|
Loading…
Reference in New Issue
Block a user