From dcccf737589d6ce2c7734466baf62ce663f2d76e Mon Sep 17 00:00:00 2001 From: Trixkz Date: Thu, 19 Sep 2024 23:19:34 -0400 Subject: [PATCH] Initial commit. --- pom.xml | 89 + .../java/com/loganmagnan/lasers/Lasers.java | 108 ++ .../lasers/chatcolor/ColorSet.java | 17 + .../lasers/chatcolor/GradientColor.java | 16 + .../lasers/commands/LaserCommand.java | 83 + .../lasers/listeners/MenuListener.java | 29 + .../listeners/PlayerInteractListener.java | 93 + .../lasers/managers/CooldownManager.java | 37 + .../lasers/menusystem/ItemStackButton.java | 29 + .../loganmagnan/lasers/menusystem/Menu.java | 64 + .../lasers/menusystem/PaginatedMenu.java | 49 + .../lasers/menusystem/PlayerMenuUtil.java | 20 + .../lasers/runnables/CooldownRunnable.java | 49 + .../lasers/runnables/LaserRunnable.java | 160 ++ .../lasers/utils/AsyncScheduler.java | 34 + .../loganmagnan/lasers/utils/BlockUtils.java | 47 + .../com/loganmagnan/lasers/utils/Cache.java | 29 + .../lasers/utils/CachedInventory.java | 189 ++ .../lasers/utils/ClassRegistrationUtils.java | 95 + .../loganmagnan/lasers/utils/Clickable.java | 51 + .../loganmagnan/lasers/utils/ColorUtils.java | 193 ++ .../com/loganmagnan/lasers/utils/Cuboid.java | 45 + .../lasers/utils/CustomLocation.java | 125 ++ .../loganmagnan/lasers/utils/ItemBuilder.java | 216 +++ .../loganmagnan/lasers/utils/ItemUtil.java | 167 ++ .../lasers/utils/LocationUtils.java | 34 + .../loganmagnan/lasers/utils/MathUtil.java | 58 + .../loganmagnan/lasers/utils/NBTEditor.java | 1571 +++++++++++++++++ .../com/loganmagnan/lasers/utils/Pair.java | 17 + .../lasers/utils/ParameterType.java | 14 + .../lasers/utils/PlayerHeadUtils.java | 51 + .../loganmagnan/lasers/utils/PlayerUtil.java | 42 + .../loganmagnan/lasers/utils/SpigotUtils.java | 46 + .../loganmagnan/lasers/utils/StringUtils.java | 244 +++ .../loganmagnan/lasers/utils/TeamAction.java | 8 + .../loganmagnan/lasers/utils/TimeUtil.java | 141 ++ .../loganmagnan/lasers/utils/TimeUtils.java | 110 ++ .../lasers/utils/TimerRunnable.java | 35 + .../loganmagnan/lasers/utils/TtlHandler.java | 8 + .../loganmagnan/lasers/utils/TtlHashMap.java | 128 ++ .../com/loganmagnan/lasers/utils/Utils.java | 130 ++ .../com/loganmagnan/lasers/utils/Vector3.java | 76 + .../loganmagnan/lasers/utils/WorldUtils.java | 322 ++++ .../lasers/utils/command/BaseCommand.java | 12 + .../lasers/utils/command/BukkitCommand.java | 82 + .../lasers/utils/command/BukkitCompleter.java | 48 + .../lasers/utils/command/Command.java | 23 + .../utils/command/CommandArguments.java | 52 + .../utils/command/CommandFramework.java | 172 ++ .../lasers/utils/command/Completer.java | 15 + .../lasers/utils/config/ConfigCursor.java | 88 + .../lasers/utils/config/FileConfig.java | 50 + .../lasers/utils/config/file/Config.java | 39 + .../lasers/utils/config/file/ConfigFile.java | 103 ++ .../lasers/utils/cuboid/Cuboid.java | 497 ++++++ .../utils/cuboid/CuboidBlockIterator.java | 97 + .../lasers/utils/cuboid/CuboidDirection.java | 46 + .../utils/cuboid/CuboidLocationIterator.java | 97 + src/main/resources/config.yml | 1 + src/main/resources/messages.yml | 1 + src/main/resources/plugin.yml | 5 + 61 files changed, 6497 insertions(+) create mode 100644 pom.xml create mode 100644 src/main/java/com/loganmagnan/lasers/Lasers.java create mode 100644 src/main/java/com/loganmagnan/lasers/chatcolor/ColorSet.java create mode 100644 src/main/java/com/loganmagnan/lasers/chatcolor/GradientColor.java create mode 100644 src/main/java/com/loganmagnan/lasers/commands/LaserCommand.java create mode 100644 src/main/java/com/loganmagnan/lasers/listeners/MenuListener.java create mode 100644 src/main/java/com/loganmagnan/lasers/listeners/PlayerInteractListener.java create mode 100644 src/main/java/com/loganmagnan/lasers/managers/CooldownManager.java create mode 100644 src/main/java/com/loganmagnan/lasers/menusystem/ItemStackButton.java create mode 100644 src/main/java/com/loganmagnan/lasers/menusystem/Menu.java create mode 100644 src/main/java/com/loganmagnan/lasers/menusystem/PaginatedMenu.java create mode 100644 src/main/java/com/loganmagnan/lasers/menusystem/PlayerMenuUtil.java create mode 100644 src/main/java/com/loganmagnan/lasers/runnables/CooldownRunnable.java create mode 100644 src/main/java/com/loganmagnan/lasers/runnables/LaserRunnable.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/AsyncScheduler.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/BlockUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Cache.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/CachedInventory.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/ClassRegistrationUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Clickable.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/ColorUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Cuboid.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/CustomLocation.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/ItemBuilder.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/ItemUtil.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/LocationUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/MathUtil.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/NBTEditor.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Pair.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/ParameterType.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/PlayerHeadUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/PlayerUtil.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/SpigotUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/StringUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TeamAction.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TimeUtil.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TimeUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TimerRunnable.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TtlHandler.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/TtlHashMap.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Utils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/Vector3.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/WorldUtils.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/BaseCommand.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/BukkitCommand.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/BukkitCompleter.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/Command.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/CommandArguments.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/CommandFramework.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/command/Completer.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/config/ConfigCursor.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/config/FileConfig.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/config/file/Config.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/config/file/ConfigFile.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/cuboid/Cuboid.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/cuboid/CuboidBlockIterator.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/cuboid/CuboidDirection.java create mode 100644 src/main/java/com/loganmagnan/lasers/utils/cuboid/CuboidLocationIterator.java create mode 100644 src/main/resources/config.yml create mode 100644 src/main/resources/messages.yml create mode 100644 src/main/resources/plugin.yml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a6e0087 --- /dev/null +++ b/pom.xml @@ -0,0 +1,89 @@ + + + 4.0.0 + + com.loganmagnan + Lasers + 1.0 + + + 1.8 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + false + + + + + + + + src/main/resources + true + + + + + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + fawe-repo + https://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/ + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + codemc-snapshots + https://repo.codemc.io/repository/maven-snapshots/ + + + + + + io.papermc.paper + paper-api + 1.20-R0.1-SNAPSHOT + provided + + + org.projectlombok + lombok + 1.18.20 + provided + + + \ No newline at end of file diff --git a/src/main/java/com/loganmagnan/lasers/Lasers.java b/src/main/java/com/loganmagnan/lasers/Lasers.java new file mode 100644 index 0000000..38d7c97 --- /dev/null +++ b/src/main/java/com/loganmagnan/lasers/Lasers.java @@ -0,0 +1,108 @@ +package com.loganmagnan.lasers; + +import com.loganmagnan.lasers.managers.CooldownManager; +import com.loganmagnan.lasers.menusystem.PlayerMenuUtil; +import com.loganmagnan.lasers.runnables.CooldownRunnable; +import com.loganmagnan.lasers.utils.ClassRegistrationUtils; +import com.loganmagnan.lasers.utils.ColorUtils; +import com.loganmagnan.lasers.utils.ItemBuilder; +import com.loganmagnan.lasers.utils.Utils; +import com.loganmagnan.lasers.utils.command.CommandFramework; +import com.loganmagnan.lasers.utils.config.FileConfig; +import com.loganmagnan.lasers.utils.config.file.Config; +import lombok.Getter; +import lombok.Setter; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ShapedRecipe; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.*; + +@Getter +@Setter +public class Lasers extends JavaPlugin { + + // Main Class Instance + @Getter private static Lasers instance; + + // Configuration Files + private Config mainConfig; + private FileConfig messagesConfig; + private FileConfig envoysConfig; + + // Managers + private CooldownManager cooldownManager; + + // Menu System + private HashMap playerMenuUtilMap = new HashMap<>(); + + // Command Framework + private CommandFramework commandFramework = new CommandFramework(this); + + @Override + public void onEnable() { + instance = this; + + this.saveDefaultConfig(); + this.mainConfig = new Config("config", this); + this.messagesConfig = new FileConfig(this, "messages.yml"); + + this.getServer().getConsoleSender().sendMessage(Utils.chatBar); + this.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&dLasers &7- &av" + this.getDescription().getVersion())); + this.getServer().getConsoleSender().sendMessage(ColorUtils.getMessageType("&7Made by &eLoganM Development")); + this.getServer().getConsoleSender().sendMessage(Utils.chatBar); + this.loadCommands(); + this.loadManagers(); + this.loadListeners(); + this.loadRunnables(); + + ItemStack itemStack = new ItemBuilder(Material.DIAMOND_HORSE_ARMOR).name(ColorUtils.getMessageType("&4&lLaser")).lore(Arrays.asList(ColorUtils.getMessageType("&7&oRight click to use"))).build(); + + ShapedRecipe shapedRecipe = new ShapedRecipe(itemStack); + shapedRecipe.shape("ABA", "BCB", "ABA"); + shapedRecipe.setIngredient('A', Material.GOLD_INGOT); + shapedRecipe.setIngredient('B', Material.IRON_INGOT); + shapedRecipe.setIngredient('C', Material.DIAMOND); + + this.getServer().addRecipe(shapedRecipe); + } + + @Override + public void onDisable() { + instance = null; + } + + private void loadCommands() { + ClassRegistrationUtils.loadCommands("com.loganmagnan.lasers.commands"); + } + + private void loadManagers() { + this.cooldownManager = new CooldownManager(); + } + + private void loadListeners() { + ClassRegistrationUtils.loadListeners("com.loganmagnan.lasers.listeners"); + } + + private void loadRunnables() { + this.getServer().getScheduler().runTaskTimerAsynchronously(this, new CooldownRunnable(), 0, 20); + } + + public PlayerMenuUtil getPlayerMenuUtil(Player player) { + PlayerMenuUtil playerMenuUtil; + + if (playerMenuUtilMap.containsKey(player)) { + return playerMenuUtilMap.get(player); + } else { + playerMenuUtil = new PlayerMenuUtil(player); + + playerMenuUtilMap.put(player, playerMenuUtil); + + return playerMenuUtil; + } + } +} diff --git a/src/main/java/com/loganmagnan/lasers/chatcolor/ColorSet.java b/src/main/java/com/loganmagnan/lasers/chatcolor/ColorSet.java new file mode 100644 index 0000000..219631c --- /dev/null +++ b/src/main/java/com/loganmagnan/lasers/chatcolor/ColorSet.java @@ -0,0 +1,17 @@ +package com.loganmagnan.lasers.chatcolor; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@RequiredArgsConstructor +public class ColorSet { + + private R red = null; + private G green = null; + private B blue = null; +} diff --git a/src/main/java/com/loganmagnan/lasers/chatcolor/GradientColor.java b/src/main/java/com/loganmagnan/lasers/chatcolor/GradientColor.java new file mode 100644 index 0000000..2ab874e --- /dev/null +++ b/src/main/java/com/loganmagnan/lasers/chatcolor/GradientColor.java @@ -0,0 +1,16 @@ +package com.loganmagnan.lasers.chatcolor; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@RequiredArgsConstructor +public class GradientColor { + + private ColorSet colorCodeOne; + private ColorSet colorCodeTwo; +} diff --git a/src/main/java/com/loganmagnan/lasers/commands/LaserCommand.java b/src/main/java/com/loganmagnan/lasers/commands/LaserCommand.java new file mode 100644 index 0000000..535813e --- /dev/null +++ b/src/main/java/com/loganmagnan/lasers/commands/LaserCommand.java @@ -0,0 +1,83 @@ +package com.loganmagnan.lasers.commands; + +import com.loganmagnan.lasers.Lasers; +import com.loganmagnan.lasers.runnables.LaserRunnable; +import com.loganmagnan.lasers.utils.ColorUtils; +import com.loganmagnan.lasers.utils.CustomLocation; +import com.loganmagnan.lasers.utils.Utils; +import com.loganmagnan.lasers.utils.command.BaseCommand; +import com.loganmagnan.lasers.utils.command.Command; +import com.loganmagnan.lasers.utils.command.CommandArguments; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +public class LaserCommand extends BaseCommand { + + private Lasers main = Lasers.getInstance(); + + @Command(name = "laser", permission = "laser.admin") + @Override + public void executeAs(CommandArguments command) { + Player player = command.getPlayer(); + + String[] args = command.getArgs(); + + if (args.length == 0) { + player.sendMessage(ColorUtils.getMessageType("&cUsage:")); + player.sendMessage(ColorUtils.getMessageType(" &c/laser start