code cleanup
This commit is contained in:
parent
6c39053bdf
commit
27c90aaed9
5 changed files with 12 additions and 17 deletions
Binary file not shown.
|
@ -1,6 +1,5 @@
|
||||||
package net.brysonsteck.Resurrection.commands;
|
package net.brysonsteck.Resurrection.commands;
|
||||||
|
|
||||||
import net.brysonsteck.Resurrection.startup.CheckForUpdate;
|
|
||||||
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;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package net.brysonsteck.Resurrection.player;
|
package net.brysonsteck.Resurrection.player;
|
||||||
|
|
||||||
import net.brysonsteck.Resurrection.Resurrection;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
public class PlayerData {
|
public class PlayerData {
|
||||||
|
@ -26,10 +23,9 @@ public class PlayerData {
|
||||||
try {
|
try {
|
||||||
rawData = "";
|
rawData = "";
|
||||||
BufferedReader reader = new BufferedReader(new FileReader("plugins/playerData.resurrection"));
|
BufferedReader reader = new BufferedReader(new FileReader("plugins/playerData.resurrection"));
|
||||||
String line = "";
|
String line;
|
||||||
String[] playerData;
|
String[] playerData;
|
||||||
while (true) {
|
while (true) {
|
||||||
playerData = new String[3];
|
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
break;
|
break;
|
||||||
|
@ -46,9 +42,9 @@ public class PlayerData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable<String, Hashtable<String, String>> getPlayers() {
|
// public Hashtable<String, Hashtable<String, String>> getPlayers() {
|
||||||
return playerData;
|
// return playerData;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getRawData() {
|
public String getRawData() {
|
||||||
return rawData;
|
return rawData;
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
if (resumeDeath && !timerRunning) {
|
if (resumeDeath && !timerRunning) {
|
||||||
spawn = p.getLocation();
|
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() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -71,7 +73,9 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1);
|
}.runTaskLater(JavaPlugin.getProvidingPlugin(Resurrection.class), 1);
|
||||||
resurrectTime = resurrectTime - System.currentTimeMillis();
|
resurrectTime = resurrectTime - System.currentTimeMillis();
|
||||||
|
// to seconds
|
||||||
resurrectTime = resurrectTime / 1000;
|
resurrectTime = resurrectTime / 1000;
|
||||||
|
// to ticks
|
||||||
resurrectTime = resurrectTime * 20;
|
resurrectTime = resurrectTime * 20;
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -102,7 +106,7 @@ public class PlayerListener implements Listener {
|
||||||
//
|
//
|
||||||
// String deathFormatted = death.formatTime();
|
// String deathFormatted = death.formatTime();
|
||||||
// String resurrectFormatted = resurrect.formatTime();
|
// String resurrectFormatted = resurrect.formatTime();
|
||||||
long timeOfDeath = System.currentTimeMillis();
|
// long timeOfDeath = System.currentTimeMillis();
|
||||||
long resurrectionTime = System.currentTimeMillis() + 86400000;
|
long resurrectionTime = System.currentTimeMillis() + 86400000;
|
||||||
|
|
||||||
p.sendMessage("You have died!! You will be able to respawn in the next 24 hours.");
|
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 rawData = playerData.getRawData();
|
||||||
String[] rawPlayers = rawData.split(";");
|
String[] rawPlayers = rawData.split(";");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
boolean found = false;
|
|
||||||
for (String players : rawPlayers) {
|
for (String players : rawPlayers) {
|
||||||
if (players.startsWith(p.getDisplayName())) {
|
if (players.startsWith(p.getDisplayName())) {
|
||||||
found = true;
|
|
||||||
String[] playerSplit = players.split(",");
|
String[] playerSplit = players.split(",");
|
||||||
playerSplit[1] = "true";
|
playerSplit[1] = "true";
|
||||||
playerSplit[2] = String.valueOf(resurrectionTime);
|
playerSplit[2] = String.valueOf(resurrectionTime);
|
||||||
|
@ -169,7 +171,8 @@ public class PlayerListener implements Listener {
|
||||||
if (stillDead) {
|
if (stillDead) {
|
||||||
final Player p = e.getPlayer();
|
final Player p = e.getPlayer();
|
||||||
p.setGameMode(GameMode.SPECTATOR);
|
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() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -10,13 +10,10 @@ public class TimeCheck {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatTime() {
|
public String formatTime() {
|
||||||
long hours = TimeUnit.MILLISECONDS.toHours(millis);
|
return String.format("%d hrs, %d min, %d sec",
|
||||||
|
|
||||||
String formattedTime = String.format("%d hrs, %d min, %d sec",
|
|
||||||
TimeUnit.MILLISECONDS.toHours(millis),
|
TimeUnit.MILLISECONDS.toHours(millis),
|
||||||
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
|
TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
|
||||||
TimeUnit.MILLISECONDS.toSeconds(millis) -
|
TimeUnit.MILLISECONDS.toSeconds(millis) -
|
||||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
|
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
|
||||||
return formattedTime;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue