diff --git a/.factorypath b/.factorypath
new file mode 100644
index 0000000..610dea5
--- /dev/null
+++ b/.factorypath
@@ -0,0 +1,2 @@
+
+
diff --git a/.gitignore b/.gitignore
index 1917a1a..84dff78 100644
--- a/.gitignore
+++ b/.gitignore
@@ -224,3 +224,4 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
*.xml
TBMC/
+/.apt_generated/
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 672496e..edf183d 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,14 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.8
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/META-INF/services/javax.annotation.processing.Processor b/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..c52a464
--- /dev/null
+++ b/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+buttondevteam.lib.AnnotationProcessor
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8609c02..ba1b5fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,12 +9,6 @@
src/main/java
-
- src
-
- **/*.java
-
-
src/main/resources
@@ -34,6 +28,7 @@
1.8
+ -proc:none
@@ -76,7 +71,7 @@
target
- resources
+ src/main/resources
@@ -114,7 +109,7 @@
- org.apache.commons
+ commons-io
commons-io
1.3.2
provided
diff --git a/src/main/java/buttondevteam/core/CommandCaller.java b/src/main/java/buttondevteam/core/CommandCaller.java
index cb1b050..2b27f9e 100644
--- a/src/main/java/buttondevteam/core/CommandCaller.java
+++ b/src/main/java/buttondevteam/core/CommandCaller.java
@@ -5,43 +5,35 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
-import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.lib.TBMCCoreAPI;
+import buttondevteam.lib.chat.CommandClass;
import buttondevteam.lib.chat.TBMCChatAPI;
import buttondevteam.lib.chat.TBMCCommandBase;
public class CommandCaller implements CommandExecutor {
- private static final String REGISTER_ERROR_MSG = "An error occured while registering commands";
-
private CommandCaller() {
}
private static CommandCaller instance;
- public static void RegisterCommand(TBMCCommandBase cmd) {
+ public static void RegisterCommand(TBMCCommandBase cmd) throws Exception {
if (instance == null)
instance = new CommandCaller();
- if (cmd.GetCommandPath() == null) {
- TBMCCoreAPI.SendException(REGISTER_ERROR_MSG,
- new Exception("Command " + cmd.getClass().getSimpleName() + " has no command path!"));
- return;
- }
- if (cmd.getPlugin() == null) {
- TBMCCoreAPI.SendException(REGISTER_ERROR_MSG,
- new Exception("Command " + cmd.GetCommandPath() + " has no plugin!"));
- return;
- }
+ String topcmd = cmd.GetCommandPath();
+ if (topcmd == null)
+ throw new Exception("Command " + cmd.getClass().getSimpleName() + " has no command path!");
+ if (cmd.getPlugin() == null)
+ throw new Exception("Command " + cmd.GetCommandPath() + " has no plugin!");
int i;
- String topcmd;
- if ((i = (topcmd = cmd.GetCommandPath()).indexOf(' ')) != -1) // Get top-level command
- topcmd = cmd.GetCommandPath().substring(0, i);
+ if ((i = topcmd.indexOf(' ')) != -1) // Get top-level command
+ topcmd = topcmd.substring(0, i);
{
PluginCommand pc = ((JavaPlugin) cmd.getPlugin()).getCommand(topcmd);
if (pc == null)
- TBMCCoreAPI.SendException(REGISTER_ERROR_MSG, new Exception("Top level command " + topcmd
- + " not registered in plugin.yml for plugin: " + cmd.getPlugin().getName()));
+ throw new Exception("Top level command " + topcmd + " not registered in plugin.yml for plugin: "
+ + cmd.getPlugin().getName());
else
pc.setExecutor(instance);
}
@@ -69,14 +61,11 @@ public class CommandCaller implements CommandExecutor {
}
return true;
}
- if (cmd.GetModOnly() && !MainPlugin.permission.has(sender, "tbmc.admin")) {
+ if (cmd.getClass().getAnnotation(CommandClass.class).modOnly()
+ && !MainPlugin.permission.has(sender, "tbmc.admin")) {
sender.sendMessage("§cYou need to be a mod to use this command.");
return true;
}
- if (cmd.GetPlayerOnly() && !(sender instanceof Player)) {
- sender.sendMessage("§cOnly ingame players can use this command.");
- return true;
- }
final String[] cmdargs = args.length > 0 ? Arrays.copyOfRange(args, args.length - argc, args.length) : args;
try {
if (!cmd.OnCommand(sender, alias, cmdargs)) {
diff --git a/src/main/java/buttondevteam/core/MainPlugin.java b/src/main/java/buttondevteam/core/MainPlugin.java
index 9d48e81..b8ae2da 100644
--- a/src/main/java/buttondevteam/core/MainPlugin.java
+++ b/src/main/java/buttondevteam/core/MainPlugin.java
@@ -1,22 +1,16 @@
package buttondevteam.core;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
import java.util.logging.Logger;
-import org.bukkit.Bukkit;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
-
import buttondevteam.lib.TBMCCoreAPI;
+import buttondevteam.lib.chat.Channel;
+import buttondevteam.lib.chat.Color;
import buttondevteam.lib.chat.TBMCChatAPI;
-import buttondevteam.lib.player.ChromaGamerBase;
+import buttondevteam.lib.chat.Channel.RecipientTestResult;
import buttondevteam.lib.player.TBMCPlayerBase;
import net.milkbowl.vault.permission.Permission;
@@ -27,7 +21,6 @@ public class MainPlugin extends JavaPlugin {
private PluginDescriptionFile pdfFile;
private Logger logger;
- private int C = 0, keep = 0;
@Override
public void onEnable() {
@@ -42,46 +35,15 @@ public class MainPlugin extends JavaPlugin {
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
- logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ").");
- Arrays.stream(new File(ChromaGamerBase.TBMC_PLAYERS_DIR).listFiles(f -> !f.isDirectory())).map(f -> {
- YamlConfiguration yc = new YamlConfiguration();
- try {
- yc.load(f);
- } catch (IOException | InvalidConfigurationException e) {
- TBMCCoreAPI.SendException("Error while converting player data!", e);
- }
- f.delete();
- return yc;
- }).forEach(yc -> {
- try {
- int flairtime = yc.getInt("flairtime"), fcount = yc.getInt("fcount"), fdeaths = yc.getInt("fdeaths");
- String flairstate = yc.getString("flairstate");
- List usernames = yc.getStringList("usernames");
- boolean flaircheater = yc.getBoolean("flaircheater");
- final String uuid = yc.getString("uuid");
- C++;
- if ((fcount == 0 || fdeaths == 0)
- && (flairstate == null || "NoComment".equals(flairstate) || flairtime <= 0))
- return; // Those who received no Fs yet will also get their stats reset if no flair
- final File file = new File(ChromaGamerBase.TBMC_PLAYERS_DIR + "minecraft", uuid + ".yml");
- YamlConfiguration targetyc = YamlConfiguration.loadConfiguration(file);
- targetyc.set("PlayerName", yc.getString("playername"));
- targetyc.set("minecraft_id", uuid);
- ConfigurationSection bc = targetyc.createSection("ButtonChat");
- bc.set("FlairTime", "NoComment".equals(flairstate) ? -3 : flairtime); // FlairTimeNone: -3
- bc.set("FCount", fcount);
- bc.set("FDeaths", fdeaths);
- bc.set("FlairState", flairstate);
- bc.set("UserNames", usernames);
- bc.set("FlairCheater", flaircheater);
- targetyc.save(file);
- keep++;
- } catch (Exception e) {
- TBMCCoreAPI.SendException("Error while converting player data!", e);
- }
- });
- Bukkit.getScheduler().runTask(this, () -> logger.info("Converted " + keep + " player data from " + C));
- //TODO: Remove once ran it at least once
+ TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fg§f", Color.White, "g", null));
+ TBMCChatAPI.RegisterChatChannel(
+ Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", s -> s.isOp() ? new RecipientTestResult(0)
+ : new RecipientTestResult("You need to be an admin to use this channel.")));
+ TBMCChatAPI.RegisterChatChannel(Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod",
+ s -> s.isOp() || (s instanceof Player && MainPlugin.permission.playerInGroup((Player) s, "mod"))
+ ? new RecipientTestResult(0) //
+ : new RecipientTestResult("You need to be a mod to use this channel.")));
+ logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ") Test: " + Test + ".");
}
@Override
diff --git a/src/main/java/buttondevteam/core/ScheduledRestartCommand.java b/src/main/java/buttondevteam/core/ScheduledRestartCommand.java
index 77bc185..b80c2de 100644
--- a/src/main/java/buttondevteam/core/ScheduledRestartCommand.java
+++ b/src/main/java/buttondevteam/core/ScheduledRestartCommand.java
@@ -9,8 +9,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitTask;
import buttondevteam.lib.ScheduledServerRestartEvent;
+import buttondevteam.lib.chat.CommandClass;
import buttondevteam.lib.chat.TBMCCommandBase;
+@CommandClass(modOnly = true, path = "schrestart")
public class ScheduledRestartCommand extends TBMCCommandBase {
private static volatile int restartcounter;
private static volatile BukkitTask restarttask;
@@ -32,11 +34,7 @@ public class ScheduledRestartCommand extends TBMCCommandBase {
restartbar = Bukkit.createBossBar("Server restart in " + ticks / 20f, BarColor.RED, BarStyle.SOLID,
BarFlag.DARKEN_SKY);
restartbar.setProgress(1);
- // System.out.println("Progress: " + restartbar.getProgress());
Bukkit.getOnlinePlayers().stream().forEach(p -> restartbar.addPlayer(p));
- /*
- * System.out.println( "Players: " + restartbar.getPlayers().stream().map(p -> p.getName()).collect(Collectors.joining(", ")));
- */
sender.sendMessage("Scheduled restart in " + ticks / 20f);
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(ticks);
Bukkit.getPluginManager().callEvent(e);
@@ -50,9 +48,6 @@ public class ScheduledRestartCommand extends TBMCCommandBase {
Bukkit.broadcastMessage("§c-- The server is restarting in " + restartcounter / 20 + " seconds!");
restartbar.setProgress(restartcounter / (double) restarttime);
restartbar.setTitle(String.format("Server restart in %f.2", restartcounter / 20f));
- /*
- * if (restartcounter % 20 == 0) System.out.println("Progress: " + restartbar.getProgress());
- */
restartcounter--;
}, 1, 1);
return true;
@@ -66,19 +61,4 @@ public class ScheduledRestartCommand extends TBMCCommandBase {
"You can optionally set the amount of ticks to wait before the restart." //
};
}
-
- @Override
- public boolean GetPlayerOnly() {
- return false;
- }
-
- @Override
- public boolean GetModOnly() {
- return true;
- }
-
- @Override
- public String GetCommandPath() {
- return "schrestart";
- }
}
diff --git a/src/main/java/buttondevteam/core/TestPrepare.java b/src/main/java/buttondevteam/core/TestPrepare.java
index e135a6a..3b6c837 100644
--- a/src/main/java/buttondevteam/core/TestPrepare.java
+++ b/src/main/java/buttondevteam/core/TestPrepare.java
@@ -11,14 +11,16 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import buttondevteam.lib.chat.Channel;
+import buttondevteam.lib.chat.Color;
+import buttondevteam.lib.chat.TBMCChatAPI;
+
public class TestPrepare {
public static void PrepareServer() {
Bukkit.setServer(Mockito.mock(Server.class, new Answer