Test config option upd.
And indentation fixes apparently
This commit is contained in:
parent
5872117d28
commit
cc3ed7cf52
4 changed files with 69 additions and 75 deletions
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||
|
|
|
@ -45,9 +45,8 @@ import java.util.logging.Logger;
|
|||
|
||||
public class MainPlugin extends ButtonPlugin {
|
||||
public static MainPlugin Instance;
|
||||
public static Permission permission;
|
||||
public static boolean Test;
|
||||
public static Essentials ess;
|
||||
public static Permission permission;
|
||||
public static Essentials ess;
|
||||
|
||||
private Logger logger;
|
||||
@Nullable
|
||||
|
@ -69,24 +68,20 @@ public class MainPlugin extends ButtonPlugin {
|
|||
"{channel}] <{name}> {message}");
|
||||
}
|
||||
|
||||
/**
|
||||
* The permission group for users that aren't online on the server. Currently this can happen for people using commands from Discord.
|
||||
*/
|
||||
public ConfigData<String> unconnPermGroup() {
|
||||
return getIConfig().getData("unconnPermGroup", "unconnected");
|
||||
public ConfigData<Boolean> test() {
|
||||
return getIConfig().getData("test", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pluginEnable() {
|
||||
// Logs "Plugin Enabled", registers commands
|
||||
Instance = this;
|
||||
PluginDescriptionFile pdf = getDescription();
|
||||
PluginDescriptionFile pdf = getDescription();
|
||||
logger = getLogger();
|
||||
if (!setupPermissions())
|
||||
throw new NullPointerException("No permission plugin found!");
|
||||
if (!setupEconomy()) //Though Essentials always provides economy so this shouldn't happen
|
||||
getLogger().warning("No economy plugin found! Components using economy will not be registered.");
|
||||
Test = getConfig().getBoolean("test", true);
|
||||
saveConfig();
|
||||
Component.registerComponent(this, new PluginUpdaterComponent());
|
||||
Component.registerComponent(this, new RestartComponent());
|
||||
|
@ -103,31 +98,31 @@ public class MainPlugin extends ButtonPlugin {
|
|||
getCommand2MC().registerCommand(new ThorpeCommand());
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
|
||||
ChromaGamerBase.addConverter(commandSender -> Optional.ofNullable(commandSender instanceof ConsoleCommandSender || commandSender instanceof BlockCommandSender
|
||||
? TBMCPlayer.getPlayer(new UUID(0, 0), TBMCPlayer.class) : null)); //Console & cmdblocks
|
||||
? TBMCPlayer.getPlayer(new UUID(0, 0), TBMCPlayer.class) : null)); //Console & cmdblocks
|
||||
ChromaGamerBase.addConverter(sender -> Optional.ofNullable(sender instanceof Player
|
||||
? TBMCPlayer.getPlayer(((Player) sender).getUniqueId(), TBMCPlayer.class) : null)); //Players, has higher priority
|
||||
? TBMCPlayer.getPlayer(((Player) sender).getUniqueId(), TBMCPlayer.class) : null)); //Players, has higher priority
|
||||
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
|
||||
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fg§f", Color.White, "g", null)); //The /ooc ID has moved to the config
|
||||
TBMCChatAPI.RegisterChatChannel(
|
||||
Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", Channel.inGroupFilter(null)));
|
||||
Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", Channel.inGroupFilter(null)));
|
||||
TBMCChatAPI.RegisterChatChannel(
|
||||
Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod", Channel.inGroupFilter("mod")));
|
||||
TBMCChatAPI.RegisterChatChannel(new Channel("§6DEV§f", Color.Gold, "dev", Channel.inGroupFilter("developer")));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§cRED§f", Color.DarkRed, "red"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§6ORANGE§f", Color.Gold, "orange"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§eYELLOW§f", Color.Yellow, "yellow"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§aGREEN§f", Color.Green, "green"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§bBLUE§f", Color.Blue, "blue"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§5PURPLE§f", Color.DarkPurple, "purple"));
|
||||
Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod", Channel.inGroupFilter("mod")));
|
||||
TBMCChatAPI.RegisterChatChannel(new Channel("§6DEV§f", Color.Gold, "dev", Channel.inGroupFilter("developer")));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§cRED§f", Color.DarkRed, "red"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§6ORANGE§f", Color.Gold, "orange"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§eYELLOW§f", Color.Yellow, "yellow"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§aGREEN§f", Color.Green, "green"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§bBLUE§f", Color.Blue, "blue"));
|
||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§5PURPLE§f", Color.DarkPurple, "purple"));
|
||||
if (writePluginList().get()) {
|
||||
try {
|
||||
Files.write(new File("plugins", "plugins.txt").toPath(), Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(p -> (CharSequence) p.getDataFolder().getName())::iterator);
|
||||
} catch (IOException e) {
|
||||
TBMCCoreAPI.SendException("Failed to write plugin list!", e);
|
||||
}
|
||||
}
|
||||
ess = Essentials.getPlugin(Essentials.class);
|
||||
logger.info(pdf.getName() + " has been Enabled (V." + pdf.getVersion() + ") Test: " + Test + ".");
|
||||
}
|
||||
ess = Essentials.getPlugin(Essentials.class);
|
||||
logger.info(pdf.getName() + " has been Enabled (V." + pdf.getVersion() + ") Test: " + test().get() + ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,21 +130,21 @@ public class MainPlugin extends ButtonPlugin {
|
|||
logger.info("Saving player data...");
|
||||
TBMCPlayerBase.savePlayers();
|
||||
logger.info("Player data saved.");
|
||||
new Thread(() -> {
|
||||
File[] files = PluginUpdater.updatedir.listFiles();
|
||||
if (files == null)
|
||||
return;
|
||||
logger.info("Updating " + files.length + " plugins...");
|
||||
for (File file : files) {
|
||||
try {
|
||||
Files.move(file.toPath(), new File("plugins", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
logger.info("Updated " + file.getName());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
logger.info("Update complete!");
|
||||
}).start();
|
||||
new Thread(() -> {
|
||||
File[] files = PluginUpdater.updatedir.listFiles();
|
||||
if (files == null)
|
||||
return;
|
||||
logger.info("Updating " + files.length + " plugins...");
|
||||
for (File file : files) {
|
||||
try {
|
||||
Files.move(file.toPath(), new File("plugins", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
logger.info("Updated " + file.getName());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
logger.info("Update complete!");
|
||||
}).start();
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
|
|
|
@ -22,8 +22,9 @@ import java.util.List;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
public class TBMCCoreAPI {
|
||||
static final List<String> coders = new ArrayList<String>() {
|
||||
static final List<String> coders = new ArrayList<String>() {
|
||||
private static final long serialVersionUID = -4462159250738367334L;
|
||||
|
||||
{
|
||||
add("Alisolarflare");
|
||||
add("NorbiPeti");
|
||||
|
@ -35,11 +36,9 @@ public class TBMCCoreAPI {
|
|||
|
||||
/**
|
||||
* Updates or installs the specified plugin. The plugin must use Maven.
|
||||
*
|
||||
* @param name
|
||||
* The plugin's repository name.
|
||||
* @param sender
|
||||
* The command sender (if not console, messages will be printed to console as well).
|
||||
*
|
||||
* @param name The plugin's repository name.
|
||||
* @param sender The command sender (if not console, messages will be printed to console as well).
|
||||
*/
|
||||
public static void UpdatePlugin(String name, CommandSender sender) {
|
||||
UpdatePlugin(name, sender, "master");
|
||||
|
@ -47,20 +46,17 @@ public class TBMCCoreAPI {
|
|||
|
||||
/**
|
||||
* Updates or installs the specified plugin from the specified branch. The plugin must use Maven.
|
||||
*
|
||||
* @param name
|
||||
* The plugin's repository name.
|
||||
* @param sender
|
||||
* The command sender (if not console, messages will be printed to console as well).
|
||||
* @param branch
|
||||
* The branch to download the plugin from.
|
||||
*
|
||||
* @param name The plugin's repository name.
|
||||
* @param sender The command sender (if not console, messages will be printed to console as well).
|
||||
* @param branch The branch to download the plugin from.
|
||||
* @return Success or not
|
||||
*/
|
||||
public static boolean UpdatePlugin(String name, CommandSender sender, String branch) {
|
||||
return PluginUpdater.UpdatePlugin(name, sender, branch);
|
||||
}
|
||||
|
||||
public static String DownloadString(String urlstr) throws IOException {
|
||||
public static String DownloadString(String urlstr) throws IOException {
|
||||
URL url = new URL(urlstr);
|
||||
URLConnection con = url.openConnection();
|
||||
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
||||
|
@ -72,16 +68,14 @@ public class TBMCCoreAPI {
|
|||
return body;
|
||||
}
|
||||
|
||||
private static final HashMap<String, Throwable> exceptionsToSend = new HashMap<>();
|
||||
private static final List<String> debugMessagesToSend = new ArrayList<>();
|
||||
private static final HashMap<String, Throwable> exceptionsToSend = new HashMap<>();
|
||||
private static final List<String> debugMessagesToSend = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Send exception to the {@link TBMCExceptionEvent}.
|
||||
*
|
||||
* @param sourcemsg
|
||||
* A message that is shown at the top of the exception (before the exception's message)
|
||||
* @param e
|
||||
* The exception to send
|
||||
*
|
||||
* @param sourcemsg A message that is shown at the top of the exception (before the exception's message)
|
||||
* @param e The exception to send
|
||||
*/
|
||||
public static void SendException(String sourcemsg, Throwable e) {
|
||||
SendException(sourcemsg, e, false);
|
||||
|
@ -98,7 +92,7 @@ public class TBMCCoreAPI {
|
|||
Bukkit.getLogger().warning(sourcemsg);
|
||||
e.printStackTrace();
|
||||
if (debugPotato) {
|
||||
List<Player> devsOnline = new ArrayList<Player>();
|
||||
List<Player> devsOnline = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (coders.contains(player.getName())) {
|
||||
devsOnline.add(player);
|
||||
|
@ -106,14 +100,14 @@ public class TBMCCoreAPI {
|
|||
}
|
||||
if (!devsOnline.isEmpty()) {
|
||||
DebugPotato potato = new DebugPotato()
|
||||
.setMessage(new String[] { //
|
||||
"§b§o" + e.getClass().getSimpleName(), //
|
||||
"§c§o" + sourcemsg, //
|
||||
"§a§oFind a dev to fix this issue" })
|
||||
.setType(e instanceof IOException ? "Throwable Potato"
|
||||
: e instanceof ClassCastException ? "Squished Potato"
|
||||
: e instanceof NullPointerException ? "Plain Potato"
|
||||
: e instanceof StackOverflowError ? "Chips" : "Error Potato");
|
||||
.setMessage(new String[]{ //
|
||||
"§b§o" + e.getClass().getSimpleName(), //
|
||||
"§c§o" + sourcemsg, //
|
||||
"§a§oFind a dev to fix this issue"})
|
||||
.setType(e instanceof IOException ? "Throwable Potato"
|
||||
: e instanceof ClassCastException ? "Squished Potato"
|
||||
: e instanceof NullPointerException ? "Plain Potato"
|
||||
: e instanceof StackOverflowError ? "Chips" : "Error Potato");
|
||||
for (Player dev : devsOnline) {
|
||||
potato.Send(dev);
|
||||
}
|
||||
|
@ -133,11 +127,9 @@ public class TBMCCoreAPI {
|
|||
|
||||
/**
|
||||
* Registers Bukkit events, handling the exceptions occurring in those events
|
||||
*
|
||||
* @param listener
|
||||
* The class that handles the events
|
||||
* @param plugin
|
||||
* The plugin which the listener belongs to
|
||||
*
|
||||
* @param listener The class that handles the events
|
||||
* @param plugin The plugin which the listener belongs to
|
||||
*/
|
||||
public static void RegisterEventsForExceptions(Listener listener, Plugin plugin) {
|
||||
EventExceptionHandler.registerEvents(listener, plugin, new EventExceptionCoreHandler());
|
||||
|
@ -183,6 +175,7 @@ public class TBMCCoreAPI {
|
|||
}
|
||||
|
||||
public static boolean IsTestServer() {
|
||||
return MainPlugin.Test;
|
||||
if (MainPlugin.Instance == null) return true;
|
||||
return MainPlugin.Instance.test().get();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue