some bugs fixed

DeathListener still not working
This commit is contained in:
BuildTools 2016-08-23 22:55:58 -04:00
parent 3b2be4a9b3
commit 7651b14c93
3 changed files with 56 additions and 6 deletions

View file

@ -27,9 +27,13 @@ public class DeathListener implements Listener {
Location location = player.getLocation(); Location location = player.getLocation();
String worldString = (String) location.getWorld().getName(); String worldString = (String) location.getWorld().getName();
player.sendMessage(timeString);
player.sendMessage(playerString);
player.sendMessage(worldString);
if (worldString == "hardcore"){ if (worldString == "hardcore"){
plugin.deathMap.put(playerString, timeString); plugin.deathMap.put(playerString, timeString);
player.sendMessage(plugin.deathMap.toString());
} }
} }

View file

@ -21,18 +21,41 @@ public class HelloWorld implements CommandExecutor {
sender.sendMessage("WELL, AT LEAST THIS WORKS"); sender.sendMessage("WELL, AT LEAST THIS WORKS");
if (sender instanceof Player){ if (sender instanceof Player){
String playername = sender.getName(); sender.sendMessage("sender IS instanceof Player");
int deathtime = Integer.parseInt(plugin.deathMap.get(playername));
long currentTime = System.currentTimeMillis();
int timeInt = (int) currentTime;
if (timeInt - deathtime >= 86400000){ long currentTime = System.currentTimeMillis();
String playername = sender.getName();
long deathTime = 0;
if (plugin.deathMap.get(playername) != null){
deathTime = Long.parseLong(plugin.deathMap.get(playername));
}else{
sender.sendMessage("you have never died in hardcore");
Player player = (Player) sender;
World hardcoreWorld = player.getServer().getWorld("hardcore");
Location location = new Location(hardcoreWorld, 1280, 71, -179);
player.teleport(location);
}
sender.sendMessage(playername);
sender.sendMessage(String.valueOf(deathTime));
sender.sendMessage(String.valueOf(currentTime));
if (currentTime - deathTime >= 86400000){
sender.sendMessage("more than 24 hours have passed since you died in hardcore last");
Player player = (Player) sender; Player player = (Player) sender;
World hardcoreWorld = player.getServer().getWorld("hardcore"); World hardcoreWorld = player.getServer().getWorld("hardcore");
Location location = new Location(hardcoreWorld, 1280, 71, -179); Location location = new Location(hardcoreWorld, 1280, 71, -179);
player.teleport(location); player.teleport(location);
}else{ }else{
sender.sendMessage("you are dead for the next" + ((86400000 - (timeInt - deathtime))/3600000) + "hours"); sender.sendMessage("you are dead for the next " + (86400000 - (currentTime - deathTime) ) /3600000 + " hours");
} }
}else{ }else{

View file

@ -1,6 +1,10 @@
package iie; package iie;
import java.util.AbstractMap;
import java.util.HashMap;
public class publicstaticvoidmain { public class publicstaticvoidmain {
public static void main(String[] args){ public static void main(String[] args){
System.out.println("Hello World!"); System.out.println("Hello World!");
@ -9,10 +13,29 @@ public class publicstaticvoidmain {
int test2 = Integer.parseInt(testString); int test2 = Integer.parseInt(testString);
System.out.println(test2); System.out.println(test2);
if (test == 1234){
test = 12345;
}
System.out.println(test);
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
System.out.println(currentTime); System.out.println(currentTime);
System.out.println(Long.parseLong("1472003809703"));
AbstractMap<String,String> deathMap = new HashMap<String,String>();
deathMap.put("test", "1472003809703");
long deathTime = Long.parseLong(deathMap.get("test"));
System.out.println(deathMap.get("test"));
System.out.println(deathTime + " is a number");
System.out.println(deathMap.get("other"));
System.out.println("you are dead for the next " + ((86400000 - (currentTime - deathTime))/3600000) + " hours");
} }