diff --git a/.classpath b/.classpath
index f0257c5..9c4312a 100644
--- a/.classpath
+++ b/.classpath
@@ -31,6 +31,11 @@
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index 98412d6..6f967ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,7 @@
-/bin/
-spigot
-.vscode
-target
\ No newline at end of file
+.vscode/
+.settings/
+.idea/
+target/
+jars/
+.classpath
+.idea/
\ No newline at end of file
diff --git a/.project b/.project
index 036d78c..1583b3e 100644
--- a/.project
+++ b/.project
@@ -1,23 +1,23 @@
-
-
- Harbor
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.m2e.core.maven2Nature
- org.eclipse.jdt.core.javanature
-
-
+
+
+ Harbor
+
+
+
+
+
+ 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
deleted file mode 100644
index 0c43133..0000000
--- a/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding/=UTF-8
-encoding/src=UTF-8
diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs
deleted file mode 100644
index d4313d4..0000000
--- a/.settings/org.eclipse.jdt.apt.core.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.apt.aptEnabled=false
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 5592a0a..0000000
--- a/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-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.processAnnotations=disabled
-org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
deleted file mode 100644
index f897a7f..0000000
--- a/.settings/org.eclipse.m2e.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/LICENSE b/LICENSE
index 91296e2..568993c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2018 Mykyta
+Copyright (c) 2019 Mykyta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index f662073..2064832 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
-[discord-invite]: https://discord.gg/UACRzwe
-# Harbor [![Discord](https://discordapp.com/api/guilds/285623631042707457/widget.png)][discord-invite] [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/nkomarn/Harbor/blob/master/LICENSE)
-Harbor is a plugin that redefines sleep within your Spigot server!
-https://www.spigotmc.org/resources/harbor-a-sleep-enhancement-plugin.60088/
+# 🌱 The Seed - Spigot Plugin Template
+A Spigot template that I use to develop plugins for The Seed MC!
+https://theseedmc.com
+
+### test
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..a1c8e5f
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,2 @@
+mvn package
+yes | cp -rf target/*-*.jar ../Spigot/1.13.2/plugins
\ No newline at end of file
diff --git a/plugin.yml b/plugin.yml
deleted file mode 100644
index 9d6b5f5..0000000
--- a/plugin.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-name: Harbor
-version: 1.5
-main: mykyta.Harbor.Harbor
-description: Ahoy, matey! Harbor is a Spigot plugin that redefines how sleep works in your server, making it easier for all the online players to get in bed quick and skip through the night!
-author: Mykyta (TechToolbox)
-website: https://mykyta.tk
-api-version: 1.14
-
-commands:
- harbor:
- description: List information and control Harbor.
- usage: /
- sleeping:
- description: Show a list of the sleeping players in your world.
- usage: /
-
diff --git a/pom.xml b/pom.xml
index ee3995a..1bcfd30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,157 +1,146 @@
-
- 4.0.0
- mykyta.Harbor
- Harbor
- 1.5
-
- 1.8
- 1.8
- UTF-8
- ${project.basedir}/spigot
-
-
-
-
- com.google.code.gson
- gson
- 2.8.5
-
+
+
+ 4.0.0
+ xyz.nkomarn
+ Harbor
+ 1.5.1
+
+
+ UTF-8
+ 1.8
+ 1.8
+ ${project.basedir}/jars
+
+
+
-
-
- spigotmc.org
- spigot-1.14.1
- system
- ${spigot}/1.14.1.jar
- 1.14.1
-
-
- spigotmc.org
- spigot-1.14
- system
- ${spigot}/1.14.jar
- 1.14
-
-
- spigotmc.org
- spigot-1.13.2
- system
- ${spigot}/1.13.2.jar
- 1.13.2
-
-
- spigotmc.org
- spigot-1.13
- system
- ${spigot}/1.13.jar
- 1.13
-
-
- spigotmc.org
- spigot-1.12.2
- system
- ${spigot}/1.12.2.jar
- 1.12.2
-
-
- spigotmc.org
- spigot-1.11.2
- system
- ${spigot}/1.11.2.jar
- 1.11.2
-
-
- spigotmc.org
- spigot-1.10.2
- system
- ${spigot}/1.10.2.jar
- 1.10.2
-
-
- spigotmc.org
- spigot-1.9.4
- system
- ${spigot}/1.9.4.jar
- 1.9.4
-
-
- spigotmc.org
- spigot-1.9.2
- system
- ${spigot}/1.9.2.jar
- 1.9.2
-
-
- spigotmc.org
- spigot-1.8.8
- system
- ${spigot}/1.8.8.jar
- 1.8.8
-
-
- spigotmc.org
- spigot-1.8.3
- system
- ${spigot}/1.8.3.jar
- 1.8.3
-
-
- spigotmc.org
- spigot-1.8
- system
- ${spigot}/1.8.jar
- 1.8
-
-
- spigotmc.org
- spigot-1.7.2
- system
- ${spigot}/1.7.2.jar
- 1.7.2
-
-
-
-
- inventivetalent.org
- bossbarapi-2.4.1
- system
- ${spigot}/BossBarAPI.jar
- 2.4.1
-
-
-
- /home/nkomarn/Documents/Spigot Servers/1.14.2/plugins/
- ${basedir}/src/
-
-
- .
- true
- ${basedir}
-
- *.yml
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.0.2
-
-
- maven-compiler-plugin
- 3.5
-
-
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.0.1
-
-
-
-
+
+
+
+
+ spigotmc.org
+ spigot-1.14.1
+ system
+ ${jars}/1.14.1.jar
+ 1.14.1
+
+
+ spigotmc.org
+ spigot-1.14
+ system
+ ${jars}/1.14.jar
+ 1.14
+
+
+ spigotmc.org
+ spigot-1.13.2
+ system
+ ${jars}/1.13.2.jar
+ 1.13.2
+
+
+ spigotmc.org
+ spigot-1.13
+ system
+ ${jars}/1.13.jar
+ 1.13
+
+
+ spigotmc.org
+ spigot-1.12.2
+ system
+ ${jars}/1.12.2.jar
+ 1.12.2
+
+
+ spigotmc.org
+ spigot-1.11.2
+ system
+ ${jars}/1.11.2.jar
+ 1.11.2
+
+
+ spigotmc.org
+ spigot-1.10.2
+ system
+ ${jars}/1.10.2.jar
+ 1.10.2
+
+
+ spigotmc.org
+ spigot-1.9.4
+ system
+ ${jars}/1.9.4.jar
+ 1.9.4
+
+
+ spigotmc.org
+ spigot-1.9.2
+ system
+ ${jars}/1.9.2.jar
+ 1.9.2
+
+
+ spigotmc.org
+ spigot-1.8.8
+ system
+ ${jars}/1.8.8.jar
+ 1.8.8
+
+
+ spigotmc.org
+ spigot-1.8.3
+ system
+ ${jars}/1.8.3.jar
+ 1.8.3
+
+
+ spigotmc.org
+ spigot-1.8
+ system
+ ${jars}/1.8.jar
+ 1.8
+
+
+ spigotmc.org
+ spigot-1.7.2
+ system
+ ${jars}/1.7.2.jar
+ 1.7.2
+
+
+
+
+ target
+
+
+ true
+ src/main/resources
+
+ plugin.yml
+ config.yml
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.1.0
+
+
+ maven-resources-plugin
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Commands/Command.java b/src/main/java/mykyta/Harbor/Commands/Command.java
deleted file mode 100644
index b257430..0000000
--- a/src/main/java/mykyta/Harbor/Commands/Command.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package mykyta.Harbor.Commands;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-
-import mykyta.Harbor.Config;
-import mykyta.Harbor.Harbor;
-import mykyta.Harbor.Updater;
-import mykyta.Harbor.Util;
-
-public class Command implements CommandExecutor {
- @Override
- public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
- Config config = new Config();
- Util util = new Util();
-
- if (args.length < 1) {
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7Version " + util.version + " by TechToolbox."));
- return true;
- }
-
- // Permission check
- if (!sender.hasPermission("harbor.admin")) {
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.permission")));
- return true;
- }
-
- // Command arguments
- if (args[0].equalsIgnoreCase("reload")) {
- try {
- Harbor h = Config.harbor;
- h.reloadConfig();
- Bukkit.getPluginManager().disablePlugin(h);
- Bukkit.getPluginManager().enablePlugin(h);
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.reloaded")));
- }
- catch (Exception e) {
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.reloaderror")));
- if (Util.debug) e.printStackTrace();
- }
- return true;
- }
- else if (args[0].equalsIgnoreCase("update")) {
- Updater u = new Updater();
- int result = u.upgrade();
- if (result == 0) sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7Harbor was successfully updated to version " + Updater.latest + " and will be enabled after a server restart/reload."));
- else if (result == 1) sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7An error occured while updating Harbor to version " + Updater.latest + ". Check the server console for more details."));
- else if (result == 2) sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7This server is already running the latest version of Harbor. Great work!"));
- return true;
- }
-
- // Unrecognized message if nothing else worked
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.unrecognized")));
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Commands/Sleeping.java b/src/main/java/mykyta/Harbor/Commands/Sleeping.java
deleted file mode 100644
index de2bdc8..0000000
--- a/src/main/java/mykyta/Harbor/Commands/Sleeping.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package mykyta.Harbor.Commands;
-
-import java.util.ArrayList;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.World;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.SkullMeta;
-
-import mykyta.Harbor.Config;
-import mykyta.Harbor.Util;
-import mykyta.Harbor.GUI.GUIHolder;
-import mykyta.Harbor.GUI.GUIType;
-
-public class Sleeping implements CommandExecutor {
-
- private Inventory gui;
-
- @SuppressWarnings("deprecation")
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (sender instanceof Player) {
- Player p = (Player) sender;
- World w = p.getWorld();
- Config config = new Config();
- ArrayList sleeping = Util.sleeping.get(w);
- int slots = Math.min(54, ((sleeping.size() - 1) / 9 + 1) * 9);
- gui = Bukkit.createInventory(new GUIHolder(GUIType.SLEEPING), slots, config.getString("gui.sleeping"));
-
- if (sleeping.size() > 0) sleeping.forEach(pl -> {
- ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
- SkullMeta meta = (SkullMeta) item.getItemMeta();
- meta.setDisplayName(ChatColor.GRAY + pl.getName());
- meta.setOwner(pl.getName());
- item.setItemMeta(meta);
- gui.setItem(sleeping.indexOf(pl), item);
- });
-
- p.openInventory(gui);
- }
- else {
- Config config = new Config();
- if (args.length < 1) {
- ArrayList list = new ArrayList();
- Bukkit.getServer().getWorlds().forEach(w -> {list.add("&o" + w.getName());});
- Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "Specify a world name. Possible worlds are " + String.join("&r, ", list) + "&r."));
- }
- else {
- World w = Bukkit.getServer().getWorld(args[0]);
- if (w == null) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "The specified world doesn't exist."));
- else {
- ArrayList list = new ArrayList();
- Util.sleeping.get(Bukkit.getServer().getWorld(args[0])).forEach(p -> {list.add("&o" + p.getName());});
- if (list.size() > 0 && list.size() != 1) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "In &o" + args[0] + "&r, the currently sleeping players are " + String.join("&r, ", list) + "&r."));
- else if (list.size() == 1) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "In &o" + args[0] + "&r, " + list.get(0) + "&r is the only player sleeping."));
- else Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "There aren't any currently sleeping players in &o" + args[0] + "&r."));
- }
- }
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/BedEnter.java b/src/main/java/mykyta/Harbor/Events/BedEnter.java
deleted file mode 100644
index af216b1..0000000
--- a/src/main/java/mykyta/Harbor/Events/BedEnter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package mykyta.Harbor.Events;
-
-import java.util.ArrayList;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-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.PlayerBedEnterEvent;
-import org.bukkit.event.player.PlayerBedEnterEvent.BedEnterResult;
-
-import mykyta.Harbor.Config;
-import mykyta.Harbor.Util;
-
-public class BedEnter implements Listener {
- @EventHandler(priority = EventPriority.HIGH)
- public void onPlayerBedEnter(PlayerBedEnterEvent event) {
- Util util = new Util();
- Config config = new Config();
-
- // Block bed entry if enabled
- if (config.getBoolean("features.block")) {
- if (config.getString("messages.chat.blocked").length() > 0) event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.blocked")));
- util.sendActionbar(event.getPlayer(), config.getString("messages.actionbar.blocked"));
- event.setCancelled(true);
- return;
- }
-
- // 1.13.2 API change bypass
- boolean success = false;
- try {
- if (event.getBedEnterResult() == BedEnterResult.OK) success = true;
- }
- catch (NoSuchMethodError e) {
- success = true;
- }
-
- if (success) {
- Player p = event.getPlayer();
- World w = p.getWorld();
- ArrayList excluded = util.getExcluded(w);
-
- if (!excluded.contains(p)) {
- util.add(w, p);
-
- // Chat messages
- if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.sleeping").length() != 0)) {
- Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.sleeping")
- .replace("[sleeping]", String.valueOf(util.getSleeping(w))))
- .replace("[online]", String.valueOf(util.getOnline(w)))
- .replace("[player]", p.getName())
- .replace("[needed]", String.valueOf(util.getNeeded(w))));
- }
- if (config.getBoolean("messages.title.title")) {
- util.sendTitle(p, config.getString("messages.title.sleeping.top"), config.getString("messages.title.sleeping.bottom"));
- }
-
- // Skip night if possible
- if (!Util.skipping) util.skip(w);
- }
- else if (config.getString("messages.chat.bypass").length() != 0) p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.bypass")));
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/BedLeave.java b/src/main/java/mykyta/Harbor/Events/BedLeave.java
deleted file mode 100644
index 8ae05f3..0000000
--- a/src/main/java/mykyta/Harbor/Events/BedLeave.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package mykyta.Harbor.Events;
-
-import java.util.ArrayList;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-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.PlayerBedLeaveEvent;
-
-import mykyta.Harbor.Config;
-import mykyta.Harbor.Util;
-
-public class BedLeave implements Listener {
- @EventHandler(priority = EventPriority.HIGH)
- public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
- Util util = new Util();
- Config config = new Config();
- Player p = event.getPlayer();
- World w = p.getWorld();
-
- ArrayList excluded = util.getExcluded(w);
-
- // Decrement the sleeping count if player isn't excluded
- if (!excluded.contains(p)) {
- util.remove(w, p);
- }
-
- // Send a chat message when player gets out of bed (if it's not day)
- if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.left").length() != 0) && !(w.getTime() > 0 && w.getTime() < 12300) && !excluded.contains(p)) {
- Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.left")
- .replace("[sleeping]", String.valueOf(util.getSleeping(w))))
- .replace("[online]", String.valueOf(util.getOnline(w)))
- .replace("[player]", event.getPlayer().getName())
- .replace("[needed]", String.valueOf(util.getNeeded(w))));
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/ChatEvent.java b/src/main/java/mykyta/Harbor/Events/ChatEvent.java
deleted file mode 100644
index 97980f9..0000000
--- a/src/main/java/mykyta/Harbor/Events/ChatEvent.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import mykyta.Harbor.Util;
-
-public class ChatEvent implements Listener {
- Util util = new Util();
-
- @EventHandler
- public void onChat(AsyncPlayerChatEvent event) {
- util.updateActivity(event.getPlayer());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/CommandEvent.java b/src/main/java/mykyta/Harbor/Events/CommandEvent.java
deleted file mode 100644
index d139ffa..0000000
--- a/src/main/java/mykyta/Harbor/Events/CommandEvent.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import mykyta.Harbor.Util;
-
-public class CommandEvent implements Listener {
- Util util = new Util();
-
- @EventHandler
- public void onCommand(PlayerCommandPreprocessEvent event) {
- util.updateActivity(event.getPlayer());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/GUIEvent.java b/src/main/java/mykyta/Harbor/Events/GUIEvent.java
deleted file mode 100644
index 6c30595..0000000
--- a/src/main/java/mykyta/Harbor/Events/GUIEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryDragEvent;
-import mykyta.Harbor.GUI.GUIType;
-import mykyta.Harbor.Util;
-import mykyta.Harbor.GUI.GUIHolder;
-
-public class GUIEvent implements Listener {
- Util util = new Util();
-
- @EventHandler
- public void onClick(InventoryClickEvent event) {
- util.updateActivity((Player) event.getWhoClicked());
- if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof GUIHolder) {
- GUIType t = ((GUIHolder) event.getInventory().getHolder()).getType();
- if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
- }
- }
-
- @EventHandler
- public void onDrag(InventoryDragEvent event) {
- util.updateActivity((Player) event.getWhoClicked());
- if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof GUIHolder) {
- GUIType t = ((GUIHolder) event.getInventory().getHolder()).getType();
- if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/Move.java b/src/main/java/mykyta/Harbor/Events/Move.java
deleted file mode 100644
index 65317cd..0000000
--- a/src/main/java/mykyta/Harbor/Events/Move.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerMoveEvent;
-import mykyta.Harbor.Util;
-
-public class Move implements Listener {
- @EventHandler
- public void onPlayerMovement(PlayerMoveEvent event) {
- Util util = new Util();
- util.updateActivity(event.getPlayer());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/PlayerJoin.java b/src/main/java/mykyta/Harbor/Events/PlayerJoin.java
deleted file mode 100644
index f49f272..0000000
--- a/src/main/java/mykyta/Harbor/Events/PlayerJoin.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.ChatColor;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerJoinEvent;
-
-import mykyta.Harbor.Config;
-import mykyta.Harbor.Updater;
-import mykyta.Harbor.Util;
-
-public class PlayerJoin implements Listener {
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event) {
- Updater updater = new Updater();
- Config config = new Config();
- Util util = new Util();
-
- String json = "[{\"text\":\"[prefix]§7Hey there, Harbor [version] was released! \"},{\"text\":\"§7§oClick §7§ome §7§oto §7§oupdate!\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/harbor update\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"§a§l↑ §7Update Harbor.\"}}]";
- if (event.getPlayer().isOp() && updater.check() && config.getBoolean("features.notifier")) util.sendJSONMessage(event.getPlayer(), json.replace("[version]", updater.getLatest()).replace("[prefix]", config.getString("messages.miscellaneous.prefix")).replace("&", "§"));
- if (!config.getVersion().equals(util.version)) event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&7The configuration is &nout of date!&7 This server is currently using configuration &oversion " + config.getVersion() + "&7, but the latest configuration is &oversion " + util.version + "&7. Make sure you update the configuration to ensure correct functionality of the plugin."));
- Util.activity.put(event.getPlayer(), System.currentTimeMillis());
- if (event.getPlayer().isOp() && Util.unreleased) event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "&cThis Harbor version is a prerelease. Not everything is guaranteed to work correctly, but the plugin should at least be stable. "
- + "If you encounter an issue, please create an issue on GitHub: &c&ohttps://github.com/nkomarn/Harbor/issues&c."));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/PlayerLeave.java b/src/main/java/mykyta/Harbor/Events/PlayerLeave.java
deleted file mode 100644
index bc7959b..0000000
--- a/src/main/java/mykyta/Harbor/Events/PlayerLeave.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import mykyta.Harbor.Util;
-
-public class PlayerLeave implements Listener {
- @EventHandler
- public void onPlayerLeave(PlayerQuitEvent event) {
- Util util = new Util();
- Player p = event.getPlayer();
- World w = p.getWorld();
-
- new java.util.Timer().schedule(
- new java.util.TimerTask() {
- @Override
- public void run() {
- if (w.getPlayers().size() > 0 && Math.max(0, util.getNeeded(w) - util.getExcluded(w).size()) == 0 && !Util.skipping) util.skip(w);
- Util.activity.remove(p);
- }
- },
- 1000
- );
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Events/Spawn.java b/src/main/java/mykyta/Harbor/Events/Spawn.java
deleted file mode 100644
index 993e9a0..0000000
--- a/src/main/java/mykyta/Harbor/Events/Spawn.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package mykyta.Harbor.Events;
-
-import org.bukkit.entity.EntityType;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.entity.CreatureSpawnEvent;
-
-import mykyta.Harbor.Config;
-
-public class Spawn implements Listener {
- @EventHandler
- public void onSpawn(CreatureSpawnEvent event) {
- Config config = new Config();
- try {
- if (event.getEntityType().equals(EntityType.PHANTOM) && !config.getBoolean("features.phantoms")) event.setCancelled(true);
- }
- catch (NoSuchFieldError e) {
- // Do nothing, Phantom only exists in 1.13+
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Harbor.java b/src/main/java/mykyta/Harbor/Harbor.java
deleted file mode 100644
index 3752f0c..0000000
--- a/src/main/java/mykyta/Harbor/Harbor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package mykyta.Harbor;
-
-import java.util.ArrayList;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import mykyta.Harbor.Commands.Command;
-import mykyta.Harbor.Commands.Sleeping;
-import mykyta.Harbor.Events.BedEnter;
-import mykyta.Harbor.Events.BedLeave;
-import mykyta.Harbor.Events.ChatEvent;
-import mykyta.Harbor.Events.CommandEvent;
-import mykyta.Harbor.Events.GUIEvent;
-import mykyta.Harbor.Events.Move;
-import mykyta.Harbor.Events.PlayerJoin;
-import mykyta.Harbor.Events.PlayerLeave;
-import mykyta.Harbor.Events.Spawn;
-
-public class Harbor extends JavaPlugin {
- public void onEnable() {
- Config config = new Config();
- Util util = new Util();
- config.setInstance(this);
- saveDefaultConfig();
- this.getCommand("harbor").setExecutor(new Command());
- this.getCommand("sleeping").setExecutor(new Sleeping());
- Bukkit.getPluginManager().registerEvents(new BedEnter(), this);
- Bukkit.getPluginManager().registerEvents(new BedLeave(), this);
- Bukkit.getPluginManager().registerEvents(new Move(), this);
- Bukkit.getPluginManager().registerEvents(new Spawn(), this);
- Bukkit.getPluginManager().registerEvents(new GUIEvent(), this);
- Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
- Bukkit.getPluginManager().registerEvents(new PlayerLeave(), this);
- Bukkit.getPluginManager().registerEvents(new CommandEvent(), this);
- Bukkit.getPluginManager().registerEvents(new ChatEvent(), this);
- util.setupNMS();
-
- Bukkit.getServer().getWorlds().forEach(w -> {
- ArrayList sleeping = new ArrayList();
- Util.sleeping.put(w, sleeping);
- w.getPlayers().forEach(p -> {
- p.setPlayerListName(p.getName());
- Util.activity.put(p, System.currentTimeMillis());
- });
- });
-
- if (Util.enabled) Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task(), 0L, config.getInteger("values.clock") * 20);
- if (this.getConfig().getBoolean("debug")) Util.debug = true;
- if (Util.enabled && this.getConfig().getBoolean("features.notifier")) {
- if (Util.debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("messages.miscellaneous.prefix")) + "Checking for new updates...");
- Updater updater = new Updater();
- updater.check();
- }
- if (Util.unreleased) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("messages.miscellaneous.prefix") + "&cThis Harbor version is a prerelease. Not everything is guaranteed to work correctly, but the plugin should at least be stable. "
- + "If you encounter an issue, please create an issue on GitHub: &c&ohttps://github.com/nkomarn/Harbor/issues&c."));
- }
-
- public void onDisable() {
-
- }
-}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS.java b/src/main/java/mykyta/Harbor/NMS/NMS.java
deleted file mode 100644
index c498224..0000000
--- a/src/main/java/mykyta/Harbor/NMS/NMS.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.entity.Player;
-
-public interface NMS {
- public void sendActionbar(Player player, String message);
- public void sendJSONMessage(Player player, String json);
- public void sendTitle(Player player, String top, String bottom);
- public void enterBed(Player player);
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R1.java b/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R1.java
deleted file mode 100644
index 22515de..0000000
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R1.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_8_R1.ChatSerializer;
-import net.minecraft.server.v1_8_R1.EnumTitleAction;
-import net.minecraft.server.v1_8_R1.IChatBaseComponent;
-import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_8_R1.PacketPlayOutTitle;
-
-public class NMS_1_8_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleBottom = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
diff --git a/src/main/java/mykyta/Harbor/Task.java b/src/main/java/mykyta/Harbor/Task.java
deleted file mode 100644
index 5e36b79..0000000
--- a/src/main/java/mykyta/Harbor/Task.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package mykyta.Harbor;
-
-import java.util.concurrent.TimeUnit;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-
-public class Task implements Runnable {
-
- Util util = new Util();
- Config config = new Config();
-
- @Override
- public void run() {
- try {
- Bukkit.getServer().getWorlds().forEach(w -> {
- if (w.getTime() >= 12516 && w.getTime() <= 12535 && config.getBoolean("messages.title.title")) w.getPlayers().forEach(p -> {
- util.sendTitle(p, config.getString("messages.title.evening.top"), config.getString("messages.title.evening.bottom"));
- });
- if (util.getSleeping(w) > 0 && util.getNeeded(w) == 0 && !Util.skipping) {
- util.skip(w);
- }
- if (util.getSleeping(w) > 0 && util.getSleeping(w) < util.getNeeded(w)) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.sleeping"), w);});}
- else if (util.getSleeping(w) == util.getNeeded(w) && util.getSleeping(w) > 0) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.everyone"), w);});}
-
- if (config.getBoolean("features.afk")) w.getPlayers().forEach(p -> {
- if (TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - Util.activity.get(p)) >= config.getInteger("values.timeout")) {
- if (Util.sleeping.get(w).contains(p)) {
- Util.activity.put(p, System.currentTimeMillis());
- return;
- }
- if (!Util.afk.contains(p)) {
- Util.afk.add(p);
- p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.afkprefix") + p.getName()));
- if (config.getString("messages.chat.afk").length() > 0) Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.afk")
- .replace("[player]", p.getName())));
- }
- }
- });
- });
- }
- catch (Exception e) {if (Util.debug) e.printStackTrace();}
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Updater.java b/src/main/java/mykyta/Harbor/Updater.java
deleted file mode 100644
index 54d5c38..0000000
--- a/src/main/java/mykyta/Harbor/Updater.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package mykyta.Harbor;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
-import org.apache.commons.io.FileUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.ConsoleCommandSender;
-
-public class Updater {
- public static String latest = "";
- public static ArrayList releases = new ArrayList();
-
- /**
- * Checks for an update using the Spiget API
- * @see https://spiget.org/
- */
- public boolean check() {
- ConsoleCommandSender c = Bukkit.getServer().getConsoleSender();
- Util util = new Util();
- Config config = new Config();
-
- try {
- URL url = new URL("https://api.spiget.org/v2/resources/60088/versions");
- URLConnection request = url.openConnection();
- request.addRequestProperty("User-Agent", "Harbor");
- request.connect();
-
- JsonParser parser = new JsonParser();
- JsonElement element = parser.parse(new InputStreamReader((InputStream) request.getContent()));
- JsonArray versions = element.getAsJsonArray();
-
- versions.forEach(v -> {
- JsonObject n = v.getAsJsonObject();
- releases.add(n.get("name").getAsString());
- });
-
- latest = releases.get(releases.size() - 1);
-
- if (util.version.equals(latest)) {
- if (Util.debug) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Currently running the latest version of Harbor.");
- return false;
- }
- else if (!releases.contains(util.version)) {
- if (config.getBoolean("features.notifier")) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Running an unreleased version of Harbor.");
- return false;
- }
- else {
- latest = releases.get(releases.size() - 1);
- if (config.getBoolean("features.notifier")) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Currently running an outdated version of Harbor. The latest available release is version " + latest + ".");
- return true;
- }
- }
- catch (IOException e) {
- if (Util.debug) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Failed to check for updated releases of Harbor.");
- return false;
- }
- }
-
- /**
- * Replace the current Harbor version with the latest available release
- */
- public int upgrade() {
- ConsoleCommandSender c = Bukkit.getServer().getConsoleSender();
- Config config = new Config();
- Util util = new Util();
-
- if (util.version.equals(latest) || !releases.contains(util.version)) return 2;
-
- c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Downloading Harbor version " + latest + ".");
- try {
- String jar = new File(Updater.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
- new File("update").mkdir();
- URL url = new URL("http://aqua.api.spiget.org/v2/resources/60088/download");
- File f = new File("plugins" + File.separator + "update" + File.separator + jar);
- FileUtils.copyURLToFile(url, f);
- c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Harbor " + latest + " has been downloaded successfully and will be enabled after a server restart/reload.");
- return 0;
- }
- catch (Exception e) {
- c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Failed to update Harbor to version " + latest + ".");
- if (Util.debug) e.printStackTrace();
- return 1;
- }
- }
-
- /**
- * Returns the latest version number
- */
- public String getLatest() {
- return latest;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/mykyta/Harbor/Util.java b/src/main/java/mykyta/Harbor/Util.java
deleted file mode 100644
index ac8d96a..0000000
--- a/src/main/java/mykyta/Harbor/Util.java
+++ /dev/null
@@ -1,244 +0,0 @@
-package mykyta.Harbor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Random;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.GameMode;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-
-import mykyta.Harbor.NMS.NMS;
-import mykyta.Harbor.NMS.NMS_1_10_R1;
-import mykyta.Harbor.NMS.NMS_1_11_R1;
-import mykyta.Harbor.NMS.NMS_1_12_R1;
-import mykyta.Harbor.NMS.NMS_1_13_R1;
-import mykyta.Harbor.NMS.NMS_1_13_R2;
-import mykyta.Harbor.NMS.NMS_1_14_R1;
-import mykyta.Harbor.NMS.NMS_1_8_R1;
-import mykyta.Harbor.NMS.NMS_1_8_R2;
-import mykyta.Harbor.NMS.NMS_1_8_R3;
-import mykyta.Harbor.NMS.NMS_1_9_R1;
-import mykyta.Harbor.NMS.NMS_1_9_R2;
-
-public class Util {
- public static HashMap> sleeping = new HashMap>();
- public static HashMap activity = new HashMap();
- public static ArrayList afk = new ArrayList();
-
- public final String version = "1.5";
- public static boolean enabled = true;
- public static boolean debug = false;
- public static boolean unreleased = true;
- public static boolean skipping = false;
- private static NMS nms;
- Config config = new Config();
-
- /**
- * Select the correct NMS classes for the server version
- */
- public void setupNMS() {
- String version = "";
- try {version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];}
- catch (ArrayIndexOutOfBoundsException e) {
- Bukkit.getServer().getConsoleSender().sendMessage(config.getString("messages.miscellaneous.prefix") + "Could not get server version. The plugin may not function correctly as a result.");
- if (debug) System.err.println(e);
- Bukkit.getPluginManager().disablePlugin(Config.harbor);
- enabled = false;
- }
- if (debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.running").replace("[version]", version)));
- if (version.equals("v1_8_R1")) {nms = new NMS_1_8_R1();}
- else if (version.equals("v1_8_R2")) {nms = new NMS_1_8_R2();}
- else if (version.equals("v1_8_R3")) {nms = new NMS_1_8_R3();}
- else if (version.equals("v1_9_R1")) {nms = new NMS_1_9_R1();}
- else if (version.equals("v1_9_R2")) {nms = new NMS_1_9_R2();}
- else if (version.equals("v1_10_R1")) {nms = new NMS_1_10_R1();}
- else if (version.equals("v1_11_R1")) {nms = new NMS_1_11_R1();}
- else if (version.equals("v1_12_R1")) {nms = new NMS_1_12_R1();}
- else if (version.equals("v1_13_R1")) {nms = new NMS_1_13_R1();}
- else if (version.equals("v1_13_R2")) {nms = new NMS_1_13_R2();}
- else if (version.equals("v1_14_R1")) {nms = new NMS_1_14_R1();}
- else {
- Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + "This version of Harbor is incompatible with your server version. As such, Harbor will be disabled."));
- Bukkit.getPluginManager().disablePlugin(Config.harbor);
- enabled = false;
- }
- }
-
- /**
- * Increment the sleeping count for a world
- * @param world World to increment count in
- */
- public void add(World world, Player player) {
- ArrayList list = Util.sleeping.get(world);
- list.add(player);
- Util.sleeping.put(world, list);
- }
-
- /**
- * Decrement the sleeping count for a world
- * @param world World to increment count in
- */
- public void remove(World world, Player player) {
- ArrayList list = Util.sleeping.get(world);
- list.remove(player);
- }
-
- /**
- * Fetch the sleeping count for a world
- * @param world World to fetch count for
- */
- public int getSleeping(World w) {
- try {return Math.max(0, Util.sleeping.get(w).size());}
- catch (NullPointerException e) {return 0;}
- }
-
- /**
- * Fetch the amount of players needed to skip night
- * @param world World to fetch count for
- */
- public int getNeeded(World w) {
- try {return Math.max(0, (int) Math.ceil((w.getPlayers().size() - getExcluded(w).size()) * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));}
- //try {return Math.max(0, (int) Math.ceil((w.getPlayers().size()) * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));}
- catch (NullPointerException e) {return 0;}
- }
-
- /**
- * Get players in a world (returns zero if negative)
- * @param world World to check player count for
- */
- public int getOnline(World w) {
- try {return Math.max(0, w.getPlayers().size() - getExcluded(w).size());}
- catch (NullPointerException e) {return 0;}
- }
-
- /**
- * Fetch the excluded players in a world
- * @param world World to fetch count for
- */
- public ArrayList getExcluded(World w) {
- ArrayList excluded = new ArrayList();
- w.getPlayers().forEach(p -> {
- if (this.isExcluded(p)) excluded.add(p);
- });
- return excluded;
- }
-
- /**
- * Returns whether or not a player should be excluded from the sleep count
- * @param player Target player
- */
- public boolean isExcluded(Player p) {
- boolean state = false;
- if (config.getBoolean("features.ignore")) if (p.getGameMode() == GameMode.SURVIVAL) state = false; else state = true;
- if (config.getBoolean("features.bypass")) if (p.hasPermission("harbor.bypass")) state = true; else state = false;
- if (afk.contains(p)) state = true;
- return state;
- }
-
- /**
- * Sends an actionbar message to the given player
- * @param player Player to show actionbar to
- * @param message Actionbar message with color codes
- */
- public void sendActionbar(Player player, String message) {
- if (config.getBoolean("messages.actionbar.actionbar")) nms.sendActionbar(player, message);
- }
-
- /**
- * Sends actionbar with world information
- * @see sendActionbar(Player player, String message)
- * @param player Player to show actionbar to
- * @param message Actionbar message with color codes
- * @param world World to fetch information for
- */
- public void sendActionbar(Player p, String message, World w) {
- if (config.getBoolean("messages.actionbar.actionbar")) nms.sendActionbar(p, message
- .replace("[sleeping]", String.valueOf(this.getSleeping(w)))
- .replace("[online]", String.valueOf(this.getOnline(w)))
- .replace("[needed]", String.valueOf(this.getNeeded(w))));
- }
-
- /**
- * Sends a custom JSON message to selected player
- * @param player Player to send message to
- * @param JSON Message in JSON format
- */
- public void sendJSONMessage(Player player, String JSON) {
- nms.sendJSONMessage(player, JSON);
- }
-
- /**
- * Sends a title to selected player
- * @param player Player to send message to
- * @param JSON Message in JSON format
- */
- public void sendTitle(Player player, String top, String bottom) {
- nms.sendTitle(player, top, bottom);
- }
-
- /**
- * Puts selected player in a sleeping state
- * @param player Player to send message to
- * @param JSON Message in JSON format
- */
- public void enterBed(Player player) {
- nms.enterBed(player);
- }
-
- /**
- * Skips the night in the specified world (if possible)
- * @param World to return value for
- */
- public void skip(World w) {
- if (config.getBoolean("features.skip") && Math.max(0, this.getNeeded(w) - this.getExcluded(w).size()) == 0) {
- skipping = true;
-
- new java.util.Timer().schedule (
- new java.util.TimerTask() {
- @Override
- public void run() {
- w.setTime(1000L);
-
- // Set weather to clear
- if (config.getBoolean("features.weather")) {
- w.setStorm(false);
- w.setThundering(false);
- }
-
- // Display messages
- if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.skipped").length() != 0)) {
- List msgs = config.getList("messages.chat.skipped");
- Random r = new Random();
- int n = r.nextInt(msgs.size());
- Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', msgs.get(n)));
- }
- if (config.getBoolean("messages.title.title")) {
- w.getPlayers().forEach(p -> {
- sendTitle(p, config.getString("messages.title.morning.top"), config.getString("messages.title.morning.bottom"));
- });
- }
- skipping = false;
- }
- },
- 1000 * config.getInteger("values.delay")
- );
- }
- }
-
- /**
- * Updates the current player activity (AFK system)
- * @param p Player to update activity for
- */
- public void updateActivity(Player p) {
- if (afk.contains(p)) {
- afk.remove(p);
- p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', p.getName()));
- if (config.getString("messages.chat.unafk").length() > 0) Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.unafk").replace("[player]", p.getName())));
- }
- activity.put(p, System.currentTimeMillis());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/xyz/nkomarn/Harbor/Harbor.java b/src/main/java/xyz/nkomarn/Harbor/Harbor.java
new file mode 100644
index 0000000..8e00e65
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/Harbor.java
@@ -0,0 +1,70 @@
+package xyz.nkomarn.Harbor;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.java.JavaPlugin;
+import xyz.nkomarn.Harbor.command.HarborCommand;
+import xyz.nkomarn.Harbor.command.SleepingCommand;
+import xyz.nkomarn.Harbor.event.GUIEvent;
+import xyz.nkomarn.Harbor.event.PlayerEvent;
+import xyz.nkomarn.Harbor.event.SpawnEvent;
+import xyz.nkomarn.Harbor.nms.NMSUtils;
+import xyz.nkomarn.Harbor.task.Timer;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+import xyz.nkomarn.Harbor.util.Updater;
+
+import java.util.ArrayList;
+import java.util.stream.Stream;
+
+public class Harbor extends JavaPlugin {
+ public static Harbor instance;
+ public static String version = "1.5.1";
+ public static boolean debug = false;
+ public static boolean enabled = false;
+ public static boolean prerelease = false;
+
+ private Config config = new Config();
+ private NMSUtils nms = new NMSUtils();
+
+ public void onEnable() {
+ saveDefaultConfig();
+ instance = this;
+ nms.setNMS();
+
+ final PluginManager pm = Bukkit.getPluginManager();
+ Stream.of(
+ new PlayerEvent(), new SpawnEvent(), new GUIEvent()
+ ).forEach(l -> pm.registerEvents(l, this));
+ getCommand("harbor").setExecutor(new HarborCommand());
+ getCommand("sleeping").setExecutor(new SleepingCommand());
+
+ Bukkit.getServer().getWorlds().forEach(w -> {
+ ArrayList s = new ArrayList<>();
+ Counters.sleeping.put(w, s);
+ w.getPlayers().forEach(p -> {
+ p.setPlayerListName(p.getName());
+ Counters.activity.put(p, System.currentTimeMillis());
+ });
+ });
+
+ if (enabled) Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Timer(), 0L, config.getInteger("values.clock") * 20);
+ if (getConfig().getBoolean("debug")) debug = true;
+ if (enabled && this.getConfig().getBoolean("features.notifier")) {
+ if (debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
+ getConfig().getString("messages.miscellaneous.prefix")) + "Checking for new updates...");
+ if (!prerelease) {
+ Updater updater = new Updater();
+ updater.check();
+ }
+ }
+ if (prerelease) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("messages.miscellaneous.prefix") + "&cThis Harbor version is a prerelease. Not everything is guaranteed to work correctly, but the plugin should at least be stable. "
+ + "If you encounter an issue, please create an issue on GitHub: &c&ohttps://github.com/nkomarn/Harbor/issues&c. You can download newer builds when they're available at &c&ohttps://harbor.nkomarn.xyz&c."));
+ }
+
+ public void onDisable() {
+
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java b/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java
new file mode 100644
index 0000000..7281489
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java
@@ -0,0 +1,58 @@
+package xyz.nkomarn.Harbor.command;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import xyz.nkomarn.Harbor.Harbor;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Updater;
+
+public class HarborCommand implements CommandExecutor {
+ private Config c = new Config();
+
+ @Override
+ public boolean onCommand(CommandSender s, Command x, String l, String[] a) {
+ if (a.length < 1) {
+ s.sendMessage(ChatColor.translateAlternateColorCodes('&', c
+ .getString("messages.miscellaneous.prefix") + "&7Version " + Harbor.version
+ + " by TechToolbox (@nkomarn)."));
+ return true;
+ }
+ if (!s.hasPermission("harbor.admin")) {
+ s.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ c.getString("messages.miscellaneous.prefix")
+ + c.getString("messages.miscellaneous.permission")));
+ return true;
+ }
+ if (a[0].equalsIgnoreCase("reload")) {
+ try {
+ Harbor h = Harbor.instance;
+ h.reloadConfig();
+ Bukkit.getPluginManager().disablePlugin(h);
+ Bukkit.getPluginManager().enablePlugin(h);
+ s.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ c.getString("messages.miscellaneous.prefix")
+ + c.getString("messages.miscellaneous.reloaded")));
+ }
+ catch (Exception e) {
+ s.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ c.getString("messages.miscellaneous.prefix")
+ + c.getString("messages.miscellaneous.reloaderror")));
+ if (Harbor.debug) e.printStackTrace();
+ }
+ return true;
+ }
+ else if (a[0].equalsIgnoreCase("update")) {
+ Updater u = new Updater();
+ int result = u.upgrade();
+ if (result == 0) s.sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "&7Harbor was successfully updated to version " + Updater.latest + " and will be enabled after a server restart/reload."));
+ else if (result == 1) s.sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "&7An error occured while updating Harbor to version " + Updater.latest + ". Check the server console for more details."));
+ else if (result == 2) s.sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "&7This server is already running the latest version of Harbor. Great work!"));
+ return true;
+ }
+ s.sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + c.getString("messages.miscellaneous.unrecognized")));
+ return true;
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/command/SleepingCommand.java b/src/main/java/xyz/nkomarn/Harbor/command/SleepingCommand.java
new file mode 100644
index 0000000..359edea
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/command/SleepingCommand.java
@@ -0,0 +1,47 @@
+package xyz.nkomarn.Harbor.command;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import xyz.nkomarn.Harbor.gui.SleepingGUI;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+
+import java.util.ArrayList;
+
+public class SleepingCommand implements CommandExecutor {
+ private Config c = new Config();
+
+ @Override
+ public boolean onCommand(CommandSender s, Command x, String l, String[] a) {
+ if (s instanceof Player) {
+ Player p = (Player) s;
+ new SleepingGUI(p, 1);
+ }
+ else {
+ if (a.length < 1) {
+ ArrayList list = new ArrayList<>();
+ Bukkit.getServer().getWorlds().forEach(w -> {list.add("&o" + w.getName());});
+ Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
+ c.getString("messages.miscellaneous.prefix")
+ + "Specify a world name. Possible worlds are " + String.join("&r, ", list) + "&r."));
+ }
+ else {
+ World w = Bukkit.getServer().getWorld(a[0]);
+ if (w == null) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "The specified world doesn't exist."));
+ else {
+ ArrayList list = new ArrayList();
+ Counters.sleeping.get(Bukkit.getServer().getWorld(a[0])).forEach(p -> {list.add("&o" + p.getName());});
+ if (list.size() > 0 && list.size() != 1) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "In &o" + a[0] + "&r, the currently sleeping players are " + String.join("&r, ", list) + "&r."));
+ else if (list.size() == 1) Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "In &o" + a[0] + "&r, " + list.get(0) + "&r is the only player sleeping."));
+ else Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "There aren't any currently sleeping players in &o" + a[0] + "&r."));
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/event/GUIEvent.java b/src/main/java/xyz/nkomarn/Harbor/event/GUIEvent.java
new file mode 100644
index 0000000..9c21720
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/event/GUIEvent.java
@@ -0,0 +1,37 @@
+package xyz.nkomarn.Harbor.event;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.Inventory;
+import xyz.nkomarn.Harbor.gui.GUIHolder;
+import xyz.nkomarn.Harbor.gui.GUIType;
+import xyz.nkomarn.Harbor.gui.SleepingGUI;
+import xyz.nkomarn.Harbor.util.Counters;
+
+public class GUIEvent implements Listener {
+ private Counters n = new Counters();
+
+ @EventHandler
+ public void onClick(InventoryClickEvent e) {
+ n.updateActivity((Player) e.getWhoClicked());
+ Inventory i = e.getInventory();
+ if (i.getHolder() != null && i.getHolder() instanceof GUIHolder) {
+ GUIType t = ((GUIHolder) i.getHolder()).getType();
+ final Player p = (Player) e.getWhoClicked();
+ e.setCancelled(true);
+
+ if (t.equals(GUIType.SLEEPING)) {
+ int page = ((GUIHolder) i.getHolder()).getPage();
+ if (e.getSlot() == 39) {
+ if (page <= 1) {e.getWhoClicked().closeInventory();}
+ else new SleepingGUI(p, Math.max(1, --page));
+ }
+ else if (e.getSlot() == 41) {
+ new SleepingGUI(p, Math.max(1, ++page));
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/event/PlayerEvent.java b/src/main/java/xyz/nkomarn/Harbor/event/PlayerEvent.java
new file mode 100644
index 0000000..3b59505
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/event/PlayerEvent.java
@@ -0,0 +1,107 @@
+package xyz.nkomarn.Harbor.event;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+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.*;
+import xyz.nkomarn.Harbor.Harbor;
+import xyz.nkomarn.Harbor.nms.NMSUtils;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+import xyz.nkomarn.Harbor.util.Updater;
+
+import java.util.ArrayList;
+
+public class PlayerEvent implements Listener {
+ private Config config = new Config();
+ private NMSUtils nms = new NMSUtils();
+ private Counters counters = new Counters();
+ private Updater updater = new Updater();
+
+ @EventHandler
+ public void onJoin(PlayerJoinEvent e) {
+ Player p = e.getPlayer();
+ String json = "[{\"text\":\"[prefix]§7Hey there, Harbor [version] was released! \"},{\"text\":\"§7§oClick §7§ome §7§oto §7§oupdate!\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/harbor update\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"§a§l↑ §7Update Harbor.\"}}]";
+ if (p.isOp() && updater.check() && config.getBoolean("features.notifier")) nms.sendJSONMessage(p, json.replace("[version]", updater.getLatest()).replace("[prefix]", config.getString("messages.miscellaneous.prefix")).replace("&", "§"));
+ Counters.activity.put(p, System.currentTimeMillis());
+ if (p.isOp() && Harbor.prerelease) p.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ config.getString("messages.miscellaneous.prefix") + "&cThis Harbor version is a prerelease. Not everything is guaranteed to work correctly, but the plugin should at least be stable. "
+ + "If you encounter an issue, please create an issue on GitHub: &c&ohttps://github.com/nkomarn/Harbor/issues&c."));
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBedEnter(PlayerBedEnterEvent e) {
+ if (config.getBoolean("features.block")) {
+ if (config.getString("messages.chat.blocked").length() > 0) e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',
+ config.getString("messages.chat.blocked")));
+ nms.sendActionbar(e.getPlayer(), config.getString("messages.actionbar.blocked"));
+ e.setCancelled(true);
+ return;
+ }
+
+ boolean success = false;
+ try {if (e.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK) success = true;}
+ catch (NoSuchMethodError nme) {success = true;}
+
+ if (success) {
+ Player p = e.getPlayer();
+ World w = p.getWorld();
+ ArrayList ex = counters.getExcluded(w);
+
+ if (!ex.contains(p)) {
+ counters.add(w, p);
+ if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.sleeping").length() != 0)) {
+ Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&',
+ config.getString("messages.chat.sleeping")
+ .replace("[sleeping]", String.valueOf(counters.getSleeping(w))))
+ .replace("[online]", String.valueOf(counters.getOnline(w)))
+ .replace("[player]", p.getName())
+ .replace("[needed]", String.valueOf(counters.getNeeded(w))));
+ }
+ if (config.getBoolean("messages.title.title")) {
+ nms.sendTitle(p, config.getString("messages.title.sleeping.top"),
+ config.getString("messages.title.sleeping.bottom"));
+ }
+ counters.skip(w);
+ }
+ else if (config.getString("messages.chat.bypass").length() != 0)
+ p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.bypass")));
+ }
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
+ public void onBedLeave(PlayerBedLeaveEvent e) {
+ Player p = e.getPlayer();
+ World w = p.getWorld();
+
+ ArrayList ex = counters.getExcluded(w);
+ if (!ex.contains(p)) counters.remove(w, p);
+ if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.left").length() != 0)
+ && !(w.getTime() > 0 && w.getTime() < 12300) && !ex.contains(p)) {
+ Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.left")
+ .replace("[sleeping]", String.valueOf(counters.getSleeping(w))))
+ .replace("[online]", String.valueOf(counters.getOnline(w)))
+ .replace("[player]", p.getName())
+ .replace("[needed]", String.valueOf(counters.getNeeded(w))));
+ }
+ }
+
+ @EventHandler
+ public void onChat(AsyncPlayerChatEvent e) {
+ counters.updateActivity(e.getPlayer());
+ }
+
+ @EventHandler
+ public void onCommand(PlayerCommandPreprocessEvent e) {
+ counters.updateActivity(e.getPlayer());
+ }
+
+ @EventHandler
+ public void onMove(PlayerMoveEvent e) {
+ counters.updateActivity(e.getPlayer());
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/event/SpawnEvent.java b/src/main/java/xyz/nkomarn/Harbor/event/SpawnEvent.java
new file mode 100644
index 0000000..07a22ed
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/event/SpawnEvent.java
@@ -0,0 +1,21 @@
+package xyz.nkomarn.Harbor.event;
+
+import org.bukkit.entity.EntityType;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntitySpawnEvent;
+import xyz.nkomarn.Harbor.util.Config;
+
+public class SpawnEvent implements Listener {
+ private Config c = new Config();
+
+ @EventHandler
+ public void onSpawn(EntitySpawnEvent e) {
+ Config config = new Config();
+ try {if (e.getEntityType().equals(EntityType.PHANTOM)
+ && !config.getBoolean("features.phantoms")) e.setCancelled(true);}
+ catch (NoSuchFieldError nsf) {
+ // Do nothing, Phantom only exists in 1.13+
+ }
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/GUI/GUIHolder.java b/src/main/java/xyz/nkomarn/Harbor/gui/GUIHolder.java
similarity index 62%
rename from src/main/java/mykyta/Harbor/GUI/GUIHolder.java
rename to src/main/java/xyz/nkomarn/Harbor/gui/GUIHolder.java
index 82a6a92..6957401 100644
--- a/src/main/java/mykyta/Harbor/GUI/GUIHolder.java
+++ b/src/main/java/xyz/nkomarn/Harbor/gui/GUIHolder.java
@@ -1,4 +1,4 @@
-package mykyta.Harbor.GUI;
+package xyz.nkomarn.Harbor.gui;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
@@ -6,17 +6,23 @@ import org.bukkit.inventory.InventoryHolder;
public class GUIHolder implements InventoryHolder {
private Inventory inv;
private GUIType type;
+ private int page;
- public GUIHolder(GUIType type) {
+ public GUIHolder(GUIType type, int page) {
this.type = type;
+ this.page = page;
}
@Override
public Inventory getInventory() {
- return inv; // Required by InventoryHolder
+ return inv;
}
public GUIType getType() {
return type;
}
+
+ public int getPage() {
+ return this.page;
+ }
}
diff --git a/src/main/java/mykyta/Harbor/GUI/GUIType.java b/src/main/java/xyz/nkomarn/Harbor/gui/GUIType.java
similarity index 51%
rename from src/main/java/mykyta/Harbor/GUI/GUIType.java
rename to src/main/java/xyz/nkomarn/Harbor/gui/GUIType.java
index 495eea0..6dca827 100644
--- a/src/main/java/mykyta/Harbor/GUI/GUIType.java
+++ b/src/main/java/xyz/nkomarn/Harbor/gui/GUIType.java
@@ -1,5 +1,5 @@
-package mykyta.Harbor.GUI;
+package xyz.nkomarn.Harbor.gui;
public enum GUIType {
SLEEPING
-}
\ No newline at end of file
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/gui/SleepingGUI.java b/src/main/java/xyz/nkomarn/Harbor/gui/SleepingGUI.java
new file mode 100644
index 0000000..e922899
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/gui/SleepingGUI.java
@@ -0,0 +1,62 @@
+package xyz.nkomarn.Harbor.gui;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.inventory.meta.SkullMeta;
+import xyz.nkomarn.Harbor.gui.GUIHolder;
+import xyz.nkomarn.Harbor.gui.GUIType;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+
+import java.util.ArrayList;
+
+public class SleepingGUI {
+
+ private Inventory i;
+ Config c = new Config();
+
+ public SleepingGUI(Player p, int page) {
+ ArrayList s = Counters.sleeping.get(p.getWorld());
+ i = Bukkit.createInventory(new GUIHolder(GUIType.SLEEPING, page),
+ 45, c.getString("gui.sleeping").replace("[page]", String.valueOf(page)));
+
+ ItemStack glass = new ItemStack(Material.WHITE_STAINED_GLASS_PANE, 1);
+ ItemMeta glassMeta = glass.getItemMeta();
+ glassMeta.setDisplayName(" ");
+ glass.setItemMeta(glassMeta);
+ int[] slots = {36, 37, 38, 40, 42, 43, 44};
+ for (int x = 0; x < slots.length; x++) {i.setItem(slots[x], glass);}
+
+ ItemStack bb = new ItemStack(Material.OAK_BUTTON, 1);
+ ItemMeta bbm = bb.getItemMeta();
+ bbm.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&6&lPrevious"));
+ bb.setItemMeta(bbm);
+ i.setItem(39, bb);
+
+ ItemStack nb = new ItemStack(Material.OAK_BUTTON, 1);
+ ItemMeta nbm = nb.getItemMeta();
+ nbm.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&6&lNext"));
+ nb.setItemMeta(nbm);
+ i.setItem(41, nb);
+
+ int f = (((page - 1) * 35) + (page + 1) - 1) - 1;
+ int l = Math.min(s.size(), (f + 36));
+
+ int t = 0;
+ for (int c = f; c < l; c++) {
+ ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
+ SkullMeta sm = (SkullMeta) item.getItemMeta();
+ sm.setDisplayName(ChatColor.GRAY + s.get(c).getName());
+ sm.setOwningPlayer(p);
+ item.setItemMeta(sm);
+ i.setItem(s.indexOf(s.get(c)), item);
+ t++;
+ }
+ p.openInventory(i);
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/nms/NMS.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS.java
new file mode 100644
index 0000000..a3c1403
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS.java
@@ -0,0 +1,9 @@
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.entity.Player;
+
+public interface NMS {
+ void sendActionbar(Player p, String m);
+ void sendJSONMessage(Player p, String j);
+ void sendTitle(Player p, String t, String n);
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/nms/NMSUtils.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMSUtils.java
new file mode 100644
index 0000000..7d9a314
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMSUtils.java
@@ -0,0 +1,61 @@
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import xyz.nkomarn.Harbor.Harbor;
+import xyz.nkomarn.Harbor.nms.NMS;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+
+public class NMSUtils {
+
+ static Counters n = new Counters();
+ static Config c = new Config();
+ static NMS nms;
+
+ public void setNMS() {
+ String v = "";
+ try {v = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];}
+ catch (ArrayIndexOutOfBoundsException e) {
+ Bukkit.getServer().getConsoleSender().sendMessage(c.getString("messages.miscellaneous.prefix") + "Could not get server version. The plugin may not function correctly as a result.");
+ if (Harbor.debug) e.printStackTrace();
+ Bukkit.getPluginManager().disablePlugin(Harbor.instance);
+ Harbor.enabled = false;
+ }
+ if (Harbor.debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + c.getString("messages.miscellaneous.running").replace("[version]", v)));
+ if (v.equals("v1_8_R1")) {nms = new NMS_1_8_R1();}
+ else if (v.equals("v1_8_R2")) {nms = new NMS_1_8_R2();}
+ else if (v.equals("v1_8_R3")) {nms = new NMS_1_8_R3();}
+ else if (v.equals("v1_9_R1")) {nms = new NMS_1_9_R1();}
+ else if (v.equals("v1_9_R2")) {nms = new NMS_1_9_R2();}
+ else if (v.equals("v1_10_R1")) {nms = new NMS_1_10_R1();}
+ else if (v.equals("v1_11_R1")) {nms = new NMS_1_11_R1();}
+ else if (v.equals("v1_12_R1")) {nms = new NMS_1_12_R1();}
+ else if (v.equals("v1_13_R1")) {nms = new NMS_1_13_R1();}
+ else if (v.equals("v1_13_R2")) {nms = new NMS_1_13_R2();}
+ else if (v.equals("v1_14_R1")) {nms = new NMS_1_14_R1();}
+ else {
+ Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.prefix") + "This version of Harbor is incompatible with your server version. As such, Harbor will be disabled."));
+ Bukkit.getPluginManager().disablePlugin(Harbor.instance);
+ Harbor.enabled = false;
+ }
+ }
+
+ public void sendActionbar(Player player, String message) {
+ if (c.getBoolean("messages.actionbar.actionbar")) nms.sendActionbar(player, message);
+ }
+ public void sendActionbar(Player p, String message, World w) {
+ if (c.getBoolean("messages.actionbar.actionbar")) nms.sendActionbar(p, message
+ .replace("[sleeping]", String.valueOf(n.getSleeping(w)))
+ .replace("[online]", String.valueOf(n.getOnline(w)))
+ .replace("[needed]", String.valueOf(n.getNeeded(w))));
+ }
+ public void sendJSONMessage(Player p, String j) {
+ nms.sendJSONMessage(p, j);
+ }
+ public void sendTitle(Player p, String t, String b) {
+ nms.sendTitle(p, t, b);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_10_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_10_R1.java
similarity index 89%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_10_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_10_R1.java
index b7e8a72..56a79c7 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_10_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_10_R1.java
@@ -1,42 +1,34 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_10_R1.IChatBaseComponent;
-import net.minecraft.server.v1_10_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_10_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_10_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_10_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_10_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_10_R1.IChatBaseComponent;
+import net.minecraft.server.v1_10_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_10_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_10_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_10_R1.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_10_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_11_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_11_R1.java
similarity index 90%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_11_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_11_R1.java
index e93bffd..6d1aeb5 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_11_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_11_R1.java
@@ -1,42 +1,34 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_11_R1.IChatBaseComponent;
-import net.minecraft.server.v1_11_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_11_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_11_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_11_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_11_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_11_R1.IChatBaseComponent;
+import net.minecraft.server.v1_11_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_11_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_11_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_11_R1.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_11_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_12_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_12_R1.java
similarity index 90%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_12_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_12_R1.java
index 08caabf..8a27d53 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_12_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_12_R1.java
@@ -1,42 +1,34 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_12_R1.IChatBaseComponent;
-import net.minecraft.server.v1_12_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_12_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_12_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_12_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_12_R1.IChatBaseComponent;
+import net.minecraft.server.v1_12_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_12_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_12_R1.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_12_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_13_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R1.java
similarity index 90%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_13_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R1.java
index 471435f..ebc1328 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_13_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R1.java
@@ -1,42 +1,34 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_13_R1.IChatBaseComponent;
-import net.minecraft.server.v1_13_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_13_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_13_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_13_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_13_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_13_R1.IChatBaseComponent;
+import net.minecraft.server.v1_13_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_13_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_13_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_13_R1.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_13_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_13_R2.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R2.java
similarity index 83%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_13_R2.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R2.java
index 011cc40..c416f62 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_13_R2.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_13_R2.java
@@ -1,45 +1,35 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_13_R2.PacketPlayOutBed;
-import net.minecraft.server.v1_13_R2.IChatBaseComponent;
-import net.minecraft.server.v1_13_R2.PacketPlayOutChat;
-import net.minecraft.server.v1_13_R2.PacketPlayOutTitle;
-import net.minecraft.server.v1_13_R2.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_13_R2.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_13_R2 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
- PacketPlayOutBed sleep = new PacketPlayOutBed();
- ((CraftPlayer)player).getHandle().a(true, true, false);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(sleep);
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_13_R2.PacketPlayOutBed;
+import net.minecraft.server.v1_13_R2.IChatBaseComponent;
+import net.minecraft.server.v1_13_R2.PacketPlayOutChat;
+import net.minecraft.server.v1_13_R2.PacketPlayOutTitle;
+import net.minecraft.server.v1_13_R2.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_13_R2.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_13_R2 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_14_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_14_R1.java
similarity index 90%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_14_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_14_R1.java
index 855456b..8e2c132 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_14_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_14_R1.java
@@ -1,42 +1,34 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_14_R1.IChatBaseComponent;
-import net.minecraft.server.v1_14_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_14_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_14_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_14_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_14_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_14_R1.IChatBaseComponent;
+import net.minecraft.server.v1_14_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_14_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_14_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_14_R1.PacketPlayOutTitle.EnumTitleAction;
+
+class NMS_1_14_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.ACTIONBAR, titleComponent);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R1.java
new file mode 100644
index 0000000..06ba6d7
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R1.java
@@ -0,0 +1,35 @@
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_8_R1.ChatSerializer;
+import net.minecraft.server.v1_8_R1.EnumTitleAction;
+import net.minecraft.server.v1_8_R1.IChatBaseComponent;
+import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_8_R1.PacketPlayOutTitle;
+import xyz.nkomarn.Harbor.nms.NMS;
+
+class NMS_1_8_R1 implements NMS {
+ public void sendActionbar(Player p, String m) {
+ IChatBaseComponent tc = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', m) + "\"}");
+ PacketPlayOutChat tp = new PacketPlayOutChat(tc, (byte) 2);
+ ((CraftPlayer) p).getHandle().playerConnection.sendPacket(tp);
+ }
+
+ public void sendJSONMessage(Player p, String j) {
+ IChatBaseComponent c = ChatSerializer.a(j);
+ PacketPlayOutChat packet = new PacketPlayOutChat(c);
+ ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player p, String t, String b) {
+ IChatBaseComponent tt = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', t) + "\"}");
+ IChatBaseComponent tm = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', b) + "\"}");
+ PacketPlayOutTitle x = new PacketPlayOutTitle(EnumTitleAction.TITLE, tt);
+ PacketPlayOutTitle y = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, tm);
+ ((CraftPlayer) p).getHandle().playerConnection.sendPacket(x);
+ ((CraftPlayer) p).getHandle().playerConnection.sendPacket(y);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R2.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R2.java
similarity index 85%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_8_R2.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R2.java
index 6789cfa..24064c2 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R2.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R2.java
@@ -1,42 +1,35 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_8_R2.IChatBaseComponent;
-import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
-import net.minecraft.server.v1_8_R2.PacketPlayOutTitle;
-import net.minecraft.server.v1_8_R2.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_8_R2 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleBottom = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_8_R2.IChatBaseComponent;
+import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
+import net.minecraft.server.v1_8_R2.PacketPlayOutTitle;
+import net.minecraft.server.v1_8_R2.PacketPlayOutTitle.EnumTitleAction;
+import xyz.nkomarn.Harbor.nms.NMS;
+
+class NMS_1_8_R2 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte) 2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleBottom = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R3.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R3.java
similarity index 89%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_8_R3.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R3.java
index 04a2b4b..774c0fd 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_8_R3.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_8_R3.java
@@ -1,42 +1,35 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_8_R3.IChatBaseComponent;
-import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
-import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
-import net.minecraft.server.v1_8_R3.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_8_R3 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleBottom = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_8_R3.IChatBaseComponent;
+import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
+import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
+import net.minecraft.server.v1_8_R3.PacketPlayOutTitle.EnumTitleAction;
+import xyz.nkomarn.Harbor.nms.NMS;
+
+class NMS_1_8_R3 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleBottom = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_9_R1.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R1.java
similarity index 89%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_9_R1.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R1.java
index a77efb6..b1e300d 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_9_R1.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R1.java
@@ -1,42 +1,35 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_9_R1.IChatBaseComponent;
-import net.minecraft.server.v1_9_R1.PacketPlayOutChat;
-import net.minecraft.server.v1_9_R1.PacketPlayOutTitle;
-import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_9_R1.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_9_R1 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_9_R1.IChatBaseComponent;
+import net.minecraft.server.v1_9_R1.PacketPlayOutChat;
+import net.minecraft.server.v1_9_R1.PacketPlayOutTitle;
+import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_9_R1.PacketPlayOutTitle.EnumTitleAction;
+import xyz.nkomarn.Harbor.nms.NMS;
+
+class NMS_1_9_R1 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/NMS/NMS_1_9_R2.java b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R2.java
similarity index 89%
rename from src/main/java/mykyta/Harbor/NMS/NMS_1_9_R2.java
rename to src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R2.java
index ac8f088..ee2bb46 100644
--- a/src/main/java/mykyta/Harbor/NMS/NMS_1_9_R2.java
+++ b/src/main/java/xyz/nkomarn/Harbor/nms/NMS_1_9_R2.java
@@ -1,42 +1,35 @@
-package mykyta.Harbor.NMS;
-
-import org.bukkit.ChatColor;
-import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-import net.minecraft.server.v1_9_R2.IChatBaseComponent;
-import net.minecraft.server.v1_9_R2.PacketPlayOutChat;
-import net.minecraft.server.v1_9_R2.PacketPlayOutTitle;
-import net.minecraft.server.v1_9_R2.IChatBaseComponent.ChatSerializer;
-import net.minecraft.server.v1_9_R2.PacketPlayOutTitle.EnumTitleAction;
-
-public class NMS_1_9_R2 implements NMS {
- @Override
- public void sendActionbar(Player player, String message) {
- IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
- PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
- }
-
- @Override
- public void sendJSONMessage(Player player, String json) {
- IChatBaseComponent component = ChatSerializer.a(json);
- PacketPlayOutChat packet = new PacketPlayOutChat(component);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
- }
-
- @Override
- public void sendTitle(Player player, String top, String bottom) {
- IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
- IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
- PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
- PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
- ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
- }
-
- @Override
- public void enterBed(Player player) {
-
- }
-}
+package xyz.nkomarn.Harbor.nms;
+
+import org.bukkit.ChatColor;
+import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+
+import net.minecraft.server.v1_9_R2.IChatBaseComponent;
+import net.minecraft.server.v1_9_R2.PacketPlayOutChat;
+import net.minecraft.server.v1_9_R2.PacketPlayOutTitle;
+import net.minecraft.server.v1_9_R2.IChatBaseComponent.ChatSerializer;
+import net.minecraft.server.v1_9_R2.PacketPlayOutTitle.EnumTitleAction;
+import xyz.nkomarn.Harbor.nms.NMS;
+
+class NMS_1_9_R2 implements NMS {
+ public void sendActionbar(Player player, String message) {
+ IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
+ PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
+ }
+
+ public void sendJSONMessage(Player player, String json) {
+ IChatBaseComponent component = ChatSerializer.a(json);
+ PacketPlayOutChat packet = new PacketPlayOutChat(component);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
+ }
+
+ public void sendTitle(Player player, String top, String bottom) {
+ IChatBaseComponent titleComponentTop = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
+ IChatBaseComponent titleComponentBottom = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', bottom) + "\"}");
+ PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleComponentTop);
+ PacketPlayOutTitle subtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, titleComponentBottom);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
+ ((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/task/Timer.java b/src/main/java/xyz/nkomarn/Harbor/task/Timer.java
new file mode 100644
index 0000000..2246821
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/task/Timer.java
@@ -0,0 +1,51 @@
+package xyz.nkomarn.Harbor.task;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import xyz.nkomarn.Harbor.Harbor;
+import xyz.nkomarn.Harbor.nms.NMSUtils;
+import xyz.nkomarn.Harbor.util.Config;
+import xyz.nkomarn.Harbor.util.Counters;
+
+import java.util.concurrent.TimeUnit;
+
+public class Timer implements Runnable {
+ Config c = new Config();
+ Counters n = new Counters();
+ NMSUtils nms = new NMSUtils();
+
+ @Override
+ public void run() {
+ try {
+ Bukkit.getServer().getWorlds().forEach(w -> {
+ if (w.getTime() >= 12516 && w.getTime() <= 12535 && c.getBoolean("messages.title.title"))
+ w.getPlayers().forEach(p -> nms.sendTitle(p, c.getString("messages.title.evening.top"), c.getString("messages.title.evening.bottom")));
+ if (n.getSleeping(w) > 0 && n.getNeeded(w) == 0) n.skip(w);
+
+ if (n.getSleeping(w) > 0 && n.getSleeping(w) < n.getNeeded(w))
+ w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.sleeping"), w));
+ else if (n.getSleeping(w) == n.getNeeded(w) && n.getSleeping(w) > 0)
+ w.getPlayers().forEach(p -> nms.sendActionbar(p, c.getString("messages.actionbar.everyone"), w));
+
+ if (c.getBoolean("features.afk")) w.getPlayers().forEach(p -> {
+ if (TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - Counters.activity.get(p)) >= c.getInteger("values.timeout")) {
+ if (Counters.sleeping.get(w).contains(p)) {
+ Counters.activity.put(p, System.currentTimeMillis());
+ return;
+ }
+ if (!Counters.afk.contains(p)) {
+ Counters.afk.add(p);
+ p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', c.getString("messages.miscellaneous.afkprefix")
+ + p.getDisplayName()));
+ if (c.getString("messages.chat.afk").length() > 0)
+ Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', c.getString("messages.chat.afk")
+ .replace("[player]", p.getName())));
+ }
+ }
+ });
+ });
+ } catch (Exception e) {
+ if (Harbor.debug) e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/mykyta/Harbor/Config.java b/src/main/java/xyz/nkomarn/Harbor/util/Config.java
similarity index 60%
rename from src/main/java/mykyta/Harbor/Config.java
rename to src/main/java/xyz/nkomarn/Harbor/util/Config.java
index 341f009..be61ade 100644
--- a/src/main/java/mykyta/Harbor/Config.java
+++ b/src/main/java/xyz/nkomarn/Harbor/util/Config.java
@@ -1,4 +1,4 @@
-package mykyta.Harbor;
+package xyz.nkomarn.Harbor.util;
import java.util.ArrayList;
import java.util.List;
@@ -6,36 +6,19 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
+import xyz.nkomarn.Harbor.Harbor;
public class Config {
- private String error = "An error occured while trying to read the configuration. Harbor may not function correctly as a result.";
- public static Harbor harbor;
private ConsoleCommandSender c = Bukkit.getServer().getConsoleSender();
- /**
- * Sets main class instance for accessing configuration
- * @param instance Instance of the main class
- */
- public void setInstance(Harbor instance) {
- harbor = instance;
- }
-
/**
* Report an error in reading the configuration
* @param e Exception generated from reading configuration
*/
private void error(Exception e) {
- c.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getString("messages.miscellaneous.prefix") + error));
- if (Util.debug) e.printStackTrace();
- }
-
- /**
- * Fetches a boolean from the configuration
- * @param location Configuration location of the boolean
- */
- public String getVersion() {
- try {return this.getString("version");}
- catch (Exception e) {error(e); return "";}
+ c.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ "An error occurred while trying to read the configuration. Harbor may not function correctly as a result."));
+ if (Harbor.debug) e.printStackTrace();
}
/**
@@ -43,7 +26,7 @@ public class Config {
* @param location Configuration location of the boolean
*/
public boolean getBoolean(String location) {
- try {return harbor.getConfig().getBoolean(location);}
+ try {return Harbor.instance.getConfig().getBoolean(location);}
catch (Exception e) {error(e); return false;}
}
@@ -52,7 +35,7 @@ public class Config {
* @param location Configuration location of the string
*/
public String getString(String location) {
- try {return harbor.getConfig().getString(location);}
+ try {return Harbor.instance.getConfig().getString(location);}
catch (Exception e) {error(e); return "";}
}
@@ -61,7 +44,7 @@ public class Config {
* @param location Configuration location of the integer
*/
public int getInteger(String location) {
- try {return harbor.getConfig().getInt(location);}
+ try {return Harbor.instance.getConfig().getInt(location);}
catch (Exception e) {error(e); return 0;}
}
@@ -70,7 +53,7 @@ public class Config {
* @param location Configuration location of the double
*/
public double getDouble(String location) {
- try {return Double.parseDouble(harbor.getConfig().getString(location));}
+ try {return Double.parseDouble(Harbor.instance.getConfig().getString(location));}
catch (Exception e) {error(e); return 0.0;}
}
@@ -79,7 +62,7 @@ public class Config {
* @param location Configuration location of the double
*/
public List getList(String location) {
- try {return harbor.getConfig().getStringList(location);}
+ try {return Harbor.instance.getConfig().getStringList(location);}
catch (Exception e) {error(e); return new ArrayList();}
}
}
\ No newline at end of file
diff --git a/src/main/java/xyz/nkomarn/Harbor/util/Counters.java b/src/main/java/xyz/nkomarn/Harbor/util/Counters.java
new file mode 100644
index 0000000..29d697f
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/util/Counters.java
@@ -0,0 +1,107 @@
+package xyz.nkomarn.Harbor.util;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import xyz.nkomarn.Harbor.Harbor;
+import xyz.nkomarn.Harbor.nms.NMSUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+
+public class Counters {
+ public static HashMap> sleeping = new HashMap<>();
+ public static HashMap activity = new HashMap<>();
+ public static ArrayList afk = new ArrayList<>();
+
+ private Config c = new Config();
+ private NMSUtils nms = new NMSUtils();
+
+ public void add(World w, Player p) {
+ ArrayList a = sleeping.get(w);
+ a.add(p);
+ sleeping.put(w, a);
+ }
+
+ public void remove(World w, Player p) {
+ ArrayList a = sleeping.get(w);
+ a.remove(p);
+ }
+
+ public int getSleeping(World w) {
+ try {return Math.max(0, sleeping.get(w).size());}
+ catch (NullPointerException e) {
+ if (Harbor.debug) e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public int getNeeded(World w) {
+ try {return Math.max(0, (int) Math.ceil((w.getPlayers().size() - getExcluded(w).size()) * (c.getDouble("values.percent") / 100) - getSleeping(w)));}
+ catch (NullPointerException e) {
+ if (Harbor.debug) e.printStackTrace();
+ return 0;
+ }
+ }
+
+ public int getOnline(World w) {
+ try {return Math.max(0, w.getPlayers().size() - getExcluded(w).size());}
+ catch (NullPointerException e) {return 0;}
+ }
+
+ public ArrayList getExcluded(World w) {
+ ArrayList a = new ArrayList<>();
+ w.getPlayers().forEach(p -> {
+ if (isExcluded(p)) a.add(p);
+ });
+ return a;
+ }
+
+ public boolean isExcluded(Player p) {
+ boolean s = false;
+ if (c.getBoolean("features.ignore")) if (p.getGameMode() == GameMode.SURVIVAL) s = false; else s = true;
+ if (c.getBoolean("features.bypass")) if (p.hasPermission("harbor.bypass")) s = true; else s = false;
+ if (afk.contains(p)) s = true;
+ return s;
+ }
+
+ public void skip(World w) {
+ if (c.getBoolean("features.skip") && Math.max(0, this.getNeeded(w) - this.getExcluded(w).size()) == 0) {
+ w.setTime(1000L);
+
+ // Set weather to clear TODO ASYNC NO BAD DON'T ASYNC CAUSE 1.14 API CHANGE BAD
+ if (c.getBoolean("features.weather")) {
+ w.setStorm(false);
+ w.setThundering(false);
+ }
+
+ // Display messages
+ if (c.getBoolean("messages.chat.chat") && (c.getString("messages.chat.skipped").length() != 0)) {
+ List m = c.getList("messages.chat.skipped");
+ Random r = new Random();
+ int n = r.nextInt(m.size());
+ Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', m.get(n)));
+ }
+ if (c.getBoolean("messages.title.title")) {
+ w.getPlayers().forEach(p -> {
+ nms.sendTitle(p, c.getString("messages.title.morning.top"), c.getString("messages.title.morning.bottom"));
+ });
+ }
+ }
+ }
+
+ public void updateActivity(Player p) {
+ if (afk.contains(p)) {
+ afk.remove(p);
+ p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', p.getDisplayName()));
+ if (c.getString("messages.chat.unafk").length() > 0)
+ Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
+ c.getString("messages.chat.unafk").replace("[player]", p.getName())));
+ }
+ activity.put(p, System.currentTimeMillis());
+ }
+}
diff --git a/src/main/java/xyz/nkomarn/Harbor/util/Updater.java b/src/main/java/xyz/nkomarn/Harbor/util/Updater.java
new file mode 100644
index 0000000..f39a25a
--- /dev/null
+++ b/src/main/java/xyz/nkomarn/Harbor/util/Updater.java
@@ -0,0 +1,86 @@
+package xyz.nkomarn.Harbor.util;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.ConsoleCommandSender;
+import xyz.nkomarn.Harbor.Harbor;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class Updater {
+ public static String latest = "";
+
+ /**
+ * Checks for an update using the Spigot API
+ */
+ public boolean check() {
+ ConsoleCommandSender c = Bukkit.getServer().getConsoleSender();
+ Config config = new Config();
+
+ try {
+ URL url = new URL("https://api.spigotmc.org/legacy/update.php?resource=60088");
+ URLConnection request = url.openConnection();
+ request.addRequestProperty("User-Agent", "Harbor");
+ request.connect();
+
+ StringWriter writer = new StringWriter();
+ IOUtils.copy((InputStream) request.getContent(), writer, "UTF-8");
+ latest = writer.toString();
+
+ if (Harbor.version.equals(latest)) {
+ if (Harbor.debug) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Currently running the latest version of Harbor.");
+ return false;
+ }
+ else {
+ if (config.getBoolean("features.notifier")) c.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ config.getString("messages.miscellaneous.prefix")) + "Currently running an outdated version of Harbor. The latest available release is version " + latest + ".");
+ return true;
+ }
+ }
+ catch (IOException e) {
+ if (Harbor.debug) c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Failed to check for updated releases of Harbor.");
+ return false;
+ }
+ }
+
+ /**
+ * Replace the current Harbor version with the latest available release
+ */
+ public int upgrade() {
+ ConsoleCommandSender c = Bukkit.getServer().getConsoleSender();
+ Config config = new Config();
+
+ if (Harbor.version.equals(latest)) return 2;
+
+ c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Downloading Harbor version " + latest + ".");
+ try {
+ String jar = new File(Updater.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
+ new File("update").mkdir();
+ URL url = new URL("http://aqua.api.spiget.org/v2/resources/60088/download");
+ File f = new File("plugins" + File.separator + "update" + File.separator + jar);
+ FileUtils.copyURLToFile(url, f);
+ c.sendMessage(ChatColor.translateAlternateColorCodes('&',
+ config.getString("messages.miscellaneous.prefix")) + "Harbor " + latest + " has been downloaded successfully and will be enabled after a server restart/reload.");
+ return 0;
+ }
+ catch (Exception e) {
+ c.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix")) + "Failed to update Harbor to version " + latest + ".");
+ if (Harbor.debug) e.printStackTrace();
+ return 1;
+ }
+ }
+
+ /**
+ * Returns the latest version number
+ */
+ public String getLatest() {
+ return latest;
+ }
+}
diff --git a/config.yml b/src/main/resources/config.yml
similarity index 85%
rename from config.yml
rename to src/main/resources/config.yml
index 398870a..ddee2ae 100644
--- a/config.yml
+++ b/src/main/resources/config.yml
@@ -1,110 +1,108 @@
-# _
-# /\ /\__ _ _ __| |__ ___ _ __
-# / /_/ / _` | '__| '_ \ / _ \| '__|
-# / __ / (_| | | | |_) | (_) | |
-# \/ /_/ \__,_|_| |_.__/ \___/|_|
-#
-# An open-source project by Mykyta (TechToolbox)
-# https://mykyta.tk/
-#
-# Ahoy, matey! You've arrived at the configuration file, where things get a bit scary.
-# Every single thing within this plugin is customizable (at least I tried to make it that way),
-# so every message and plugin module can be modified here. If you would like to report a bug
-# or suggest a feature, make sure to add an issue on the GitHub page for this plugin!
-# GitHub URL: https://github.com/nkomarn/Harbor/issues
-
-values:
- # How often to run the clock task (used to detect sleep, AFK players, time actionbar, etc.)
- # Lower this value for relatively slow servers
- clock: 1
- # Percent of players that need to sleep to skip night (must be between 0 to 100)
- percent: 35
- # Time that it takes to be considered AFK (in minutes)
- timeout: 15
- # Time to wait before skipping the night (in seconds)
- delay: 3
-
-features:
- # Toggle night skipping feature. Configure amount of players needed to skip above (percent)
- skip: true
- # Clear weather when skipping night
- weather: true
- # Toggle the spawning of phantoms
- phantoms: false
- # Toggle exclusion of operators/players with permission "harbor.bypass" from sleep count
- bypass: true
- # Toggle exclusion of players in creative and spectator mode
- ignore: true
- # Prevent all players from entering a bed
- block: false
- # Detect AFK players and remove them from the sleep count
- afk: true
- # Displays a notification when a new update is released
- notifier: true
-
-messages:
- chat:
- # Toggle chat messages
- chat: true
- # "Night skipped" chat messages
- skipped:
- - "&eThe night has been skipped."
- - "&eAhhh, finally morning."
- - "&eArghh, it's so bright outside."
- # Display which player went to bed
- sleeping: "&e[player] is now sleeping ([sleeping]/[online], [needed] more needed to skip)."
- # Display when a player left their bed
- left: "&e[player] got out of bed ([sleeping]/[online], [needed] more needed to skip)."
- # Shown when a player tries to sleep and sleeping is blocked
- blocked: "&cSleeping is disabled."
- # Sent to player when they sleep with "harbor.bypass" permission
- bypass: "&eYou're excluded from the needed count. However, you have been added to the sleep count."
- # Shown when a player goes AFK
- afk: "&7[player] has gone AFK."
- # Shown when a player comes back after being AFK
- unafk: "&7[player] is no longer AFK."
- actionbar:
- # Enable/Disable actionbar message
- actionbar: true
- # Shown when some players are in bed
- sleeping: "&e[sleeping] out of [online] players are sleeping ([needed] more needed to skip)."
- # Shown when all players are in bed
- everyone: "&eEveryone is sleeping. Sweet dreams!"
- # Shown when a player tries to sleep and sleeping is blocked
- blocked: "&cSleeping is disabled."
- title:
- # Enable/Disable title messages
- title: true
- morning:
- top: "&6Good morning!"
- bottom: "&7Ah, such wonderful weather."
- evening:
- top: "&cIt's getting a bit late."
- bottom: "&7Might want to hit the hay..."
- sleeping:
- top: "&8ZZZZZZ..."
- bottom: "&7Sweet dreams."
- miscellaneous:
- # Prefix for Harbor command/miscellaneous messages
- prefix: "&8&l(&6&lHarbor&8&l)&r "
- # Prefix for player list names when a player is AFK
- afkprefix: "&8&l(&7AFK&8&l)&7 "
- # Display server version in console
- running: "&7Running on version [version]."
- # Sent in console when the plugin isn't compatible with the server
- incompatible: "&7Spigot [version] isn't compatible with Harbor."
- # Harbor reload message
- reloaded: "&7Reloaded Harbor."
- reloaderror: "&7Error reloading Harbor."
- # Sent when player doesn't have permissions to run command
- permission: "&7Insufficient permissions."
- # Sent when command argument isn't recognized
- unrecognized: "&7Urecognized command."
-
-gui:
- # Title for menu that shows when a player executes /sleeping
- sleeping: "Sleeping Players"
-
-# Spooky controls (don't change)
-version: 1.5
-debug: false
+# _
+# /\ /\__ _ _ __| |__ ___ _ __
+# / /_/ / _` | '__| '_ \ / _ \| '__|
+# / __ / (_| | | | |_) | (_) | |
+# \/ /_/ \__,_|_| |_.__/ \___/|_|
+#
+# An open-source project by Mykyta (TechToolbox)
+# https://harbor.nkomarn.xyz
+#
+# Ahoy, matey! You've arrived at the configuration file, where things get a bit scary.
+# Every single thing within this plugin is customizable (at least I tried to make it that way),
+# so every message and plugin module can be modified here. If you would like to report a bug
+# or suggest a feature, make sure to add an issue on the GitHub page for this plugin!
+# GitHub URL: https://github.com/nkomarn/Harbor/issues
+
+values:
+ # How often to run the clock task (used to detect sleep, AFK players, time actionbar, etc.)
+ # Lower this value for relatively slow servers
+ clock: 1
+ # Percent of players that need to sleep to skip night (must be between 0 to 100)
+ percent: 35
+ # Time that it takes to be considered AFK (in minutes)
+ timeout: 15
+
+features:
+ # Toggle night skipping feature. Configure amount of players needed to skip above (percent)
+ skip: true
+ # Clear weather when skipping night
+ weather: true
+ # Toggle the spawning of phantoms (false = no phantom spawning)
+ phantoms: false
+ # Toggle exclusion of operators/players with permission "harbor.bypass" from sleep count
+ bypass: true
+ # Toggle exclusion of players in creative and spectator mode
+ ignore: true
+ # Prevent all players from entering a bed
+ block: false
+ # Detect AFK players and remove them from the sleep count
+ afk: true
+ # Displays a notification when a new update is released
+ notifier: true
+
+messages:
+ chat:
+ # Toggle chat messages
+ chat: true
+ # "Night skipped" chat messages
+ skipped:
+ - "&eThe night has been skipped."
+ - "&eAhhh, finally morning."
+ - "&eArghh, it's so bright outside."
+ # Display which player went to bed
+ sleeping: "&e[player] is now sleeping ([sleeping]/[online], [needed] more needed to skip)."
+ # Display when a player left their bed
+ left: "&e[player] got out of bed ([sleeping]/[online], [needed] more needed to skip)."
+ # Shown when a player tries to sleep and sleeping is blocked
+ blocked: "&cSleeping is disabled."
+ # Sent to player when they sleep with "harbor.bypass" permission
+ bypass: "&eYou've been excluded from the sleep count."
+ # Shown when a player goes AFK
+ afk: "&7[player] has gone AFK."
+ # Shown when a player comes back after being AFK
+ unafk: "&7[player] is no longer AFK."
+ actionbar:
+ # Enable/Disable actionbar message
+ actionbar: true
+ # Shown when some players are in bed
+ sleeping: "&e[sleeping] out of [online] players are sleeping ([needed] more needed to skip)."
+ # Shown when all players are in bed
+ everyone: "&eEveryone is sleeping. Sweet dreams!"
+ # Shown when a player tries to sleep and sleeping is blocked
+ blocked: "&cSleeping is disabled."
+ title:
+ # Enable/Disable title messages
+ title: true
+ morning:
+ top: "&6Good morning!"
+ bottom: "&7Ah, such wonderful weather."
+ evening:
+ top: "&cIt's getting a bit late."
+ bottom: "&7Might want to hit the hay..."
+ sleeping:
+ top: "&8ZZZZZZ..."
+ bottom: "&7Sweet dreams."
+ miscellaneous:
+ # Prefix for Harbor command/miscellaneous messages
+ prefix: "&8&l(&6&lHarbor&8&l)&r "
+ # Prefix for player list names when a player is AFK
+ afkprefix: "&8&l(&7AFK&8&l)&7 "
+ # Display server version in console
+ running: "&7Running on version [version]."
+ # Sent in console when the plugin isn't compatible with the server
+ incompatible: "&7Spigot [version] isn't compatible with Harbor."
+ # Harbor reload message
+ reloaded: "&7Reloaded Harbor."
+ reloaderror: "&7Error reloading Harbor."
+ # Sent when player doesn't have permissions to run command
+ permission: "&7Insufficient permissions."
+ # Sent when command argument isn't recognized
+ unrecognized: "&7Urecognized command."
+
+gui:
+ # Title for menu that shows when a player executes /sleeping
+ sleeping: "Sleeping Players | Page [page]"
+
+# Spooky controls (don't change)
+version: 1.5.1
+debug: false
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
new file mode 100644
index 0000000..2379668
--- /dev/null
+++ b/src/main/resources/plugin.yml
@@ -0,0 +1,15 @@
+name: ${name}
+description: Harbor is a Spigot plugin that redefines how sleep works in your server, making it easier for all the online players to get in bed quickly and skip through the night!
+main: xyz.nkomarn.${name}.${name}
+version: ${version}
+author: TechToolbox (@nkomarn)
+website: https://nkomarn.xyz
+api-version: 1.13
+
+commands:
+ harbor:
+ description: "Base command for Harbor!"
+ usage: "/harbor {subcommand}"
+ sleeping:
+ description: "Display a list of the currently sleeping players."
+ usage: "/sleeping"
\ No newline at end of file