From 1ec94c06e841f1548a32478db8b5772139c56f36 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 23 Aug 2016 14:25:31 -0400 Subject: [PATCH] human beings are pitiful clumps of matter --- config.yml | 0 plugin.yml | 6 ++++ src/iie/DeathListener.java | 37 +++++++++++++++++++++++++ src/iie/HelloWorld.java | 46 +++++++++++++++++++++++++++++++ src/iie/HelloWorldPlugin.java | 18 ++++++++++++ src/iie/publicstaticvoidmain.java | 19 +++++++++++++ 6 files changed, 126 insertions(+) create mode 100644 config.yml create mode 100644 plugin.yml create mode 100644 src/iie/DeathListener.java create mode 100644 src/iie/HelloWorld.java create mode 100644 src/iie/HelloWorldPlugin.java create mode 100644 src/iie/publicstaticvoidmain.java diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..e69de29 diff --git a/plugin.yml b/plugin.yml new file mode 100644 index 0000000..13eb73d --- /dev/null +++ b/plugin.yml @@ -0,0 +1,6 @@ + main: iie.HelloWorldPlugin + version: 1.0.0 + name: HelloWorldPlugin + commands: + HelloWorld: + description: Command that says Hello World! \ No newline at end of file diff --git a/src/iie/DeathListener.java b/src/iie/DeathListener.java new file mode 100644 index 0000000..6e9baa6 --- /dev/null +++ b/src/iie/DeathListener.java @@ -0,0 +1,37 @@ +package iie; + +import java.time.Clock; +import java.time.LocalDateTime; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; + +public class DeathListener implements Listener { + + HelloWorldPlugin plugin; + public DeathListener(HelloWorldPlugin plugin){ + this.plugin = plugin; + } + + @EventHandler + public void onHardcoreDeath(PlayerDeathEvent deathEvent){ + + + LocalDateTime currentTime = LocalDateTime.now(Clock.systemUTC()); + String timeString = currentTime.toString(); + Player player = deathEvent.getEntity(); + String playerString = (String) player.getName(); + Location location = player.getLocation(); + String worldString = (String) location.getWorld().getName(); + + + if (worldString == "hardcore"){ + plugin.deathMap.put(playerString, timeString); + } + + } + +} diff --git a/src/iie/HelloWorld.java b/src/iie/HelloWorld.java new file mode 100644 index 0000000..50a2b5b --- /dev/null +++ b/src/iie/HelloWorld.java @@ -0,0 +1,46 @@ +package iie; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class HelloWorld implements CommandExecutor { + + HelloWorldPlugin plugin; + public HelloWorld(HelloWorldPlugin plugin){ + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command label, String command, String[] args) { + // TODO Auto-generated method stub + + 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; + + if (timeInt - deathtime >= 86400000){ + 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"); + } + + }else{ + + sender.sendMessage("You must be a player to use this command!"); + + } + return false; + } + +} diff --git a/src/iie/HelloWorldPlugin.java b/src/iie/HelloWorldPlugin.java new file mode 100644 index 0000000..f96ed78 --- /dev/null +++ b/src/iie/HelloWorldPlugin.java @@ -0,0 +1,18 @@ +package iie; + +import java.util.AbstractMap; +import java.util.HashMap; + +import org.bukkit.plugin.java.JavaPlugin; + +public class HelloWorldPlugin extends JavaPlugin { + public AbstractMap deathMap = new HashMap(); + public void onEnable(){ + registerCommands(); + getServer().getPluginManager().registerEvents(new DeathListener(this), this); + } + public void registerCommands(){ + getCommand("HelloWorld").setExecutor(new HelloWorld(this)); + } + +} diff --git a/src/iie/publicstaticvoidmain.java b/src/iie/publicstaticvoidmain.java new file mode 100644 index 0000000..d12060d --- /dev/null +++ b/src/iie/publicstaticvoidmain.java @@ -0,0 +1,19 @@ +package iie; + +public class publicstaticvoidmain { + public static void main(String[] args){ + System.out.println("Hello World!"); + + int test = 1234; + String testString = Integer.toString(test); + int test2 = Integer.parseInt(testString); + System.out.println(test2); + + + long currentTime = System.currentTimeMillis(); + System.out.println(currentTime); + + + + } +}