commit dcccf737589d6ce2c7734466baf62ce663f2d76e Author: Trixkz Date: Thu Sep 19 23:19:34 2024 -0400 Initial commit. 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