testing new debug mode

This commit is contained in:
Bryson Steck 2021-09-13 16:02:00 -06:00
parent 58ea62e82d
commit eec1131610
4 changed files with 15 additions and 4 deletions

View file

@ -102,7 +102,7 @@ public class Resurrection extends JavaPlugin implements Listener {
if (parseSettings.isSettingsComplete() && !fileFail) { if (parseSettings.isSettingsComplete() && !fileFail) {
System.out.println("[Resurrection] Registering listeners and adding commands..."); System.out.println("[Resurrection] Registering listeners and adding commands...");
// register listener // register listener
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this); this.getServer().getPluginManager().registerEvents(new PlayerListener(parseSettings), this);
// register commands // register commands
this.getCommand("about").setExecutor(new CommandAbout(parseSettings.getSetting("debug"), pluginInfo.getVersion(), outdated)); this.getCommand("about").setExecutor(new CommandAbout(parseSettings.getSetting("debug"), pluginInfo.getVersion(), outdated));

View file

@ -1,5 +1,6 @@
package net.brysonsteck.Resurrection.commands; package net.brysonsteck.Resurrection.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -7,19 +8,26 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CommandAbout implements CommandExecutor { public class CommandAbout implements CommandExecutor {
boolean debug;
String currentVersion; String currentVersion;
boolean outdated; boolean outdated;
public CommandAbout(String debug, String currentVersion, boolean outdated) { public CommandAbout(String debug, String currentVersion, boolean outdated) {
this.debug = Boolean.parseBoolean(debug);
this.currentVersion = currentVersion; this.currentVersion = currentVersion;
this.outdated = outdated; this.outdated = outdated;
} }
@Override @Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (debug) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: The `/about` command was ran by " + commandSender.getName());
}
if (commandSender instanceof Player) { if (commandSender instanceof Player) {
if (debug) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is a player.");
}
Player p = (Player) commandSender; Player p = (Player) commandSender;
p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "--- Resurrection ---" + ChatColor.RESET); p.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "--- Resurrection ---" + ChatColor.RESET);
p.sendMessage(ChatColor.YELLOW + "Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning."); p.sendMessage(ChatColor.YELLOW + "Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning.");
@ -32,6 +40,9 @@ public class CommandAbout implements CommandExecutor {
p.sendMessage(ChatColor.YELLOW + "For more info on this plugin or to download it, visit the GitHub repository at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection"); p.sendMessage(ChatColor.YELLOW + "For more info on this plugin or to download it, visit the GitHub repository at " + ChatColor.AQUA + "https://github.com/brysonsteck/resurrection");
p.sendMessage(ChatColor.YELLOW + "\u00a9 2021 Bryson Steck"); p.sendMessage(ChatColor.YELLOW + "\u00a9 2021 Bryson Steck");
} else { } else {
if (debug) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: CommandSender is console.");
}
System.out.println("[Resurrection] --- Resurrection ---"); System.out.println("[Resurrection] --- Resurrection ---");
System.out.println("[Resurrection]"); System.out.println("[Resurrection]");
System.out.println("[Resurrection] Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning."); System.out.println("[Resurrection] Resurrection is a Spigot Minecraft plugin that forces players to wait a certain amount of time before respawning.");

View file

@ -26,8 +26,8 @@ public class PlayerListener implements Listener {
Hashtable<String, Location> playerSpawns = new Hashtable<>(); Hashtable<String, Location> playerSpawns = new Hashtable<>();
ParseSettings parseSettings; ParseSettings parseSettings;
public PlayerListener() { public PlayerListener(ParseSettings parseSettings) {
parseSettings = new ParseSettings(); this.parseSettings = parseSettings;
} }
@EventHandler @EventHandler