diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..be86bf9 --- /dev/null +++ b/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 32858aa..829bbce 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..a9ec82a --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + unconflicted-Hardcore + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..7a53139 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..714351a --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c3f7a4a --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + com.github.TBMCPlugins + Hardcore + 0.0.1-SNAPSHOT + + src + + + src + + *.yml + + + **/*.java + + + + + + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + + + UTF-8 + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + jcenter + http://jcenter.bintray.com + + + jitpack.io + https://jitpack.io + + + + + org.spigotmc + spigot-api + 1.9.2-R0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/src/iie/BoundaryListener.java b/src/iie/BoundaryListener.java new file mode 100644 index 0000000..31123a1 --- /dev/null +++ b/src/iie/BoundaryListener.java @@ -0,0 +1,87 @@ +package iie; + +import java.util.AbstractMap; +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +public class BoundaryListener implements Listener { + + HelloWorldPlugin plugin; + public BoundaryListener(HelloWorldPlugin plugin){ + this.plugin = plugin; + } + + int minX = 666; // MAP BORDER COORDS HERE + int maxX = 2366; + int minZ = -1520; + int maxZ = 280; + + public boolean OutOfBounds (Player player, int x, int z){ + boolean isOutOfBounds = false; + x = player.getLocation().getBlockX(); + z = player.getLocation().getBlockZ(); + if (x < minX || x > maxX || z < minZ || z > maxZ) isOutOfBounds = true; + return isOutOfBounds; + } + + public boolean FurtherOut (Player player, int x, int z){ + boolean isFurtherOut = false; + x = player.getLocation().getBlockX(); + z = player.getLocation().getBlockZ(); + if (x < minX - 50 || x > maxX + 50 || z < minZ - 50 || z > maxZ + 50) isFurtherOut = true; + return isFurtherOut; + } + + public static AbstractMap moveDelay = new HashMap(); + public static AbstractMap boundaryWarning = new HashMap(); + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerMove(PlayerMoveEvent event){ + + Player player = (Player) event.getPlayer(); + String playername = player.getName(); + World world = player.getWorld(); + String worldname = world.getName(); + if (playername == "iie") world.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP,1F,1F); + + new Thread(() -> { + + + + if (worldname != "hardcore") return; + + int currentTime = (int) (System.currentTimeMillis()/1000); + int playerTime = moveDelay.get(playername); + boolean playerWarning = boundaryWarning.get(playername); + int x = player.getLocation().getBlockX(); + int z = player.getLocation().getBlockZ(); + boolean OutOfBounds = OutOfBounds(player, x, z); + + + if (playerWarning && currentTime > playerTime + 1 && OutOfBounds){ + world.playSound(player.getLocation(), Sound.AMBIENT_CAVE,1F,1F); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ("tellraw " + playername + " {\"text\":\"...out of bounds...\",\"color\":\"dark_red\"}")); + boundaryWarning.put(playername, false); + } else if (playerWarning && currentTime > playerTime && FurtherOut(player, x, z)){ + world.playSound(player.getLocation(), Sound.AMBIENT_CAVE,1F,1F); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ("tellraw " + playername + " {\"text\":\"...out of bounds...\",\"color\":\"dark_red\"}")); + boundaryWarning.put(playername, false); + if (playername == "iie") ; + } else if (!playerWarning && !OutOfBounds) boundaryWarning.put(playername, true); + + + moveDelay.put(playername, currentTime); + + }).start(); + + } + +} diff --git a/src/iie/ChatFormattingListener.java b/src/iie/ChatFormattingListener.java new file mode 100644 index 0000000..c8676ed --- /dev/null +++ b/src/iie/ChatFormattingListener.java @@ -0,0 +1,14 @@ +package iie; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; + +public class ChatFormattingListener implements Listener{ + + @EventHandler(priority = EventPriority.MONITOR) + public void AsyncPlayerChatEvent (){ + + } + +} diff --git a/src/iie/EnderchestListener.java b/src/iie/EnderchestListener.java new file mode 100644 index 0000000..08be92d --- /dev/null +++ b/src/iie/EnderchestListener.java @@ -0,0 +1,5 @@ +package iie; + +public class EnderchestListener { + +} diff --git a/src/iie/HelloWorldPlugin.java b/src/iie/HelloWorldPlugin.java index a3a1995..34f5063 100644 --- a/src/iie/HelloWorldPlugin.java +++ b/src/iie/HelloWorldPlugin.java @@ -2,8 +2,10 @@ package iie; import java.util.AbstractMap; import java.util.HashMap; +import java.util.UUID; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; @@ -11,13 +13,18 @@ import org.bukkit.scoreboard.Scoreboard; public class HelloWorldPlugin extends JavaPlugin { + public static Player iie; + public static Scoreboard board; public static Objective hardcoreTimeDead; public static Objective hardcoreInvite; + public static Objective hardcoreOutBound; public static AbstractMap deathMap = new HashMap(); public void onEnable(){ + iie = Bukkit.getServer().getOfflinePlayer((UUID) UUID.fromString("633d0de1-4a67-46ff-bd8a-004fa8ce4858")).getPlayer(); + board = Bukkit.getServer().getScoreboardManager().getMainScoreboard(); if (board.getObjective("hardcoreTimeDead") != null){ //null check hardcoreTimeDead hardcoreTimeDead = board.getObjective("hardcoreTimeDead"); @@ -29,10 +36,16 @@ public class HelloWorldPlugin extends JavaPlugin { }else{ hardcoreInvite = board.registerNewObjective("hardcoreInvite", "dummy"); } + if (board.getObjective("hardcoreOutBound") != null){ //null check hardcoreOutBound + hardcoreOutBound = board.getObjective("hardcoreOutBound"); + }else{ + hardcoreOutBound = board.registerNewObjective("hardcoreOutBound", "dummy"); + } registerCommands(); getServer().getPluginManager().registerEvents(new JoinListener(this), this); getServer().getPluginManager().registerEvents(new DeathListener(this), this); + getServer().getPluginManager().registerEvents(new BoundaryListener(this), this); } diff --git a/src/iie/JoinListener.java b/src/iie/JoinListener.java index 5bf6b1b..b55762e 100644 --- a/src/iie/JoinListener.java +++ b/src/iie/JoinListener.java @@ -19,7 +19,7 @@ public class JoinListener implements Listener { Player player = JoinEvent.getPlayer(); String playername = (String) player.getName(); - + if (HelloWorldPlugin.hardcoreInvite.getScore(playername) == null){ //null check HelloWorldPlugin.hardcoreInvite.getScore(playername).setScore(0); //convert null to 0 @@ -43,6 +43,9 @@ public class JoinListener implements Listener { return; } + BoundaryListener.moveDelay.put(playername, currentTime); + BoundaryListener.boundaryWarning.put(playername, true); + //HelloWorldPlugin.deathMap.put(playername, String.valueOf(HelloWorldPlugin.hardcoreTimeDead.getScore(playername).getScore()));