mirror of
https://github.com/nkomarn/harbor.git
synced 2024-12-24 09:17:34 +01:00
Fix up sleeping GUI and add 1.14 NMS
This commit is contained in:
parent
a79c305ba6
commit
73df60d41a
10
config.yml
10
config.yml
@ -54,6 +54,10 @@ messages:
|
|||||||
blocked: "&cSleeping is disabled."
|
blocked: "&cSleeping is disabled."
|
||||||
# Sent to player when they sleep with "harbor.bypass" permission
|
# Sent to player when they sleep with "harbor.bypass" permission
|
||||||
bypass: "&eYou've been excluded from the sleep count."
|
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:
|
actionbar:
|
||||||
# Enable/Disable actionbar message
|
# Enable/Disable actionbar message
|
||||||
actionbar: true
|
actionbar: true
|
||||||
@ -76,12 +80,14 @@ messages:
|
|||||||
miscellaneous:
|
miscellaneous:
|
||||||
# Prefix for Harbor command/miscellaneous messages
|
# Prefix for Harbor command/miscellaneous messages
|
||||||
prefix: "&8&l(&6&lHarbor&8&l)&r "
|
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
|
# Display server version in console
|
||||||
running: "&7Running on version [version]."
|
running: "&7Running on version [version]."
|
||||||
# Sent in console when the plugin isn't compatible with the server
|
# Sent in console when the plugin isn't compatible with the server
|
||||||
incompatible: "&7Spigot version [version] isn't compatible with Harbor."
|
incompatible: "&7Spigot version [version] isn't compatible with Harbor."
|
||||||
# Harbor reload message
|
# Harbor reload message
|
||||||
reloaded: "&7Reloaded Harbor"
|
reloaded: "&7Reloaded Harbor."
|
||||||
reloaderror: "&7Error reloading Harbor."
|
reloaderror: "&7Error reloading Harbor."
|
||||||
# Sent when player doesn't have permissions to run command
|
# Sent when player doesn't have permissions to run command
|
||||||
permission: "&7Insufficient permissions."
|
permission: "&7Insufficient permissions."
|
||||||
@ -90,7 +96,7 @@ messages:
|
|||||||
|
|
||||||
gui:
|
gui:
|
||||||
# Title for menu that shows when a player executes /sleeping
|
# Title for menu that shows when a player executes /sleeping
|
||||||
sleeping: "Sleeping players"
|
sleeping: "Sleeping Players"
|
||||||
|
|
||||||
# Version identifier (do not change)
|
# Version identifier (do not change)
|
||||||
version: 1.5
|
version: 1.5
|
||||||
|
@ -4,7 +4,7 @@ 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!
|
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)
|
author: Mykyta (TechToolbox)
|
||||||
website: https://mykyta.tk
|
website: https://mykyta.tk
|
||||||
api-version: 1.13
|
api-version: 1.14
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
harbor:
|
harbor:
|
||||||
|
83
pom.xml
83
pom.xml
@ -11,6 +11,21 @@
|
|||||||
<spigot>${project.basedir}/spigot</spigot>
|
<spigot>${project.basedir}/spigot</spigot>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- GSON -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Spigot versions -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.14</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.14.jar</systemPath>
|
||||||
|
<version>1.14</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>spigotmc.org</groupId>
|
<groupId>spigotmc.org</groupId>
|
||||||
<artifactId>spigot-1.13.2</artifactId>
|
<artifactId>spigot-1.13.2</artifactId>
|
||||||
@ -19,13 +34,73 @@
|
|||||||
<version>1.13.2</version>
|
<version>1.13.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>spigotmc.org</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>spigot-1.13</artifactId>
|
||||||
<version>2.8.5</version>
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.13.jar</systemPath>
|
||||||
|
<version>1.13</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.12.2</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.12.2.jar</systemPath>
|
||||||
|
<version>1.12.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.11.2</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.11.2.jar</systemPath>
|
||||||
|
<version>1.11.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.10.2</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.10.2.jar</systemPath>
|
||||||
|
<version>1.10.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.9.4</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.9.4.jar</systemPath>
|
||||||
|
<version>1.9.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.9.2</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.9.2.jar</systemPath>
|
||||||
|
<version>1.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.8</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.8.jar</systemPath>
|
||||||
|
<version>1.8</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>spigotmc.org</groupId>
|
||||||
|
<artifactId>spigot-1.7.2</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/1.7.2.jar</systemPath>
|
||||||
|
<version>1.7.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- BossBarAPI for 1.7 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>inventivetalent.org</groupId>
|
||||||
|
<artifactId>bossbarapi-2.4.1</artifactId>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${spigot}/BossBarAPI.jar</systemPath>
|
||||||
|
<version>2.4.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<directory>/home/nkomarn/Documents/Spigot Servers/1.13.2/plugins/</directory>
|
<directory>/home/nkomarn/Documents/Spigot Servers/1.14/plugins/</directory>
|
||||||
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mykyta.Harbor.Config;
|
import mykyta.Harbor.Config;
|
||||||
import mykyta.Harbor.Harbor;
|
import mykyta.Harbor.Harbor;
|
||||||
|
@ -11,10 +11,13 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import mykyta.Harbor.Config;
|
import mykyta.Harbor.Config;
|
||||||
|
import mykyta.Harbor.GUIType;
|
||||||
|
import mykyta.Harbor.Holder;
|
||||||
import mykyta.Harbor.Util;
|
import mykyta.Harbor.Util;
|
||||||
|
|
||||||
public class Sleeping implements CommandExecutor {
|
public class Sleeping implements CommandExecutor {
|
||||||
@ -25,27 +28,27 @@ public class Sleeping implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player p = (Player) sender;
|
||||||
World world = player.getWorld();
|
World w = p.getWorld();
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
ArrayList<Player> sleeping = Util.sleeping.get(world);
|
ArrayList<Player> sleeping = Util.sleeping.get(w);
|
||||||
int slots = Math.min(54, ((sleeping.size() - 1) / 9 + 1) * 9);
|
int slots = Math.min(54, ((sleeping.size() - 1) / 9 + 1) * 9);
|
||||||
gui = Bukkit.createInventory(player, slots, config.getString("gui.sleeping"));
|
gui = Bukkit.createInventory(new Holder(GUIType.SLEEPING), slots, config.getString("gui.sleeping"));
|
||||||
|
|
||||||
if (sleeping.size() > 0) sleeping.forEach(p -> {
|
if (sleeping.size() > 0) sleeping.forEach(pl -> {
|
||||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
|
ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.GRAY + p.getName());
|
meta.setDisplayName(ChatColor.GRAY + pl.getName());
|
||||||
/*ArrayList<String> lore = new ArrayList<String>();
|
/*ArrayList<String> lore = new ArrayList<String>();
|
||||||
lore.add("Custom head");
|
lore.add("Custom head");
|
||||||
skull.setLore(lore);
|
skull.setLore(lore);
|
||||||
*/
|
*/
|
||||||
meta.setOwner(p.getName());
|
meta.setOwner(pl.getName());
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
gui.setItem(sleeping.indexOf(p), item);
|
gui.setItem(sleeping.indexOf(pl), item);
|
||||||
});
|
});
|
||||||
|
|
||||||
player.openInventory(gui);
|
p.openInventory(gui);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
@ -29,7 +29,16 @@ public class BedEnter implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getBedEnterResult() == BedEnterResult.OK) {
|
// 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();
|
Player p = event.getPlayer();
|
||||||
World w = p.getWorld();
|
World w = p.getWorld();
|
||||||
ArrayList<Player> excluded = util.getExcluded(w);
|
ArrayList<Player> excluded = util.getExcluded(w);
|
||||||
@ -41,9 +50,9 @@ public class BedEnter implements Listener {
|
|||||||
if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.sleeping").length() != 0)) {
|
if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.sleeping").length() != 0)) {
|
||||||
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.sleeping")
|
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.sleeping")
|
||||||
.replace("[sleeping]", String.valueOf(util.getSleeping(w))))
|
.replace("[sleeping]", String.valueOf(util.getSleeping(w))))
|
||||||
.replace("[online]", String.valueOf(util.getOnline(w) - excluded.size()))
|
.replace("[online]", String.valueOf(util.getOnline(w)))
|
||||||
.replace("[player]", p.getName())
|
.replace("[player]", p.getName())
|
||||||
.replace("[needed]", String.valueOf(util.getNeeded(w) - excluded.size())));
|
.replace("[needed]", String.valueOf(util.getNeeded(w))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip night if possible
|
// Skip night if possible
|
||||||
|
@ -33,9 +33,9 @@ public class BedLeave implements Listener {
|
|||||||
if (config.getBoolean("messages.chat.chat") && (config.getString("messages.chat.left").length() != 0) && !(w.getTime() > 0 && w.getTime() < 12300) && !excluded.contains(p)) {
|
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")
|
Bukkit.getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.left")
|
||||||
.replace("[sleeping]", String.valueOf(util.getSleeping(w))))
|
.replace("[sleeping]", String.valueOf(util.getSleeping(w))))
|
||||||
.replace("[online]", String.valueOf(util.getOnline(w) - excluded.size()))
|
.replace("[online]", String.valueOf(util.getOnline(w)))
|
||||||
.replace("[player]", event.getPlayer().getName())
|
.replace("[player]", event.getPlayer().getName())
|
||||||
.replace("[needed]", String.valueOf(util.getNeeded(w) - excluded.size())));
|
.replace("[needed]", String.valueOf(util.getNeeded(w))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +0,0 @@
|
|||||||
package mykyta.Harbor.Events;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
|
|
||||||
import mykyta.Harbor.Config;
|
|
||||||
|
|
||||||
public class GUIClick implements Listener {
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventHandler
|
|
||||||
public void onGUIClick(InventoryClickEvent event) {
|
|
||||||
Config config = new Config();
|
|
||||||
String title = event.getInventory().getName();
|
|
||||||
|
|
||||||
if (title.equals(config.getString("gui.sleeping"))) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package mykyta.Harbor.Events;
|
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
|
||||||
|
|
||||||
public class GUIDrag implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public void onGUIDrag(InventoryDragEvent event) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
30
src/main/java/mykyta/Harbor/Events/GUIEvent.java
Normal file
30
src/main/java/mykyta/Harbor/Events/GUIEvent.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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.GUIType;
|
||||||
|
import mykyta.Harbor.Holder;
|
||||||
|
|
||||||
|
public class GUIEvent implements Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(InventoryClickEvent event) {
|
||||||
|
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) {
|
||||||
|
Player p = ((Player) event.getWhoClicked());
|
||||||
|
GUIType t = ((Holder) event.getInventory().getHolder()).getType();
|
||||||
|
if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDrag(InventoryDragEvent event) {
|
||||||
|
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) {
|
||||||
|
Player p = ((Player) event.getWhoClicked());
|
||||||
|
GUIType t = ((Holder) event.getInventory().getHolder()).getType();
|
||||||
|
if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,27 @@
|
|||||||
package mykyta.Harbor.Events;
|
package mykyta.Harbor.Events;
|
||||||
|
|
||||||
import java.time.Instant;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import mykyta.Harbor.Config;
|
||||||
import mykyta.Harbor.Util;
|
import mykyta.Harbor.Util;
|
||||||
|
|
||||||
public class Move implements Listener {
|
public class Move implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMovement(PlayerMoveEvent event) {
|
public void onPlayerMovement(PlayerMoveEvent event) {
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
Config config = new Config();
|
||||||
|
|
||||||
|
if (Util.afk.contains(p)) {
|
||||||
|
Util.afk.remove(p);
|
||||||
|
p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', p.getName()));
|
||||||
|
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.unafk")
|
||||||
|
.replace("[player]", p.getName())));
|
||||||
|
}
|
||||||
Util.activity.put(event.getPlayer(), System.currentTimeMillis());
|
Util.activity.put(event.getPlayer(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,6 +19,7 @@ public class PlayerLeave implements Listener {
|
|||||||
new java.util.TimerTask() {
|
new java.util.TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
// FIXME IM BROKE THE THING UPDATES NIGHT WHEN PEOPLE LEAVE IS BAD
|
||||||
if (w.getPlayers().size() > 0 && Math.max(0, util.getNeeded(w) - util.getExcluded(w).size()) == 0) util.skip(w);
|
if (w.getPlayers().size() > 0 && Math.max(0, util.getNeeded(w) - util.getExcluded(w).size()) == 0) util.skip(w);
|
||||||
Util.activity.remove(p);
|
Util.activity.remove(p);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,11 @@ public class Spawn implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSpawn(CreatureSpawnEvent event) {
|
public void onSpawn(CreatureSpawnEvent event) {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
try {
|
||||||
if (event.getEntityType().equals(EntityType.PHANTOM) && !config.getBoolean("features.phantoms")) event.setCancelled(true);
|
if (event.getEntityType().equals(EntityType.PHANTOM) && !config.getBoolean("features.phantoms")) event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
catch (NoSuchFieldError e) {
|
||||||
|
// Do nothing, Phantom only exists in 1.13+
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
5
src/main/java/mykyta/Harbor/GUIType.java
Normal file
5
src/main/java/mykyta/Harbor/GUIType.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package mykyta.Harbor;
|
||||||
|
|
||||||
|
public enum GUIType {
|
||||||
|
SLEEPING
|
||||||
|
}
|
@ -1,11 +1,8 @@
|
|||||||
package mykyta.Harbor;
|
package mykyta.Harbor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -13,8 +10,7 @@ import mykyta.Harbor.Commands.Command;
|
|||||||
import mykyta.Harbor.Commands.Sleeping;
|
import mykyta.Harbor.Commands.Sleeping;
|
||||||
import mykyta.Harbor.Events.BedEnter;
|
import mykyta.Harbor.Events.BedEnter;
|
||||||
import mykyta.Harbor.Events.BedLeave;
|
import mykyta.Harbor.Events.BedLeave;
|
||||||
import mykyta.Harbor.Events.GUIClick;
|
import mykyta.Harbor.Events.GUIEvent;
|
||||||
import mykyta.Harbor.Events.GUIDrag;
|
|
||||||
import mykyta.Harbor.Events.Move;
|
import mykyta.Harbor.Events.Move;
|
||||||
import mykyta.Harbor.Events.PlayerJoin;
|
import mykyta.Harbor.Events.PlayerJoin;
|
||||||
import mykyta.Harbor.Events.PlayerLeave;
|
import mykyta.Harbor.Events.PlayerLeave;
|
||||||
@ -32,27 +28,27 @@ public class Harbor extends JavaPlugin {
|
|||||||
Bukkit.getPluginManager().registerEvents(new BedLeave(), this);
|
Bukkit.getPluginManager().registerEvents(new BedLeave(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new Move(), this);
|
Bukkit.getPluginManager().registerEvents(new Move(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new Spawn(), this);
|
Bukkit.getPluginManager().registerEvents(new Spawn(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new GUIClick(), this);
|
Bukkit.getPluginManager().registerEvents(new GUIEvent(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new GUIDrag(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
|
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerLeave(), this);
|
Bukkit.getPluginManager().registerEvents(new PlayerLeave(), this);
|
||||||
util.setupNMS();
|
util.setupNMS();
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task(), 0L, config.getInteger("values.clock") * 20);
|
|
||||||
|
Bukkit.getServer().getWorlds().forEach(w -> {
|
||||||
|
ArrayList<Player> sleeping = new ArrayList<Player>();
|
||||||
|
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 (this.getConfig().getBoolean("debug")) Util.debug = true;
|
||||||
if (this.getConfig().getBoolean("features.notifier")) {
|
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...");
|
if (Util.debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getConfig().getString("messages.miscellaneous.prefix")) + "Checking for new updates...");
|
||||||
Updater updater = new Updater();
|
Updater updater = new Updater();
|
||||||
updater.check();
|
updater.check();
|
||||||
}
|
}
|
||||||
for (World w : Bukkit.getServer().getWorlds()) {
|
|
||||||
ArrayList<Player> sleeping = new ArrayList<Player>();
|
|
||||||
Util.sleeping.put(w, sleeping);
|
|
||||||
}
|
|
||||||
Bukkit.getServer().getWorlds().forEach(w -> {
|
|
||||||
w.getPlayers().forEach(p -> {
|
|
||||||
Util.activity.put(p, System.currentTimeMillis());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
22
src/main/java/mykyta/Harbor/Holder.java
Normal file
22
src/main/java/mykyta/Harbor/Holder.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package mykyta.Harbor;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
public class Holder implements InventoryHolder {
|
||||||
|
Inventory inv;
|
||||||
|
GUIType type;
|
||||||
|
|
||||||
|
public Holder(GUIType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Inventory getInventory() {
|
||||||
|
return inv; // Required by InvetoryHolder
|
||||||
|
}
|
||||||
|
|
||||||
|
public GUIType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,5 @@ public interface NMS {
|
|||||||
public void sendActionbar(Player player, String message);
|
public void sendActionbar(Player player, String message);
|
||||||
public void sendJSONMessage(Player player, String json);
|
public void sendJSONMessage(Player player, String json);
|
||||||
public void sendTitle(Player player, String top, String bottom);
|
public void sendTitle(Player player, String top, String bottom);
|
||||||
|
public void enterBed(Player player);
|
||||||
}
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_10_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_10_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_11_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_11_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_12_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_12_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_13_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_13_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
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.IChatBaseComponent;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutChat;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutChat;
|
||||||
import net.minecraft.server.v1_13_R2.PacketPlayOutTitle;
|
import net.minecraft.server.v1_13_R2.PacketPlayOutTitle;
|
||||||
@ -34,4 +35,11 @@ public class NMS_1_13_R2 implements NMS {
|
|||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(title);
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
|
((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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_14_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_14_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_7_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_7_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package mykyta.Harbor.NMS;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.inventivetalent.bossbar.BossBarAPI;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.minecraft.server.v1_7_R1.ChatSerializer;
|
||||||
|
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
|
||||||
|
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
|
||||||
|
|
||||||
|
public class NMS_1_7_R1 implements NMS {
|
||||||
|
@Override
|
||||||
|
public void sendActionbar(Player player, String message) {
|
||||||
|
if (Bukkit.getServer().getPluginManager().getPlugin("BossBarAPI") == null) System.out.println("API missing");
|
||||||
|
else BossBarAPI.addBar(player, new TextComponent(ChatColor.translateAlternateColorCodes('&', message)), BossBarAPI.Color.RED, BossBarAPI.Style.PROGRESS, 1.0f, 20, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_8_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_8_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_9_R1.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_9_R1.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
42
src/main/java/mykyta/Harbor/NMS/NMS_1_9_R2.java
Normal file
42
src/main/java/mykyta/Harbor/NMS/NMS_1_9_R2.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -20,16 +20,22 @@ public class Task implements Runnable {
|
|||||||
util.skip(w);
|
util.skip(w);
|
||||||
}
|
}
|
||||||
if (util.getSleeping(w) > 0 && util.getSleeping(w) < w.getPlayers().size()) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.sleeping"), w);});}
|
if (util.getSleeping(w) > 0 && util.getSleeping(w) < w.getPlayers().size()) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.sleeping"), w);});}
|
||||||
else if (util.getSleeping(w) == w.getPlayers().size()) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.everyone"), w);});}
|
else if (util.getSleeping(w) == util.getNeeded(w)) {w.getPlayers().forEach(p -> {util.sendActionbar(p, config.getString("messages.actionbar.everyone"), w);});}
|
||||||
|
|
||||||
/*w.getPlayers().forEach(p -> {
|
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)) {
|
||||||
if (TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - Util.activity.get(p)) > config.getInteger("values.timeout")) {
|
Util.activity.put(p, System.currentTimeMillis());
|
||||||
///TODO custom afk prefix
|
return;
|
||||||
//p.setPlayerListName(ChatColor.GRAY + "[AFK] - " + ChatColor.RESET + p.getDisplayName());
|
|
||||||
System.out.println(p.getName() + " is AFK.");
|
|
||||||
}
|
}
|
||||||
|
if (!Util.afk.contains(p)) {
|
||||||
|
Util.afk.add(p);
|
||||||
|
p.setPlayerListName(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.afkprefix") + p.getName()));
|
||||||
|
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.chat.afk")
|
||||||
|
.replace("[player]", p.getName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,17 +2,23 @@ package mykyta.Harbor;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mykyta.Harbor.NMS.NMS;
|
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_13_R2;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import mykyta.Harbor.NMS.NMS_1_14_R1;
|
||||||
|
import mykyta.Harbor.NMS.NMS_1_8_R1;
|
||||||
|
import mykyta.Harbor.NMS.NMS_1_9_R1;
|
||||||
|
import mykyta.Harbor.NMS.NMS_1_9_R2;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
public static HashMap<World, ArrayList<Player>> sleeping = new HashMap<World, ArrayList<Player>>();
|
public static HashMap<World, ArrayList<Player>> sleeping = new HashMap<World, ArrayList<Player>>();
|
||||||
@ -20,6 +26,7 @@ public class Util {
|
|||||||
public static ArrayList<Player> afk = new ArrayList<Player>();
|
public static ArrayList<Player> afk = new ArrayList<Player>();
|
||||||
|
|
||||||
public String version = "1.5";
|
public String version = "1.5";
|
||||||
|
public static boolean enabled = true;
|
||||||
public static boolean debug = false;
|
public static boolean debug = false;
|
||||||
private static NMS nms;
|
private static NMS nms;
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
@ -33,15 +40,29 @@ public class Util {
|
|||||||
catch (ArrayIndexOutOfBoundsException e) {
|
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.");
|
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);
|
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 (debug) Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.prefix") + config.getString("messages.miscellaneous.running").replace("[version]", version)));
|
||||||
|
|
||||||
if (version.equals("v1_13_R2")) {
|
// FIXME maybe later
|
||||||
nms = new NMS_1_13_R2();
|
/*if (version.equals("v1_7_R1")) {
|
||||||
}
|
nms = new NMS_1_7_R1();
|
||||||
|
}*/
|
||||||
|
if (version.equals("v1_8_R1")) {nms = new NMS_1_8_R1();}
|
||||||
|
//TODO more 1.8 versions
|
||||||
|
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 {
|
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.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);
|
Bukkit.getPluginManager().disablePlugin(Config.harbor);
|
||||||
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +90,7 @@ public class Util {
|
|||||||
* @param world World to fetch count for
|
* @param world World to fetch count for
|
||||||
*/
|
*/
|
||||||
public int getSleeping(World w) {
|
public int getSleeping(World w) {
|
||||||
return Util.sleeping.get(w).size();
|
return Math.max(0, Util.sleeping.get(w).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +98,7 @@ public class Util {
|
|||||||
* @param world World to fetch count for
|
* @param world World to fetch count for
|
||||||
*/
|
*/
|
||||||
public int getNeeded(World w) {
|
public int getNeeded(World w) {
|
||||||
//FIXME i think its broke
|
//FIXME make sure to remove excluded players
|
||||||
return Math.max(0, (int) Math.ceil(w.getPlayers().size() * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));
|
return Math.max(0, (int) Math.ceil(w.getPlayers().size() * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +107,7 @@ public class Util {
|
|||||||
* @param world World to check player count for
|
* @param world World to check player count for
|
||||||
*/
|
*/
|
||||||
public int getOnline(World w) {
|
public int getOnline(World w) {
|
||||||
return Math.max(0, w.getPlayers().size());
|
return Math.max(0, w.getPlayers().size() - getExcluded(w).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,7 +130,7 @@ public class Util {
|
|||||||
boolean state = true;
|
boolean state = true;
|
||||||
if (config.getBoolean("features.ignore")) if (p.getGameMode() == GameMode.SURVIVAL) state = false; else state = true;
|
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 (config.getBoolean("features.bypass")) if (p.hasPermission("harbor.bypass")) state = true; else state = false;
|
||||||
if (TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis() - activity.get(p)) > config.getInteger("values.timeout")) state = true;
|
if (afk.contains(p)) state = true;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,12 +151,10 @@ public class Util {
|
|||||||
* @param world World to fetch information for
|
* @param world World to fetch information for
|
||||||
*/
|
*/
|
||||||
public void sendActionbar(Player p, String message, World w) {
|
public void sendActionbar(Player p, String message, World w) {
|
||||||
ArrayList<Player> excluded = this.getExcluded(w);
|
|
||||||
|
|
||||||
nms.sendActionbar(p, message
|
nms.sendActionbar(p, message
|
||||||
.replace("[sleeping]", String.valueOf(this.getSleeping(w)))
|
.replace("[sleeping]", String.valueOf(this.getSleeping(w)))
|
||||||
.replace("[online]", String.valueOf(w.getPlayers().size() - excluded.size()))
|
.replace("[online]", String.valueOf(this.getOnline(w)))
|
||||||
.replace("[needed]", String.valueOf(this.getNeeded(w) - excluded.size())));
|
.replace("[needed]", String.valueOf(this.getNeeded(w))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,6 +175,15 @@ public class Util {
|
|||||||
nms.sendTitle(player, top, 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)
|
* Skips the night in the specified world (if possible)
|
||||||
* @param World to return value for
|
* @param World to return value for
|
||||||
|
Loading…
Reference in New Issue
Block a user