Skip to content

Commit

Permalink
Boolean to toggle hotbar items
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Jun 24, 2024
1 parent 29ea636 commit 7a5b86f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/main/java/dev/lrxh/neptune/configs/impl/HotbarLocale.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,47 @@ public enum HotbarLocale implements IDataAccessor {
LOBBY_UNRANKED_NAME("ITEMS.LOBBY.UNRANKED.NAME", null, DataType.STRING, "&aQueue Match &7(Right Click)"),
LOBBY_UNRANKED_MATERIAL("ITEMS.LOBBY.UNRANKED.MATERIAL", null, DataType.STRING, "IRON_SWORD"),
LOBBY_UNRANKED_SLOT("ITEMS.LOBBY.UNRANKED.SLOT", null, DataType.INT, "0"),
LOBBY_UNRANKED_ENABLED("ITEMS.LOBBY.UNRANKED.ENABLED", null, DataType.BOOLEAN, "true"),
LOBBY_SPECTATE_MENU_NAME("ITEMS.LOBBY.SPECTATE_MENU.NAME", null, DataType.STRING, "&6View Matches &7(Right Click)"),
LOBBY_SPECTATE_MENU_MATERIAL("ITEMS.LOBBY.SPECTATE_MENU.MATERIAL", null, DataType.STRING, "EMERALD"),
LOBBY_SPECTATE_MENU_SLOT("ITEMS.LOBBY.SPECTATE_MENU.SLOT", null, DataType.INT, "1"),
LOBBY_SPECTATE_MENU_ENABLED("ITEMS.LOBBY.SPECTATE_MENU.ENABLED", null, DataType.BOOLEAN, "true"),
LOBBY_PARTY_CREATE_NAME("ITEMS.LOBBY.PARTY_CREATE.NAME", null, DataType.STRING, "&9Create Party &7(Right Click)"),
LOBBY_PARTY_CREATE_MATERIAL("ITEMS.LOBBY.PARTY_CREATE.MATERIAL", null, DataType.STRING, "NAME_TAG"),
LOBBY_PARTY_CREATE_SLOT("ITEMS.LOBBY.PARTY_CREATE.SLOT", null, DataType.INT, "3"),
LOBBY_PARTY_CREATE_ENABLED("ITEMS.LOBBY.PARTY_CREATE.ENABLED", null, DataType.BOOLEAN, "true"),
LOBBY_LEADERBOARDS_NAME("ITEMS.LOBBY.LEADERBOARDS.NAME", null, DataType.STRING, "&cLeaderboards &7(Right Click)"),
LOBBY_LEADERBOARDS_MATERIAL("ITEMS.LOBBY.LEADERBOARDS.MATERIAL", null, DataType.STRING, "NETHER_STAR"),
LOBBY_LEADERBOARDS_SLOT("ITEMS.LOBBY.LEADERBOARDS.SLOT", null, DataType.INT, "5"),
LOBBY_LEADERBOARDS_ENABLED("ITEMS.LOBBY.LEADERBOARDS.ENABLED", null, DataType.BOOLEAN, "true"),
LOBBY_STATS_NAME("ITEMS.LOBBY.STATS.NAME", null, DataType.STRING, "&eStats &7(Right Click)"),
LOBBY_STATS_MATERIAL("ITEMS.LOBBY.STATS.MATERIAL", null, DataType.STRING, "COMPASS"),
LOBBY_STATS_SLOT("ITEMS.LOBBY.STATS.SLOT", null, DataType.INT, "7"),
LOBBY_STATS_ENABLED("ITEMS.LOBBY.STATS.ENABLED", null, DataType.BOOLEAN, "true"),
LOBBY_KIT_EDITOR_NAME("ITEMS.LOBBY.KIT_EDITOR.NAME", null, DataType.STRING, "&dKit Editor &7(Right Click)"),
LOBBY_KIT_EDITOR_MATERIAL("ITEMS.LOBBY.KIT_EDITOR.MATERIAL", null, DataType.STRING, "BOOK"),
LOBBY_KIT_EDITOR_SLOT("ITEMS.LOBBY.KIT_EDITOR.SLOT", null, DataType.INT, "8"),
LOBBY_KIT_EDITOR_ENABLED("ITEMS.LOBBY.KIT_EDITOR.ENABLED", null, DataType.BOOLEAN, "true"),
IN_QUEUE_QUEUE_LEAVE_NAME("ITEMS.IN_QUEUE.QUEUE_LEAVE.NAME", null, DataType.STRING, "&cLeave Queue &7(Right Click)"),
IN_QUEUE_QUEUE_LEAVE_MATERIAL("ITEMS.IN_QUEUE.QUEUE_LEAVE.MATERIAL", null, DataType.STRING, "RED_DYE"),
IN_QUEUE_QUEUE_LEAVE_SLOT("ITEMS.IN_QUEUE.QUEUE_LEAVE.SLOT", null, DataType.INT, "8"),
IN_QUEUE_QUEUE_LEAVE_ENABLED("ITEMS.IN_QUEUE.QUEUE_LEAVE.ENABLED", null, DataType.BOOLEAN, "true"),
IN_PARTY_PARTY_INFO_NAME("ITEMS.IN_PARTY.PARTY_INFO.NAME", null, DataType.STRING, "&aParty Information &7(Right Click)"),
IN_PARTY_PARTY_INFO_MATERIAL("ITEMS.IN_PARTY.PARTY_INFO.MATERIAL", null, DataType.STRING, "COMPASS"),
IN_PARTY_PARTY_INFO_SLOT("ITEMS.IN_PARTY.PARTY_INFO.SLOT", null, DataType.INT, "0"),
IN_PARTY_PARTY_INFO_ENABLED("ITEMS.IN_PARTY.PARTY_INFO.ENABLED", null, DataType.BOOLEAN, "true"),
IN_PARTY_PARTY_SETTINGS_NAME("ITEMS.IN_PARTY.PARTY_SETTINGS.NAME", null, DataType.STRING, "&eParty Settings &7(Right Click)"),
IN_PARTY_PARTY_SETTINGS_MATERIAL("ITEMS.IN_PARTY.PARTY_SETTINGS.MATERIAL", null, DataType.STRING, "PAPER"),
IN_PARTY_PARTY_SETTINGS_SLOT("ITEMS.IN_PARTY.PARTY_SETTINGS.SLOT", null, DataType.INT, "1"),
IN_PARTY_PARTY_SETTINGS_ENABLED("ITEMS.IN_PARTY.PARTY_SETTINGS.ENABLED", null, DataType.BOOLEAN, "true"),
IN_PARTY_PARTY_EVENTS_NAME("ITEMS.IN_PARTY.PARTY_EVENTS.NAME", null, DataType.STRING, "&dParty Events &7(Right Click)"),
IN_PARTY_PARTY_EVENTS_MATERIAL("ITEMS.IN_PARTY.PARTY_EVENTS.MATERIAL", null, DataType.STRING, "NAME_TAG"),
IN_PARTY_PARTY_EVENTS_SLOT("ITEMS.IN_PARTY.PARTY_EVENTS.SLOT", null, DataType.INT, "2"),
IN_PARTY_PARTY_EVENTS_ENABLED("ITEMS.IN_PARTY.PARTY_EVENTS.ENABLED", null, DataType.BOOLEAN, "true"),
IN_PARTY_PARTY_DISBAND_NAME("ITEMS.IN_PARTY.PARTY_DISBAND.NAME", null, DataType.STRING, "&cLeave Party &7(Right Click)"),
IN_PARTY_PARTY_DISBAND_MATERIAL("ITEMS.IN_PARTY.PARTY_DISBAND.MATERIAL", null, DataType.STRING, "RED_DYE"),
IN_PARTY_PARTY_DISBAND_SLOT("ITEMS.IN_PARTY.PARTY_DISBAND.SLOT", null, DataType.INT, "8");
IN_PARTY_PARTY_DISBAND_SLOT("ITEMS.IN_PARTY.PARTY_DISBAND.SLOT", null, DataType.INT, "8"),
IN_PARTY_PARTY_DISBAND_ENABLED("ITEMS.IN_PARTY.PARTY_DISBAND.ENABLED", null, DataType.BOOLEAN, "true");

private final String path;
private final String comment;
Expand All @@ -60,5 +71,4 @@ public enum HotbarLocale implements IDataAccessor {
public ConfigFile getConfigFile() {
return plugin.getConfigManager().getHotbarConfig();
}

}
5 changes: 3 additions & 2 deletions src/main/java/dev/lrxh/neptune/hotbar/HotbarManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void giveItems(UUID playerUUID) {
for (int slot = 0; slot <= 8; slot++) {
Item item = getItemForSlot(inventory, slot);

if (item != null) {
if (item != null && item.isEnabled()) {
player.getInventory().setItem(item.getSlot(), item.constructItem(playerUUID));
}
}
Expand All @@ -68,9 +68,10 @@ public void loadItems() {

String displayName = config.getString(path + "NAME");
String material = config.getString(path + "MATERIAL");
boolean enabled = config.getBoolean(path + "ENABLED");
byte slot = (byte) config.getInt(path + "SLOT");

Item item = new Item(itemName, displayName, material, slot);
Item item = new Item(itemName, displayName, material, enabled, slot);

if (slot >= 0 && slot < inventory.getSlots().length) {
inventory.setSlot(slot, item);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/lrxh/neptune/hotbar/impl/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Item {
private String name;
private String displayName;
private String material;
private boolean enabled;
private byte slot;

public static Item getByItemStack(ItemStack itemStack, UUID playerUUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ public ItemStack getItem(Player player) {
};

public abstract ItemStack getItem(Player player);

}

0 comments on commit 7a5b86f

Please sign in to comment.