mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-30 12:29:16 +00:00
clean: annotation & variable modifier changes
This commit is contained in:
@@ -17,6 +17,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
@@ -25,13 +27,13 @@ import java.util.List;
|
||||
|
||||
public class Menu {
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
private int rows;
|
||||
private ConfigurationNode config;
|
||||
private String permissionNode;
|
||||
private final String id;
|
||||
private final String title;
|
||||
private final int rows;
|
||||
private final ConfigurationNode config;
|
||||
private final String permissionNode;
|
||||
|
||||
public Menu(String id, ConfigurationNode config) {
|
||||
public Menu(String id, @NotNull ConfigurationNode config) {
|
||||
this.id = id;
|
||||
this.config = config;
|
||||
|
||||
@@ -58,7 +60,7 @@ public class Menu {
|
||||
openMenu(user, false);
|
||||
}
|
||||
|
||||
public void openMenu(CosmeticUser user, boolean ignorePermission) {
|
||||
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
|
||||
Player player = user.getPlayer();
|
||||
if (player == null) return;
|
||||
if (!ignorePermission && !permissionNode.isEmpty()) {
|
||||
@@ -97,7 +99,8 @@ public class Menu {
|
||||
|
||||
}
|
||||
|
||||
private Gui getItems(CosmeticUser user, Gui gui) {
|
||||
@Contract("_, _ -> param2")
|
||||
private Gui getItems(@NotNull CosmeticUser user, Gui gui) {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
|
||||
@@ -164,7 +167,8 @@ public class Menu {
|
||||
return gui;
|
||||
}
|
||||
|
||||
private List<Integer> getSlots(List<String> slotString) {
|
||||
@NotNull
|
||||
private List<Integer> getSlots(@NotNull List<String> slotString) {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
|
||||
for (String a : slotString) {
|
||||
@@ -181,6 +185,7 @@ public class Menu {
|
||||
return slots;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Integer> getSlots(int small, int max) {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
|
||||
@@ -188,7 +193,9 @@ public class Menu {
|
||||
return slots;
|
||||
}
|
||||
|
||||
private ItemStack updateLore(CosmeticUser user, ItemStack itemStack, Type type, ConfigurationNode config) {
|
||||
@Contract("_, _, _, _ -> param2")
|
||||
@NotNull
|
||||
private ItemStack updateLore(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config) {
|
||||
if (itemStack.hasItemMeta()) {
|
||||
itemStack.setItemMeta(type.setLore(user, config, itemStack.getItemMeta()));
|
||||
}
|
||||
@@ -201,7 +208,6 @@ public class Menu {
|
||||
|
||||
public boolean canOpen(Player player) {
|
||||
if (permissionNode.isEmpty()) return true;
|
||||
if (player.isOp() || player.hasPermission(permissionNode)) return true;
|
||||
return false;
|
||||
return player.isOp() || player.hasPermission(permissionNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
@@ -17,21 +19,23 @@ import java.util.logging.Level;
|
||||
|
||||
public class Menus {
|
||||
|
||||
private static HashMap<String, Menu> MENUS = new HashMap<>();
|
||||
private static final HashMap<String, Menu> MENUS = new HashMap<>();
|
||||
|
||||
public static void addMenu(Menu menu) {
|
||||
MENUS.put(menu.getId().toUpperCase(), menu);
|
||||
}
|
||||
|
||||
public static Menu getMenu(String id) {
|
||||
public static Menu getMenu(@NotNull String id) {
|
||||
return MENUS.get(id.toUpperCase());
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@NotNull
|
||||
public static Collection<Menu> getMenu() {
|
||||
return MENUS.values();
|
||||
}
|
||||
|
||||
public static boolean hasMenu(String id) {
|
||||
public static boolean hasMenu(@NotNull String id) {
|
||||
return MENUS.containsKey(id.toUpperCase());
|
||||
}
|
||||
|
||||
@@ -41,6 +45,7 @@ public class Menus {
|
||||
|
||||
public static Menu getDefaultMenu() { return Menus.getMenu(Settings.getDefaultMenu()); }
|
||||
|
||||
@NotNull
|
||||
public static List<String> getMenuNames() {
|
||||
List<String> names = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Action {
|
||||
|
||||
private String id;
|
||||
private final String id;
|
||||
|
||||
public Action(String id) {
|
||||
public Action(@NotNull String id) {
|
||||
this.id = id.toUpperCase();
|
||||
Actions.addAction(this);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ import com.hibiscusmc.hmccosmetics.gui.action.actions.*;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Actions {
|
||||
|
||||
private static HashMap<String, Action> actions = new HashMap<>();
|
||||
private static final HashMap<String, Action> actions = new HashMap<>();
|
||||
|
||||
// [ID]
|
||||
private static ActionMessage ACTION_MESSAGE = new ActionMessage();
|
||||
@@ -27,11 +28,11 @@ public class Actions {
|
||||
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||
|
||||
|
||||
public static Action getAction(String id) {
|
||||
public static Action getAction(@NotNull String id) {
|
||||
return actions.get(id.toUpperCase());
|
||||
}
|
||||
|
||||
public static boolean isAction(String id) {
|
||||
public static boolean isAction(@NotNull String id) {
|
||||
return actions.containsKey(id.toUpperCase());
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ public class Actions {
|
||||
actions.put(action.getId().toUpperCase(), action);
|
||||
}
|
||||
|
||||
public static void runActions(CosmeticUser user, List<String> raw) {
|
||||
public static void runActions(CosmeticUser user, @NotNull List<String> raw) {
|
||||
for (String a : raw) {
|
||||
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
|
||||
String message = StringUtils.substringAfter(a, "] ");
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCloseMenu extends Action {
|
||||
|
||||
@@ -10,7 +11,7 @@ public class ActionCloseMenu extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
user.getPlayer().closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionConsoleCommand extends Action {
|
||||
|
||||
@@ -11,7 +12,7 @@ public class ActionConsoleCommand extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticHide extends Action {
|
||||
|
||||
@@ -10,10 +11,9 @@ public class ActionCosmeticHide extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (!user.getHidden()) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticShow extends Action {
|
||||
|
||||
@@ -10,7 +11,7 @@ public class ActionCosmeticShow extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
|
||||
user.showCosmetics();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionCosmeticToggle extends Action {
|
||||
|
||||
@@ -10,13 +11,12 @@ public class ActionCosmeticToggle extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
return;
|
||||
}
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionMessage extends Action {
|
||||
|
||||
@@ -11,7 +12,7 @@ public class ActionMessage extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
MessagesUtil.sendMessageNoKey(user.getPlayer(), raw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.owen1212055.particlehelper.api.particle.Particle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
|
||||
@@ -14,6 +13,7 @@ import com.owen1212055.particlehelper.api.type.Particles;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionParticle extends Action {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ActionParticle extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(CosmeticUser user, @NotNull String raw) {
|
||||
String[] rawString = raw.split(" ");
|
||||
var particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
|
||||
if (particleType == null) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionPlayerCommand extends Action {
|
||||
|
||||
@@ -11,7 +12,7 @@ public class ActionPlayerCommand extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, String raw) {
|
||||
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -15,7 +16,7 @@ public class ActionSound extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
public void run(@NotNull CosmeticUser user, @NotNull String raw) {
|
||||
Player player = user.getPlayer();
|
||||
String[] processedString = raw.split(" ");
|
||||
|
||||
|
||||
@@ -17,13 +17,12 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DyeMenu {
|
||||
|
||||
// Yes, I do know how tacted on this feels.
|
||||
|
||||
|
||||
public static void openMenu(CosmeticUser user, Cosmetic cosmetic) {
|
||||
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
|
||||
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
|
||||
if (originalItem == null || !cosmetic.isDyable()) return;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class Type {
|
||||
|
||||
private String id;
|
||||
private final String id;
|
||||
|
||||
public Type(String id) {
|
||||
this.id = id;
|
||||
|
||||
@@ -2,21 +2,22 @@ package com.hibiscusmc.hmccosmetics.gui.type;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeEmpty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Types {
|
||||
|
||||
private static HashMap<String, Type> types = new HashMap<>();
|
||||
private static final HashMap<String, Type> types = new HashMap<>();
|
||||
|
||||
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
|
||||
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
|
||||
|
||||
public static Type getType(String id) {
|
||||
public static Type getType(@NotNull String id) {
|
||||
return types.get(id.toUpperCase());
|
||||
}
|
||||
|
||||
public static boolean isType(String id) {
|
||||
public static boolean isType(@NotNull String id) {
|
||||
return types.containsKey(id.toUpperCase());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
@@ -31,7 +33,7 @@ public class TypeCosmetic extends Type {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
if (config.node("cosmetic").virtual()) return;
|
||||
String cosmeticName = config.node("cosmetic").getString();
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
|
||||
@@ -92,7 +94,7 @@ public class TypeCosmetic extends Type {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
||||
public ItemMeta setLore(CosmeticUser user, @NotNull ConfigurationNode config, ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (config.node("cosmetic").virtual()) return processLoreLines(user, itemMeta);;
|
||||
@@ -143,7 +145,9 @@ public class TypeCosmetic extends Type {
|
||||
return itemMeta;
|
||||
}
|
||||
|
||||
private ItemMeta processLoreLines(CosmeticUser user, ItemMeta itemMeta) {
|
||||
@Contract("_, _ -> param2")
|
||||
@NotNull
|
||||
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
@@ -25,7 +26,7 @@ public class TypeEmpty extends Type {
|
||||
|
||||
// This is the code that's run when the item is clicked.
|
||||
@Override
|
||||
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
|
||||
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
|
||||
List<String> actionStrings = new ArrayList<>(); // List where we keep the actions the server will execute.
|
||||
ConfigurationNode actionConfig = config.node("actions"); // Configuration node that actions are under.
|
||||
|
||||
@@ -53,7 +54,7 @@ public class TypeEmpty extends Type {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
|
||||
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
|
||||
List<String> processedLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Hook implements Listener {
|
||||
|
||||
private String id;
|
||||
private final String id;
|
||||
private boolean active;
|
||||
private boolean itemHook;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Hook implements Listener {
|
||||
// Override
|
||||
}
|
||||
|
||||
public ItemStack getItem(String itemid) {
|
||||
public ItemStack getItem(String itemId) {
|
||||
return null;
|
||||
// Override
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Hooks {
|
||||
|
||||
private static HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||
private static HookLooty LOOTY_HOOK = new HookLooty();
|
||||
@@ -23,11 +25,11 @@ public class Hooks {
|
||||
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
|
||||
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
|
||||
|
||||
public static Hook getHook(String id) {
|
||||
public static Hook getHook(@NotNull String id) {
|
||||
return hooks.get(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean isItemHook(String id) {
|
||||
public static boolean isItemHook(@NotNull String id) {
|
||||
return hooks.containsKey(id.toLowerCase());
|
||||
}
|
||||
|
||||
@@ -46,7 +48,8 @@ public class Hooks {
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItem(String raw) {
|
||||
@Nullable
|
||||
public static ItemStack getItem(@NotNull String raw) {
|
||||
if (!raw.contains(":")) {
|
||||
Material mat = Material.getMaterial(raw.toUpperCase());
|
||||
if (mat == null) return null;
|
||||
@@ -61,8 +64,7 @@ public class Hooks {
|
||||
Hook hook = getHook(split[0]);
|
||||
if (!hook.hasEnabledItemHook()) return null;
|
||||
if (!hook.getActive()) return null;
|
||||
ItemStack item = hook.getItem(split[1]);
|
||||
return item;
|
||||
return hook.getItem(split[1]);
|
||||
}
|
||||
|
||||
public static boolean isActiveHook(String id) {
|
||||
|
||||
@@ -14,8 +14,8 @@ public class HookHMCCosmetics extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String itemid) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(itemid);
|
||||
public ItemStack getItem(String itemId) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
||||
if (cosmetic == null) return null;
|
||||
return cosmetic.getItem();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class HookItemAdder extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String itemid) {
|
||||
public ItemStack getItem(String itemId) {
|
||||
if (enabled) {
|
||||
CustomStack stack = CustomStack.getInstance(itemid);
|
||||
CustomStack stack = CustomStack.getInstance(itemId);
|
||||
if (stack == null) return null;
|
||||
return stack.getItemStack();
|
||||
} else {
|
||||
|
||||
@@ -14,8 +14,8 @@ public class HookLooty extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String itemid) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemid);
|
||||
public ItemStack getItem(String itemId) {
|
||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||
if (prefabKey == null) return null;
|
||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class HookMythic extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String itemid) {
|
||||
return MythicBukkit.inst().getItemManager().getItemStack(itemid);
|
||||
public ItemStack getItem(String itemId) {
|
||||
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public class HookOraxen extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(String itemid) {
|
||||
ItemBuilder builder = OraxenItems.getItemById(itemid);
|
||||
public ItemStack getItem(String itemId) {
|
||||
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||
if (builder == null) return null;
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HookPremiumVanish extends Hook implements Listener {
|
||||
|
||||
@@ -18,7 +19,7 @@ public class HookPremiumVanish extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerVanish(PlayerHideEvent event) {
|
||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
@@ -26,7 +27,7 @@ public class HookPremiumVanish extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShow(PlayerShowEvent event) {
|
||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
|
||||
@@ -8,6 +8,7 @@ import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HookSuperVanish extends Hook implements Listener {
|
||||
|
||||
@@ -18,7 +19,7 @@ public class HookSuperVanish extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerVanish(PlayerHideEvent event) {
|
||||
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
@@ -26,7 +27,7 @@ public class HookSuperVanish extends Hook implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShow(PlayerShowEvent event) {
|
||||
public void onPlayerShow(@NotNull PlayerShowEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
|
||||
@@ -25,22 +25,25 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
@NotNull
|
||||
public String getIdentifier() {
|
||||
return "HMCCosmetics";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
@NotNull
|
||||
public String getAuthor() {
|
||||
return "HibiscusMC";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer player, String params) {
|
||||
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
|
||||
if (!player.isOnline()) return null;
|
||||
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
|
||||
if (user == null) return null;
|
||||
@@ -132,13 +135,13 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMaterial(Cosmetic cosmetic) {
|
||||
public String getMaterial(@NotNull Cosmetic cosmetic) {
|
||||
ItemStack item = cosmetic.getItem();
|
||||
if (item == null) return null;
|
||||
return cosmetic.getItem().getType().toString();
|
||||
}
|
||||
|
||||
public String getModelData(Cosmetic cosmetic) {
|
||||
public String getModelData(@NotNull Cosmetic cosmetic) {
|
||||
ItemStack item = cosmetic.getItem();
|
||||
if (item == null) return null;
|
||||
if (!item.hasItemMeta()) return null;
|
||||
@@ -146,7 +149,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return String.valueOf(itemMeta.getCustomModelData());
|
||||
}
|
||||
|
||||
public String getItemName(Cosmetic cosmetic) {
|
||||
public String getItemName(@NotNull Cosmetic cosmetic) {
|
||||
ItemStack item = cosmetic.getItem();
|
||||
if (item == null) return null;
|
||||
if (!item.hasItemMeta()) return null;
|
||||
@@ -154,7 +157,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return itemMeta.getDisplayName();
|
||||
}
|
||||
|
||||
public String getItemLore(Cosmetic cosmetic) {
|
||||
public String getItemLore(@NotNull Cosmetic cosmetic) {
|
||||
ItemStack item = cosmetic.getItem();
|
||||
if (item == null) return null;
|
||||
if (item.hasItemMeta()) {
|
||||
|
||||
@@ -12,11 +12,12 @@ import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WGListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||
if (user == null) return;
|
||||
Location location = event.getPlayer().getLocation();
|
||||
|
||||
Reference in New Issue
Block a user