From 9ccaaca6da8d1e323a6fe88087c9ece90aff2cc6 Mon Sep 17 00:00:00 2001 From: FirephoenixX02 Date: Tue, 31 Oct 2023 18:15:51 +0100 Subject: [PATCH] Initial commit --- .gitignore | 113 +++++++ pom.xml | 36 +++ .../anticheatmanager/AnticheatManager.java | 17 + .../cmds/AnticheatManagerGUI.java | 8 + .../cmds/AnticheatSelector.java | 6 + .../anticheatmanager/listener/InvClick.java | 8 + .../anticheatmanager/util/ItemBuilder.java | 301 ++++++++++++++++++ src/main/resources/config.yml | 0 src/main/resources/plugin.yml | 3 + 9 files changed, 492 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/me/firephoenix/anticheatmanager/AnticheatManager.java create mode 100644 src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatManagerGUI.java create mode 100644 src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatSelector.java create mode 100644 src/main/java/me/firephoenix/anticheatmanager/listener/InvClick.java create mode 100644 src/main/java/me/firephoenix/anticheatmanager/util/ItemBuilder.java create mode 100644 src/main/resources/config.yml create mode 100644 src/main/resources/plugin.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4788b4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,113 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..56da438 --- /dev/null +++ b/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + me.firephoenix + AnticheatManager + 1.0 + AnticheatManager + + + 8 + 8 + UTF-8 + + + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + provided + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + + \ No newline at end of file diff --git a/src/main/java/me/firephoenix/anticheatmanager/AnticheatManager.java b/src/main/java/me/firephoenix/anticheatmanager/AnticheatManager.java new file mode 100644 index 0000000..779659e --- /dev/null +++ b/src/main/java/me/firephoenix/anticheatmanager/AnticheatManager.java @@ -0,0 +1,17 @@ +package me.firephoenix.anticheatmanager; + +import org.bukkit.plugin.java.JavaPlugin; + +public final class AnticheatManager extends JavaPlugin { + + @Override + public void onEnable() { + // Plugin startup logic + + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } +} diff --git a/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatManagerGUI.java b/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatManagerGUI.java new file mode 100644 index 0000000..34f9565 --- /dev/null +++ b/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatManagerGUI.java @@ -0,0 +1,8 @@ +package me.firephoenix.anticheatmanager.cmds; + +/** + * @author NieGestorben + * Copyright© (c) 2023, All Rights Reserved. + */ +public class AnticheatManagerGUI { +} diff --git a/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatSelector.java b/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatSelector.java new file mode 100644 index 0000000..39a3baf --- /dev/null +++ b/src/main/java/me/firephoenix/anticheatmanager/cmds/AnticheatSelector.java @@ -0,0 +1,6 @@ +package me.firephoenix.anticheatmanager.cmds;/** + * @author NieGestorben + * Copyright© (c) 2023, All Rights Reserved. + */ + public class AnticheatSelector { +} diff --git a/src/main/java/me/firephoenix/anticheatmanager/listener/InvClick.java b/src/main/java/me/firephoenix/anticheatmanager/listener/InvClick.java new file mode 100644 index 0000000..ebfb80c --- /dev/null +++ b/src/main/java/me/firephoenix/anticheatmanager/listener/InvClick.java @@ -0,0 +1,8 @@ +package me.firephoenix.anticheatmanager.listener; + +/** + * @author NieGestorben + * Copyright© (c) 2023, All Rights Reserved. + */ +public class InvClick { +} diff --git a/src/main/java/me/firephoenix/anticheatmanager/util/ItemBuilder.java b/src/main/java/me/firephoenix/anticheatmanager/util/ItemBuilder.java new file mode 100644 index 0000000..b2af343 --- /dev/null +++ b/src/main/java/me/firephoenix/anticheatmanager/util/ItemBuilder.java @@ -0,0 +1,301 @@ +package me.firephoenix.anticheatmanager.cmds.util; + +import org.bukkit.Color; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.material.MaterialData; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Easily create itemstacks, without messing your hands. + * Note that if you do use this in one of your projects, leave this notice. + * Please do credit me if you do use this in one of your projects. + * @author NonameSL + */ +public class ItemBuilder { + private final ItemStack is; + /** + * Create a new ItemBuilder from scratch. + * @param m The material to create the ItemBuilder with. + */ + public ItemBuilder(Material m){ + this(m, 1); + } + /** + * Create a new ItemBuilder over an existing itemstack. + * @param is The itemstack to create the ItemBuilder over. + */ + public ItemBuilder(ItemStack is){ + this.is=is; + } + /** + * Create a new ItemBuilder from scratch. + * @param m The material of the item. + * @param amount The amount of the item. + */ + public ItemBuilder(Material m, int amount){ + is= new ItemStack(m, amount); + } + /** + * Create a new ItemBuilder from scratch. + * @param m The material of the item. + * @param amount The amount of the item. + * @param durability The durability of the item. + */ + public ItemBuilder(Material m, int amount, byte durability){ + is = new ItemStack(m, amount, durability); + } + /** + * Clone the ItemBuilder into a new one. + * @return The cloned instance. + */ + public ItemBuilder clone() { + return new ItemBuilder(is); + } + /** + * Change the durability of the item. + * @param dur The durability to set it to. + */ + public ItemBuilder setDurability(short dur){ + is.setDurability(dur); + return this; + } + /** + * Change the amount of the item. + * @param amount The amount to set it to. + */ + public ItemBuilder setAmount(int amount) { + is.setAmount(amount); + return this; + } + /** + * Set the displayname of the item. + * @param name The name to change it to. + */ + public ItemBuilder setName(String name){ + ItemMeta im = is.getItemMeta(); + im.setDisplayName(name); + is.setItemMeta(im); + return this; + } + /** + * Add an unsafe enchantment. + * @param ench The enchantment to add. + * @param level The level to put the enchant on. + */ + public ItemBuilder addUnsafeEnchantment(Enchantment ench, int level){ + is.addUnsafeEnchantment(ench, level); + return this; + } + /** + * Remove a certain enchant from the item. + * @param ench The enchantment to remove + */ + public ItemBuilder removeEnchantment(Enchantment ench){ + is.removeEnchantment(ench); + return this; + } + /** + * Set the skull owner for the item. Works on skulls only. + * @param owner The name of the skull's owner. + */ + public ItemBuilder setSkullOwner(String owner){ + try{ + SkullMeta im = (SkullMeta)is.getItemMeta(); + im.setOwner(owner); + is.setItemMeta(im); + }catch(ClassCastException ignored){} + return this; + } + /** + * Add an enchant to the item. + * @param ench The enchant to add + * @param level The level + */ + public ItemBuilder addEnchant(Enchantment ench, int level){ + ItemMeta im = is.getItemMeta(); + im.addEnchant(ench, level, true); + is.setItemMeta(im); + return this; + } + /** + * Add multiple enchants at once. + * @param enchantments The enchants to add. + */ + public ItemBuilder addEnchantments(Map enchantments){ + is.addEnchantments(enchantments); + return this; + } + /** + * Sets infinity durability on the item by setting the durability to Short.MAX_VALUE. + */ + public ItemBuilder setInfinityDurability(){ + is.setDurability(Short.MAX_VALUE); + return this; + } + /** + * Sets the durability to unbreakable + */ + public ItemBuilder setUnbreakable(boolean unbreakable) { + ItemMeta im = is.getItemMeta(); + im.spigot().setUnbreakable(unbreakable); + is.setItemMeta(im); + return this; + } + /** + * Re-sets the lore. + * @param lore The lore to set it to. + */ + public ItemBuilder setLore(String... lore){ + ItemMeta im = is.getItemMeta(); + im.setLore(Arrays.asList(lore)); + is.setItemMeta(im); + return this; + } + /** + * Re-sets the lore. + * @param lore The lore to set it to. + */ + public ItemBuilder setLore(List lore) { + ItemMeta im = is.getItemMeta(); + im.setLore(lore); + is.setItemMeta(im); + return this; + } + /** + * Remove a lore line. + * @param line The lore to remove. + */ + public ItemBuilder removeLoreLine(String line){ + ItemMeta im = is.getItemMeta(); + List lore = new ArrayList<>(im.getLore()); + if(!lore.contains(line))return this; + lore.remove(line); + im.setLore(lore); + is.setItemMeta(im); + return this; + } + /** + * Remove a lore line. + * @param index The index of the lore line to remove. + */ + public ItemBuilder removeLoreLine(int index){ + ItemMeta im = is.getItemMeta(); + List lore = new ArrayList<>(im.getLore()); + if(index<0||index>lore.size())return this; + lore.remove(index); + im.setLore(lore); + is.setItemMeta(im); + return this; + } + /** + * Add a lore line. + * @param line The lore line to add. + */ + public ItemBuilder addLoreLine(String line){ + ItemMeta im = is.getItemMeta(); + List lore = new ArrayList<>(); + if(im.hasLore())lore = new ArrayList<>(im.getLore()); + lore.add(line); + im.setLore(lore); + is.setItemMeta(im); + return this; + } + /** + * Add a lore line. + * @param line The lore line to add. + * @param pos The index of where to put it. + */ + public ItemBuilder addLoreLine(String line, int pos){ + ItemMeta im = is.getItemMeta(); + List lore = new ArrayList<>(im.getLore()); + lore.set(pos, line); + im.setLore(lore); + is.setItemMeta(im); + return this; + } + /** + * Sets the dye color on an item. + * * Notice that this doesn't check for item type, sets the literal data of the dyecolor as durability. + * @param color The color to put. + */ + @SuppressWarnings("deprecation") + public ItemBuilder setDyeColor(DyeColor color){ + this.is.setDurability(color.getDyeData()); + return this; + } + /** + * Sets the dye color of a wool item. Works only on wool. + * @deprecated As of version 1.2 changed to setDyeColor. + * @see ItemBuilder@setDyeColor(DyeColor) + * @param color The DyeColor to set the wool item to. + */ + @Deprecated + public ItemBuilder setWoolColor(DyeColor color){ + if(!is.getType().equals(Material.WOOL))return this; + this.is.setDurability(color.getDyeData()); + return this; + } + /** + * Sets the armor color of a leather armor piece. Works only on leather armor pieces. + * @param color The color to set it to. + */ + public ItemBuilder setLeatherArmorColor(Color color){ + try{ + LeatherArmorMeta im = (LeatherArmorMeta)is.getItemMeta(); + im.setColor(color); + is.setItemMeta(im); + }catch(ClassCastException ignored){} + return this; + } + + /** + * Sets the itemflag of the item. Works on every item. + * @param flag Set a specific itemflag + */ + public ItemBuilder setItemFlags(ItemFlag flag) { + ItemMeta im = is.getItemMeta(); + im.addItemFlags(flag); + is.setItemMeta(im); + return this; + } + + /** + * Sets the data of the item. Works on every item. + * @param data Set a specific data + */ + public ItemBuilder setData(MaterialData data) { + is.setData(data); + return this; + } + + /** + * Sets the typeId of the item. Works on every item. + * @param typeId Set a specific typeId + */ + @SuppressWarnings("deprecation") + public ItemBuilder setTypeId(int typeId) { + try { + is.setTypeId(typeId); + }catch (ClassCastException ignored) {} + return this; + } + + /** + * Retrieves the itemstack from the ItemBuilder. + * @return The itemstack created/modified by the ItemBuilder instance. + */ + public ItemStack toItemStack(){ + return is; + } +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..2b8d011 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: AnticheatManager +version: '${project.version}' +main: me.firephoenix.anticheatmanager.AnticheatManager