From 7651b14c939cb200be871936a232e2d21cba1e92 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 23 Aug 2016 22:55:58 -0400 Subject: [PATCH] some bugs fixed DeathListener still not working --- src/iie/DeathListener.java | 4 ++++ src/iie/HelloWorld.java | 35 +++++++++++++++++++++++++------ src/iie/publicstaticvoidmain.java | 23 ++++++++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/iie/DeathListener.java b/src/iie/DeathListener.java index 6e9baa6..c2ad90f 100644 --- a/src/iie/DeathListener.java +++ b/src/iie/DeathListener.java @@ -27,9 +27,13 @@ public class DeathListener implements Listener { Location location = player.getLocation(); String worldString = (String) location.getWorld().getName(); + player.sendMessage(timeString); + player.sendMessage(playerString); + player.sendMessage(worldString); if (worldString == "hardcore"){ plugin.deathMap.put(playerString, timeString); + player.sendMessage(plugin.deathMap.toString()); } } diff --git a/src/iie/HelloWorld.java b/src/iie/HelloWorld.java index 50a2b5b..32d7a4b 100644 --- a/src/iie/HelloWorld.java +++ b/src/iie/HelloWorld.java @@ -21,18 +21,41 @@ public class HelloWorld implements CommandExecutor { sender.sendMessage("WELL, AT LEAST THIS WORKS"); if (sender instanceof Player){ - String playername = sender.getName(); - int deathtime = Integer.parseInt(plugin.deathMap.get(playername)); - long currentTime = System.currentTimeMillis(); - int timeInt = (int) currentTime; + sender.sendMessage("sender IS instanceof Player"); - 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; World hardcoreWorld = player.getServer().getWorld("hardcore"); Location location = new Location(hardcoreWorld, 1280, 71, -179); player.teleport(location); + }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{ diff --git a/src/iie/publicstaticvoidmain.java b/src/iie/publicstaticvoidmain.java index d12060d..5c4a587 100644 --- a/src/iie/publicstaticvoidmain.java +++ b/src/iie/publicstaticvoidmain.java @@ -1,6 +1,10 @@ package iie; +import java.util.AbstractMap; +import java.util.HashMap; + public class publicstaticvoidmain { + public static void main(String[] args){ System.out.println("Hello World!"); @@ -9,10 +13,29 @@ public class publicstaticvoidmain { int test2 = Integer.parseInt(testString); System.out.println(test2); + if (test == 1234){ + test = 12345; + } + + System.out.println(test); + long currentTime = System.currentTimeMillis(); + System.out.println(currentTime); + + System.out.println(Long.parseLong("1472003809703")); + AbstractMap deathMap = new HashMap(); + 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"); + + }