code cleanup

This commit is contained in:
Bryson Steck 2021-07-04 21:56:15 -06:00
parent 6c39053bdf
commit 27c90aaed9
5 changed files with 12 additions and 17 deletions

View file

@ -1,6 +1,5 @@
package net.brysonsteck.Resurrection.commands;
import net.brysonsteck.Resurrection.startup.CheckForUpdate;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;

View file

@ -1,10 +1,7 @@
package net.brysonsteck.Resurrection.player;
import net.brysonsteck.Resurrection.Resurrection;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.Arrays;
import java.util.Hashtable;
public class PlayerData {
@ -26,10 +23,9 @@ public class PlayerData {
try {
rawData = "";
BufferedReader reader = new BufferedReader(new FileReader("plugins/playerData.resurrection"));
String line = "";
String line;
String[] playerData;
while (true) {
playerData = new String[3];
line = reader.readLine();
if (line == null) {
break;
@ -46,9 +42,9 @@ public class PlayerData {
}
}
public Hashtable<String, Hashtable<String, String>> getPlayers() {
return playerData;
}
// public Hashtable<String, Hashtable<String, String>> getPlayers() {
// return playerData;
// }
public String getRawData() {
return rawData;

View file

@ -59,6 +59,8 @@ public class PlayerListener implements Listener {
}
if (resumeDeath && !timerRunning) {
spawn = p.getLocation();
p.sendMessage(ChatColor.RED + "You are still dead. To check how long you have left before you are resurrected, " +
"run \"howlong\" in chat.");
new BukkitRunnable() {
@Override
public void run() {
@ -71,7 +73,9 @@ public class PlayerListener implements Listener {
}
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1);
resurrectTime = resurrectTime - System.currentTimeMillis();
// to seconds
resurrectTime = resurrectTime / 1000;
// to ticks
resurrectTime = resurrectTime * 20;
new BukkitRunnable() {
@ -102,7 +106,7 @@ public class PlayerListener implements Listener {
//
// String deathFormatted = death.formatTime();
// String resurrectFormatted = resurrect.formatTime();
long timeOfDeath = System.currentTimeMillis();
// long timeOfDeath = System.currentTimeMillis();
long resurrectionTime = System.currentTimeMillis() + 86400000;
p.sendMessage("You have died!! You will be able to respawn in the next 24 hours.");
@ -114,10 +118,8 @@ public class PlayerListener implements Listener {
String rawData = playerData.getRawData();
String[] rawPlayers = rawData.split(";");
int index = 0;
boolean found = false;
for (String players : rawPlayers) {
if (players.startsWith(p.getDisplayName())) {
found = true;
String[] playerSplit = players.split(",");
playerSplit[1] = "true";
playerSplit[2] = String.valueOf(resurrectionTime);
@ -169,7 +171,8 @@ public class PlayerListener implements Listener {
if (stillDead) {
final Player p = e.getPlayer();
p.setGameMode(GameMode.SPECTATOR);
p.sendTitle("You have died!", "You must wait 24 hours before you can respawn.");
p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "YOU HAVE DIED!!");
p.sendMessage(ChatColor.RED + "You will be able to respawn in the next 24 hours.");
new BukkitRunnable() {
@Override
public void run() {

View file

@ -10,13 +10,10 @@ public class TimeCheck {
}
public String formatTime() {
long hours = TimeUnit.MILLISECONDS.toHours(millis);
String formattedTime = String.format("%d hrs, %d min, %d sec",
return String.format("%d hrs, %d min, %d sec",
TimeUnit.MILLISECONDS.toHours(millis),
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
TimeUnit.MILLISECONDS.toSeconds(millis) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
return formattedTime;
}
}