diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 6f67cf7..47333cd 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 861936a..72054a0 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -1,6 +1,11 @@
+
+
+
+
+
@@ -16,6 +21,11 @@
+
+
+
+
+
@@ -26,5 +36,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 4e95dde..4d52929 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,9 +1,4 @@
-
-
-
-
-
@@ -17,7 +12,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 00d395a..88d685d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,49 @@
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -17,6 +56,7 @@
@@ -32,10 +72,13 @@
+ {
+ "customColor": "",
+ "associatedIndex": 5
+}
-
{
@@ -43,18 +86,24 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
+ "codeWithMe.voiceChat.enabledByDefault": "false",
"git-widget-placeholder": "dev",
- "last_opened_file_path": "C:/Users/Timongcraft/IdeaProjects/Tgc-System (Plugin)/src/main/java/timongcraft/util",
+ "ignore.virus.scanning.warn.message": "true",
+ "last_opened_file_path": "C:/Users/Timongcraft/IdeaProjects/Coords-Saver",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
+ "project.structure.last.edited": "Project",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.0",
"vue.rearranger.settings.migration": "true"
}
}
+
@@ -64,6 +113,8 @@
+
+
@@ -76,6 +127,7 @@
+
@@ -88,6 +140,9 @@
+
+
+
@@ -136,7 +191,110 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1683395873207
@@ -208,7 +366,51 @@
1683811095673
-
+
+ 1684125673274
+
+
+
+ 1684125673275
+
+
+ 1686334705625
+
+
+
+ 1686334705625
+
+
+ 1686515664928
+
+
+
+ 1686515664928
+
+
+ 1686806447863
+
+
+
+ 1686806447863
+
+
+
+ 1691271269012
+
+
+
+ 1691271269012
+
+
+
+ 1698636742591
+
+
+
+ 1698636742591
+
+
@@ -237,6 +439,13 @@
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 1079824..9ef3078 100644
--- a/README.md
+++ b/README.md
@@ -21,13 +21,13 @@
- Sound/Highlight your player name in chat
- A permission system
- A maintenance system
-- A auto save system
+- A hopper sorting system
+- A coordinate save system
- A team chat
- A resource pack system
- A alert/broadcast command
-- A speed, walkspeed and flyspeed command
+- A walkspeed and flyspeed command
- A reboot command that reboots server after a specified amount of minutes with a reason
-- A plugin command to disable plugins
- Time in chat messages with formatting
- A configs reload command for the plugin
- Block commands & prefixes
@@ -249,9 +249,6 @@ blockedCommands:
- 'icanhasbukkit'
- 'pl'
- 'plugins'
- - 'me'
- - 'tm'
- - 'teammsg'
- 'ver'
- 'version'
@@ -260,7 +257,7 @@ blockedCommands:
blockedPrefix:
- 'bukkit:'
- 'minecraft:'
- - 'sbs-system:'
+ - 'tgc-system:'
````
diff --git a/pom.xml b/pom.xml
index 06e9edb..c6be197 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
timongcraft
Tgc-System
- 1.42
+ 1.43
jar
Tgc-System
@@ -28,22 +28,6 @@
${java.version}
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.4
-
-
- package
-
- shade
-
-
- false
-
-
-
-
@@ -62,19 +46,31 @@
sonatype
https://oss.sonatype.org/content/groups/public/
+
+ minecraft-libraries
+ Minecraft Libraries
+ https://libraries.minecraft.net
+
org.spigotmc
spigot-api
- 1.19.4-R0.1-SNAPSHOT
+ 1.19-R0.1-SNAPSHOT
provided
dev.jorel
- commandapi-bukkit-shade
- 9.0.1
+ commandapi-bukkit-core
+ 9.3.0
+ provided
+
+
+ com.mojang
+ brigadier
+ 1.0.18
+ provided
diff --git a/src/main/java/timongcraft/commands/AlertCommand.java b/src/main/java/timongcraft/commands/AlertCommand.java
deleted file mode 100644
index 4038670..0000000
--- a/src/main/java/timongcraft/commands/AlertCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.Sound;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-
-public class AlertCommand {
- public static void register() {
- new CommandTree("alert")
- .withFullDescription("Sends an alert to all players")
- .withAliases("broadcast")
- .withPermission("tgc-system.team")
- .then(new GreedyStringArgument("message")
- .executes(new AlertExecutor()))
- .register();
- }
-
- private static class AlertExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String message = (String) args.get("message");
-
- for(Player player : Bukkit.getOnlinePlayers()) {
- player.sendMessage(Main.get().getConfig().getString("prefix.alertPrefix") + message.replaceAll("&", "§"));
- player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F,.5F);
- }
- }
- }
-}
diff --git a/src/main/java/timongcraft/commands/ColorCodesCommand.java b/src/main/java/timongcraft/commands/ColorCodesCommand.java
deleted file mode 100644
index 5d0c2ac..0000000
--- a/src/main/java/timongcraft/commands/ColorCodesCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import net.md_5.bungee.api.ChatColor;
-import org.bukkit.command.CommandSender;
-
-public class ColorCodesCommand {
- public static void register() {
- new CommandTree("colorcodes")
- .withFullDescription("Get all color codes as well as the format codes")
- .withPermission("tgc-system.team")
- .executes(new ColorCodesExecutor())
- .register();
- }
-
- private static class ColorCodesExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- sender.sendMessage(ChatColor.GOLD + "======== Color Codes ========");
- sender.sendMessage("&0 = " + ChatColor.BLACK + "Black" + " " + ChatColor.WHITE + "&1 = " + ChatColor.DARK_BLUE + "Dark Blue");
- sender.sendMessage("&2 = " + ChatColor.DARK_GREEN + "Dark Green" + " " + ChatColor.WHITE + "&3 = " + ChatColor.DARK_AQUA + "Dark Aqua");
- sender.sendMessage("&4 = " + ChatColor.DARK_RED + "Dark Red" + " " + ChatColor.WHITE + "&5 = " + ChatColor.DARK_PURPLE + "Dark Purple");
- sender.sendMessage("&6 = " + ChatColor.GOLD + "Gold" + " " + ChatColor.WHITE + "&7 = " + ChatColor.GRAY + "Gray");
- sender.sendMessage("&8 = " + ChatColor.DARK_GRAY + "Dark Gray" + " " + ChatColor.WHITE + "&9 = " + ChatColor.BLUE + "Blue");
- sender.sendMessage("&a = " + ChatColor.GREEN + "Green" + " " + ChatColor.WHITE + "&b = " + ChatColor.AQUA + "Aqua");
- sender.sendMessage("&c = " + ChatColor.RED + "Red" + " " + ChatColor.WHITE + "&d = " + ChatColor.LIGHT_PURPLE + "Light Purple");
- sender.sendMessage("&e = " + ChatColor.YELLOW + "Yellow" + " " + ChatColor.WHITE + "&f = " + ChatColor.WHITE + "White");
- sender.sendMessage("\n");
- sender.sendMessage(ChatColor.GOLD + "======== Format Codes ========");
- sender.sendMessage("&k = " + ChatColor.MAGIC + "Magic" + ChatColor.WHITE + " " + "&l = " + ChatColor.BOLD + "Bold");
- sender.sendMessage("&m = " + ChatColor.STRIKETHROUGH + "Strikethrough" + ChatColor.WHITE + " " + "&n = " + ChatColor.UNDERLINE + "Underline");
- sender.sendMessage("&o = " + ChatColor.ITALIC + "Italic" + ChatColor.WHITE + " " + "&r = " + ChatColor.RESET + "Reset");
- }
- }
-}
diff --git a/src/main/java/timongcraft/commands/FlySpeedCommand.java b/src/main/java/timongcraft/commands/FlySpeedCommand.java
deleted file mode 100644
index f9b92a4..0000000
--- a/src/main/java/timongcraft/commands/FlySpeedCommand.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.ArgumentSuggestions;
-import dev.jorel.commandapi.arguments.EntitySelectorArgument;
-import dev.jorel.commandapi.arguments.IntegerArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-public class FlySpeedCommand {
- public static void register() {
- new CommandTree("flyspeed")
- .withFullDescription("Set fly speed")
- .withAliases("fs")
- .withPermission("tgc-system.team")
- .then(new IntegerArgument("flyspeed", 1, 10)
- .setOptional(true)
- .executes(new FlySpeedExecutor())
- .then(new EntitySelectorArgument.OnePlayer("target")
- .setOptional(true)
- .replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
- .map(Player::getName)
- .toArray(String[]::new)))
- .executes(new FlySpeedExecutor())))
- .register();
- }
-
- private static class FlySpeedExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- if(args.args().length == 0) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /flyspeed [] []");
- return;
- }
-
- player.setFlySpeed(0.1f);
- player.sendMessage(Main.get().getPrefix() + "Fly speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his fly speed");
- } else if(args.args().length == 1 || (args.args().length == 2 && sender == args.get("target"))) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /flyspeed [] []");
- return;
- }
-
- float flySpeed = 0.2f;
-
- if((int) args.get("speed") <= 9) {
- flySpeed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) flySpeed = 1f;
-
- player.setFlySpeed(flySpeed);
- if((int) args.get("flyspeed") == 1) {
- player.sendMessage(Main.get().getPrefix() + "Fly speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his fly speed" );
- } else {
- player.sendMessage(Main.get().getPrefix() + "Set fly speed to " + args.get("flyspeed"));
- PlayerUtils.sendToTeam(player.getName(), null, "Set his fly speed to " + args.get("flyspeed"));
- }
- } else if(args.args().length == 2) {
- float flySpeed = 0.2f;
-
- if((int) args.get("speed") <= 9) {
- flySpeed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) flySpeed = 1f;
-
- Player target = (Player) args.get("target");
- target.setFlySpeed(flySpeed);
- if((int) args.get("flyspeed") == 1) {
- target.sendMessage(Main.get().getPrefix() + "Fly speed has been reset by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Reset fly speed of " + target.getName());
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Reset the fly speed of " + target.getName());
- } else {
- target.sendMessage(Main.get().getPrefix() + "Fly speed has been set to " + args.get("flyspeed") + " by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Set fly speed of " + target.getName() + " to " + args.get("flyspeed"));
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Set the fly speed of " + target.getName() + " to " + args.get("flyspeed"));
- }
- }
-
- }
- }
-
-}
diff --git a/src/main/java/timongcraft/commands/MaintenanceCommand.java b/src/main/java/timongcraft/commands/MaintenanceCommand.java
deleted file mode 100644
index abe0764..0000000
--- a/src/main/java/timongcraft/commands/MaintenanceCommand.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.*;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class MaintenanceCommand {
- public static void register() {
- new CommandTree("maintenance")
- .withFullDescription("A maintenance system")
- .withPermission("tgc-system.team")
- .executes(new MaintenanceExecutor())
- .then(new LiteralArgument("add")
- .then(new EntitySelectorArgument.OnePlayer("target")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> notMaintenanceList()))
- .executes(new MaintenanceAddExecutor())))
- .then(new LiteralArgument("remove")
- .then(new EntitySelectorArgument.OnePlayer("target")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> maintenanceList()))
- .executes(new MaintenanceRemoveExecutor())))
- .then(new LiteralArgument("list")
- .executes(new MaintenanceListExecutor()))
- .register();
- }
-
- private static String[] maintenanceList() {
- List inMainenanceList = new ArrayList<>();
-
- for(Player player : Bukkit.getOnlinePlayers()) {
- if(Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".maintenanceAllowed")) {
- inMainenanceList.add(player.getName());
- }
- }
-
- return inMainenanceList.toArray(new String[0]);
- }
-
- private static String[] notMaintenanceList() {
- List notInMainenanceList = new ArrayList<>();
-
- for(Player player : Bukkit.getOnlinePlayers()) {
- if(!Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".maintenanceAllowed")) {
- notInMainenanceList.add(player.getName());
- }
- }
-
- return notInMainenanceList.toArray(new String[0]);
- }
-
- private static class MaintenanceExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- final String maintenanceKickMessage = Main.get().getConfig().getString("maintenance.kickMessage");
-
- if(args.args().length == 0) {
- boolean maintenanceMode = Main.get().getDataConfig().getBoolean("maintenance.enabled");
- maintenanceMode = !maintenanceMode;
- Main.get().getDataConfig().set("maintenance.enabled", maintenanceMode);
- Main.get().getDataConfig().save();
-
- if(maintenanceMode) {
- sender.sendMessage(Main.get().getPrefix() + "Maintenance mode enabled.");
- PlayerUtils.sendToTeam(sender.getName(), null, "Enabled maintenance mode");
- for(Player player : Bukkit.getOnlinePlayers()) {
- if(!isAllowed(player)) {
- player.kickPlayer(maintenanceKickMessage);
- }
- }
- } else {
- sender.sendMessage(Main.get().getPrefix() + "Maintenance mode disabled.");
- PlayerUtils.sendToTeam(sender.getName(), null, "Disabled maintenance mode");
- }
-
- }
- }
- }
-
- private static class MaintenanceListExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- sender.sendMessage(Main.get().getPrefix() + "Allowed players:");
-
- for (String uuid : Main.get().getDataConfig().getConfigurationSection("players").getKeys(false)) {
- boolean maintenanceAllowed = Main.get().getDataConfig().getBoolean("players." + uuid + ".maintenanceAllowed");
- if (maintenanceAllowed) {
- String playerName = Main.get().getDataConfig().getString("players." + uuid + ".name");
- sender.sendMessage(playerName);
- }
- }
- }
- }
-
- private static class MaintenanceAddExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- Player target = (Player) args.get("target");
- if(isAllowed(target)) {
- sender.sendMessage(Main.get().getPrefix() + target.getName() + " is already on the maintenance list");
- return;
- }
-
- Main.get().getDataConfig().set("players." + target.getUniqueId() + ".maintenanceAllowed", true);
- Main.get().getDataConfig().save();
-
- sender.sendMessage(Main.get().getPrefix() + target.getName() + " has been added to the maintenance list");
- }
- }
-
- private static class MaintenanceRemoveExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- Player target = (Player) args.get("target");
- if(!isAllowed(target)) {
- sender.sendMessage(Main.get().getPrefix() + target.getName() + " isn't on the maintenance list");
- return;
- }
-
- Main.get().getDataConfig().set("players." + target.getUniqueId() + ".maintenanceAllowed", false);
- Main.get().getDataConfig().save();
-
- sender.sendMessage(Main.get().getPrefix() + target.getName() + " has been removed from the maintenance list");
- }
- }
-
- public static boolean isAllowed(Player player) {
- return Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".maintenanceAllowed");
- }
-
-}
diff --git a/src/main/java/timongcraft/commands/MsgCommand.java b/src/main/java/timongcraft/commands/MsgCommand.java
deleted file mode 100644
index 4d6307e..0000000
--- a/src/main/java/timongcraft/commands/MsgCommand.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandAPI;
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.ArgumentSuggestions;
-import dev.jorel.commandapi.arguments.EntitySelectorArgument;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandBlockCommandExecutor;
-import dev.jorel.commandapi.executors.ConsoleCommandExecutor;
-import dev.jorel.commandapi.executors.PlayerCommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.BlockCommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
-
-public class MsgCommand {
- public static void register() {
- CommandAPI.unregister("msg", true);
- CommandAPI.unregister("minecraft:msg", true);
- CommandAPI.unregister("tell", true);
- CommandAPI.unregister("minecraft:tell", true);
- CommandAPI.unregister("w", true);
- CommandAPI.unregister("minecraft:w", true);
-
- new CommandTree("msg")
- .withFullDescription("Send a private message to a player")
- .withAliases("tell", "w")
- .then(new EntitySelectorArgument.OnePlayer("target").replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
- .map(Player::getName)
- .toArray(String[]::new)))
- .then(new GreedyStringArgument("message")
- .executesPlayer(new PlayerMsgExecutor())
- .executesCommandBlock(new CommandBlockMsgExecutor())
- .executesConsole(new ConsoleMsgExecutor())))
- .register();
- }
-
- private static class PlayerMsgExecutor implements PlayerCommandExecutor {
- @Override
- public void run(Player player, CommandArguments args) throws WrapperCommandSyntaxException {
- Player target = (Player) args.get("target");
- String message = (String) args.get("message");
-
- if(player.hasPermission("tgc-system.team")) {
- message = message.replaceAll("&", "§");
- }
-
- player.sendMessage("§7§oYou whisper to " + target.getName() + ": " + message);
- target.sendMessage("§7§o" + player.getName() + " whispers to you: " + message);
- ReplyCommand.setLastReply(player.getUniqueId(), target.getUniqueId());
- }
- }
-
- private static class ConsoleMsgExecutor implements ConsoleCommandExecutor {
- @Override
- public void run(ConsoleCommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- Player target = (Player) args.get("target");
- String message = (String) args.get("message");
- message = message.replaceAll("&", "§");
-
- sender.sendMessage("§7§oYou whisper to " + target.getName() + ": " + message);
- target.sendMessage("§7§oServer whispers to you: " + message);
- }
- }
-
- private static class CommandBlockMsgExecutor implements CommandBlockCommandExecutor {
- @Override
- public void run(BlockCommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- Player target = (Player) args.get("target");
- String message = (String) args.get("message");
- message = message.replaceAll("&", "§");
-
- sender.sendMessage("§7§oYou whisper to " + target.getName() + message);
- target.sendMessage("§7§o@ whispers to you: " + message);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/PermissionManagerCommand.java b/src/main/java/timongcraft/commands/PermissionManagerCommand.java
deleted file mode 100644
index 6239fdf..0000000
--- a/src/main/java/timongcraft/commands/PermissionManagerCommand.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.*;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-public class PermissionManagerCommand {
- public static void register() {
- new CommandTree("permissionmanager")
- .withFullDescription("Set or unset groups for players")
- .withPermission("tgc-system.team")
- .withAliases("pm")
- .then(new LiteralArgument("player")
- .then(new OfflinePlayerArgument("target")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
- .map(Player::getName)
- .toArray(String[]::new)))
- .then(new LiteralArgument("permission")
- .then(new LiteralArgument("set")
- .then(new StringArgument("permission")
- .then(new BooleanArgument("value")
- .executes(new SetPermissionExecutor()))))
- .then(new LiteralArgument("unset")
- .then(new StringArgument("permission")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> getPermissionsForPlayer((OfflinePlayer) info.previousArgs().get("target"))))
- .executes(new UnsetPermissionExecutor()))))
- .then(new LiteralArgument("group")
- .then(new MultiLiteralArgument("set", "unset")
- .then(new StringArgument("group")
- .includeSuggestions(ArgumentSuggestions.strings(getGroups()))
- .executes(new PlayerGroupExecutor()))))))
- .then(new LiteralArgument("group")
- .then(new StringArgument("group")
- .includeSuggestions(ArgumentSuggestions.strings(getGroups()))
- .then(new LiteralArgument("set")
- .then(new StringArgument("permission")
- .then(new BooleanArgument("value")
- .executes(new GroupSetPermissionExecutor()))))
- .then(new LiteralArgument("unset")
- .then(new StringArgument("permission")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> getPermissionsForGroup((String) info.previousArgs().get("group"))))
- .executes(new GroupUnsetPermissionExecutor())))))
- .register();
- }
-
- private static String[] getGroups() {
- ConfigurationSection groupsSection = Main.get().getDataConfig().getConfigurationSection("groups");
- if (groupsSection == null) {
- return new String[0];
- }
-
- Set topLevelGroups = groupsSection.getKeys(false);
- return topLevelGroups.toArray(new String[0]);
- }
-
- private static String[] getPermissionsForPlayer(OfflinePlayer playerName) {
- List permissionsList = Main.get().getDataConfig().getStringList("players." + playerName.getUniqueId() + ".permissions");
- List permissionNames = new ArrayList<>();
-
- for (String permissionString : permissionsList) {
- String permissionName = permissionString.split(":")[0];
- permissionNames.add(permissionName);
- }
-
- return permissionNames.toArray(new String[0]);
- }
-
- private static String[] getPermissionsForGroup(String groupName) {
- List permissionsList = Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions");
- List permissionNames = new ArrayList<>();
-
- for (String permissionString : permissionsList) {
- String permissionName = permissionString.split(":")[0];
- permissionNames.add(permissionName);
- }
-
- return permissionNames.toArray(new String[0]);
- }
-
- private static class SetPermissionExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
- String permission = (String) args.get("permission");
- Boolean value = (Boolean) args.get("value");
-
- List playerPermissions = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".permissions");
- if(playerPermissions == null) playerPermissions = new ArrayList<>();
-
- String permissionString = permission + ":" + value;
-
- playerPermissions.removeIf(s -> s.split(":")[0].equals(permission));
- playerPermissions.add(permissionString);
- sender.sendMessage(Main.get().getPrefix() + "Set permission " + permission + " for player " + targetPlayer.getName());
- PlayerUtils.sendToTeam(sender.getName(), null, "Set permission " + permission + " from " + targetPlayer.getName());
-
- Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".permissions", playerPermissions);
- Main.get().getDataConfig().save();
- }
- }
-
- private static class UnsetPermissionExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
- String permission = (String) args.get("permission");
-
- List playerPermissions = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".permissions");
- if(playerPermissions == null) playerPermissions = new ArrayList<>();
-
- playerPermissions.removeIf(s -> s.split(":")[0].equals(permission));
- sender.sendMessage(Main.get().getPrefix() + "Unset permission " + permission + " from player " + targetPlayer.getName());
- PlayerUtils.sendToTeam(sender.getName(), null, "Unset permission " + permission + " from " + targetPlayer.getName());
-
- Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".permissions", playerPermissions);
- Main.get().getDataConfig().save();
- }
- }
-
- private static class PlayerGroupExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
- String action = (String) args.get(1);
- String group = (String) args.get("group");
-
- if(targetPlayer == null) {
- sender.sendMessage(Main.get().getPrefix() + "§cPlayer not found");
- return;
- }
-
- List playerGroups = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".groups");
- if(playerGroups == null) playerGroups = new ArrayList<>();
-
- if(action.equalsIgnoreCase("set")) {
- if(!playerGroups.contains(group)) playerGroups.add(group);
- sender.sendMessage(Main.get().getPrefix() + "Added player " + targetPlayer.getPlayer().getName() + " to group " + group);
- PlayerUtils.sendToTeam(sender.getName(), null, "Added player " + targetPlayer.getPlayer().getName() + " to group " + group);
- } else if(action.equalsIgnoreCase("unset")) {
- playerGroups.remove(group);
- sender.sendMessage(Main.get().getPrefix() + "Removed player " + targetPlayer.getPlayer().getName() + " from group " + group);
- PlayerUtils.sendToTeam(sender.getName(), null, "Removed player " + targetPlayer.getPlayer().getName() + " from group " + group);
- }
-
- Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".groups", playerGroups);
- Main.get().getDataConfig().save();
- }
- }
-
- private static class GroupSetPermissionExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String groupName = (String) args.get("group");
- String permission = (String) args.get("permission");
- Boolean value = (Boolean) args.get("value");
-
- List groupPermissions = Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions");
- if(groupPermissions == null) groupPermissions = new ArrayList<>();
-
- String permissionString = permission + ":" + value;
-
- groupPermissions.removeIf(s -> s.split(":")[0].equals(permission));
- groupPermissions.add(permissionString);
- sender.sendMessage(Main.get().getPrefix() + "Set permission " + permissionString + " for group " + groupName);
- PlayerUtils.sendToTeam(sender.getName(), null, "Set permission " + permission + " for group " + groupName);
-
- Main.get().getDataConfig().set("groups." + groupName + ".permissions", groupPermissions);
- Main.get().getDataConfig().save();
- }
- }
-
- private static class GroupUnsetPermissionExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String groupName = (String) args.get("group");
- String permission = (String) args.get("permission");
-
- List groupPermissions = Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions");
- if(groupPermissions == null) groupPermissions = new ArrayList<>();
-
- groupPermissions.removeIf(s -> s.split(":")[0].equals(permission));
- sender.sendMessage(Main.get().getPrefix() + "Unset permission " + permission + " from group " + groupName);
- PlayerUtils.sendToTeam(sender.getName(), null, "Unset permission " + permission + " from group " + groupName);
-
- Main.get().getDataConfig().set("groups." + groupName + ".permissions", groupPermissions);
- Main.get().getDataConfig().save();
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/PluginCommand.java b/src/main/java/timongcraft/commands/PluginCommand.java
deleted file mode 100644
index 8bd2966..0000000
--- a/src/main/java/timongcraft/commands/PluginCommand.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.ArgumentSuggestions;
-import dev.jorel.commandapi.arguments.LiteralArgument;
-import dev.jorel.commandapi.arguments.StringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginManager;
-import timongcraft.Main;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PluginCommand {
- public static void register() {
- new CommandTree("plugin")
- .withFullDescription("Turn Plugins on/off")
- .withPermission("tgc-system.team")
- .then(new LiteralArgument("enable")
- .then(new StringArgument("plugin")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> getDisabledPlugins()))
- .executes(new PluginEnableExecutor())))
- .then(new LiteralArgument("disable")
- .then(new StringArgument("plugin")
- .replaceSuggestions(ArgumentSuggestions.strings(info -> getEnabledPlugins()))
- .executes(new PluginDisableExecutor())))
- .register();
- }
-
- private static String[] getDisabledPlugins() {
- List plugins = new ArrayList<>();
- List disabledPlugins = Main.get().getDataConfig().getStringList("disabledPlugins");
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
- if(!plugin.getName().equalsIgnoreCase(Main.get().getName())) {
- if((disabledPlugins.contains(plugin.getName()))) {
- plugins.add(plugin.getName());
- }
- }
- }
- return plugins.toArray(new String[0]);
- }
-
- private static String[] getEnabledPlugins() {
- List plugins = new ArrayList<>();
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
- if(!plugin.getName().equalsIgnoreCase(Main.get().getName())) {
- if(plugin.isEnabled()) {
- plugins.add(plugin.getName());
- }
- }
- }
- return plugins.toArray(new String[0]);
- }
-
- private static class PluginEnableExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String pluginName = (String) args.get("plugin");
-
- Plugin targetPlugin = Main.get().getServer().getPluginManager().getPlugin(pluginName);
- if(targetPlugin == null) {
- sender.sendMessage(Main.get().getPrefix() + "§c" + pluginName + " not found.");
- return;
- }
-
- if(!Main.get().getDataConfig().isSet("disabledPlugins") || Main.get().getDataConfig().getStringList("disabledPlugins").isEmpty()) {
- sender.sendMessage(Main.get().getPrefix() + "§c" + pluginName + " can't be enabled.");
- return;
- }
-
- List disabledPlugins = Main.get().getDataConfig().getStringList("disabledPlugins");
- if(disabledPlugins.contains(pluginName)) {
- Main.get().getServer().getPluginManager().enablePlugin(targetPlugin);
- disabledPlugins.remove(pluginName);
- Main.get().getDataConfig().set("disabledPlugins", disabledPlugins);
- Main.get().getDataConfig().save();
- sender.sendMessage(Main.get().getPrefix() + pluginName + " has been enabled.");
- } else {
- sender.sendMessage(Main.get().getPrefix() + "§c" + pluginName + " is not disabled.");
- }
- }
- }
-
- private static class PluginDisableExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String pluginName = (String) args.get("plugin");
-
- Plugin targetPlugin = Main.get().getServer().getPluginManager().getPlugin(pluginName);
- if(targetPlugin == null) {
- sender.sendMessage(Main.get().getPrefix() + "§c" + pluginName + " not found.");
- return;
- }
-
- if(targetPlugin.getName().equals(Main.get().getName())) {
- sender.sendMessage(Main.get().getPrefix() + "§cThis plugin can't be disabled.");
- return;
- }
-
- Main.get().getServer().getPluginManager().disablePlugin(targetPlugin);
- if(!Main.get().getDataConfig().isSet("disabledPlugins")) {
- Main.get().getDataConfig().set("disabledPlugins", new ArrayList<>());
- }
- List disabledPlugins = Main.get().getDataConfig().getStringList("disabledPlugins");
- disabledPlugins.add(pluginName);
- Main.get().getDataConfig().set("disabledPlugins", disabledPlugins);
- Main.get().getDataConfig().save();
- sender.sendMessage(Main.get().getPrefix() + pluginName + " has been disabled.");
- }
- }
-
- public static void disablePluginsOnBoot() {
- List disabledPlugins = Main.get().getDataConfig().getStringList("disabledPlugins");
- if(disabledPlugins.isEmpty()) {
- return;
- }
-
- PluginManager pluginManager = Main.get().getServer().getPluginManager();
- for (String pluginName : disabledPlugins) {
- Plugin targetPlugin = pluginManager.getPlugin(pluginName);
- if(targetPlugin != null) {
- Bukkit.getScheduler().runTaskLater(Main.get(), () -> {
- Main.get().getLogger().info("Disabling " + targetPlugin.getName());
- pluginManager.disablePlugin(targetPlugin);
- },200);
- }
- }
- }
-}
diff --git a/src/main/java/timongcraft/commands/RebootCommand.java b/src/main/java/timongcraft/commands/RebootCommand.java
deleted file mode 100644
index 0369d63..0000000
--- a/src/main/java/timongcraft/commands/RebootCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.arguments.IntegerArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.Sound;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-public class RebootCommand {
- public static void register() {
- new CommandTree("reboot")
- .withFullDescription("Reboot the server after a specified time")
- .withPermission("tgc-system.team")
- .then(new IntegerArgument("minutes", 1)
- .then(new GreedyStringArgument("reason")
- .executes(new RebootExecutor())))
- .register();
- }
-
- private static class RebootExecutor implements CommandExecutor {
- static int seconds;
-
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- seconds = (int) args.get("minutes") * 60;
- String reason = (String) args.get("reason");
-
- sender.sendMessage(Main.get().getPrefix() + "Scheduled reboot task in: " + args.get("minutes") + " Minutes with reason: " + reason);
- PlayerUtils.sendToTeam(sender.getName(), null , "Scheduled reboot task in: " + args.get("minutes") + " Minutes with reason: " + reason);
-
- BukkitRunnable runnable = new BukkitRunnable() {
- @Override
- public void run() {
- if(seconds == 600) {
- for(Player player : Bukkit.getOnlinePlayers()) {
- player.sendMessage(Main.get().getConfig().getString("prefix.alertPrefix") + "The server will reboot in " + seconds / 60 + " minutes because: " + reason.replaceAll("&", "§"));
- player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F,.5F);
- }
- }
- if(seconds == 60 || seconds == 10|| seconds == 3|| seconds == 2|| seconds == 1) {
- for(Player player : Bukkit.getOnlinePlayers()) {
- player.sendMessage(Main.get().getConfig().getString("prefix.alertPrefix") + "The server will reboot in " + seconds + " seconds because: " + reason.replaceAll("&", "§"));
- player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F,.5F);
- }
- }
- if(seconds == 0) {
- for(Player player : Bukkit.getOnlinePlayers()) {
- player.kickPlayer("The server is rebooting because:\n" + reason.replaceAll("&", "§"));
- }
- cancel();
- Bukkit.spigot().restart();
- return;
- }
- seconds--;
- }
- };
- runnable.runTaskTimer(Main.get(), 0, 20);
- }
- }
-}
diff --git a/src/main/java/timongcraft/commands/ReloadConfigsCommand.java b/src/main/java/timongcraft/commands/ReloadConfigsCommand.java
deleted file mode 100644
index 7be6483..0000000
--- a/src/main/java/timongcraft/commands/ReloadConfigsCommand.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-public class ReloadConfigsCommand {
- public static void register() {
- new CommandTree("tgcreload-configs")
- .withFullDescription("Reloads the plugin config and the data config")
- .withPermission("tgc-system.team")
- .executes(new ReloadConfigsExecutor())
- .register();
- }
-
- public static class ReloadConfigsExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- Main.get().reloadConfig();
- Main.get().getDataConfig().load();
- sender.sendMessage(Main.get().getPrefix() + "The Configs have been reloaded!");
- PlayerUtils.sendToTeam(sender.getName(), null, "Reloaded the plugins's configs");
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/ReplyCommand.java b/src/main/java/timongcraft/commands/ReplyCommand.java
deleted file mode 100644
index e3f6b6b..0000000
--- a/src/main/java/timongcraft/commands/ReplyCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.PlayerCommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-public class ReplyCommand {
- private static final Map lastRepliedTo = new HashMap<>();
-
- public static void register() {
- new CommandTree("reply")
- .withFullDescription("Send a private message to the player you last sent a private message too")
- .withAliases("r")
- .then(new GreedyStringArgument("message")
- .executesPlayer(new PlayerMsgExecutor()))
- .register();
- }
-
- private static class PlayerMsgExecutor implements PlayerCommandExecutor {
- @Override
- public void run(Player player, CommandArguments args) throws WrapperCommandSyntaxException {
- String message = (String) args.get("message");
-
- if (!lastRepliedTo.containsKey(player.getUniqueId())) {
- player.sendMessage(Main.get().getPrefix() + "§cYou have no one to reply to.");
- return;
- }
-
- Player target = Bukkit.getPlayer(lastRepliedTo.get(player.getUniqueId()));
-
- if (target == null) {
- player.sendMessage(Main.get().getPrefix() + "§cThe player you last messaged is not online.");
- return;
- }
-
- if(player.hasPermission("tgc-system.team")) {
- message = message.replaceAll("&", "§");
- }
-
- player.sendMessage("§7§oYou whisper to " + "§7§o" + target.getName() + "§7§o: " + message);
- target.sendMessage("§7§o" + player.getName() + "§7§o whispers to you§7§o: " + message);
- }
- }
-
- public static void setLastReply(UUID senderUuid, UUID targetUuid) {
- lastRepliedTo.put(senderUuid, targetUuid);
- if(!lastRepliedTo.containsKey(targetUuid) || Bukkit.getPlayer(lastRepliedTo.get(targetUuid)) == null) {
- lastRepliedTo.put(targetUuid, senderUuid);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/ResourcePackCommand.java b/src/main/java/timongcraft/commands/ResourcePackCommand.java
deleted file mode 100644
index b52c338..0000000
--- a/src/main/java/timongcraft/commands/ResourcePackCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.PlayerCommandExecutor;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-
-public class ResourcePackCommand {
- public static void register() {
- new CommandTree("resourcepack")
- .withFullDescription("With this you can toggle the resource pack on/off")
- .withRequirement(sender -> (Main.get().getConfig().isSet("resourcePack.url") && !Main.get().getConfig().getString("resourcePack.url").isEmpty()) && (Main.get().getConfig().isSet("resourcePack.hash") && !Main.get().getConfig().getString("resourcePack.hash").isEmpty()))
- .withPermission("tgc-system.team")
- .executesPlayer(new ResourcePackExecutor())
- .register();
- }
-
- private static class ResourcePackExecutor implements PlayerCommandExecutor {
- @Override
- public void run(Player player, CommandArguments args) throws WrapperCommandSyntaxException {
- if(!Main.get().getDataConfig().isSet("players." + player.getUniqueId() + ".resourcepack")) {
- Main.get().getDataConfig().set("players." + player.getUniqueId() + ".resourcepack", true);
- }
-
- if(Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".resourcepack")) {
- Main.get().getDataConfig().set("players." + player.getUniqueId() + ".resourcepack", false);
- player.sendMessage(Main.get().getPrefix() + "Disabled resource pack request");
- } else {
- Main.get().getDataConfig().set("players." + player.getUniqueId() + ".resourcepack", true);
- player.sendMessage(Main.get().getPrefix() + "Enabled resource pack request");
- }
- Main.get().getDataConfig().save();
- }
-
- }
-
-}
diff --git a/src/main/java/timongcraft/commands/SayCommand.java b/src/main/java/timongcraft/commands/SayCommand.java
deleted file mode 100644
index bac7759..0000000
--- a/src/main/java/timongcraft/commands/SayCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandAPI;
-import dev.jorel.commandapi.CommandPermission;
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public class SayCommand {
- public static void register() {
- CommandAPI.unregister("say", true);
-
- new CommandTree("say")
- .withFullDescription("Send a message from that sender")
- .withPermission(CommandPermission.OP)
- .then(new GreedyStringArgument("message")
- .executes(new SayExecutor()))
- .register();
- }
-
- public static class SayExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- String msg = (String) args.get("message");
-
- for(Player player : Bukkit.getOnlinePlayers()) {
- player.sendMessage("[" + sender.getName() + "] " + msg);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/SpeedCommand.java b/src/main/java/timongcraft/commands/SpeedCommand.java
deleted file mode 100644
index 5928c6a..0000000
--- a/src/main/java/timongcraft/commands/SpeedCommand.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.ArgumentSuggestions;
-import dev.jorel.commandapi.arguments.EntitySelectorArgument;
-import dev.jorel.commandapi.arguments.IntegerArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-public class SpeedCommand {
- public static void register() {
- new CommandTree("speed")
- .withFullDescription("Set fly & walk speed")
- .withAliases("ws")
- .withPermission("tgc-system.team")
- .then(new IntegerArgument("speed", 1, 10)
- .setOptional(true)
- .executes(new SpeedExecutor())
- .then(new EntitySelectorArgument.OnePlayer("target")
- .setOptional(true)
- .replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
- .map(Player::getName)
- .toArray(String[]::new)))
- .executes(new SpeedExecutor())))
- .register();
- }
-
- private static class SpeedExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- if(args.args().length == 0) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /speed [] []");
- return;
- }
-
- player.setWalkSpeed(0.2f);
- player.setFlySpeed(0.1f);
- player.sendMessage(Main.get().getPrefix() + "Speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his speed");
- } else if(args.args().length == 1 || (args.args().length == 2 && sender == args.get("target"))) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /speed [] []");
- return;
- }
-
- float speed = 0.1f;
-
- if((int) args.get("speed") <= 9) {
- speed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) speed = 1f;
-
- player.setWalkSpeed(speed);
- player.setFlySpeed(speed);
- if((int) args.get("speed") == 1) {
- player.sendMessage(Main.get().getPrefix() + "Speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his speed" );
- } else {
- player.sendMessage(Main.get().getPrefix() + "Set speed to " + args.get("speed"));
- PlayerUtils.sendToTeam(player.getName(), null, "Set his speed to " + args.get("speed"));
- }
- } else if(args.args().length == 2) {
- float speed = 0.1f;
-
- if((int) args.get("speed") <= 9) {
- speed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) speed = 1f;
-
- Player target = (Player) args.get("target");
- target.setWalkSpeed(speed);
- target.setFlySpeed(speed);
- if((int) args.get("speed") == 1) {
- target.sendMessage(Main.get().getPrefix() + "Speed has been reset by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Reset speed of " + target.getName());
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Reset the speed of " + target.getName());
- } else {
- target.sendMessage(Main.get().getPrefix() + "Speed has been set to " + args.get("speed") + " by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Set speed of " + target.getName() + " to " + args.get("speed"));
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Set the speed of " + target.getName() + " to " + args.get("speed"));
- }
- }
-
- }
- }
-}
diff --git a/src/main/java/timongcraft/commands/StatusCommand.java b/src/main/java/timongcraft/commands/StatusCommand.java
deleted file mode 100644
index 8bf04c2..0000000
--- a/src/main/java/timongcraft/commands/StatusCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.GreedyStringArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.PlayerCommandExecutor;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.StatusHandler;
-
-public class StatusCommand {
- public static void register() {
- new CommandTree("status")
- .withFullDescription("Set a status for yourself in the chat and tab list")
- .withRequirement(sender -> Main.get().getConfig().getBoolean("statuses.enabled"))
- .executesPlayer(new StatusExecutor())
- .then(new GreedyStringArgument("status")
- .setOptional(true)
- .executesPlayer(new StatusExecutor()))
- .register();
- }
-
- private static class StatusExecutor implements PlayerCommandExecutor {
- @Override
- public void run(Player player, CommandArguments args) throws WrapperCommandSyntaxException {
- String status = (String) args.get("status");
-
- if(args.args().length == 0) {
- if(StatusHandler.getStatus(player) == null) {
- player.sendMessage(Main.get().getPrefix() + "§cUsage: /status ");
- return;
- }
-
- StatusHandler.setStatus(player, null);
- player.sendMessage(Main.get().getPrefix() + "§aSuccessfully reset your status");
- } else if(args.args().length == 1) {
- if(status.replaceAll("&[a-z-0-9]", "").length() > Main.get().getConfig().getInt("statuses.characterLimit")) {
- player.sendMessage(Main.get().getPrefix() + "§cStatus can only be up to " + Main.get().getConfig().getInt("statuses.characterLimit") + " characters long!");
- return;
- }
-
- StatusHandler.setStatus(player, status.replaceAll("&", "§"));
- player.sendMessage(Main.get().getPrefix() + "§aSuccessfully set your status to: " + status);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/commands/WalkSpeedCommand.java b/src/main/java/timongcraft/commands/WalkSpeedCommand.java
deleted file mode 100644
index 138a517..0000000
--- a/src/main/java/timongcraft/commands/WalkSpeedCommand.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package timongcraft.commands;
-
-import dev.jorel.commandapi.CommandTree;
-import dev.jorel.commandapi.arguments.ArgumentSuggestions;
-import dev.jorel.commandapi.arguments.EntitySelectorArgument;
-import dev.jorel.commandapi.arguments.IntegerArgument;
-import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
-import dev.jorel.commandapi.executors.CommandArguments;
-import dev.jorel.commandapi.executors.CommandExecutor;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import timongcraft.Main;
-import timongcraft.util.PlayerUtils;
-
-public class WalkSpeedCommand {
- public static void register() {
- new CommandTree("walkspeed")
- .withFullDescription("Set walk speed")
- .withAliases("ws")
- .withPermission("tgc-system.team")
- .then(new IntegerArgument("walkspeed", 1, 10)
- .setOptional(true)
- .executes(new WalkSpeedExecutor())
- .then(new EntitySelectorArgument.OnePlayer("target")
- .setOptional(true)
- .replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
- .map(Player::getName)
- .toArray(String[]::new)))
- .executes(new WalkSpeedExecutor())))
- .register();
- }
-
- private static class WalkSpeedExecutor implements CommandExecutor {
- @Override
- public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
- if(args.args().length == 0) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /walkspeed [] []");
- return;
- }
-
- player.setWalkSpeed(0.2f);
- player.sendMessage(Main.get().getPrefix() + "Walk speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his walk speed");
- } else if(args.args().length == 1 || (args.args().length == 2 && sender == args.get("target"))) {
- if(!(sender instanceof Player player)) {
- sender.sendMessage(Main.get().getPrefix() + "§cUsage: /walkspeed [] []");
- return;
- }
-
- float walkSpeed = 0.2f;
-
- if((int) args.get("speed") <= 9) {
- walkSpeed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) walkSpeed = 1f;
-
- player.setWalkSpeed(walkSpeed);
- if((int) args.get("walkspeed") == 1) {
- player.sendMessage(Main.get().getPrefix() + "Walk speed has been reset");
- PlayerUtils.sendToTeam(player.getName(), null, "Reset his walk speed" );
- } else {
- player.sendMessage(Main.get().getPrefix() + "Set walk speed to " + args.get("walkspeed"));
- PlayerUtils.sendToTeam(player.getName(), null, "Set his walk speed to " + args.get("walkspeed"));
- }
- } else if(args.args().length == 2) {
- float walkSpeed = 0.2f;
-
- if((int) args.get("speed") <= 9) {
- walkSpeed = Float.parseFloat("0." + args.get("speed"));
-
- } else if((int) args.get("speed") == 10) walkSpeed = 1f;
-
- Player target = (Player) args.get("target");
- target.setWalkSpeed(walkSpeed);
- if((int) args.get("walkspeed") == 1) {
- target.sendMessage(Main.get().getPrefix() + "Walk speed has been reset by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Reset walk speed of " + target.getName());
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Reset the walk speed of " + target.getName());
- } else {
- target.sendMessage(Main.get().getPrefix() + "Walk speed has been set to " + args.get("walkspeed") + " by " + sender.getName());
- sender.sendMessage(Main.get().getPrefix() + "Set walk speed of " + target.getName() + " to " + args.get("walkspeed"));
- PlayerUtils.sendToTeam(sender.getName(), target.getName(), "Set the walk speed of " + target.getName() + " to " + args.get("walkspeed"));
- }
- }
-
- }
- }
-
-}
diff --git a/src/main/java/timongcraft/listeners/BlockCommandsListeners.java b/src/main/java/timongcraft/listeners/BlockCommandsListeners.java
deleted file mode 100644
index 282c6b1..0000000
--- a/src/main/java/timongcraft/listeners/BlockCommandsListeners.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package timongcraft.listeners;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.player.PlayerCommandSendEvent;
-import timongcraft.Main;
-
-import java.util.Iterator;
-
-public class BlockCommandsListeners implements Listener {
-
- @EventHandler
- public void blockPrefixes(PlayerCommandPreprocessEvent event) {
- Player player = event.getPlayer();
-
- if(player.hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedPrefixes").isEmpty()) return;
- for (String blockedPrefixes : Main.get().getConfig().getStringList("blockedPrefixes")) {
- if(event.getMessage().toLowerCase().startsWith("/" + blockedPrefixes)) {
- event.setCancelled(true);
- player.sendMessage(Main.get().getPrefix() + "§cThe '" + blockedPrefixes + "' prefix is blocked!");
- break;
- }
- }
- }
-
- @EventHandler
- public void hidePrefixes(PlayerCommandSendEvent event) {
- Iterator iterator = event.getCommands().iterator();
- if(event.getPlayer().hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedPrefixes").isEmpty()) return;
- while (iterator.hasNext()) {
- String command = iterator.next();
- for (String blockedPrefixes : Main.get().getConfig().getStringList("blockedPrefixes")) {
- if(command.startsWith(blockedPrefixes)) {
- iterator.remove();
- break;
- }
- }
- }
- }
-
- @EventHandler
- public void blockCommands(PlayerCommandPreprocessEvent event) {
- Player player = event.getPlayer();
-
- if(player.hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedCommands").isEmpty()) return;
- String command = event.getMessage().substring(1).toLowerCase().split("\\s+")[0];
- if(!Main.get().getConfig().getStringList("blockedCommands").contains(command)) return;
- player.sendMessage(Main.get().getPrefix() + "§cThe '" + command + "' command is blocked!");
- event.setCancelled(true);
- }
-
- @EventHandler
- public void hideCommands(PlayerCommandSendEvent event) {
- if(event.getPlayer().hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedCommands").isEmpty()) return;
- event.getCommands().removeIf(command -> Main.get().getConfig().getStringList("blockedCommands").contains(command));
- }
-}
diff --git a/src/main/java/timongcraft/listeners/OtherListeners.java b/src/main/java/timongcraft/listeners/OtherListeners.java
deleted file mode 100644
index d5f78e3..0000000
--- a/src/main/java/timongcraft/listeners/OtherListeners.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package timongcraft.listeners;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.Sound;
-import org.bukkit.block.Block;
-import org.bukkit.block.data.Ageable;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.Action;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerResourcePackStatusEvent;
-import timongcraft.Main;
-import timongcraft.util.CropDrop;
-import timongcraft.util.CropDrops;
-import timongcraft.util.PlayerUtils;
-
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class OtherListeners implements Listener {
-
- @EventHandler
- public void onPlayerChat(AsyncPlayerChatEvent event) {
- if(event.isCancelled()) return;
- if(!Main.get().getConfig().getBoolean("chatSystem.enabled")) return;
-
- Player player = event.getPlayer();
- String playerChatName;
- String message = event.getMessage();
-
- if(Main.get().getConfig().getBoolean("statuses.enabled")) {
- if(player.hasPermission("tgc-system.team")) {
- playerChatName = "§4<§c" + PlayerUtils.getPlayerNameWithStatus(player, true) + "§4>§f";
- } else playerChatName = "§8<§7" + PlayerUtils.getPlayerNameWithStatus(player, true) + "§8>§7";
- } else {
- if(player.hasPermission("tgc-system.team")) {
- playerChatName = "§4<§c" + PlayerUtils.getPlayerNameWithStatus(player, false) + "§4>§f";
- } else playerChatName = "§f<" + PlayerUtils.getPlayerNameWithStatus(player, false) + "§f>";
- }
-
- if(player.hasPermission("sbs.team")) {
- message = message.replaceAll("&", "§");
-
- if (message.startsWith(Main.get().getConfig().getString("prefix.teamChatPrefixInChat"))) {
- for (Player teamPlayer : Bukkit.getOnlinePlayers()) {
- if (teamPlayer.hasPermission("sbs.team")) {
- teamPlayer.sendMessage(Main.get().getConfig().getString("prefix.teamChatPrefix") + message);
-
- }
- }
- event.setCancelled(true);
- return;
- }
- }
-
-
- if(Main.get().getConfig().getBoolean("chatSystem.noLinks") && !player.hasPermission("tgc-system.team")) {
- Pattern urlPattern = Pattern.compile("^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$");
- for (String messagePart : message.split("\\s+")) {
- Matcher matcher = urlPattern.matcher(messagePart);
- if (matcher.matches()) {
- player.sendMessage(Main.get().getPrefix() + "§cYou don't have the permission to send links!");
- event.setCancelled(true);
- return;
- }
- }
- }
-
- final String[] highlightedMessage = {message};
- for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
- if(highlightedMessage[0].contains(onlinePlayer.getName())) {
- ChatColor highlightColor = (onlinePlayer.hasPermission("tgc-system.team") && (player.hasPermission("tgc-system.team"))) ? ChatColor.YELLOW : ChatColor.GRAY;
- highlightedMessage[0] = highlightedMessage[0].replaceAll(onlinePlayer.getName(), highlightColor + onlinePlayer.getName() + ChatColor.RESET);
-
- if(highlightColor == ChatColor.YELLOW) {
- onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_BIT, 1.0F, 2.0F);
- }
- }
-
- onlinePlayer.sendMessage(null, (Main.get().getConfig().getBoolean("chatSystem.timeStampInChat.enabled") ? "§7[" + DateTimeFormatter.ofPattern(Main.get().getConfig().getString("chatSystem.timeStampInChat.format")).format(ZonedDateTime.now(ZoneId.of(Main.get().getConfig().getString("chatSystem.timeStampInChat.timeZone")))) + "] §f" : "") + playerChatName + " " + highlightedMessage[0]);
- Bukkit.getLogger().info("Chat: " + playerChatName + " " + highlightedMessage[0]);
- }
-
- event.setCancelled(true);
- }
-
- @EventHandler
- public void onPlayerCropInteract(PlayerInteractEvent event) {
- if(!Main.get().getConfig().getBoolean("easyHarvest.enabled")) return;
- if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
-
- Block block = event.getClickedBlock();
- if(block == null) return;
- final Map cropDrops = Map.of(
- Material.WHEAT, new CropDrops(new CropDrop(1, 1, Material.WHEAT, 100), new CropDrop(1, 3, Material.WHEAT_SEEDS, 100)),
- Material.POTATOES, new CropDrops(new CropDrop(2, 4, Material.POTATO, 100), new CropDrop(1, 1, Material.POISONOUS_POTATO, 2)),
- Material.CARROTS, new CropDrops(new CropDrop(1, 4, Material.CARROT, 100)),
- Material.BEETROOTS, new CropDrops(new CropDrop(1, 1, Material.BEETROOT, 100), new CropDrop(1, 3, Material.BEETROOT_SEEDS, 100)),
- Material.COCOA, new CropDrops(new CropDrop(2, 2, Material.COCOA_BEANS, 100))
- );
- if(!cropDrops.containsKey(block.getType())) return;
-
- Player player = event.getPlayer();
- if(player.isSneaking()) return;
-
- Ageable ageable = (Ageable) block.getBlockData();
- if(ageable.getAge() != ageable.getMaximumAge()) return;
-
- CropDrops drops = cropDrops.get(block.getType());
- if(drops == null) return;
-
- ageable.setAge(0);
- block.setBlockData(ageable);
- player.swingMainHand();
-
- for(CropDrop cropDrop : drops.getRandoms()) {
- block.getWorld().dropItemNaturally(block.getLocation(), cropDrop.getRandom());
- }
- player.playSound(player.getLocation(), Sound.BLOCK_CROP_BREAK, 1.0f, 1.0f);
- event.setUseItemInHand(Event.Result.DENY);
- }
-
- @EventHandler
- public void onPlayerResourcePackStatus(PlayerResourcePackStatusEvent event) {
- Player player = event.getPlayer();
- if(!Main.get().getConfig().getBoolean("resourcePack.force")) return;
- if(player.hasPermission("tgc-system.team")) return;
- PlayerResourcePackStatusEvent.Status status = event.getStatus();
-
- if(status == PlayerResourcePackStatusEvent.Status.DECLINED || status == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD) {
- player.kickPlayer("§cYou must use the server's resource pack.");
- }
-
- if (status == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED) {
- ConnectionListeners.resourcePackLoaded.add(player.getUniqueId());
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/Main.java b/src/main/java/timongcraft/system/Main.java
similarity index 62%
rename from src/main/java/timongcraft/Main.java
rename to src/main/java/timongcraft/system/Main.java
index 71c7c26..6c44e6e 100644
--- a/src/main/java/timongcraft/Main.java
+++ b/src/main/java/timongcraft/system/Main.java
@@ -1,69 +1,66 @@
-package timongcraft;
+package timongcraft.system;
-import dev.jorel.commandapi.CommandAPI;
-import dev.jorel.commandapi.CommandAPIBukkitConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
-import timongcraft.commands.*;
-import timongcraft.listeners.*;
-import timongcraft.util.AutoSaveHandler;
-import timongcraft.util.DataConfigHandler;
-import timongcraft.util.UpdateCheckHandler;
+import timongcraft.system.commands.*;
+import timongcraft.system.listeners.BlockCommandsListeners;
+import timongcraft.system.listeners.ConnectionListeners;
+import timongcraft.system.listeners.OtherListeners;
+import timongcraft.system.listeners.SpawnElytraListeners;
+import timongcraft.system.util.*;
import java.io.File;
public class Main extends JavaPlugin {
+
private static Main instance;
private final String prefix = getConfig().getString("prefix.pluginPrefix");
private DataConfigHandler dataConfigHandler;
- private AutoSaveHandler autoSaveHandler;
private boolean noLoad;
@Override
public void onLoad() {
+ instance = this;
+
noLoad = !new File(getDataFolder(), "config.yml").exists();
- if(noLoad) return;
- CommandAPI.onLoad(new CommandAPIBukkitConfig(this).silentLogs(true).missingExecutorImplementationMessage("This command can't be executed with the %s"));
+ if (noLoad || Main.get().getConfig().getBoolean("commandAPI.autoDownload")) {
+ try {
+ CommandAPILoader.load("9.3.0", noLoad);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
}
@Override
public void onEnable() {
loadConfigs();
- if(noLoad) return;
-
- instance = this;
+ if (noLoad) return;
configVersionCheck();
- if(noLoad) return;
-
- PluginCommand.disablePluginsOnBoot();
+ if (noLoad) return;
- if(getConfig().getBoolean("newUpdateNotifications.console")) {
+ if (getConfig().getBoolean("newUpdateNotifications.console"))
UpdateCheckHandler.checkForUpdate(Double.parseDouble(getDescription().getVersion()));
- }
-
- CommandAPI.onEnable();
registerCommandsInOnEnable();
registerEvents();
-
- enableAutoSave();
}
@Override
public void onDisable() {
- if(noLoad) return;
+ if (noLoad) return;
- if(getConfig().getBoolean("autoSave.enabled")) autoSaveHandler.cancel();
+ if (dataConfigHandler != null) dataConfigHandler.save();
}
private void configVersionCheck() {
double configVersion = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")).getDouble("configVersion");
- if(configVersion != 1.6) {
+ if (configVersion != 1.8) {
getLogger().info("§cThe version of the config.yml does not match with the current plugin version!");
getLogger().info("§cUnless you delete the config and restart the server the plugin will be stopped!");
getLogger().info("§cDo not edit the version in the config.yml or things will break!");
@@ -75,24 +72,26 @@ private void configVersionCheck() {
private void registerCommandsInOnEnable() {
AlertCommand.register();
ColorCodesCommand.register();
+ if (Main.get().getConfig().getBoolean("coordsSaver.enabled"))
+ CoordinatesCommand.register();
FlySpeedCommand.register();
- if(Main.get().getConfig().getBoolean("chatSystem.enabled")) {
+ if (getConfig().getBoolean("hopperFilters.enabled"))
+ HopperFiltersCommand.register();
+ if (Main.get().getConfig().getBoolean("chatSystem.enabled")) {
MsgCommand.register();
ReplyCommand.register();
+ MeCommand.register();
+ SayCommand.register();
}
MaintenanceCommand.register();
- if(Main.get().getConfig().getBoolean("permissionSystem.enabled")) {
+ if (Main.get().getConfig().getBoolean("permissionSystem.enabled"))
PermissionManagerCommand.register();
- }
- PluginCommand.register();
RebootCommand.register();
ReloadConfigsCommand.register();
ResourcePackCommand.register();
- if(Main.get().getConfig().getBoolean("statuses.enabled")) {
+ if (Main.get().getConfig().getBoolean("statuses.enabled"))
StatusCommand.register();
- }
- SayCommand.register();
- SpeedCommand.register();
+ TeamMsgCommand.register();
WalkSpeedCommand.register();
}
@@ -101,22 +100,17 @@ private void registerEvents() {
pluginManager.registerEvents(new BlockCommandsListeners(), this);
pluginManager.registerEvents(new ConnectionListeners(), this);
pluginManager.registerEvents(new OtherListeners(), this);
- if(!getConfig().getStringList("blockedCommands").isEmpty() || !getConfig().getStringList("blockedPrefix").isEmpty()) {
+ pluginManager.registerEvents(new HopperFilterHandler(), this);
+ if (!getConfig().getStringList("blockedCommands").isEmpty() || !getConfig().getStringList("blockedPrefix").isEmpty())
pluginManager.registerEvents(new BlockCommandsListeners(), this);
- }
- if(getConfig().getBoolean("spawnElytra.enabled")) {
+ if (getConfig().getBoolean("spawnElytra.enabled"))
pluginManager.registerEvents(new SpawnElytraListeners(), this);
- }
-
- }
-
- private void enableAutoSave() {
- autoSaveHandler = new AutoSaveHandler();
- if(getConfig().getBoolean("autoSave.enabled")) autoSaveHandler.runTaskTimer(this, autoSaveHandler.parseInterval(Main.get().getConfig().getString("autoSave.time")), autoSaveHandler.parseInterval(Main.get().getConfig().getString("autoSave.time")));
+ if (getConfig().getBoolean("hopperFilters.enabled"))
+ pluginManager.registerEvents(new HopperFilterHandler(), this);
}
private void loadConfigs() {
- if(!new File(getDataFolder(), "config.yml").exists()) {
+ if (!new File(getDataFolder(), "config.yml").exists()) {
saveDefaultConfig();
new DataConfigHandler(new File(getDataFolder(), "data.yml")).save();
getLogger().warning("Loaded for the first time, please set the config values!");
@@ -136,5 +130,8 @@ public String getPrefix() {
return prefix;
}
- public DataConfigHandler getDataConfig() { return dataConfigHandler; }
+ public DataConfigHandler getDataConfig() {
+ return dataConfigHandler;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/AlertCommand.java b/src/main/java/timongcraft/system/commands/AlertCommand.java
new file mode 100644
index 0000000..ee1429c
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/AlertCommand.java
@@ -0,0 +1,34 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import org.bukkit.Bukkit;
+import org.bukkit.Sound;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+
+public class AlertCommand {
+
+ public static void register() {
+ new CommandTree("alert")
+ .withShortDescription("Sends an alert to all players")
+ .withUsage("/alert ")
+ .withAliases("broadcast")
+ .withPermission("tgc-system.team")
+ .then(new GreedyStringArgument("message")
+ .executes(AlertCommand::alertManager))
+ .register();
+ }
+
+ private static void alertManager(CommandSender sender, CommandArguments args) {
+ String message = (String) args.get("message");
+
+ Bukkit.broadcastMessage(Main.get().getConfig().getString("prefix.alertPrefix") + message.replaceAll("&", "§"));
+
+ for (Player player : Bukkit.getOnlinePlayers())
+ player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F, .5F);
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/ColorCodesCommand.java b/src/main/java/timongcraft/system/commands/ColorCodesCommand.java
new file mode 100644
index 0000000..036ea49
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/ColorCodesCommand.java
@@ -0,0 +1,36 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.ChatColor;
+import org.bukkit.command.CommandSender;
+
+public class ColorCodesCommand {
+
+ public static void register() {
+ new CommandTree("colorcodes")
+ .withShortDescription("Get all color codes as well as the format codes")
+ .withUsage("/colorcodes")
+ .withPermission("tgc-system.team")
+ .executes(ColorCodesCommand::colorCodesManager)
+ .register();
+ }
+
+ private static void colorCodesManager(CommandSender sender, CommandArguments args) {
+ sender.sendMessage(ChatColor.GOLD + "======== Color Codes ========");
+ sender.sendMessage("&0 = " + ChatColor.BLACK + "Black" + " " + ChatColor.WHITE + "&1 = " + ChatColor.DARK_BLUE + "Dark Blue");
+ sender.sendMessage("&2 = " + ChatColor.DARK_GREEN + "Dark Green" + " " + ChatColor.WHITE + "&3 = " + ChatColor.DARK_AQUA + "Dark Aqua");
+ sender.sendMessage("&4 = " + ChatColor.DARK_RED + "Dark Red" + " " + ChatColor.WHITE + "&5 = " + ChatColor.DARK_PURPLE + "Dark Purple");
+ sender.sendMessage("&6 = " + ChatColor.GOLD + "Gold" + " " + ChatColor.WHITE + "&7 = " + ChatColor.GRAY + "Gray");
+ sender.sendMessage("&8 = " + ChatColor.DARK_GRAY + "Dark Gray" + " " + ChatColor.WHITE + "&9 = " + ChatColor.BLUE + "Blue");
+ sender.sendMessage("&a = " + ChatColor.GREEN + "Green" + " " + ChatColor.WHITE + "&b = " + ChatColor.AQUA + "Aqua");
+ sender.sendMessage("&c = " + ChatColor.RED + "Red" + " " + ChatColor.WHITE + "&d = " + ChatColor.LIGHT_PURPLE + "Light Purple");
+ sender.sendMessage("&e = " + ChatColor.YELLOW + "Yellow" + " " + ChatColor.WHITE + "&f = " + ChatColor.WHITE + "White");
+ sender.sendMessage("\n");
+ sender.sendMessage(ChatColor.GOLD + "======== Format Codes ========");
+ sender.sendMessage("&k = " + ChatColor.MAGIC + "Magic" + ChatColor.WHITE + " " + "&l = " + ChatColor.BOLD + "Bold");
+ sender.sendMessage("&m = " + ChatColor.STRIKETHROUGH + "Strikethrough" + ChatColor.WHITE + " " + "&n = " + ChatColor.UNDERLINE + "Underline");
+ sender.sendMessage("&o = " + ChatColor.ITALIC + "Italic" + ChatColor.WHITE + " " + "&r = " + ChatColor.RESET + "Reset");
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/CoordinatesCommand.java b/src/main/java/timongcraft/system/commands/CoordinatesCommand.java
new file mode 100644
index 0000000..d89d843
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/CoordinatesCommand.java
@@ -0,0 +1,238 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandPermission;
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.*;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.ClickEvent;
+import net.md_5.bungee.api.chat.HoverEvent;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.chat.hover.content.Text;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+import java.util.List;
+
+public class CoordinatesCommand {
+
+ public static void register() {
+ new CommandTree("coordinates")
+ .withShortDescription("A more vanilla like alternative to waypoints")
+ .withUsage(
+ "/coords",
+ "/coords "
+ )
+ .withAliases("coords")
+ .executesPlayer(CoordinatesCommand::coordsList)
+ .then(new LiteralArgument("list")
+ .withPermission(CommandPermission.OP)
+ .then(new OfflinePlayerArgument("target")
+ .replaceSuggestions(ArgumentSuggestions.strings(info ->
+ Bukkit.getOnlinePlayers().stream().map(OfflinePlayer::getName).toArray(String[]::new)))
+ .executes(CoordinatesCommand::coordsListOther)))
+ .then(new LiteralArgument("add")
+ .then(new TextArgument("name")
+ .executesPlayer(CoordinatesCommand::coordsAdder)))
+ .then(new LiteralArgument("remove")
+ .then(new GreedyStringArgument("name")
+ .includeSuggestions(ArgumentSuggestions.strings(info -> getCoordinates((Player) info.sender())))
+ .executesPlayer(CoordinatesCommand::coordsRemover)))
+ .then(new LiteralArgument("get")
+ .then(new GreedyStringArgument("name")
+ .includeSuggestions(ArgumentSuggestions.strings(info -> getCoordinates((Player) info.sender())))
+ .executesPlayer(CoordinatesCommand::coordsGrabber)))
+ .then(new LiteralArgument("save")
+ .then(new GreedyStringArgument("coords")
+ .executesPlayer(CoordinatesCommand::coordsSaver)))
+ .register();
+ }
+
+ private static String[] getCoordinates(Player sender) {
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+ if (coordinatesList.isEmpty()) return new String[0];
+
+ String[] coordinateNames = new String[coordinatesList.size()];
+ int index = 0;
+
+ for (String coordinateNamesName : coordinatesList)
+ coordinateNames[index++] = (coordinateNamesName.split(":")[0]);
+
+ return coordinateNames;
+ }
+
+ private static int coordsList(Player sender, CommandArguments args) {
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+
+ if (coordinatesList.isEmpty()) {
+ sender.sendMessage(Main.get().getPrefix() + "§cYou haven't any saved coordinates");
+ return 0;
+ }
+
+ sender.sendMessage("Saved Coordinates:\n");
+ for (String coordinate : coordinatesList) {
+ String coordinateName = coordinate.split(":")[0];
+ String coordinateCoordinates = coordinate.split(":")[1].replaceAll(",", " ");
+ ChatColor color = getEnvironmentColor(coordinate.split(":")[2]);
+
+ TextComponent coordinateNameComponent = new TextComponent(color + coordinateName);
+ coordinateNameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "[coords:" + coordinateName + "]"));
+ coordinateNameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy.")));
+
+ TextComponent coordinateCoordinatesComponent = new TextComponent(color + " (" + coordinateCoordinates + ")");
+ coordinateCoordinatesComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, coordinateCoordinates));
+ coordinateCoordinatesComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy raw coordinates.")));
+
+ sender.spigot().sendMessage(new TextComponent(" - "), coordinateNameComponent, coordinateCoordinatesComponent);
+ }
+
+ return 1;
+ }
+
+ private static int coordsListOther(CommandSender sender, CommandArguments args) {
+ OfflinePlayer target = (OfflinePlayer) args.get("target");
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + target.getUniqueId() + ".coords");
+
+ if (coordinatesList.isEmpty()) {
+ sender.sendMessage(Main.get().getPrefix() + "§c" + target.getName() + " hasn't saved any coordinates");
+ return 0;
+ }
+
+ sender.sendMessage(Main.get().getPrefix() + target.getName() + "s Saved Coordinates:\n");
+ for (String coordinate : coordinatesList) {
+ String coordinateName = coordinate.split(":")[0];
+ String coordinateCoordinates = coordinate.split(":")[1].replaceAll(",", " ");
+ ChatColor color = getEnvironmentColor(coordinate.split(":")[2]);
+
+ TextComponent coordinateNameComponent = new TextComponent(color + coordinateName);
+ coordinateNameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "[coords:" + coordinateName + "]"));
+ coordinateNameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy.")));
+
+ TextComponent coordinateCoordinatesComponent = new TextComponent(color + " (" + coordinateCoordinates + ")");
+ coordinateCoordinatesComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, coordinateCoordinates));
+ coordinateCoordinatesComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy coordinates.")));
+
+ sender.spigot().sendMessage(new TextComponent(" - "), coordinateNameComponent, coordinateCoordinatesComponent);
+ }
+
+ return 1;
+ }
+
+ private static int coordsAdder(Player sender, CommandArguments args) {
+ String coordinateName = (String) args.get("name");
+ Location location = sender.getLocation().getBlock().getLocation();
+ String coordinate = String.format("%d,%d,%d", (int) location.getX(), (int) location.getY(), (int) location.getZ());
+ String coordinateClean = coordinate.replaceAll(",", " ");
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+ int coordinatesLimit = Main.get().getConfig().getInt("coordsSaver.limit");
+
+ if (coordinatesLimit != -1 && coordinatesList.size() >= coordinatesLimit) {
+ sender.sendMessage(Main.get().getPrefix() + "§cYou succeeded the limit of " + coordinatesLimit + " coordinates");
+ return 0;
+ }
+
+ coordinatesList.removeIf(searchedCoordinate -> searchedCoordinate.startsWith(coordinateName + ":"));
+ coordinatesList.add(coordinateName + ":" + coordinate + ":" + sender.getWorld().getEnvironment().name());
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".coords", coordinatesList);
+ Main.get().getDataConfig().save();
+
+ ChatColor color = getEnvironmentColor(sender.getWorld().getEnvironment().name());
+
+ TextComponent coordinateNameComponent = new TextComponent(color + coordinateName);
+ coordinateNameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "[coords:" + coordinateName + "]"));
+ coordinateNameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy.")));
+
+ TextComponent coordinateCoordinatesComponent = new TextComponent(color + " (" + coordinateClean + ")");
+ coordinateCoordinatesComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, coordinateClean));
+ coordinateCoordinatesComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy coordinates.")));
+
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Added coordinate: " + coordinateName + " (" + coordinateClean + ")"));
+ return 1;
+ }
+
+ private static int coordsRemover(Player sender, CommandArguments args) {
+ String coordinateName = (String) args.get("name");
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+
+ if (coordinatesList.isEmpty()) {
+ sender.sendMessage(Main.get().getPrefix() + "§cThere aren't any saved coordinates");
+ return 0;
+ }
+
+ for (String coordinate : coordinatesList) {
+ if (coordinate.startsWith(coordinateName + ":")) {
+ coordinatesList.remove(coordinate);
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".coords", coordinatesList);
+ Main.get().getDataConfig().save();
+
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Removed coordinate: " + coordinateName));
+ return 1;
+ }
+ }
+
+ sender.sendMessage(Main.get().getPrefix() + "§cNo coordinate with the name: " + coordinateName + "could be found");
+ return 0;
+ }
+
+ private static int coordsGrabber(Player sender, CommandArguments args) {
+ String coordinateName = (String) args.get("name");
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+
+ if (coordinatesList.isEmpty()) {
+ sender.sendMessage(Main.get().getPrefix() + "§cThere aren't any saved coordinates");
+ return 0;
+ }
+
+ for (String coordinate : coordinatesList) {
+ if (coordinate.startsWith(coordinateName + ":")) {
+ String coordinateCoordinates = coordinate.split(":")[1].replaceAll(",", " ");
+ ChatColor color = getEnvironmentColor(coordinate.split(":")[2]);
+
+ TextComponent coordinateNameComponent = new TextComponent(color + coordinateName);
+ coordinateNameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "[coords:" + coordinateName + "]"));
+ coordinateNameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy.")));
+
+ TextComponent coordinateCoordinatesComponent = new TextComponent(color + " (" + coordinateCoordinates + ")");
+ coordinateCoordinatesComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, coordinateCoordinates));
+ coordinateCoordinatesComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy coordinates.")));
+
+ sender.spigot().sendMessage(new TextComponent(Main.get().getPrefix() + "Coordinates of "), coordinateNameComponent, new TextComponent(": "), coordinateCoordinatesComponent);
+ return 1;
+ }
+ }
+
+ sender.sendMessage(Main.get().getPrefix() + "§cNo coordinate with the name: " + coordinateName + "could be found");
+ return 0;
+ }
+
+ private static void coordsSaver(Player sender, CommandArguments args) {
+ String coords = (String) args.get("coords");
+ String coordsName = coords.split(":")[0];
+ ChatColor color = getEnvironmentColor(coords.split(":")[2]);
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + sender.getUniqueId() + ".coords");
+
+ coordinatesList.removeIf(searchedCoordinate -> searchedCoordinate.startsWith(coordsName));
+ coordinatesList.add(coords);
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".coords", coordinatesList);
+ Main.get().getDataConfig().save();
+
+ sender.sendMessage(Main.get().getPrefix() + "Added " + color + coordsName + "§r to your coords list");
+ }
+
+ public static ChatColor getEnvironmentColor(String environment) {
+ return switch (environment) {
+ case "NORMAL" -> ChatColor.GREEN;
+ case "NETHER" -> ChatColor.RED;
+ case "THE_END" -> ChatColor.LIGHT_PURPLE;
+ case "CUSTOM" -> ChatColor.BLUE;
+ default -> null;
+ };
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/FlySpeedCommand.java b/src/main/java/timongcraft/system/commands/FlySpeedCommand.java
new file mode 100644
index 0000000..42750bf
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/FlySpeedCommand.java
@@ -0,0 +1,47 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.IntegerArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+import timongcraft.system.util.PlayerOnlyArgument;
+
+public class FlySpeedCommand {
+
+ public static void register() {
+ new CommandTree("flyspeed")
+ .withShortDescription("Set fly speed")
+ .withUsage("/flyspeed [] []")
+ .withAliases("fs")
+ .withPermission("tgc-system.team")
+ .executesPlayer(FlySpeedCommand::flySpeedOwnResetManager)
+ .then(new IntegerArgument("speed", 2, 10)
+ .executesPlayer(FlySpeedCommand::flySpeedOwnManager)
+ .then(new PlayerOnlyArgument("target")
+ .executes(FlySpeedCommand::flySpeedOtherManager)))
+ .register();
+ }
+
+ private static void flySpeedOwnResetManager(Player sender, CommandArguments args) {
+ sender.setFlySpeed(0.2f);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Fly speed has been reset"));
+ }
+
+ private static void flySpeedOwnManager(Player sender, CommandArguments args) {
+ sender.setFlySpeed((int) args.get("speed") / 10f);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set fly speed to " + args.get("speed")));
+ }
+
+
+ private static void flySpeedOtherManager(CommandSender sender, CommandArguments args) {
+ Player target = (Player) args.get("target");
+ target.setFlySpeed((int) args.get("speed") / 10f);
+ target.sendMessage(Main.get().getPrefix() + "Fly speed has been set to " + args.get("speed") + " by " + sender.getName());
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set fly speed of " + target.getName() + " to " + args.get("speed")));
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/HopperFiltersCommand.java b/src/main/java/timongcraft/system/commands/HopperFiltersCommand.java
new file mode 100644
index 0000000..e3cc472
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/HopperFiltersCommand.java
@@ -0,0 +1,60 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.arguments.LiteralArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import org.bukkit.Material;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import timongcraft.system.Main;
+
+public class HopperFiltersCommand {
+
+ public static String HOPPER_SORTER_PREFIX = "§6Sorter: ";
+
+ public static void register() {
+ new CommandTree("hopperfilter")
+ .withShortDescription("A explanation for the hopper sorting system")
+ .then(new LiteralArgument("rename")
+ .then(new GreedyStringArgument("name")
+ .executesPlayer(HopperFiltersCommand::hopperFiltersRenamer)))
+ .executes(HopperFiltersCommand::hopperFiltersManager)
+ .register();
+ }
+
+ private static void hopperFiltersManager(CommandSender sender, CommandArguments args) {
+ sender.sendMessage(Main.get().getPrefix() + "Hopper Sorting System Usage:");
+ sender.sendMessage("To use hopper filters you need to rename a hopper, the following features will help you");
+ sender.sendMessage("1. Separate items with commas.");
+ sender.sendMessage("2. Use wildcards like * (infinite chars) and ? (as many chars as question marks).");
+ sender.sendMessage("3. Use exclamation marks as inverters.");
+ sender.sendMessage("Example: '*spruce*,!*boat' will let every spruce item except boats trough");
+ }
+
+ private static int hopperFiltersRenamer(Player sender, CommandArguments args) {
+ ItemStack item = sender.getInventory().getItemInMainHand();
+
+ if (!item.getType().equals(Material.HOPPER)) {
+ sender.sendMessage(Main.get().getPrefix() + "§cYou need to hold a hopper in you hand to rename it.");
+ return 0;
+ }
+
+ String name = (String) args.get("name");
+ ItemMeta itemMeta = item.getItemMeta();
+
+ if (itemMeta == null) {
+ sender.sendMessage(Main.get().getPrefix() + "§cNo item meta present!");
+ return 0;
+ }
+
+ itemMeta.setDisplayName(HOPPER_SORTER_PREFIX + name);
+ item.setItemMeta(itemMeta);
+
+ sender.sendMessage(Main.get().getPrefix() + "Renamed hopper");
+ return 1;
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/MaintenanceCommand.java b/src/main/java/timongcraft/system/commands/MaintenanceCommand.java
new file mode 100644
index 0000000..e9480fc
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/MaintenanceCommand.java
@@ -0,0 +1,122 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.ArgumentSuggestions;
+import dev.jorel.commandapi.arguments.LiteralArgument;
+import dev.jorel.commandapi.arguments.OfflinePlayerArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+public class MaintenanceCommand {
+
+ public static void register() {
+ new CommandTree("maintenance")
+ .withShortDescription("A maintenance system")
+ .withUsage(
+ "/maintenance []",
+ "/maintenance list"
+ )
+ .withPermission("tgc-system.team")
+ .executes(MaintenanceCommand::maintenanceManager)
+ .then(new LiteralArgument("add")
+ .then(new OfflinePlayerArgument("target")
+ .replaceSuggestions(ArgumentSuggestions.strings(info -> notMaintenanceList()))
+ .executes(MaintenanceCommand::maintenanceAddManager)))
+ .then(new LiteralArgument("remove")
+ .then(new OfflinePlayerArgument("target")
+ .replaceSuggestions(ArgumentSuggestions.strings(info -> maintenanceList()))
+ .executes(MaintenanceCommand::maintenanceRemoveManager)))
+ .then(new LiteralArgument("list")
+ .executes(MaintenanceCommand::maintenanceListManager))
+ .register();
+ }
+
+ private static String[] maintenanceList() {
+ List inMainenanceList = new ArrayList<>();
+
+ for (Player player : Bukkit.getOnlinePlayers())
+ if (isAllowed(player.getUniqueId()))
+ inMainenanceList.add(player.getName());
+
+ return inMainenanceList.toArray(new String[0]);
+ }
+
+ private static String[] notMaintenanceList() {
+ List notInMainenanceList = new ArrayList<>();
+
+ for (Player player : Bukkit.getOnlinePlayers())
+ if (!isAllowed(player.getUniqueId()))
+ notInMainenanceList.add(player.getName());
+
+ return notInMainenanceList.toArray(new String[0]);
+ }
+
+ private static void maintenanceManager(CommandSender sender, CommandArguments args) {
+ final String maintenanceKickMessage = Main.get().getConfig().getString("maintenance.kickMessage");
+
+ boolean maintenanceMode = Main.get().getDataConfig().getBoolean("maintenance.enabled");
+ maintenanceMode = !maintenanceMode;
+ Main.get().getDataConfig().set("maintenance.enabled", maintenanceMode);
+ Main.get().getDataConfig().save();
+
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Maintenance mode set to " + maintenanceMode));
+ if (maintenanceMode)
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ if (isAllowed(player.getUniqueId())) continue;
+ player.kickPlayer(maintenanceKickMessage);
+ }
+ }
+
+ private static void maintenanceListManager(CommandSender sender, CommandArguments args) {
+ sender.sendMessage(Main.get().getPrefix() + "Allowed players:");
+ for (String uniqueId : Main.get().getDataConfig().getConfigurationSection("players").getKeys(false)) {
+ if (!Main.get().getDataConfig().getBoolean("players." + uniqueId + ".maintenanceAllowed")) continue;
+ sender.sendMessage(Main.get().getDataConfig().getString("players." + uniqueId + ".name"));
+ }
+ }
+
+ private static int maintenanceAddManager(CommandSender sender, CommandArguments args) {
+ OfflinePlayer target = (OfflinePlayer) args.get("target");
+
+ if (isAllowed(target.getUniqueId())) {
+ sender.sendMessage(Main.get().getPrefix() + "§c" + target.getName() + " is already on the maintenance list");
+ return 0;
+ }
+
+ Main.get().getDataConfig().set("players." + target.getUniqueId() + ".maintenanceAllowed", true);
+ Main.get().getDataConfig().save();
+
+ sender.sendMessage(Main.get().getPrefix() + target.getName() + " has been added to the maintenance list");
+ return 1;
+ }
+
+ private static int maintenanceRemoveManager(CommandSender sender, CommandArguments args) {
+ OfflinePlayer target = (OfflinePlayer) args.get("target");
+
+ if (!isAllowed(target.getUniqueId())) {
+ sender.sendMessage(Main.get().getPrefix() + "§c" + target.getName() + " isn't on the maintenance list");
+ return 0;
+ }
+
+ Main.get().getDataConfig().set("players." + target.getUniqueId() + ".maintenanceAllowed", false);
+ Main.get().getDataConfig().save();
+
+ sender.sendMessage(Main.get().getPrefix() + target.getName() + " has been removed from the maintenance list");
+ return 1;
+ }
+
+ public static boolean isAllowed(UUID playerUniqueId) {
+ return Main.get().getDataConfig().getBoolean("players." + playerUniqueId + ".maintenanceAllowed");
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/MeCommand.java b/src/main/java/timongcraft/system/commands/MeCommand.java
new file mode 100644
index 0000000..d161bb1
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/MeCommand.java
@@ -0,0 +1,30 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandAPIBukkit;
+import dev.jorel.commandapi.CommandPermission;
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TranslatableComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+
+public class MeCommand {
+
+ public static void register() {
+ CommandAPIBukkit.unregister("me", true, false);
+
+ new CommandTree("me")
+ .withShortDescription("Send a me message from that sender")
+ .withUsage("/me ")
+ .withPermission(CommandPermission.OP)
+ .then(new GreedyStringArgument("message")
+ .executes(MeCommand::meManager))
+ .register();
+ }
+
+ private static void meManager(CommandSender sender, CommandArguments args) {
+ Bukkit.spigot().broadcast(new TranslatableComponent("chat.type.emote", sender.getName(), args.get("message")));
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/MsgCommand.java b/src/main/java/timongcraft/system/commands/MsgCommand.java
new file mode 100644
index 0000000..fa72dc7
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/MsgCommand.java
@@ -0,0 +1,62 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandAPIBukkit;
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.ComponentBuilder;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.chat.TranslatableComponent;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.CoordsMessageUtils;
+import timongcraft.system.util.PlayerOnlyArgument;
+
+public class MsgCommand {
+
+ public static void register() {
+ CommandAPIBukkit.unregister("msg", true, false);
+ CommandAPIBukkit.unregister("tell", true, false);
+ CommandAPIBukkit.unregister("w", true, false);
+
+ new CommandTree("msg")
+ .withShortDescription("Send a private message to a player")
+ .withUsage("/msg ")
+ .withAliases("tell", "w")
+ .then(new PlayerOnlyArgument("target")
+ .then(new GreedyStringArgument("message")
+ .executes(MsgCommand::msgManager)))
+ .register();
+ }
+
+ private static void msgManager(CommandSender sender, CommandArguments args) {
+ Player target = (Player) args.get("target");
+ String rawMessage = (String) args.get("message");
+
+ if (sender.hasPermission("tgc-system.team"))
+ rawMessage = rawMessage.replaceAll("&", "§");
+
+ TextComponent message = new TextComponent(rawMessage);
+
+ if (sender instanceof Player player && Main.get().getConfig().getBoolean("coordsSaver.enabled"))
+ if (Main.get().getConfig().getBoolean("coordsSaver.xaerosWaypointCompatability")) {
+ TextComponent xaerosWaypoint = CoordsMessageUtils.getXaerosWaypointAsClickableCoordinatesMessage(rawMessage);
+
+ if (xaerosWaypoint != null) {
+ message = xaerosWaypoint;
+ } else {
+ message = CoordsMessageUtils.getAsClickableCoordinatesMessage(player, rawMessage, true);
+ }
+ } else {
+ message = CoordsMessageUtils.getAsClickableCoordinatesMessage(player, rawMessage, false);
+ }
+
+ sender.spigot().sendMessage(new ComponentBuilder(new TranslatableComponent("commands.message.display.outgoing", target.getName(), message)).color(ChatColor.GRAY).italic(true).create());
+ target.spigot().sendMessage(new ComponentBuilder(new TranslatableComponent("commands.message.display.incoming", sender.getName(), message)).color(ChatColor.GRAY).italic(true).create());
+ if (sender instanceof Player player)
+ ReplyCommand.setLastReply(player.getUniqueId(), target.getUniqueId());
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/PermissionManagerCommand.java b/src/main/java/timongcraft/system/commands/PermissionManagerCommand.java
new file mode 100644
index 0000000..2c95c63
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/PermissionManagerCommand.java
@@ -0,0 +1,171 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.*;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.ConfigurationSection;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PermissionManagerCommand {
+
+ public static void register() {
+ new CommandTree("permissionmanager")
+ .withShortDescription("Set or unset groups for players")
+ .withUsage(
+ "/permissionmanager player permission set ",
+ "/permissionmanager player permission unset ",
+ "/permissionmanager player group ",
+ "/permissionmanager group set ",
+ "/permissionmanager group unset "
+ )
+ .withPermission("tgc-system.team")
+ .withAliases("pm")
+ .then(new LiteralArgument("player")
+ .then(new OfflinePlayerArgument("target")
+ .replaceSuggestions(ArgumentSuggestions.strings(info -> Bukkit.getOnlinePlayers().stream()
+ .map(OfflinePlayer::getName)
+ .toArray(String[]::new)))
+ .then(new LiteralArgument("permission")
+ .then(new LiteralArgument("set")
+ .then(new StringArgument("permission")
+ .then(new BooleanArgument("value")
+ .executes(PermissionManagerCommand::permissionSetManager))))
+ .then(new LiteralArgument("unset")
+ .then(new StringArgument("permission")
+ .replaceSuggestions(ArgumentSuggestions.strings(info -> getPermissionsForPlayer((OfflinePlayer) info.previousArgs().get("target"))))
+ .executes(PermissionManagerCommand::permissionUnsetManager))))
+ .then(new LiteralArgument("group")
+ .then(new MultiLiteralArgument("mode", "set", "unset")
+ .then(new StringArgument("group")
+ .includeSuggestions(ArgumentSuggestions.strings(info -> getGroups()))
+ .executes(PermissionManagerCommand::playerGroupManager))))))
+ .then(new LiteralArgument("group")
+ .then(new StringArgument("group")
+ .includeSuggestions(ArgumentSuggestions.strings(info -> getGroups()))
+ .then(new LiteralArgument("set")
+ .then(new StringArgument("permission")
+ .then(new BooleanArgument("value")
+ .executes(PermissionManagerCommand::groupSetPermissionManager))))
+ .then(new LiteralArgument("unset")
+ .then(new StringArgument("permission")
+ .replaceSuggestions(ArgumentSuggestions.strings(info -> getPermissionsForGroup((String) info.previousArgs().get("group"))))
+ .executes(PermissionManagerCommand::groupUnsetPermissionManager)))))
+ .register();
+ }
+
+ private static String[] getGroups() {
+ ConfigurationSection groupsSection = Main.get().getDataConfig().getConfigurationSection("groups");
+ if (groupsSection == null)
+ return new String[0];
+
+ return groupsSection.getKeys(false).toArray(new String[0]);
+ }
+
+ private static String[] getPermissionsForPlayer(OfflinePlayer playerName) {
+ List permissionNames = new ArrayList<>();
+
+ for (String permissionString : Main.get().getDataConfig().getStringList("players." + playerName.getUniqueId() + ".permissions")) {
+ String permissionName = permissionString.split(":")[0];
+ permissionNames.add(permissionName);
+ }
+
+ return permissionNames.toArray(new String[0]);
+ }
+
+ private static String[] getPermissionsForGroup(String groupName) {
+ List permissionNames = new ArrayList<>();
+
+ for (String permissionString : Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions")) {
+ String permissionName = permissionString.split(":")[0];
+ permissionNames.add(permissionName);
+ }
+
+ return permissionNames.toArray(new String[0]);
+ }
+
+ private static void permissionSetManager(CommandSender sender, CommandArguments args) {
+ OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
+ String permission = (String) args.get("permission");
+ Boolean value = (Boolean) args.get("value");
+
+ List playerPermissions = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".permissions");
+
+ playerPermissions.removeIf(s -> s.split(":")[0].equals(permission));
+ playerPermissions.add(permission + ":" + value);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set permission " + permission + " of " + targetPlayer.getName()));
+
+ Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".permissions", playerPermissions);
+ Main.get().getDataConfig().save();
+ }
+
+ private static void permissionUnsetManager(CommandSender sender, CommandArguments args) {
+ OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
+ String permission = (String) args.get("permission");
+
+ List playerPermissions = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".permissions");
+ if (playerPermissions.equals(new ArrayList<>())) playerPermissions = new ArrayList<>();
+
+ playerPermissions.removeIf(s -> s.split(":")[0].equals(permission));
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Unset permission " + permission + " of " + targetPlayer.getName()));
+
+ Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".permissions", playerPermissions);
+ Main.get().getDataConfig().save();
+ }
+
+ private static void playerGroupManager(CommandSender sender, CommandArguments args) {
+ OfflinePlayer targetPlayer = (OfflinePlayer) args.get("target");
+ String action = (String) args.get("mode");
+ String group = (String) args.get("group");
+
+ List playerGroups = Main.get().getDataConfig().getStringList("players." + targetPlayer.getUniqueId() + ".groups");
+ if (playerGroups.equals(new ArrayList<>())) playerGroups = new ArrayList<>();
+
+ if (action.equals("set")) {
+ if (!playerGroups.contains(group)) playerGroups.add(group);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Added player " + targetPlayer.getPlayer().getName() + " to group " + group));
+ } else {
+ playerGroups.remove(group);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Removed player " + targetPlayer.getPlayer().getName() + " from group " + group));
+ }
+
+ Main.get().getDataConfig().set("players." + targetPlayer.getUniqueId() + ".groups", playerGroups);
+ Main.get().getDataConfig().save();
+ }
+
+ private static void groupSetPermissionManager(CommandSender sender, CommandArguments args) {
+ String groupName = (String) args.get("group");
+ String permission = (String) args.get("permission");
+ Boolean value = (Boolean) args.get("value");
+
+ List groupPermissions = Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions");
+
+ groupPermissions.removeIf(s -> s.split(":")[0].equals(permission));
+ groupPermissions.add(permission + ":" + value);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set permission " + permission + " of group " + groupName));
+
+ Main.get().getDataConfig().set("groups." + groupName + ".permissions", groupPermissions);
+ Main.get().getDataConfig().save();
+ }
+
+ private static void groupUnsetPermissionManager(CommandSender sender, CommandArguments args) {
+ String groupName = (String) args.get("group");
+ String permission = (String) args.get("permission");
+
+ List groupPermissions = Main.get().getDataConfig().getStringList("groups." + groupName + ".permissions");
+
+ groupPermissions.removeIf(s -> s.split(":")[0].equals(permission));
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Unset permission " + permission + " of group " + groupName));
+
+ Main.get().getDataConfig().set("groups." + groupName + ".permissions", groupPermissions);
+ Main.get().getDataConfig().save();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/RebootCommand.java b/src/main/java/timongcraft/system/commands/RebootCommand.java
new file mode 100644
index 0000000..32a53e3
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/RebootCommand.java
@@ -0,0 +1,65 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.arguments.IntegerArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.Sound;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+public class RebootCommand {
+
+ static int seconds;
+ static BukkitRunnable runnable = null;
+
+ public static void register() {
+ new CommandTree("reboot")
+ .withShortDescription("Reboot the server after a specified time")
+ .withUsage("/reboot")
+ .withPermission("tgc-system.team")
+ .then(new IntegerArgument("minutes", 1)
+ .then(new GreedyStringArgument("reason")
+ .executes(RebootCommand::rebootManager)))
+ .register();
+ }
+
+ private static void rebootManager(CommandSender sender, CommandArguments args) {
+ seconds = (int) args.get("minutes") * 60;
+ String reason = ((String) args.get("reason")).replaceAll("&", "§");
+
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Scheduled reboot in: " + args.get("minutes") + " minutes with reason: " + reason));
+
+ if (runnable != null)
+ runnable.cancel();
+
+ runnable = new BukkitRunnable() {
+ @Override
+ public void run() {
+ if (seconds == 600 || seconds % 1200 == 0) {
+ Bukkit.broadcastMessage(Main.get().getConfig().getString("prefix.alertPrefix") + "The server will reboot in " + seconds / 60 + " minutes because: " + reason);
+ for (Player player : Bukkit.getOnlinePlayers())
+ player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F, .5F);
+ } else if (seconds == 60 || seconds == 10 || seconds == 3 || seconds == 2 || seconds == 1) {
+ Bukkit.broadcastMessage(Main.get().getConfig().getString("prefix.alertPrefix") + "The server will reboot in " + seconds + " seconds because: " + reason);
+ for (Player player : Bukkit.getOnlinePlayers())
+ player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F, .5F);
+ } else if (seconds == 0) {
+ for (Player player : Bukkit.getOnlinePlayers())
+ player.kickPlayer("The server is rebooting because:\n" + reason.replaceAll("&", "§"));
+ cancel();
+ Bukkit.spigot().restart();
+ return;
+ }
+ seconds--;
+ }
+ };
+ runnable.runTaskTimer(Main.get(), 0, 20);
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/ReloadConfigsCommand.java b/src/main/java/timongcraft/system/commands/ReloadConfigsCommand.java
new file mode 100644
index 0000000..79a6b11
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/ReloadConfigsCommand.java
@@ -0,0 +1,30 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.command.CommandSender;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+public class ReloadConfigsCommand {
+
+ public static void register() {
+ new CommandTree("tgcreload-configs")
+ .withShortDescription("Reloads the plugin configs")
+ .withUsage("/tgcreload-configs")
+ .withPermission("tgc-system.team")
+ .executes(ReloadConfigsCommand::reloadConfigsManager)
+ .register();
+ }
+
+ private static int reloadConfigsManager(CommandSender sender, CommandArguments args) {
+ Main.get().reloadConfig();
+ Main.get().getDataConfig().load();
+
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Reloaded the plugins's configs"));
+ sender.sendMessage("§eNot all modules are compatible with config reloading!");
+ return 1;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/ReplyCommand.java b/src/main/java/timongcraft/system/commands/ReplyCommand.java
new file mode 100644
index 0000000..a7b3fe2
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/ReplyCommand.java
@@ -0,0 +1,60 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.ComponentBuilder;
+import net.md_5.bungee.api.chat.TranslatableComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class ReplyCommand {
+
+ private static final Map lastRepliedTo = new HashMap<>();
+
+ public static void register() {
+ new CommandTree("reply")
+ .withShortDescription("Reply to a private message")
+ .withUsage("/reply ")
+ .withAliases("r")
+ .then(new GreedyStringArgument("message")
+ .executesPlayer(ReplyCommand::replyManager))
+ .register();
+ }
+
+ private static int replyManager(Player sender, CommandArguments args) {
+ String message = (String) args.get("message");
+
+ if (!lastRepliedTo.containsKey(sender.getUniqueId())) {
+ sender.sendMessage(Main.get().getPrefix() + "§cYou have no one to reply to.");
+ return 0;
+ }
+
+ Player target = Bukkit.getPlayer(lastRepliedTo.get(sender.getUniqueId()));
+
+ if (target == null) {
+ sender.sendMessage(Main.get().getPrefix() + "§cThe player you last messaged is not online.");
+ return 0;
+ }
+
+ if (sender.hasPermission("tgc-system.team"))
+ message = message.replaceAll("&", "§");
+
+ sender.spigot().sendMessage(new ComponentBuilder(new TranslatableComponent("commands.message.display.outgoing", target.getName(), message)).color(ChatColor.GRAY).italic(true).create());
+ target.spigot().sendMessage(new ComponentBuilder(new TranslatableComponent("commands.message.display.incoming", sender.getName(), message)).color(ChatColor.GRAY).italic(true).create());
+ return 1;
+ }
+
+ public static void setLastReply(UUID senderUuid, UUID targetUuid) {
+ lastRepliedTo.put(senderUuid, targetUuid);
+ if (!lastRepliedTo.containsKey(targetUuid) || Bukkit.getPlayer(lastRepliedTo.get(targetUuid)) == null)
+ lastRepliedTo.put(targetUuid, senderUuid);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/ResourcePackCommand.java b/src/main/java/timongcraft/system/commands/ResourcePackCommand.java
new file mode 100644
index 0000000..cc5e29c
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/ResourcePackCommand.java
@@ -0,0 +1,42 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.executors.CommandArguments;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+
+import java.util.HexFormat;
+
+public class ResourcePackCommand {
+
+ public static void register() {
+ new CommandTree("resourcepack")
+ .withShortDescription("Toggle the server resource pack")
+ .withUsage("/resourcepack")
+ .withRequirement(sender -> (Main.get().getConfig().isSet("resourcePack.url") && !Main.get().getConfig().getString("resourcePack.url").isEmpty()) && (Main.get().getConfig().isSet("resourcePack.hash") && !Main.get().getConfig().getString("resourcePack.hash").isEmpty()))
+ .withPermission("tgc-system.team")
+ .executesPlayer(ResourcePackCommand::resourcePackManager)
+ .register();
+ }
+
+ private static void resourcePackManager(Player sender, CommandArguments args) {
+ if (!Main.get().getDataConfig().isSet("players." + sender.getUniqueId() + ".resourcepack"))
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".resourcepack", false);
+
+ if (Main.get().getDataConfig().getBoolean("players." + sender.getUniqueId() + ".resourcepack")) {
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".resourcepack", false);
+ sender.sendMessage(Main.get().getPrefix() + "Disabled resource pack request");
+ } else {
+ Main.get().getDataConfig().set("players." + sender.getUniqueId() + ".resourcepack", true);
+ sender.sendMessage(Main.get().getPrefix() + "Enabled resource pack request");
+
+ final String url = Main.get().getConfig().getString("resourcePack.url");
+ final byte[] hash = HexFormat.of().parseHex(Main.get().getConfig().getString("resourcePack.hash"));
+
+ if (url != null && hash != null && sender.hasPermission("tgc-system.team") && Main.get().getDataConfig().getBoolean("players." + sender.getUniqueId() + ".resourcepack"))
+ sender.setResourcePack(url, hash, false);
+ }
+ Main.get().getDataConfig().save();
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/commands/SayCommand.java b/src/main/java/timongcraft/system/commands/SayCommand.java
new file mode 100644
index 0000000..dbcb061
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/SayCommand.java
@@ -0,0 +1,30 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandAPIBukkit;
+import dev.jorel.commandapi.CommandPermission;
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TranslatableComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+
+public class SayCommand {
+
+ public static void register() {
+ CommandAPIBukkit.unregister("say", true, false);
+
+ new CommandTree("say")
+ .withShortDescription("Send a message from that sender")
+ .withUsage("/say ")
+ .withPermission(CommandPermission.OP)
+ .then(new GreedyStringArgument("message")
+ .executes(SayCommand::sayManager))
+ .register();
+ }
+
+ private static void sayManager(CommandSender sender, CommandArguments args) {
+ Bukkit.spigot().broadcast(new TranslatableComponent("chat.type.announcement", sender.getName(), args.get("message")));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/StatusCommand.java b/src/main/java/timongcraft/system/commands/StatusCommand.java
new file mode 100644
index 0000000..653881c
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/StatusCommand.java
@@ -0,0 +1,47 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.StatusHandler;
+
+public class StatusCommand {
+
+ public static void register() {
+ new CommandTree("status")
+ .withShortDescription("Set a status for yourself in the chat and tab list")
+ .withUsage("/status []")
+ .withRequirement(sender -> Main.get().getConfig().getBoolean("statuses.enabled"))
+ .executesPlayer(StatusCommand::statusResetManager)
+ .then(new GreedyStringArgument("status")
+ .executesPlayer(StatusCommand::statusManager))
+ .register();
+ }
+
+ private static int statusResetManager(Player sender, CommandArguments args) {
+ if (StatusHandler.getStatus(sender) == null) {
+ sender.sendMessage(Main.get().getPrefix() + "§cUsage: /status []");
+ return 0;
+ }
+
+ StatusHandler.setStatus(sender, null);
+ sender.sendMessage(Main.get().getPrefix() + "Reset your status");
+ return 1;
+ }
+
+ private static int statusManager(Player sender, CommandArguments args) {
+ String status = (String) args.get("status");
+
+ if (status.replaceAll("&[a-z-0-9]", "").length() > Main.get().getConfig().getInt("statuses.characterLimit")) {
+ sender.sendMessage(Main.get().getPrefix() + "§cStatus can only be up to " + Main.get().getConfig().getInt("statuses.characterLimit") + " characters long!");
+ return 0;
+ }
+
+ StatusHandler.setStatus(sender, status.replaceAll("&", "§"));
+ sender.sendMessage(Main.get().getPrefix() + "Set your status to: " + status);
+ return 1;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/TeamMsgCommand.java b/src/main/java/timongcraft/system/commands/TeamMsgCommand.java
new file mode 100644
index 0000000..cb5fe21
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/TeamMsgCommand.java
@@ -0,0 +1,51 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandAPIBukkit;
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.GreedyStringArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.Team;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+
+public class TeamMsgCommand {
+
+ public static void register() {
+ CommandAPIBukkit.unregister("teammsg", true, false);
+ CommandAPIBukkit.unregister("tm", true, false);
+
+ new CommandTree("teammsg")
+ .withShortDescription("Send a private message to your team")
+ .withUsage("/teammsg ")
+ .withAliases("tm")
+ .then(new GreedyStringArgument("message")
+ .executesPlayer(TeamMsgCommand::teamMsgManager))
+ .register();
+ }
+
+ private static int teamMsgManager(Player sender, CommandArguments args) {
+ String message = (String) args.get("message");
+
+ if (sender.hasPermission("tgc-system.team"))
+ message = message.replaceAll("&", "§");
+
+ Team targetTeam = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(sender.getName());
+
+ if (targetTeam == null) {
+ sender.sendMessage(Main.get().getPrefix() + "§cYou must be on a team to message your team");
+ return 0;
+ }
+
+ for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
+ for (Team onlinePlayersTeam : onlinePlayer.getScoreboard().getTeams()) {
+ if (!onlinePlayersTeam.hasEntry(onlinePlayer.getName()) || !targetTeam.equals(onlinePlayersTeam))
+ continue;
+ onlinePlayer.sendMessage("-> " + targetTeam.getColor() + "[" + targetTeam.getDisplayName() + "] §r<" + MessageUtils.getPlayerNameWithStatus(sender, true) + "§r" + "> " + message);
+ }
+ }
+ return 1;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/commands/WalkSpeedCommand.java b/src/main/java/timongcraft/system/commands/WalkSpeedCommand.java
new file mode 100644
index 0000000..940f773
--- /dev/null
+++ b/src/main/java/timongcraft/system/commands/WalkSpeedCommand.java
@@ -0,0 +1,47 @@
+package timongcraft.system.commands;
+
+import dev.jorel.commandapi.CommandTree;
+import dev.jorel.commandapi.arguments.IntegerArgument;
+import dev.jorel.commandapi.executors.CommandArguments;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.util.MessageUtils;
+import timongcraft.system.util.PlayerOnlyArgument;
+
+public class WalkSpeedCommand {
+
+ public static void register() {
+ new CommandTree("walkspeed")
+ .withShortDescription("Set walk speed")
+ .withUsage("/walkspeed [] []")
+ .withAliases("ws")
+ .withPermission("tgc-system.team")
+ .executesPlayer(WalkSpeedCommand::walkSpeedOwnResetManager)
+ .then(new IntegerArgument("speed", 1, 10)
+ .executesPlayer(WalkSpeedCommand::walkSpeedOwnManager)
+ .then(new PlayerOnlyArgument("target")
+ .executes(WalkSpeedCommand::walkSpeedOtherManager)))
+ .register();
+ }
+
+ private static void walkSpeedOwnResetManager(Player sender, CommandArguments args) {
+ sender.setWalkSpeed(0.1f);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Walk speed has been reset"));
+ }
+
+ private static void walkSpeedOwnManager(Player sender, CommandArguments args) {
+ sender.setWalkSpeed((int) args.get("speed") / 10f);
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set walk speed to " + args.get("speed")));
+ }
+
+
+ private static void walkSpeedOtherManager(CommandSender sender, CommandArguments args) {
+ Player target = (Player) args.get("target");
+ target.setWalkSpeed((int) args.get("speed") / 10f);
+ target.sendMessage(Main.get().getPrefix() + "Walk speed has been set to " + args.get("speed") + " by " + sender.getName());
+ MessageUtils.sendAdminMessage(sender, new TextComponent("Set walk speed of " + target.getName() + " to " + args.get("speed")));
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/listeners/BlockCommandsListeners.java b/src/main/java/timongcraft/system/listeners/BlockCommandsListeners.java
new file mode 100644
index 0000000..4d8604b
--- /dev/null
+++ b/src/main/java/timongcraft/system/listeners/BlockCommandsListeners.java
@@ -0,0 +1,54 @@
+package timongcraft.system.listeners;
+
+import dev.jorel.commandapi.CommandAPIBukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import org.bukkit.event.player.PlayerCommandSendEvent;
+import timongcraft.system.Main;
+
+import java.util.Iterator;
+import java.util.List;
+
+public class BlockCommandsListeners implements Listener {
+
+ public BlockCommandsListeners() {
+ List blockedCommands = Main.get().getConfig().getStringList("blockedCommands");
+
+ for (String command : blockedCommands)
+ CommandAPIBukkit.unregister(command, true, true);
+ }
+
+ @EventHandler
+ public void blockPrefixes(PlayerCommandPreprocessEvent event) {
+ Player player = event.getPlayer();
+
+ if (player.hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedPrefixes").isEmpty())
+ return;
+ for (String blockedPrefixes : Main.get().getConfig().getStringList("blockedPrefixes")) {
+ if (event.getMessage().toLowerCase().startsWith("/" + blockedPrefixes)) {
+ event.setCancelled(true);
+ player.sendMessage(Main.get().getPrefix() + "§cThe '" + blockedPrefixes + "' prefix is blocked!");
+ break;
+ }
+ }
+ }
+
+ @EventHandler
+ public void hidePrefixes(PlayerCommandSendEvent event) {
+ Iterator iterator = event.getCommands().iterator();
+ if (event.getPlayer().hasPermission("tgc-system.team") || Main.get().getConfig().getStringList("blockedPrefixes").isEmpty())
+ return;
+ while (iterator.hasNext()) {
+ String command = iterator.next();
+ for (String blockedPrefixes : Main.get().getConfig().getStringList("blockedPrefixes")) {
+ if (command.startsWith(blockedPrefixes)) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/timongcraft/listeners/ConnectionListeners.java b/src/main/java/timongcraft/system/listeners/ConnectionListeners.java
similarity index 57%
rename from src/main/java/timongcraft/listeners/ConnectionListeners.java
rename to src/main/java/timongcraft/system/listeners/ConnectionListeners.java
index f4ece97..61a676c 100644
--- a/src/main/java/timongcraft/listeners/ConnectionListeners.java
+++ b/src/main/java/timongcraft/system/listeners/ConnectionListeners.java
@@ -1,4 +1,4 @@
-package timongcraft.listeners;
+package timongcraft.system.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -8,14 +8,15 @@
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
-import timongcraft.Main;
-import timongcraft.commands.MaintenanceCommand;
-import timongcraft.util.StatusHandler;
+import timongcraft.system.Main;
+import timongcraft.system.commands.MaintenanceCommand;
+import timongcraft.system.util.StatusHandler;
import java.io.File;
import java.util.*;
public class ConnectionListeners implements Listener {
+
public static final List resourcePackLoaded = new ArrayList<>();
@EventHandler
@@ -59,14 +60,13 @@ public void onQuit(PlayerQuitEvent event) {
}
private void motdHandler(ServerListPingEvent event) {
- if(Main.get().getConfig().getBoolean("motds.hiddenMode")) {
+ if (Main.get().getConfig().getBoolean("motds.hiddenMode")) {
String ipAddress = event.getAddress().toString().substring(1).split(":")[0];
List knownIpAddresses = new ArrayList<>();
- for(Player player : Bukkit.getOnlinePlayers()) {
- if(Main.get().getDataConfig().isSet("players." + player.getUniqueId() + ".ipAddress")) {
- knownIpAddresses.add(Main.get().getDataConfig().getString("players." + player.getUniqueId() + ".ipAddress"));
- }
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ if (!Main.get().getDataConfig().isSet("players." + player.getUniqueId() + ".ipAddress")) continue;
+ knownIpAddresses.add(Main.get().getDataConfig().getString("players." + player.getUniqueId() + ".ipAddress"));
}
if (!knownIpAddresses.contains(ipAddress)) {
@@ -77,46 +77,39 @@ private void motdHandler(ServerListPingEvent event) {
}
}
- if(Main.get().getConfig().getBoolean("motds.enabled") && !Main.get().getConfig().getStringList("motds.list").isEmpty()) {
+ if (Main.get().getConfig().getBoolean("motds.enabled") && !Main.get().getConfig().getStringList("motds.list").isEmpty()) {
String motd = Main.get().getConfig().getStringList("motds.list").get(new Random().nextInt(Main.get().getConfig().getStringList("motds.list").size()));
event.setMotd(motd.replaceAll("&", "§"));
}
}
private void maintenanceServerPingHandler(ServerListPingEvent event) {
- if(Main.get().getDataConfig().getBoolean("maintenance.enabled")) {
- event.setMotd(Main.get().getConfig().getString("maintenance.motd"));
- event.setMaxPlayers(0);
- if(Main.get().getConfig().getBoolean("maintenance.icon")) {
- File maintenanceIcon = new File(Main.get().getDataFolder(), "maintenance-icon.png");
- if(maintenanceIcon.exists()) {
- try {
- event.setServerIcon(Bukkit.loadServerIcon(maintenanceIcon));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
+ if (!Main.get().getDataConfig().getBoolean("maintenance.enabled")) return;
+ event.setMotd(Main.get().getConfig().getString("maintenance.motd"));
+ event.setMaxPlayers(0);
+ if (!Main.get().getConfig().getBoolean("maintenance.icon")) return;
+ File maintenanceIcon = new File(Main.get().getDataFolder(), "maintenance-icon.png");
+ if (!maintenanceIcon.exists()) return;
+ try {
+ event.setServerIcon(Bukkit.loadServerIcon(maintenanceIcon));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
}
}
private void maintenanceJoinHandler(Player player, PlayerLoginEvent event) {
- if(Main.get().getDataConfig().getBoolean("maintenance.enabled") && !MaintenanceCommand.isAllowed(player)) {
- Main.get().getLogger().info(Main.get().getPrefix() + player.getName() + " tried to join while maintenance mode");
- for (Player onlinePlayers : Bukkit.getOnlinePlayers()) {
- if(onlinePlayers.hasPermission("tgc-system.team")) {
- onlinePlayers.sendMessage(Main.get().getPrefix() + player.getName() + " tried to join while maintenance mode");
- }
- }
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER, Main.get().getConfig().getString("maintenance.kickMessage"));
- }
+ if (!Main.get().getDataConfig().getBoolean("maintenance.enabled") || MaintenanceCommand.isAllowed(player.getUniqueId()))
+ return;
+ Main.get().getLogger().info(Main.get().getPrefix() + player.getName() + " tried to join while maintenance mode");
+ Bukkit.broadcast(Main.get().getPrefix() + player.getName() + " tried to join while maintenance mode", "tgc-system.team");
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, Main.get().getConfig().getString("maintenance.kickMessage"));
}
private void permissionJoinHandler(Player player) {
List playerPermissions = Main.get().getDataConfig().getStringList("players." + player.getUniqueId() + ".permissions");
List playerGroups = Main.get().getDataConfig().getStringList("players." + player.getUniqueId() + ".groups");
- if(!playerGroups.contains("default")) playerGroups.add("default");
+ if (!playerGroups.contains("default")) playerGroups.add("default");
for (String permissionString : playerPermissions) {
String[] permissionParts = permissionString.split(":");
@@ -135,56 +128,47 @@ private void permissionJoinHandler(Player player) {
}
private void resourcePackJoinHandler(Player player) {
- if(Main.get().getConfig().isSet("resourcePack.url") && !Main.get().getConfig().getString("resourcePack.url").isEmpty()) {
+ if (Main.get().getConfig().isSet("resourcePack.url") && !Main.get().getConfig().getString("resourcePack.url").isEmpty()) {
final String url = Main.get().getConfig().getString("resourcePack.url");
final byte[] hash = HexFormat.of().parseHex(Main.get().getConfig().getString("resourcePack.hash"));
final String promt = Main.get().getConfig().getString("resourcePack.promt");
final boolean force = Main.get().getConfig().getBoolean("resourcePack.force");
- if(url != null && hash != null && !player.hasPermission("tgc-system.team")) {
+ if (url != null && hash != null && !player.hasPermission("tgc-system.team"))
player.setResourcePack(url, hash, promt, force);
- }
- if(url != null && hash != null && player.hasPermission("tgc-system.team") && Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".resourcepack")) {
+ if (url != null && hash != null && player.hasPermission("tgc-system.team") && Main.get().getDataConfig().getBoolean("players." + player.getUniqueId() + ".resourcepack"))
player.setResourcePack(url, hash, false);
- }
- if(Main.get().getConfig().getBoolean("resourcePack.force")) {
- Bukkit.getScheduler().runTaskLater(Main.get(), () -> {
- if (!player.isOnline() || player.hasPermission("tgc-system.team")) return;
+ if (!Main.get().getConfig().getBoolean("resourcePack.force")) return;
- if (!resourcePackLoaded.contains(player.getUniqueId())) {
- player.kickPlayer("§cYou must use the server's resource pack.");
- }
- resourcePackLoaded.remove(player.getUniqueId());
- }, Main.get().getConfig().isSet("resourcePack.maxLoadTime") ? Main.get().getConfig().getInt("resourcePack.maxLoadTime") * 20L : 300L);
- }
+ Bukkit.getScheduler().runTaskLater(Main.get(), () -> {
+ if (!player.isOnline() || player.hasPermission("tgc-system.team")) return;
+
+ if (!resourcePackLoaded.contains(player.getUniqueId()))
+ player.kickPlayer("§cYou must use the server's resource pack.");
+ resourcePackLoaded.remove(player.getUniqueId());
+ }, Main.get().getConfig().isSet("resourcePack.maxLoadTime") ? Main.get().getConfig().getInt("resourcePack.maxLoadTime") * 20L : 300L);
}
}
private void playerJoinMessageJoinHandler(Player player, PlayerJoinEvent event) {
- if(Main.get().getConfig().getBoolean("joinQuitMessage.enabled")) {
+ if (Main.get().getConfig().getBoolean("joinQuitMessage.enabled"))
event.setJoinMessage(Main.get().getConfig().getString("joinQuitMessage.joinMessage").replaceAll("%Player%", player.getName()).replaceAll("&", "§"));
- }
- if(Main.get().getConfig().getBoolean("onJoin.enabled")){
- if(Main.get().getConfig().getString("onJoin.message") != null) {
+ if (Main.get().getConfig().getBoolean("onJoin.enabled"))
+ if (Main.get().getConfig().getString("onJoin.message") != null)
player.sendMessage(Main.get().getConfig().getString("onJoin.message").replaceAll("%prefix%", Main.get().getPrefix().replaceAll("%alertPrefix%", Main.get().getConfig().getString("prefix.alertPrefix")).replaceAll("&", "§")));
- }
- }
String status = StatusHandler.getStatus(player);
- if(Main.get().getConfig().getBoolean("onJoin.status")){
- if(status != null) {
- player.sendMessage(Main.get().getPrefix() + "§aYour status is set to: " + status.replaceAll("&", "§"));
- }
- }
+ if (Main.get().getConfig().getBoolean("onJoin.status"))
+ if (status != null)
+ player.sendMessage(Main.get().getPrefix() + "Your status is set to: " + status.replaceAll("&", "§"));
}
private void playerNameQuitHandler(Player player, PlayerQuitEvent event) {
- if(Main.get().getConfig().getBoolean("joinQuitMessage.enabled")) {
+ if (Main.get().getConfig().getBoolean("joinQuitMessage.enabled"))
event.setQuitMessage(Main.get().getConfig().getString("joinQuitMessage.quitMessage").replaceAll("%Player%", player.getName()).replaceAll("&", "§"));
- }
}
-
+
}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/listeners/OtherListeners.java b/src/main/java/timongcraft/system/listeners/OtherListeners.java
new file mode 100644
index 0000000..9ab3a3d
--- /dev/null
+++ b/src/main/java/timongcraft/system/listeners/OtherListeners.java
@@ -0,0 +1,181 @@
+package timongcraft.system.listeners;
+
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.block.Block;
+import org.bukkit.block.data.Ageable;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.block.BlockFormEvent;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
+import timongcraft.system.Main;
+import timongcraft.system.util.ComponentUtils;
+import timongcraft.system.util.CoordsMessageUtils;
+import timongcraft.system.util.CropDrops;
+import timongcraft.system.util.MessageUtils;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class OtherListeners implements Listener {
+
+ private static final Pattern urlPattern = Pattern.compile("^(http://www\\.|https://www\\.|http://|https://)?[a-z0-9]+([\\-.][a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$");
+
+ @EventHandler
+ public void onPlayerChat(AsyncPlayerChatEvent event) {
+ if (event.isCancelled()) return;
+ if (!Main.get().getConfig().getBoolean("chatSystem.enabled")) return;
+
+ Player player = event.getPlayer();
+ TextComponent playerChatName;
+ String rawMessage = event.getMessage();
+ TextComponent message = new TextComponent();
+
+ if (!player.hasPermission("tgc-system.team") && Main.get().getConfig().getBoolean("chatSystem.noLinks")) {
+ for (String messagePart : rawMessage.split(" ")) {
+ if (!urlPattern.matcher(messagePart).matches()) continue;
+ player.sendMessage(Main.get().getPrefix() + "§cYou don't have the permission to send links!");
+ event.setCancelled(true);
+ return;
+ }
+ }
+
+ if (Main.get().getConfig().getBoolean("statuses.enabled")) {
+ if (player.hasPermission("tgc-system.team")) {
+ playerChatName = new TextComponent("§4<§c" + MessageUtils.getPlayerNameWithStatus(player, true) + "§4>§f ");
+ } else
+ playerChatName = new TextComponent("§8<§7" + MessageUtils.getPlayerNameWithStatus(player, true) + "§8>§7 ");
+ } else {
+ if (player.hasPermission("tgc-system.team")) {
+ playerChatName = new TextComponent("§4<§c" + MessageUtils.getPlayerNameWithStatus(player, false) + "§4>§f ");
+ } else
+ playerChatName = new TextComponent("§f<" + MessageUtils.getPlayerNameWithStatus(player, false) + "§f> ");
+ }
+
+ if (player.hasPermission("tgc-system.team"))
+ rawMessage = rawMessage.replaceAll("&", "§");
+
+ if (Main.get().getConfig().getBoolean("coordsSaver.enabled")) {
+ if (Main.get().getConfig().getBoolean("coordsSaver.xaerosWaypointCompatability")) {
+ TextComponent xaerosWaypoint = CoordsMessageUtils.getXaerosWaypointAsClickableCoordinatesMessage(rawMessage);
+
+ if (xaerosWaypoint != null) {
+ message.addExtra(xaerosWaypoint);
+ } else {
+ message.addExtra(CoordsMessageUtils.getAsClickableCoordinatesMessage(event.getPlayer(), rawMessage, true));
+ }
+ } else {
+ message.addExtra(CoordsMessageUtils.getAsClickableCoordinatesMessage(event.getPlayer(), rawMessage, false));
+ }
+ }
+
+ if (player.hasPermission("tgc-system.team") && rawMessage.startsWith(Main.get().getConfig().getString("prefix.teamChatPrefixInChat"))) {
+ for (Player teamPlayer : Bukkit.getOnlinePlayers())
+ if (teamPlayer.hasPermission("tgc-system.team"))
+ teamPlayer.spigot().sendMessage(new TextComponent(Main.get().getConfig().getString("prefix.teamChatPrefix")), message);
+ event.setCancelled(true);
+ return;
+ }
+
+ String legacyMessage = message.toLegacyText();
+ for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
+ TextComponent modifiedMessage = message.duplicate();
+
+ if (legacyMessage.contains(onlinePlayer.getName())) {
+ ChatColor highlightColor = (onlinePlayer.hasPermission("tgc-system.team") && (player.hasPermission("tgc-system.team"))) ? ChatColor.YELLOW : ChatColor.WHITE;
+ ComponentUtils.findAllTextComponents(modifiedMessage, textComponent ->
+ textComponent.setText(textComponent.getText().replaceAll(onlinePlayer.getName(), highlightColor + onlinePlayer.getName() + ChatColor.RESET)));
+
+ if (highlightColor == ChatColor.YELLOW)
+ onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_BIT, 1.0F, 2.0F);
+ }
+
+ if (Main.get().getConfig().getBoolean("chatSystem.timeStampInChat.enabled")) {
+ TextComponent timeStamp = new TextComponent("§7[" + DateTimeFormatter.ofPattern(Main.get().getConfig().getString("chatSystem.timeStampInChat.format")).format(ZonedDateTime.now(ZoneId.of(Main.get().getConfig().getString("chatSystem.timeStampInChat.timeZone")))) + "] §f");
+
+ onlinePlayer.spigot().sendMessage(timeStamp, playerChatName, modifiedMessage);
+ } else {
+ onlinePlayer.spigot().sendMessage(playerChatName, modifiedMessage);
+ }
+ }
+
+ Bukkit.getLogger().info("Chat: " + ChatColor.stripColor("<" + player.getName() + "> " + legacyMessage));
+
+ event.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onPlayerCropInteract(PlayerInteractEvent event) {
+ if (!Main.get().getConfig().getBoolean("easyHarvest.enabled")) return;
+ if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
+
+ Block block = event.getClickedBlock();
+ if (block == null) return;
+ final Map cropDrops = Map.of(
+ Material.WHEAT, new CropDrops(new CropDrops.CropDrop(1, 1, Material.WHEAT, 100), new CropDrops.CropDrop(1, 3, Material.WHEAT_SEEDS, 100)),
+ Material.POTATOES, new CropDrops(new CropDrops.CropDrop(2, 4, Material.POTATO, 100), new CropDrops.CropDrop(1, 1, Material.POISONOUS_POTATO, 2)),
+ Material.CARROTS, new CropDrops(new CropDrops.CropDrop(1, 4, Material.CARROT, 100)),
+ Material.BEETROOTS, new CropDrops(new CropDrops.CropDrop(1, 1, Material.BEETROOT, 100), new CropDrops.CropDrop(1, 3, Material.BEETROOT_SEEDS, 100)),
+ Material.COCOA, new CropDrops(new CropDrops.CropDrop(2, 2, Material.COCOA_BEANS, 100))
+ );
+ if (!cropDrops.containsKey(block.getType())) return;
+
+ Player player = event.getPlayer();
+ if (player.isSneaking()) return;
+
+ Ageable ageable = (Ageable) block.getBlockData();
+ if (ageable.getAge() != ageable.getMaximumAge()) return;
+
+ CropDrops drops = cropDrops.get(block.getType());
+ if (drops == null) return;
+
+ ageable.setAge(0);
+ block.setBlockData(ageable);
+ player.swingMainHand();
+
+ for (CropDrops.CropDrop cropDrop : drops.getRandoms())
+ block.getWorld().dropItemNaturally(block.getLocation(), cropDrop.getRandom());
+ player.playSound(player.getLocation(), Sound.BLOCK_CROP_BREAK, 1.0f, 1.0f);
+ event.setUseItemInHand(Event.Result.DENY);
+ }
+
+ @EventHandler
+ public void onBlockForm(BlockFormEvent event) {
+ if (event.getBlock().getLocation().getBlockY() >= 0) return;
+ if (!Main.get().getConfig().getBoolean("deepslateGenerator.enabled")) return;
+ Material newMaterial = switch (event.getNewState().getType()) {
+ case COBBLESTONE -> Material.COBBLED_DEEPSLATE;
+ case STONE -> Material.DEEPSLATE;
+ default -> null;
+ };
+
+ if (newMaterial == null) return;
+ event.getNewState().setType(newMaterial);
+ }
+
+ @EventHandler
+ public void onPlayerResourcePackStatus(PlayerResourcePackStatusEvent event) {
+ Player player = event.getPlayer();
+ if (!Main.get().getConfig().getBoolean("resourcePack.force")) return;
+ if (player.hasPermission("tgc-system.team")) return;
+ PlayerResourcePackStatusEvent.Status status = event.getStatus();
+
+ if (status == PlayerResourcePackStatusEvent.Status.DECLINED || status == PlayerResourcePackStatusEvent.Status.FAILED_DOWNLOAD)
+ player.kickPlayer("§cYou are required to use the server's resource pack.");
+
+ if (status == PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED)
+ ConnectionListeners.resourcePackLoaded.add(player.getUniqueId());
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/listeners/SpawnElytraListeners.java b/src/main/java/timongcraft/system/listeners/SpawnElytraListeners.java
similarity index 51%
rename from src/main/java/timongcraft/listeners/SpawnElytraListeners.java
rename to src/main/java/timongcraft/system/listeners/SpawnElytraListeners.java
index 9c6036d..fee21f4 100644
--- a/src/main/java/timongcraft/listeners/SpawnElytraListeners.java
+++ b/src/main/java/timongcraft/system/listeners/SpawnElytraListeners.java
@@ -1,4 +1,4 @@
-package timongcraft.listeners;
+package timongcraft.system.listeners;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ComponentBuilder;
@@ -14,28 +14,29 @@
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
-import timongcraft.Main;
+import timongcraft.system.Main;
import java.util.ArrayList;
import java.util.List;
public class SpawnElytraListeners implements Listener {
+
private final List flying = new ArrayList<>();
private final List boosted = new ArrayList<>();
public SpawnElytraListeners() {
Bukkit.getScheduler().runTaskTimer(Main.get(), () -> {
- for(Player playerInWorld : Bukkit.getWorld(String.valueOf(Main.get().getConfig().getString("spawnElytra.worldName"))).getPlayers()) {
- if(playerInWorld.getGameMode() == GameMode.SPECTATOR || playerInWorld.getGameMode() == GameMode.CREATIVE) return;
+ for (Player playerInWorld : Bukkit.getWorld(String.valueOf(Main.get().getConfig().getString("spawnElytra.worldName"))).getPlayers()) {
+ if (playerInWorld.getGameMode() == GameMode.SPECTATOR || playerInWorld.getGameMode() == GameMode.CREATIVE)
+ return;
playerInWorld.setAllowFlight(isInSpawnRadius(playerInWorld));
- if(flying.contains(playerInWorld) && !playerInWorld.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isAir()) {
+ if (flying.contains(playerInWorld) && !playerInWorld.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isAir()) {
playerInWorld.setAllowFlight(false);
playerInWorld.setFlying(false);
playerInWorld.setGliding(false);
boosted.remove(playerInWorld);
- Bukkit.getScheduler().runTaskLater(Main.get(), () -> {
- flying.remove(playerInWorld);
- },5);
+ Bukkit.getScheduler().runTaskLater(Main.get(), () ->
+ flying.remove(playerInWorld), 5);
}
}
}, 0, 4);
@@ -45,45 +46,50 @@ public SpawnElytraListeners() {
@EventHandler
public void onDoubleJump(PlayerToggleFlightEvent event) {
Player player = event.getPlayer();
- if(player.getGameMode() == GameMode.SPECTATOR || player.getGameMode() == GameMode.CREATIVE) return;
+ if (player.getGameMode() == GameMode.SPECTATOR || player.getGameMode() == GameMode.CREATIVE) return;
event.setCancelled(true);
player.setGliding(true);
flying.add(player);
- if(Main.get().getConfig().getBoolean("spawnElytra.boost.enabled")) {
- player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder("Press ")
- .append(new KeybindComponent("key.swapOffhand"))
- .append(" to boost")
- .create());
+ if (Main.get().getConfig().getBoolean("spawnElytra.boost.enabled")) {
+ player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new ComponentBuilder("Press ").append(new KeybindComponent("key.swapOffhand")).append(" to boost").create());
}
}
@EventHandler
public void onDamage(EntityDamageEvent event) {
- if(event.getEntityType() == EntityType.PLAYER
- && (event.getCause() == EntityDamageEvent.DamageCause.FALL
- || event.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL)
- && flying.contains(event.getEntity())) event.setCancelled(true);
+ if (event.getEntityType() != EntityType.PLAYER) return;
+ if (event.getCause() != EntityDamageEvent.DamageCause.FALL || event.getCause() != EntityDamageEvent.DamageCause.FLY_INTO_WALL)
+ return;
+ if (!flying.contains((Player) event.getEntity())) return;
+
+ event.setCancelled(true);
}
@EventHandler
public void onSwapItem(PlayerSwapHandItemsEvent event) {
Player player = event.getPlayer();
- if(boosted.contains(player) || !Main.get().getConfig().getBoolean("spawnElytra.boost.enabled")) return;
+ if (boosted.contains(player) || !Main.get().getConfig().getBoolean("spawnElytra.boost.enabled")) return;
event.setCancelled(true);
boosted.add(player);
- for(Player playerInWorld : Bukkit.getWorld(String.valueOf(Main.get().getConfig().getString("spawnElytra.worldName"))).getPlayers()) {
- if(flying.contains(playerInWorld) && playerInWorld.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isAir()) player.setVelocity(player.getLocation().getDirection().multiply(Main.get().getConfig().getInt("spawnElytra.boost.enabled.multiplyValue")));
- }
+ for (Player playerInWorld : Bukkit.getWorld(String.valueOf(Main.get().getConfig().getString("spawnElytra.worldName"))).getPlayers())
+ if (flying.contains(playerInWorld) && playerInWorld.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().isAir())
+ player.setVelocity(player.getLocation().getDirection().multiply(Main.get().getConfig().getInt("spawnElytra.boost.enabled.multiplyValue")));
}
@EventHandler
public void onToggleGlide(EntityToggleGlideEvent event) {
- if(event.getEntityType() == EntityType.PLAYER && flying.contains(event.getEntity())) event.setCancelled(true);
+ if (event.getEntityType() != EntityType.PLAYER) return;
+ if (!flying.contains((Player) event.getEntity())) return;
+
+ event.setCancelled(true);
}
private Boolean isInSpawnRadius(Player player) {
- if(!player.getWorld().getName().equals(Main.get().getConfig().getString("spawnElytra.worldName"))) return false;
+ if (!player.getWorld().getName().equals(Main.get().getConfig().getString("spawnElytra.worldName")))
+ return false;
+
return player.getWorld().getSpawnLocation().distance(player.getLocation()) < Main.get().getConfig().getInt("spawnElytra.spawnRadius");
}
+
}
diff --git a/src/main/java/timongcraft/system/util/CommandAPILoader.java b/src/main/java/timongcraft/system/util/CommandAPILoader.java
new file mode 100644
index 0000000..e36bdbe
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/CommandAPILoader.java
@@ -0,0 +1,50 @@
+package timongcraft.system.util;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.InvalidDescriptionException;
+import org.bukkit.plugin.InvalidPluginException;
+import timongcraft.system.Main;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
+public class CommandAPILoader {
+
+ public static void load(String version, boolean noConfig) throws IOException, InvalidPluginException, InvalidDescriptionException {
+ try (Stream pathStream = Files.list(Path.of("plugins"))) {
+ if (pathStream.anyMatch(file -> {
+ if (!(file.getFileName().toString().toLowerCase().contains("commandapi") && file.getFileName().toString().endsWith(".jar")))
+ return false;
+
+ if (!file.getFileName().toString().toLowerCase().equals("commandapi-" + version + ".jar")) {
+ if (noConfig || Main.get().getConfig().getBoolean("commandAPI.warnings")) {
+ Main.get().getLogger().warning("You may have loaded an incompatible version of CommandAPI. For best compatibility, use version " + version + ".");
+ }
+ }
+ return true;
+ })) return;
+ }
+
+ Main.get().getLogger().info("Required library CommandAPI not found, loading compatible version automatically...");
+
+ URL url = new URL("https://github.com/JorelAli/CommandAPI/releases/download/" + version + "/CommandAPI-" + version + ".jar");
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setRequestMethod("GET");
+
+ int responseCode = con.getResponseCode();
+ if (responseCode != 200) {
+ Main.get().getLogger().warning("Failed to load required library CommandAPI. Response code: " + responseCode);
+ }
+
+ Path commandAPIPath = Path.of("plugins/CommandAPI-" + version + ".jar");
+
+ Files.copy(con.getInputStream(), commandAPIPath);
+ con.disconnect();
+ Bukkit.getPluginManager().loadPlugin(commandAPIPath.toFile());
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/util/ComponentUtils.java b/src/main/java/timongcraft/system/util/ComponentUtils.java
new file mode 100644
index 0000000..8fa4fc4
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/ComponentUtils.java
@@ -0,0 +1,24 @@
+package timongcraft.system.util;
+
+import net.md_5.bungee.api.chat.BaseComponent;
+import net.md_5.bungee.api.chat.TextComponent;
+
+import java.util.function.Consumer;
+
+public class ComponentUtils {
+
+ public static void findAllTextComponents(BaseComponent component, Consumer consumer) {
+ if (component instanceof TextComponent textComponent)
+ consumer.accept(textComponent);
+
+ if (component.getExtra() == null) return;
+
+ for (BaseComponent c : component.getExtra()) {
+ if (c instanceof TextComponent textComponent)
+ consumer.accept(textComponent);
+
+ findAllTextComponents(c, consumer);
+ }
+ }
+
+}
diff --git a/src/main/java/timongcraft/system/util/CoordsMessageUtils.java b/src/main/java/timongcraft/system/util/CoordsMessageUtils.java
new file mode 100644
index 0000000..43c84fd
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/CoordsMessageUtils.java
@@ -0,0 +1,145 @@
+package timongcraft.system.util;
+
+import net.md_5.bungee.api.chat.ClickEvent;
+import net.md_5.bungee.api.chat.HoverEvent;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.chat.hover.content.Text;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import timongcraft.system.Main;
+import timongcraft.system.commands.CoordinatesCommand;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class CoordsMessageUtils {
+
+ public static TextComponent getAsClickableCoordinatesMessage(Player player, String message, boolean withXaerosWaypoint) {
+ Pattern coordsPattern = Pattern.compile("\\[coords(:.+)?]");
+ Matcher coordsTextMatcher = coordsPattern.matcher(message);
+ TextComponent finalMessage = new TextComponent();
+
+ int lastEndIndex = 0;
+ while (coordsTextMatcher.find()) {
+ String match = coordsTextMatcher.group();
+ String coordName = match.equals("[coords]") ? null : match.substring(8, match.length() - 1);
+
+ finalMessage.addExtra(new TextComponent(message.substring(lastEndIndex, coordsTextMatcher.start())));
+
+ TextComponent coordsComponent = new TextComponent();
+ if (coordName == null) {
+ Location playerLocation = player.getLocation().getBlock().getLocation();
+ String playerCoords = (int) playerLocation.getX() + " " + (int) playerLocation.getY() + " " + (int) playerLocation.getZ();
+ ChatColor color = CoordinatesCommand.getEnvironmentColor(player.getWorld().getEnvironment().name());
+
+ coordsComponent = new TextComponent(color + "[" + playerCoords + "]§r");
+ coordsComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, playerCoords));
+ coordsComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy raw coordinates.")));
+
+ if (withXaerosWaypoint) {
+ String coords = player.getName() + ":" + playerCoords.replaceAll(" ", ",") + ":" + player.getWorld().getEnvironment().name();
+ TextComponent xaerosComponent = new TextComponent(" §8§k" + getXaerosWaypoint(coords.split(":")));
+ xaerosComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://modrinth.com/mod/xaeros-minimap"));
+ xaerosComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6This is for players using the xaero's minimap mod.")));
+ coordsComponent.addExtra(xaerosComponent);
+ }
+ } else {
+ List coordinatesList = Main.get().getDataConfig().getStringList("players." + player.getUniqueId() + ".coords");
+ boolean found = false;
+ for (String coordinate : coordinatesList) {
+ String coordinateName = coordinate.split(":")[0];
+ if (coordName.equals(coordinateName)) {
+ ChatColor color = CoordinatesCommand.getEnvironmentColor(coordinate.split(":")[2]);
+ String coordinateCoordinates = coordinate.split(":")[1].replaceAll(",", " ");
+
+ TextComponent nameComponent = new TextComponent(color + "[" + coordinateName);
+ nameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/coords save " + coordinate));
+ nameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to save.")));
+ coordsComponent.addExtra(nameComponent);
+
+ TextComponent coordsCordsComponent = new TextComponent(color + " (" + coordinateCoordinates + ")" + "]§r");
+ coordsCordsComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, coordinateCoordinates));
+ coordsCordsComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy raw coordinates.")));
+ coordsComponent.addExtra(coordsCordsComponent);
+
+ if (withXaerosWaypoint) {
+ TextComponent xaerosComponent = new TextComponent(" §8§k" + getXaerosWaypoint(coordinate.split(":")));
+ xaerosComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://modrinth.com/mod/xaeros-minimap"));
+ xaerosComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6This is for players using the xaero's minimap mod.")));
+ coordsComponent.addExtra(xaerosComponent);
+ }
+
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ coordsComponent = new TextComponent("§4[" + coordName + " not found]");
+ coordsComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§4The player sent invalid coordinates.")));
+ }
+ }
+
+ finalMessage.addExtra(coordsComponent);
+
+ lastEndIndex = coordsTextMatcher.end();
+ }
+
+ finalMessage.addExtra(new TextComponent(message.substring(lastEndIndex)));
+ return finalMessage;
+ }
+
+ public static TextComponent getXaerosWaypointAsClickableCoordinatesMessage(String message) {
+ Pattern pattern = Pattern.compile("xaero-waypoint:[\\w\\s]+:\\w:[-]?\\d+:[-]?\\d+:[-]?\\d+:[-]?\\d+:(true|false):[-]?\\d+:Internal-\\w+-waypoints");
+ Matcher matcher = pattern.matcher(message);
+
+ if (!matcher.matches()) return null;
+
+ String[] xaerosWaypoint = message.split(":");
+ TextComponent coordsComponent = new TextComponent();
+
+ String coordinateName = xaerosWaypoint[1];
+ String cleanCoordinateCoordinates = xaerosWaypoint[3] + " " + xaerosWaypoint[4] + " " + xaerosWaypoint[5];
+ String coordinateEnvironment = getEnvironment(xaerosWaypoint[9]);
+ ChatColor color = CoordinatesCommand.getEnvironmentColor(coordinateEnvironment);
+ String coordinate = coordinateName + ":" + cleanCoordinateCoordinates.replaceAll(" ", ",") + ":" + coordinateEnvironment;
+
+ TextComponent nameComponent = new TextComponent(color + "[" + coordinateName);
+ nameComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/coords save " + coordinate));
+ nameComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to save.")));
+ coordsComponent.addExtra(nameComponent);
+
+ TextComponent coordsCordsComponent = new TextComponent(color + " (" + cleanCoordinateCoordinates + ")" + "]§r");
+ coordsCordsComponent.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, cleanCoordinateCoordinates));
+ coordsCordsComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6Click to copy raw coords.")));
+ coordsComponent.addExtra(coordsCordsComponent);
+
+ TextComponent xaerosComponent = new TextComponent(" §8§k" + getXaerosWaypoint(coordinate.split(":")));
+ xaerosComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://modrinth.com/mod/xaeros-minimap"));
+ xaerosComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§6This is for players using the xaero's minimap mod.")));
+ coordsComponent.addExtra(xaerosComponent);
+
+ return coordsComponent;
+ }
+
+ private static String getXaerosWaypoint(String[] coords) {
+ return "xaero-waypoint:" + coords[0] + ":" + coords[0].charAt(0) + ":" + coords[1].replaceAll(",", ":") + ":0:false:0:" + switch (coords[2]) {
+ case "NORMAL" -> "Internal-overworld-waypoints";
+ case "NETHER" -> "Internal-the-nether-waypoints";
+ case "THE_END" -> "Internal-the-end-waypoints";
+ default -> "Internal-CUSTOM-waypoints";
+ };
+ }
+
+ private static String getEnvironment(String xaerosWorld) {
+ return switch (xaerosWorld) {
+ case "Internal-overworld-waypoints" -> "NORMAL";
+ case "Internal-the-nether-waypoints" -> "NETHER";
+ case "Internal-the-end-waypoints" -> "THE_END";
+ default -> "CUSTOM";
+ };
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/util/CropDrops.java b/src/main/java/timongcraft/system/util/CropDrops.java
similarity index 56%
rename from src/main/java/timongcraft/util/CropDrops.java
rename to src/main/java/timongcraft/system/util/CropDrops.java
index ee2384f..4d43428 100644
--- a/src/main/java/timongcraft/util/CropDrops.java
+++ b/src/main/java/timongcraft/system/util/CropDrops.java
@@ -1,4 +1,7 @@
-package timongcraft.util;
+package timongcraft.system.util;
+
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
@@ -6,7 +9,9 @@
import java.util.stream.Collectors;
public class CropDrops {
+
private final List drops;
+
public CropDrops(CropDrop... drops) {
this.drops = Arrays.asList(drops);
}
@@ -15,4 +20,12 @@ public List getRandoms() {
return drops.stream().filter((cropDrop -> new Random().nextInt(0, 101) <= cropDrop.dropChance()))
.collect(Collectors.toList());
}
+
+ public record CropDrop(int min, int max, Material material, int dropChance) {
+ public ItemStack getRandom() {
+ int nextInt = new Random().nextInt(min(), max() + 1);
+ return new ItemStack(material(), nextInt);
+ }
+ }
+
}
diff --git a/src/main/java/timongcraft/util/DataConfigHandler.java b/src/main/java/timongcraft/system/util/DataConfigHandler.java
similarity index 91%
rename from src/main/java/timongcraft/util/DataConfigHandler.java
rename to src/main/java/timongcraft/system/util/DataConfigHandler.java
index 7223c2f..3df43f0 100644
--- a/src/main/java/timongcraft/util/DataConfigHandler.java
+++ b/src/main/java/timongcraft/system/util/DataConfigHandler.java
@@ -1,14 +1,15 @@
-package timongcraft.util;
+package timongcraft.system.util;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
-import timongcraft.Main;
+import timongcraft.system.Main;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
public class DataConfigHandler extends YamlConfiguration {
+
private final File file;
public DataConfigHandler(File file) {
@@ -35,9 +36,10 @@ public void save() {
}
public void checkIfExists() throws IOException {
- if(!file.exists()) {
+ if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
}
+
}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/util/HopperFilterHandler.java b/src/main/java/timongcraft/system/util/HopperFilterHandler.java
new file mode 100644
index 0000000..f85ea71
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/HopperFilterHandler.java
@@ -0,0 +1,61 @@
+package timongcraft.system.util;
+
+import org.bukkit.block.Container;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
+import org.bukkit.event.inventory.InventoryPickupItemEvent;
+import org.bukkit.event.inventory.InventoryType;
+import timongcraft.system.commands.HopperFiltersCommand;
+
+import java.util.HashMap;
+import java.util.regex.Pattern;
+
+public class HopperFilterHandler implements Listener {
+
+ HashMap patternCache;
+
+ public HopperFilterHandler() {
+ patternCache = new HashMap<>();
+ }
+
+ @EventHandler
+ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
+ if (!event.getDestination().getType().equals(InventoryType.HOPPER)) return;
+ if (!(event.getDestination().getHolder() instanceof Container container)) return;
+ String filter = container.getCustomName();
+ if (filter == null || !filter.startsWith(HopperFiltersCommand.HOPPER_SORTER_PREFIX)) return;
+ filter = filter.substring(HopperFiltersCommand.HOPPER_SORTER_PREFIX.length());
+ if (filterMatch(filter, event.getItem().getType().getKey().getKey())) return;
+ event.setCancelled(true);
+ }
+
+ @EventHandler
+ public void onInventoryPickupItem(InventoryPickupItemEvent event) {
+ if (!event.getInventory().getType().equals(InventoryType.HOPPER)) return;
+ if (!(event.getInventory().getHolder() instanceof Container container)) return;
+ String filter = container.getCustomName();
+ if (filter == null || !filter.startsWith(HopperFiltersCommand.HOPPER_SORTER_PREFIX)) return;
+ filter = filter.substring(HopperFiltersCommand.HOPPER_SORTER_PREFIX.length());
+ if (filterMatch(filter, event.getItem().getItemStack().getType().getKey().getKey())) return;
+ event.setCancelled(true);
+ }
+
+ private boolean filterMatch(String filterString, String fullItemName) {
+ String[] sections = filterString.split(",");
+
+ boolean matchesPositive = false;
+ boolean matchesNegative = false;
+ for (String section : sections) {
+ boolean negative = section.startsWith("!");
+ if ((negative && matchesNegative) || (!negative && matchesPositive)) break;
+ if (negative) section = section.substring(1);
+ boolean match = fullItemName.matches("^" + section.replace("*", ".*").replace("?", ".") + "$");
+ if (negative) matchesNegative = match;
+ else matchesPositive = match;
+ }
+
+ return matchesPositive && !matchesNegative;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/system/util/MessageUtils.java b/src/main/java/timongcraft/system/util/MessageUtils.java
new file mode 100644
index 0000000..84cb897
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/MessageUtils.java
@@ -0,0 +1,63 @@
+package timongcraft.system.util;
+
+import net.md_5.bungee.api.ChatColor;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.chat.TranslatableComponent;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.scoreboard.Team;
+import timongcraft.system.Main;
+
+
+public class MessageUtils {
+
+ public static void sendAdminMessage(CommandSender sender, TextComponent message) {
+ sendAdminMessage(sender, true, message);
+ }
+
+ public static void sendAdminMessage(CommandSender sender, boolean sendToSender, TextComponent message) {
+ TranslatableComponent text = new TranslatableComponent("chat.type.admin", sender.getName(), message);
+ text.setColor(ChatColor.GRAY);
+ text.setItalic(true);
+
+ for (Player adminPlayer : Bukkit.getOnlinePlayers()) {
+ if (!adminPlayer.hasPermission("tgc-system.team")) continue;
+ if (adminPlayer.equals(sender)) {
+ if (sendToSender)
+ adminPlayer.spigot().sendMessage(new TextComponent(Main.get().getPrefix()), message);
+ continue;
+ }
+
+ adminPlayer.spigot().sendMessage(text);
+ }
+ }
+
+ public static void sendAdminMessage(String senderName, TextComponent message) {
+ sendAdminMessage(senderName, true, message);
+ }
+
+ public static void sendAdminMessage(String senderName, boolean sendToSender, TextComponent message) {
+ TranslatableComponent text = new TranslatableComponent("chat.type.admin", senderName, message);
+ text.setColor(ChatColor.GRAY);
+ text.setItalic(true);
+
+ for (Player adminPlayer : Bukkit.getOnlinePlayers()) {
+ if (!adminPlayer.hasPermission("tgc-system.team")) continue;
+ if (adminPlayer.getName().equals(senderName) && sendToSender) {
+ adminPlayer.spigot().sendMessage(new TextComponent(Main.get().getPrefix()), message);
+ continue;
+ }
+
+ adminPlayer.spigot().sendMessage(text);
+ }
+ }
+
+ public static String getPlayerNameWithStatus(Player player, boolean statusEnabled) {
+ Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getName());
+ String teamPrefix = team != null ? team.getColor() + (!team.getPrefix().isEmpty() ? (team.getPrefix()) : "") : "";
+ String teamSuffix = team != null ? team.getColor() + (!team.getSuffix().isEmpty() ? (team.getSuffix()) : "") : "";
+
+ return (statusEnabled ? StatusHandler.getStatusWithBrackets(player) : "") + teamPrefix + player.getName() + teamSuffix;
+ }
+}
diff --git a/src/main/java/timongcraft/util/Messages.java b/src/main/java/timongcraft/system/util/Messages.java
similarity index 88%
rename from src/main/java/timongcraft/util/Messages.java
rename to src/main/java/timongcraft/system/util/Messages.java
index 099bbe5..420d665 100644
--- a/src/main/java/timongcraft/util/Messages.java
+++ b/src/main/java/timongcraft/system/util/Messages.java
@@ -1,4 +1,4 @@
-package timongcraft.util;
+package timongcraft.system.util;
//Maybe make all messages to a variable
public enum Messages {
diff --git a/src/main/java/timongcraft/system/util/PlayerOnlyArgument.java b/src/main/java/timongcraft/system/util/PlayerOnlyArgument.java
new file mode 100644
index 0000000..165bb47
--- /dev/null
+++ b/src/main/java/timongcraft/system/util/PlayerOnlyArgument.java
@@ -0,0 +1,17 @@
+package timongcraft.system.util;
+
+import dev.jorel.commandapi.arguments.ArgumentSuggestions;
+import dev.jorel.commandapi.arguments.EntitySelectorArgument;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+
+public class PlayerOnlyArgument extends EntitySelectorArgument.OnePlayer {
+
+ public PlayerOnlyArgument(String nodeName) {
+ super(nodeName);
+ replaceSuggestions(ArgumentSuggestions.strings(info ->
+ Bukkit.getOnlinePlayers().stream().map(OfflinePlayer::getName).toArray(String[]::new)
+ ));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/util/StatusHandler.java b/src/main/java/timongcraft/system/util/StatusHandler.java
similarity index 52%
rename from src/main/java/timongcraft/util/StatusHandler.java
rename to src/main/java/timongcraft/system/util/StatusHandler.java
index 9748aba..8a2107e 100644
--- a/src/main/java/timongcraft/util/StatusHandler.java
+++ b/src/main/java/timongcraft/system/util/StatusHandler.java
@@ -1,7 +1,7 @@
-package timongcraft.util;
+package timongcraft.system.util;
import org.bukkit.entity.Player;
-import timongcraft.Main;
+import timongcraft.system.Main;
public class StatusHandler {
public static String getStatus(Player player) {
@@ -9,19 +9,23 @@ public static String getStatus(Player player) {
}
public static String getStatusWithBrackets(Player player) {
- return "§f[" + Main.get().getDataConfig().getString("players." + player.getUniqueId() + ".status") + "§f] ";
+ String status = Main.get().getDataConfig().getString("players." + player.getUniqueId() + ".status");
+
+ if (status == null) return "";
+
+ return "§f[" + status + "§f] ";
}
public static void setStatus(Player player, String status) {
Main.get().getDataConfig().set("players." + player.getUniqueId() + ".status", status);
Main.get().getDataConfig().save();
- player.setDisplayName(PlayerUtils.getPlayerNameWithStatus(player, true));
- player.setPlayerListName(PlayerUtils.getPlayerNameWithStatus(player, true));
+ player.setDisplayName(MessageUtils.getPlayerNameWithStatus(player, true));
+ player.setPlayerListName(MessageUtils.getPlayerNameWithStatus(player, true));
}
public static void refreshStatus(Player player) {
- player.setDisplayName(PlayerUtils.getPlayerNameWithStatus(player, true));
- player.setPlayerListName(PlayerUtils.getPlayerNameWithStatus(player, true));
+ player.setDisplayName(MessageUtils.getPlayerNameWithStatus(player, true));
+ player.setPlayerListName(MessageUtils.getPlayerNameWithStatus(player, true));
}
}
diff --git a/src/main/java/timongcraft/util/UpdateCheckHandler.java b/src/main/java/timongcraft/system/util/UpdateCheckHandler.java
similarity index 73%
rename from src/main/java/timongcraft/util/UpdateCheckHandler.java
rename to src/main/java/timongcraft/system/util/UpdateCheckHandler.java
index 67efce0..2dc6991 100644
--- a/src/main/java/timongcraft/util/UpdateCheckHandler.java
+++ b/src/main/java/timongcraft/system/util/UpdateCheckHandler.java
@@ -1,6 +1,6 @@
-package timongcraft.util;
+package timongcraft.system.util;
-import timongcraft.Main;
+import timongcraft.system.Main;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -8,24 +8,22 @@
import java.net.URL;
public class UpdateCheckHandler {
+
public static void checkForUpdate(double currentVersion) {
try {
- URL url = new URL("https://api.modrinth.com/v2/project/J8w9otm3/version");
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ HttpURLConnection con = (HttpURLConnection) new URL("https://api.modrinth.com/v2/project/J8w9otm3/version").openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
- if (responseCode != 200) {
+ if (responseCode != 200)
Main.get().getLogger().warning("Failed to check for updates. Response code: " + responseCode);
- }
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
- while ((inputLine = in.readLine()) != null) {
+ while ((inputLine = in.readLine()) != null)
response.append(inputLine);
- }
in.close();
String jsonString = response.toString();
@@ -34,14 +32,14 @@ public static void checkForUpdate(double currentVersion) {
int endIndex = jsonString.indexOf('"', startIndex);
double latestVersion = Double.parseDouble(jsonString.substring(startIndex, endIndex));
- if(latestVersion != currentVersion) {
+ if (latestVersion != currentVersion) {
Main.get().getLogger().warning("You're not using the latest version!");
Main.get().getLogger().warning("Get the latest version here: https://modrinth.com/plugin/tgc-system");
}
} catch (Exception e) {
- Main.get().getLogger().warning("Failed to check for updates");
- e.printStackTrace();
+ throw new IllegalStateException("Failed to check for updates", e);
}
}
+
}
\ No newline at end of file
diff --git a/src/main/java/timongcraft/util/AutoSaveHandler.java b/src/main/java/timongcraft/util/AutoSaveHandler.java
deleted file mode 100644
index 7edd8d4..0000000
--- a/src/main/java/timongcraft/util/AutoSaveHandler.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package timongcraft.util;
-
-import org.bukkit.Bukkit;
-import org.bukkit.scheduler.BukkitRunnable;
-
-public class AutoSaveHandler extends BukkitRunnable {
- @Override
- public void run() {
- Bukkit.getLogger().info("[AutoSave] saving the game..");
- PlayerUtils.sendToTeam("AutoSave", null, "saving the game...");
-
- Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "save-all");
- }
-
- public long parseInterval(String interval) {
- if(interval == null) return 30 * 60 * 20;
- int number = Integer.parseInt(interval.substring(0, interval.length() - 1));
- char unit = interval.charAt(interval.length() - 1);
- if(unit == 'm') return (long) number * 60 * 20;
- else if(unit == 'h') return (long) number * 60 * 60 * 20;
- else return 30 * 60 * 20;
- }
-}
-
diff --git a/src/main/java/timongcraft/util/CropDrop.java b/src/main/java/timongcraft/util/CropDrop.java
deleted file mode 100644
index 4dbb972..0000000
--- a/src/main/java/timongcraft/util/CropDrop.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package timongcraft.util;
-
-import org.bukkit.Material;
-import org.bukkit.inventory.ItemStack;
-
-import java.util.Random;
-
-public record CropDrop(int min, int max, Material material, int dropChance) {
- public ItemStack getRandom() {
- int nextInt = new Random().nextInt(min(), max() + 1);
- return new ItemStack(material(), nextInt);
- }
-}
diff --git a/src/main/java/timongcraft/util/PlayerUtils.java b/src/main/java/timongcraft/util/PlayerUtils.java
deleted file mode 100644
index fb1ab76..0000000
--- a/src/main/java/timongcraft/util/PlayerUtils.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package timongcraft.util;
-
-import net.md_5.bungee.api.ChatColor;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.Team;
-import timongcraft.Main;
-
-public class PlayerUtils {
- public static void sendToTeam(String sender, String target, String msg) {
- for(Player teamPlayer : Bukkit.getOnlinePlayers()) {
- if(teamPlayer.hasPermission("tgc-system.team") && !(teamPlayer.getName().equals(sender))) {
- if(target != null && teamPlayer.getName().equals(target)) return;
-
- teamPlayer.sendMessage(Main.get().getPrefix() + "§7§o[" + sender + "§7§o: " + msg + "§7§o]");
- }
- }
- }
-
- public static String getPlayerNameWithStatus(Player player, boolean statusEnabled) {
- Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getName());
- String teamPrefix = team != null ? team.getColor() + (!team.getPrefix().isEmpty() ? (team.getPrefix() + ChatColor.RESET) : "") : "";
- String teamSuffix = team != null ? team.getColor() + (!team.getSuffix().isEmpty() ? (team.getSuffix() + ChatColor.RESET) : "") : "";
-
- if(statusEnabled) return teamPrefix + StatusHandler.getStatusWithBrackets(player) + player.getName() + teamSuffix;
- return teamPrefix + player.getName() + teamSuffix;
- }
-}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 7a975d2..817ef62 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,5 +1,5 @@
-#Do not edit or things might break!
-configVersion: 1.6
+#Do not edit config version or things might break!
+configVersion: 1.9
prefix:
pluginPrefix: '§7[§1System§7] §f'
@@ -21,8 +21,8 @@ onJoin:
#If a player joins and has a status set he will be shown a message with the players status
status: false
-#This makes chat reporting impossible my overriding the msg command and sending all chat messages as the server
-#But also includes features like a sound/highlighting when your name is in a message
+#This makes chat reporting impossible by overriding the msg, say and me commands and sending all chat messages as the server
+#But also includes features like a sound/highlighting when your name is in a message and a reply command
chatSystem:
enabled: true
noLinks: false
@@ -33,6 +33,15 @@ chatSystem:
#https://www.php.net/manual/en/timezones
timeZone: 'America/New_York'
+#The coordinate list
+coordsSaver:
+ enabled: true
+ #If players on your server use Xaero's Minimap you may want to enable this,
+ #so they can add coords from this plugin, and also you can add waypoints from Xaero's Minimap
+ xaerosWaypointCompatability: false
+ #The limit of coordinates a player should be able to save
+ limit: 10
+
#The permission manager command and the permission handling
permissionSystem:
enabled: true
@@ -44,6 +53,19 @@ statuses:
enabled: false
characterLimit: 10
+#Allow renamed hoppers to work as filters
+#Inspired by https://www.youtube.com/watch?v=Gi2PPBCEHuM&t=232s (LiveOverflow)
+#You can use commas to separate and stars as wildcards
+#also question marks act as wildcards but only for one character
+#and exclamation marks invert e.g. if you have '*spruce*,!*boat' it will
+#let every spruce item except boats trough
+hopperFilters:
+ enabled: false
+
+#Cobblestone/Stone Generators under the y level 0 are producing their deepslate variant respectively
+deepslateGenerator:
+ enabled: false
+
spawnElytra:
enabled: false
spawnRadius: 20
@@ -79,11 +101,6 @@ maintenance:
#Must be called maintenance-icon.png
icon: false
-#Auto save your world if your hoster doesn't have that functionality
-autoSave:
- enabled: false
- time: '1h'
-
#This makes to so if you right-click on wheat, potatoes, carrots, beetroots and cocoa beans
easyHarvest:
enabled: false
@@ -97,4 +114,11 @@ blockedCommands: []
#These prefixes are blocked e.g. 'bukkit:'
-blockedPrefixes: []
\ No newline at end of file
+blockedPrefixes: []
+
+commandAPI:
+ #Warns if an incompatible version of CommandAPI is loaded etc.
+ warnings: true
+ #Automaticly downloads and loads the CommandAPI if it isn't present
+ #If disabled warnings are automatically disabled as well
+ autoDownload: true
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 2216158..3edcc90 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,8 +1,10 @@
name: Tgc-System
version: '${project.version}'
-main: timongcraft.Main
+main: timongcraft.system.Main
api-version: 1.19
load: STARTUP
-authors: [ Timongcraft ]
+author: Timongcraft
description: A system plugin
-website: modrinth.com/plugin/Tgc-System
\ No newline at end of file
+website: modrinth.com/plugin/Tgc-System
+softdepend:
+ - CommandAPI
\ No newline at end of file