From a6a5292a2353ecabe9e3b2982305fb340458fb2a Mon Sep 17 00:00:00 2001 From: JobLessGod Date: Wed, 18 Sep 2024 20:29:08 +0545 Subject: [PATCH] uploaded at Spigot --- .idea/.gitignore | 3 + .idea/artifacts/JRules_jar.xml | 9 ++ .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++ JRules.iml | 20 +++ out/production/JRules/config.yml | 10 ++ out/production/JRules/plugin.yml | 14 ++ src/com/joblessgod/jrules/Commands/Rules.java | 60 +++++++++ src/com/joblessgod/jrules/JRules.java | 22 ++++ src/com/joblessgod/jrules/RuleListener.java | 24 ++++ src/config.yml | 10 ++ src/plugin.yml | 14 ++ 13 files changed, 324 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/artifacts/JRules_jar.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 JRules.iml create mode 100644 out/production/JRules/config.yml create mode 100644 out/production/JRules/plugin.yml create mode 100644 src/com/joblessgod/jrules/Commands/Rules.java create mode 100644 src/com/joblessgod/jrules/JRules.java create mode 100644 src/com/joblessgod/jrules/RuleListener.java create mode 100644 src/config.yml create mode 100644 src/plugin.yml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/artifacts/JRules_jar.xml b/.idea/artifacts/JRules_jar.xml new file mode 100644 index 0000000..9f75624 --- /dev/null +++ b/.idea/artifacts/JRules_jar.xml @@ -0,0 +1,9 @@ + + + $PROJECT_DIR$/../../Server/plugins + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a438f97 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JRules.iml b/JRules.iml new file mode 100644 index 0000000..60ffca7 --- /dev/null +++ b/JRules.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/JRules/config.yml b/out/production/JRules/config.yml new file mode 100644 index 0000000..3c06966 --- /dev/null +++ b/out/production/JRules/config.yml @@ -0,0 +1,10 @@ +rules: + - "§e" + - "§e§l▬▬▬▬▬▬▬▬▬▬▬▬ §6§lServer Rules §e§l▬▬▬▬▬▬▬▬▬▬▬▬" + - "§7➤ §b1. §fRespect all players. Harassment or abuse is not tolerated." + - "§7➤ §b2. §fNo griefing or stealing. Play fair." + - "§7➤ §b3. §fNo hacking or cheating. Use only approved mods." + - "§7➤ §b4. §fNo spamming or advertising in chat." + - "§7➤ §b5. §fKeep the chat appropriate for all ages." + - "§e§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬" + - "§e" diff --git a/out/production/JRules/plugin.yml b/out/production/JRules/plugin.yml new file mode 100644 index 0000000..c9399f8 --- /dev/null +++ b/out/production/JRules/plugin.yml @@ -0,0 +1,14 @@ +name: JRules +version: 1.0 +author: JobLessGod +main: com.joblessgod.jrules.JRules +api-version: 1.14 +description: A flexible and powerful rule-based system for managing game interactions and automations. +commands: + rule: + description: Manage and execute game rules. + usage: + aliases: [rules, guideline, policy] + jrules: + description: Reloads the JRules configuration. + usage: / reload \ No newline at end of file diff --git a/src/com/joblessgod/jrules/Commands/Rules.java b/src/com/joblessgod/jrules/Commands/Rules.java new file mode 100644 index 0000000..8b30cdd --- /dev/null +++ b/src/com/joblessgod/jrules/Commands/Rules.java @@ -0,0 +1,60 @@ +package com.joblessgod.jrules.Commands; + +import com.joblessgod.jrules.JRules; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +public class Rules implements CommandExecutor { + private final JRules plugin; + + public Rules(JRules plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + if (cmd.getName().equalsIgnoreCase("JRules")) { + if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { + // Reload the configuration + plugin.reloadConfig(); + + // Send feedback to the command sender + sender.sendMessage("§aJRules configuration reloaded successfully!"); + } else { + // Incorrect usage + sender.sendMessage("§cUsage: /JRules reload"); + } + return true; + } + + if (!(sender instanceof Player)) { + sender.sendMessage("Only players can run this command!"); + return true; // Exit early since it's a non-player + } + + if (cmd.getName().equalsIgnoreCase("rule")) { + Player player = (Player) sender; + + // Fetch the list of rules from the config + List rules = this.plugin.getConfig().getStringList("rules"); + + // Check if the rules list is empty + if (rules.isEmpty()) { + player.sendMessage("§cNo rules have been set yet!"); + return true; + } + + // Send each rule to the player + for (String rule : rules) { + player.sendMessage(rule); + } + } + + return true; + } +} + diff --git a/src/com/joblessgod/jrules/JRules.java b/src/com/joblessgod/jrules/JRules.java new file mode 100644 index 0000000..e7a8e6b --- /dev/null +++ b/src/com/joblessgod/jrules/JRules.java @@ -0,0 +1,22 @@ +package com.joblessgod.jrules; + +import com.joblessgod.jrules.Commands.Rules; +import org.bukkit.ChatColor; +import org.bukkit.plugin.java.JavaPlugin; + +public final class JRules extends JavaPlugin { + + @Override + public void onEnable() { + + getCommand("rule").setExecutor(new Rules(this)); + getCommand("JRules").setExecutor(new Rules(this)); + getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[JRules] plugin has enabled!"); + saveDefaultConfig(); // saves config file + } + + public void onDisable() { + getServer().getConsoleSender().sendMessage(ChatColor.RED + "[JRules] plugin has disabled!"); + } + +} diff --git a/src/com/joblessgod/jrules/RuleListener.java b/src/com/joblessgod/jrules/RuleListener.java new file mode 100644 index 0000000..8c93a82 --- /dev/null +++ b/src/com/joblessgod/jrules/RuleListener.java @@ -0,0 +1,24 @@ +package com.joblessgod.jrules; + +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +import java.util.List; + +public class RuleListener implements Listener { + + private final JRules plugin; + + public RuleListener(JRules plugin) { + this.plugin = plugin; + Player Player = null; + Player player = (Player); + + // grab the config value + List rules = this.plugin.getConfig().getStringList("rules"); + // Send each rule from the list + for (String rule : rules) { + player.sendMessage(rule); + } + } +} diff --git a/src/config.yml b/src/config.yml new file mode 100644 index 0000000..3c06966 --- /dev/null +++ b/src/config.yml @@ -0,0 +1,10 @@ +rules: + - "§e" + - "§e§l▬▬▬▬▬▬▬▬▬▬▬▬ §6§lServer Rules §e§l▬▬▬▬▬▬▬▬▬▬▬▬" + - "§7➤ §b1. §fRespect all players. Harassment or abuse is not tolerated." + - "§7➤ §b2. §fNo griefing or stealing. Play fair." + - "§7➤ §b3. §fNo hacking or cheating. Use only approved mods." + - "§7➤ §b4. §fNo spamming or advertising in chat." + - "§7➤ §b5. §fKeep the chat appropriate for all ages." + - "§e§l▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬" + - "§e" diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..c9399f8 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,14 @@ +name: JRules +version: 1.0 +author: JobLessGod +main: com.joblessgod.jrules.JRules +api-version: 1.14 +description: A flexible and powerful rule-based system for managing game interactions and automations. +commands: + rule: + description: Manage and execute game rules. + usage: + aliases: [rules, guideline, policy] + jrules: + description: Reloads the JRules configuration. + usage: / reload \ No newline at end of file