added debug messages to all where applicable

This commit is contained in:
Bryson Steck 2021-09-13 17:26:37 -06:00
parent 9e8c0c2a88
commit 897c2b72e6
4 changed files with 26 additions and 5 deletions

View file

@ -110,7 +110,7 @@ public class Resurrection extends JavaPlugin implements Listener {
System.out.println("[Resurrection] ---------------------------------------------------------"); System.out.println("[Resurrection] ---------------------------------------------------------");
} }
System.out.println("[Resurrection] Registering listeners and adding commands..."); System.out.println("[Resurrection] Essential files found and valid. Registering listeners and adding commands...");
// register listener // register listener
this.getServer().getPluginManager().registerEvents(new PlayerListener(parseSettings), this); this.getServer().getPluginManager().registerEvents(new PlayerListener(parseSettings), this);
if (DEBUG) { if (DEBUG) {

View file

@ -33,11 +33,11 @@ public class PlayerData {
System.out.println("[Resurrection] Resurrection will continue to run despite this error, but avoid shutting down the server until a successful save occurs."); System.out.println("[Resurrection] Resurrection will continue to run despite this error, but avoid shutting down the server until a successful save occurs.");
System.out.println("[Resurrection] In the mean time, check to make sure the playerData file exists and you have permissions to write to it."); System.out.println("[Resurrection] In the mean time, check to make sure the playerData file exists and you have permissions to write to it.");
} }
readData();
if (DEBUG) { if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player data saved successfully"); Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player data saved successfully, rereading data to ensure Resurrection is up to date");
} }
readData();
} }
public void readData() { public void readData() {

View file

@ -139,6 +139,10 @@ public class PlayerListener implements Listener {
} }
} }
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection); }.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection);
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player's resurrection thread is now delayed for (their time to resurrect - current time)");
}
} }
} }
@ -169,6 +173,9 @@ public class PlayerListener implements Listener {
int index = 0; int index = 0;
for (String players : rawPlayers) { for (String players : rawPlayers) {
if (players.startsWith(p.getDisplayName())) { if (players.startsWith(p.getDisplayName())) {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "[Res. DEBUG]: Player found in player data file, saving dead state");
}
String[] playerSplit = players.split(","); String[] playerSplit = players.split(",");
playerSplit[1] = "true"; playerSplit[1] = "true";
playerSplit[2] = String.valueOf(resurrectionTime); playerSplit[2] = String.valueOf(resurrectionTime);
@ -188,7 +195,6 @@ public class PlayerListener implements Listener {
// to ticks // to ticks
timeToResurrection = timeToResurrection * 20; timeToResurrection = timeToResurrection * 20;
new BukkitRunnable() { new BukkitRunnable() {
// save death information to player file // save death information to player file
@Override @Override
@ -222,17 +228,28 @@ public class PlayerListener implements Listener {
} }
} }
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection); }.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), timeToResurrection);
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player's resurrection thread is now delayed for resurrection_time");
}
} }
@EventHandler @EventHandler
public void onPlayerRespawn(PlayerRespawnEvent e) { public void onPlayerRespawn(PlayerRespawnEvent e) {
if (stillDead) { if (stillDead) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player " + p.getDisplayName() + " has respawned before their resurrection time");
}
TimeCheck timeCheck = new TimeCheck(Long.parseLong(parseSettings.getSetting("resurrection_time"))); TimeCheck timeCheck = new TimeCheck(Long.parseLong(parseSettings.getSetting("resurrection_time")));
playerSpawns.put(p.getDisplayName(), p.getLocation()); playerSpawns.put(p.getDisplayName(), p.getLocation());
p.setGameMode(GameMode.SPECTATOR); p.setGameMode(GameMode.SPECTATOR);
p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "YOU HAVE DIED!!"); p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "YOU HAVE DIED!!");
p.sendMessage(ChatColor.RED + "You will be able to respawn in the next " + timeCheck.formatTime('f')); p.sendMessage(ChatColor.RED + "You will be able to respawn in the next " + timeCheck.formatTime('f'));
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Applying potions, spectator mode");
}
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -252,6 +269,10 @@ public class PlayerListener implements Listener {
public void onPlayerMove(PlayerMoveEvent e) { public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (p.getGameMode() == GameMode.SPECTATOR) { if (p.getGameMode() == GameMode.SPECTATOR) {
if (DEBUG) {
Bukkit.broadcastMessage(ChatColor.YELLOW +""+ ChatColor.BOLD + "[Res. DEBUG]: Player " + p.getDisplayName() + " attempted to move while in dead state, teleporting to spawn until their resurrection time");
}
p.teleport(spawn); p.teleport(spawn);
} }
} }