From f55e2ebb7276b58f70f9e72d421c38d7d516d529 Mon Sep 17 00:00:00 2001
From: speedxx <43330808+speedxx@users.noreply.github.com>
Date: Thu, 18 Jun 2020 18:24:02 -0400
Subject: [PATCH] refactor all of this because i am dumb
---
pom.xml | 4 +-
.../totalfreedom/tfguilds/TFGuilds.java | 16 +-
.../tfguilds/command/CreateGuildCommand.java | 6 +-
.../tfguilds/command/GuildChatCommand.java | 6 +-
.../tfguilds/command/GuildTagCommand.java | 6 +-
.../tfguilds/command/TfGuildsCommand.java | 6 +-
.../totalfreedom/tfguilds/config/Config.java | 96 +++----
.../tfguilds/listener/ChatManager.java | 6 +-
.../me/totalfreedom/tfguilds/util/GBase.java | 8 +
.../totalfreedom/tfguilds/util/GLog.java | 58 ++---
.../totalfreedom/tfguilds/util/GUtil.java | 234 +++++++++---------
.../totalfreedom/tfguilds/util/GBase.java | 8 -
src/main/resources/guilds.yml | 9 +-
src/main/resources/plugin.yml | 4 +-
14 files changed, 233 insertions(+), 234 deletions(-)
rename src/main/java/{ => me}/totalfreedom/tfguilds/TFGuilds.java (73%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/command/CreateGuildCommand.java (94%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/command/GuildChatCommand.java (88%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/command/GuildTagCommand.java (93%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/command/TfGuildsCommand.java (84%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/config/Config.java (87%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/listener/ChatManager.java (85%)
create mode 100644 src/main/java/me/totalfreedom/tfguilds/util/GBase.java
rename src/main/java/{ => me}/totalfreedom/tfguilds/util/GLog.java (89%)
rename src/main/java/{ => me}/totalfreedom/tfguilds/util/GUtil.java (95%)
delete mode 100644 src/main/java/totalfreedom/tfguilds/util/GBase.java
diff --git a/pom.xml b/pom.xml
index a64d61a..e941539 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,9 +4,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- me.tf
+ me.totalfreedom
TFGuilds
- 0.0.7
+ 0.0.8
jar
TFGuilds
diff --git a/src/main/java/totalfreedom/tfguilds/TFGuilds.java b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
similarity index 73%
rename from src/main/java/totalfreedom/tfguilds/TFGuilds.java
rename to src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
index 37e7039..0584024 100644
--- a/src/main/java/totalfreedom/tfguilds/TFGuilds.java
+++ b/src/main/java/me/totalfreedom/tfguilds/TFGuilds.java
@@ -1,14 +1,14 @@
-package totalfreedom.tfguilds;
+package me.totalfreedom.tfguilds;
+import me.totalfreedom.tfguilds.util.GLog;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
-import totalfreedom.tfguilds.command.CreateGuildCommand;
-import totalfreedom.tfguilds.command.GuildChatCommand;
-import totalfreedom.tfguilds.command.GuildTagCommand;
-import totalfreedom.tfguilds.command.TfGuildsCommand;
-import totalfreedom.tfguilds.config.Config;
-import totalfreedom.tfguilds.listener.ChatManager;
-import totalfreedom.tfguilds.util.GLog;
+import me.totalfreedom.tfguilds.command.CreateGuildCommand;
+import me.totalfreedom.tfguilds.command.GuildChatCommand;
+import me.totalfreedom.tfguilds.command.GuildTagCommand;
+import me.totalfreedom.tfguilds.command.TfGuildsCommand;
+import me.totalfreedom.tfguilds.config.Config;
+import me.totalfreedom.tfguilds.listener.ChatManager;
public final class TFGuilds extends JavaPlugin
{
diff --git a/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
similarity index 94%
rename from src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java
rename to src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
index 8fa4ec9..c2cbcbb 100644
--- a/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java
@@ -1,13 +1,13 @@
-package totalfreedom.tfguilds.command;
+package me.totalfreedom.tfguilds.command;
+import me.totalfreedom.tfguilds.util.GBase;
+import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
-import totalfreedom.tfguilds.util.GBase;
-import totalfreedom.tfguilds.util.GUtil;
public class CreateGuildCommand extends GBase implements CommandExecutor
{
diff --git a/src/main/java/totalfreedom/tfguilds/command/GuildChatCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildChatCommand.java
similarity index 88%
rename from src/main/java/totalfreedom/tfguilds/command/GuildChatCommand.java
rename to src/main/java/me/totalfreedom/tfguilds/command/GuildChatCommand.java
index d7e3d96..a2eb394 100644
--- a/src/main/java/totalfreedom/tfguilds/command/GuildChatCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildChatCommand.java
@@ -1,13 +1,13 @@
-package totalfreedom.tfguilds.command;
+package me.totalfreedom.tfguilds.command;
+import me.totalfreedom.tfguilds.util.GBase;
+import me.totalfreedom.tfguilds.util.GUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import totalfreedom.tfguilds.util.GBase;
-import totalfreedom.tfguilds.util.GUtil;
public class GuildChatCommand extends GBase implements CommandExecutor
{
diff --git a/src/main/java/totalfreedom/tfguilds/command/GuildTagCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java
similarity index 93%
rename from src/main/java/totalfreedom/tfguilds/command/GuildTagCommand.java
rename to src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java
index c979a93..7e2ddbd 100644
--- a/src/main/java/totalfreedom/tfguilds/command/GuildTagCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java
@@ -1,12 +1,12 @@
-package totalfreedom.tfguilds.command;
+package me.totalfreedom.tfguilds.command;
+import me.totalfreedom.tfguilds.util.GBase;
+import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import totalfreedom.tfguilds.util.GBase;
-import totalfreedom.tfguilds.util.GUtil;
public class GuildTagCommand extends GBase implements CommandExecutor
{
diff --git a/src/main/java/totalfreedom/tfguilds/command/TfGuildsCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java
similarity index 84%
rename from src/main/java/totalfreedom/tfguilds/command/TfGuildsCommand.java
rename to src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java
index e84ba1f..1b53df7 100644
--- a/src/main/java/totalfreedom/tfguilds/command/TfGuildsCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java
@@ -1,10 +1,10 @@
-package totalfreedom.tfguilds.command;
+package me.totalfreedom.tfguilds.command;
+import me.totalfreedom.tfguilds.util.GBase;
+import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
-import totalfreedom.tfguilds.util.GBase;
-import totalfreedom.tfguilds.util.GUtil;
public class TfGuildsCommand extends GBase implements CommandExecutor
{
diff --git a/src/main/java/totalfreedom/tfguilds/config/Config.java b/src/main/java/me/totalfreedom/tfguilds/config/Config.java
similarity index 87%
rename from src/main/java/totalfreedom/tfguilds/config/Config.java
rename to src/main/java/me/totalfreedom/tfguilds/config/Config.java
index ea6f307..8aa9218 100644
--- a/src/main/java/totalfreedom/tfguilds/config/Config.java
+++ b/src/main/java/me/totalfreedom/tfguilds/config/Config.java
@@ -1,49 +1,49 @@
-package totalfreedom.tfguilds.config;
-
-import org.bukkit.configuration.file.YamlConfiguration;
-import totalfreedom.tfguilds.TFGuilds;
-
-import java.io.File;
-
-public class Config extends YamlConfiguration
-{
- private final TFGuilds plugin;
- private final File file;
-
- public Config(TFGuilds plugin, String name)
- {
- this.plugin = plugin;
- this.file = new File(plugin.getDataFolder(), name);
-
- if (!file.exists())
- {
- options().copyDefaults(true);
- plugin.saveResource(name, false);
- }
- load();
- }
-
- public void load()
- {
- try
- {
- super.load(file);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public void save()
- {
- try
- {
- super.save(file);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
+package me.totalfreedom.tfguilds.config;
+
+import me.totalfreedom.tfguilds.TFGuilds;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import java.io.File;
+
+public class Config extends YamlConfiguration
+{
+ private final TFGuilds plugin;
+ private final File file;
+
+ public Config(TFGuilds plugin, String name)
+ {
+ this.plugin = plugin;
+ this.file = new File(plugin.getDataFolder(), name);
+
+ if (!file.exists())
+ {
+ options().copyDefaults(true);
+ plugin.saveResource(name, false);
+ }
+ load();
+ }
+
+ public void load()
+ {
+ try
+ {
+ super.load(file);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void save()
+ {
+ try
+ {
+ super.save(file);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/totalfreedom/tfguilds/listener/ChatManager.java b/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java
similarity index 85%
rename from src/main/java/totalfreedom/tfguilds/listener/ChatManager.java
rename to src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java
index 18f1d39..ca051a9 100644
--- a/src/main/java/totalfreedom/tfguilds/listener/ChatManager.java
+++ b/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java
@@ -1,12 +1,12 @@
-package totalfreedom.tfguilds.listener;
+package me.totalfreedom.tfguilds.listener;
+import me.totalfreedom.tfguilds.TFGuilds;
+import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
-import totalfreedom.tfguilds.TFGuilds;
-import totalfreedom.tfguilds.util.GUtil;
public class ChatManager implements Listener
{
diff --git a/src/main/java/me/totalfreedom/tfguilds/util/GBase.java b/src/main/java/me/totalfreedom/tfguilds/util/GBase.java
new file mode 100644
index 0000000..415625d
--- /dev/null
+++ b/src/main/java/me/totalfreedom/tfguilds/util/GBase.java
@@ -0,0 +1,8 @@
+package me.totalfreedom.tfguilds.util;
+
+import me.totalfreedom.tfguilds.TFGuilds;
+
+public class GBase
+{
+ protected static TFGuilds plugin = TFGuilds.plugin;
+}
diff --git a/src/main/java/totalfreedom/tfguilds/util/GLog.java b/src/main/java/me/totalfreedom/tfguilds/util/GLog.java
similarity index 89%
rename from src/main/java/totalfreedom/tfguilds/util/GLog.java
rename to src/main/java/me/totalfreedom/tfguilds/util/GLog.java
index 868ff5c..3b6ab26 100644
--- a/src/main/java/totalfreedom/tfguilds/util/GLog.java
+++ b/src/main/java/me/totalfreedom/tfguilds/util/GLog.java
@@ -1,30 +1,30 @@
-package totalfreedom.tfguilds.util;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class GLog
-{
- private static final Logger log = Logger.getLogger("Minecraft");
- private static final String prefix = "[TFGuilds] ";
-
- private static void log(String s, Level l)
- {
- log.log(l, prefix + s);
- }
-
- public static void info(String s)
- {
- log(s, Level.INFO);
- }
-
- public static void warn(String s)
- {
- log(s, Level.WARNING);
- }
-
- public static void severe(String s)
- {
- log(s, Level.SEVERE);
- }
+package me.totalfreedom.tfguilds.util;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class GLog
+{
+ private static final Logger log = Logger.getLogger("Minecraft");
+ private static final String prefix = "[TFGuilds] ";
+
+ private static void log(String s, Level l)
+ {
+ log.log(l, prefix + s);
+ }
+
+ public static void info(String s)
+ {
+ log(s, Level.INFO);
+ }
+
+ public static void warn(String s)
+ {
+ log(s, Level.WARNING);
+ }
+
+ public static void severe(String s)
+ {
+ log(s, Level.SEVERE);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/totalfreedom/tfguilds/util/GUtil.java b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java
similarity index 95%
rename from src/main/java/totalfreedom/tfguilds/util/GUtil.java
rename to src/main/java/me/totalfreedom/tfguilds/util/GUtil.java
index 51c6e74..2307c71 100644
--- a/src/main/java/totalfreedom/tfguilds/util/GUtil.java
+++ b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java
@@ -1,118 +1,118 @@
-package totalfreedom.tfguilds.util;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.entity.Player;
-import totalfreedom.tfguilds.TFGuilds;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class GUtil
-{
- public static TFGuilds plugin = TFGuilds.plugin;
-
- public static boolean isConsole(CommandSender sender)
- {
- return sender instanceof ConsoleCommandSender;
- }
-
- public static void createGuild(CommandSender owner, String guildName)
- {
- plugin.guilds.set("guilds." + guildName, guildName);
- plugin.guilds.set("guilds." + guildName + ".owner", owner.getName());
- plugin.guilds.set("guilds." + guildName + ".members", owner.getName());
-
- List players = plugin.guilds.getStringList("guilds." + guildName + ".members");
- players.add(owner.getName());
- plugin.guilds.set("guilds." + guildName + ".members", players);
-
- plugin.guilds.save();
- GLog.info(owner.getName() + " has created a new guild: " + guildName);
- }
-
- public static void setTag(String tag, String guildName)
- {
- plugin.guilds.set("guilds." + guildName + ".tag", tag);
- plugin.guilds.save();
- }
-
- public static String getTag(String guildName)
- {
- return plugin.guilds.getString("guilds." + guildName + ".tag");
- }
-
- public static boolean hasTag(String guildName)
- {
- return plugin.guilds.contains("guilds." + guildName + ".tag");
- }
-
- public static String getGuild(Player player)
- {
- String g = "";
- boolean a = false;
- ConfigurationSection guildMembers = plugin.guilds.getConfigurationSection("guilds");
- if (guildMembers != null)
- {
- try
- {
- for (String guild : guildMembers.getKeys(false))
- {
- List members = plugin.guilds.getStringList("guilds." + guild + ".members");
- if (members.contains(player.getName()))
- {
- a = true;
- g = guild;
- }
- }
- }
- catch (Exception e)
- {
- e.fillInStackTrace();
- }
- }
- if (!a)
- return null;
- return g;
- }
-
- public static String getOwner(String guildName)
- {
- return plugin.guilds.getString("guilds." + guildName + ".owner");
- }
-
- public static List getMember(String guildName)
- {
- return plugin.guilds.getStringList("guilds." + guildName + ".members");
- }
-
- public static boolean isGuildMember(Player player, String guildName)
- {
- return getMember(guildName).contains(player.getName().toLowerCase());
- }
-
- public static void guildChat(CommandSender sender, String message, String guildName)
- {
- String sent = ChatColor.DARK_GRAY + "[" + ChatColor.BLUE + "GC" + ChatColor.DARK_GRAY + "] " + getTag(guildName) + ChatColor.BLUE + sender
- .getName() + ChatColor.GRAY + ": " + ChatColor.AQUA + message;
- GLog.info(sent);
- for (Player player : Bukkit.getOnlinePlayers())
- {
- if (isGuildMember(player, guildName))
- {
- player.sendMessage(sent);
- }
- }
- }
-
- public static List BLACKLISTED_NAMES_AND_TAGS = Arrays.asList(
- "admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
-
- public static String color(String s)
- {
- return ChatColor.translateAlternateColorCodes('&', s);
- }
+package me.totalfreedom.tfguilds.util;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.entity.Player;
+import me.totalfreedom.tfguilds.TFGuilds;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class GUtil
+{
+ public static TFGuilds plugin = TFGuilds.plugin;
+
+ public static boolean isConsole(CommandSender sender)
+ {
+ return sender instanceof ConsoleCommandSender;
+ }
+
+ public static void createGuild(CommandSender owner, String guildName)
+ {
+ plugin.guilds.set("guilds." + guildName, guildName);
+ plugin.guilds.set("guilds." + guildName + ".owner", owner.getName());
+ plugin.guilds.set("guilds." + guildName + ".members", owner.getName());
+
+ List players = plugin.guilds.getStringList("guilds." + guildName + ".members");
+ players.add(owner.getName());
+ plugin.guilds.set("guilds." + guildName + ".members", players);
+
+ plugin.guilds.save();
+ GLog.info(owner.getName() + " has created a new guild: " + guildName);
+ }
+
+ public static void setTag(String tag, String guildName)
+ {
+ plugin.guilds.set("guilds." + guildName + ".tag", tag);
+ plugin.guilds.save();
+ }
+
+ public static String getTag(String guildName)
+ {
+ return plugin.guilds.getString("guilds." + guildName + ".tag");
+ }
+
+ public static boolean hasTag(String guildName)
+ {
+ return plugin.guilds.contains("guilds." + guildName + ".tag");
+ }
+
+ public static String getGuild(Player player)
+ {
+ String g = "";
+ boolean a = false;
+ ConfigurationSection guildMembers = plugin.guilds.getConfigurationSection("guilds");
+ if (guildMembers != null)
+ {
+ try
+ {
+ for (String guild : guildMembers.getKeys(false))
+ {
+ List members = plugin.guilds.getStringList("guilds." + guild + ".members");
+ if (members.contains(player.getName()))
+ {
+ a = true;
+ g = guild;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.fillInStackTrace();
+ }
+ }
+ if (!a)
+ return null;
+ return g;
+ }
+
+ public static String getOwner(String guildName)
+ {
+ return plugin.guilds.getString("guilds." + guildName + ".owner");
+ }
+
+ public static List getMember(String guildName)
+ {
+ return plugin.guilds.getStringList("guilds." + guildName + ".members");
+ }
+
+ public static boolean isGuildMember(Player player, String guildName)
+ {
+ return getMember(guildName).contains(player.getName().toLowerCase());
+ }
+
+ public static void guildChat(CommandSender sender, String message, String guildName)
+ {
+ String sent = ChatColor.DARK_GRAY + "[" + ChatColor.BLUE + "GC" + ChatColor.DARK_GRAY + "] " + getTag(guildName) + ChatColor.BLUE + sender
+ .getName() + ChatColor.GRAY + ": " + ChatColor.AQUA + message;
+ GLog.info(sent);
+ for (Player player : Bukkit.getOnlinePlayers())
+ {
+ if (isGuildMember(player, guildName))
+ {
+ player.sendMessage(sent);
+ }
+ }
+ }
+
+ public static List BLACKLISTED_NAMES_AND_TAGS = Arrays.asList(
+ "admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
+
+ public static String color(String s)
+ {
+ return ChatColor.translateAlternateColorCodes('&', s);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/totalfreedom/tfguilds/util/GBase.java b/src/main/java/totalfreedom/tfguilds/util/GBase.java
deleted file mode 100644
index c19a65a..0000000
--- a/src/main/java/totalfreedom/tfguilds/util/GBase.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package totalfreedom.tfguilds.util;
-
-import totalfreedom.tfguilds.TFGuilds;
-
-public class GBase
-{
- protected static TFGuilds plugin = TFGuilds.plugin;
-}
diff --git a/src/main/resources/guilds.yml b/src/main/resources/guilds.yml
index c9ab33d..4c8fad1 100644
--- a/src/main/resources/guilds.yml
+++ b/src/main/resources/guilds.yml
@@ -1,5 +1,4 @@
-# Guilds
-# :
-# : speednt
-# :
-# - speednt
\ No newline at end of file
+# guild:
+# owner: speednt
+# members:
+# - speednt
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 800951f..e3d2aea 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: TFGuilds
version: ${project.version}
-main: totalfreedom.tfguilds.TFGuilds
-api-version: 1.13
+main: me.totalfreedom.tfguilds.TFGuilds
+api-version: 1.15
authors: [speednt]
description: Plugin which allows for players to make their own guilds on the server
commands: