mirror of
https://github.com/nkomarn/harbor.git
synced 2024-12-25 09:47:34 +01:00
Update 1.4.4, I guess.
This commit is contained in:
parent
771c81a7df
commit
87a7079e55
@ -26,6 +26,8 @@ features:
|
|||||||
clearWeather: true
|
clearWeather: true
|
||||||
# Toggle exclusion of operators/players with permission "harbor.bypass" from sleep count
|
# Toggle exclusion of operators/players with permission "harbor.bypass" from sleep count
|
||||||
bypass: false
|
bypass: false
|
||||||
|
# Prevent any players from entering a bed (1.13.2 OR NEWER)
|
||||||
|
blockSleep: false
|
||||||
# Display debug information in console
|
# Display debug information in console
|
||||||
debug: false
|
debug: false
|
||||||
|
|
||||||
@ -37,6 +39,8 @@ messages:
|
|||||||
skipped: "&eThe night has been skipped."
|
skipped: "&eThe night has been skipped."
|
||||||
# Display which player went to bed in chat
|
# Display which player went to bed in chat
|
||||||
sleeping: "&e[player] is now sleeping ([sleeping]/[online]. [needed] more needed to skip)."
|
sleeping: "&e[player] is now sleeping ([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
|
# 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."
|
||||||
actionbar:
|
actionbar:
|
||||||
@ -46,6 +50,8 @@ messages:
|
|||||||
sleeping: "&e[sleeping] out of [online] players are sleeping ([needed] more needed to skip)."
|
sleeping: "&e[sleeping] out of [online] players are sleeping ([needed] more needed to skip)."
|
||||||
# Shown when all players are in bed
|
# Shown when all players are in bed
|
||||||
everyone: "&eEveryone is sleeping. Sweet dreams!"
|
everyone: "&eEveryone is sleeping. Sweet dreams!"
|
||||||
|
# Shown when a player tries to sleep and sleeping is blocked
|
||||||
|
blocked: "&cSleeping is disabled."
|
||||||
miscellaneous:
|
miscellaneous:
|
||||||
# Prefix for Harbor command messages
|
# Prefix for Harbor command messages
|
||||||
prefix: "&8&l(&6&lHarbor&8&l) "
|
prefix: "&8&l(&6&lHarbor&8&l) "
|
||||||
@ -60,4 +66,4 @@ messages:
|
|||||||
permission: "&7Insufficient permissions."
|
permission: "&7Insufficient permissions."
|
||||||
|
|
||||||
# Version identifier (do not change)
|
# Version identifier (do not change)
|
||||||
version: 1.4.3
|
version: 1.4.4
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Harbor
|
name: Harbor
|
||||||
version: 1.4.3
|
version: 1.4.4
|
||||||
main: techtoolbox.Harbor.Main
|
main: techtoolbox.Harbor.Main
|
||||||
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: TechToolbox
|
author: TechToolbox
|
||||||
|
@ -5,13 +5,27 @@ import org.bukkit.Bukkit;
|
|||||||
public class ActionBarMessage implements Runnable {
|
public class ActionBarMessage implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
<<<<<<< HEAD
|
||||||
for (int i = 0; Main.worlds.size() > i; i++) {
|
for (int i = 0; Main.worlds.size() > i; i++) {
|
||||||
if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() > 0) && ((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() < (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size())) {
|
if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() > 0) && ((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() < (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size())) {
|
||||||
Main.sendActionbar("playersInBed", Bukkit.getServer().getWorlds().get(i));
|
Main.sendActionbar("playersInBed", Bukkit.getServer().getWorlds().get(i));
|
||||||
}
|
}
|
||||||
else if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() == (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size()) && ((Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size() > 1)) {
|
else if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() == (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size()) && ((Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size() > 1)) {
|
||||||
Main.sendActionbar("everyoneSleeping", Bukkit.getServer().getWorlds().get(i));
|
Main.sendActionbar("everyoneSleeping", Bukkit.getServer().getWorlds().get(i));
|
||||||
|
=======
|
||||||
|
try {
|
||||||
|
for (int i = 0; Main.worlds.size() > i; i++) {
|
||||||
|
if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() > 0) && ((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() < (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size())) {
|
||||||
|
Main.sendActionbar("playersInBed", Bukkit.getServer().getWorlds().get(i), null);
|
||||||
}
|
}
|
||||||
|
else if (((Main.worlds.get(Bukkit.getServer().getWorlds().get(i))).intValue() == (Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size()) && ((Bukkit.getServer().getWorlds().get(i)).getPlayers().size() - Main.bypassers.size() > 1)) {
|
||||||
|
Main.sendActionbar("everyoneSleeping", Bukkit.getServer().getWorlds().get(i), null);
|
||||||
|
}
|
||||||
|
>>>>>>> Update 1.4.4, I guess.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@ public class Command implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.plugin.getConfig().getString("messages.miscellaneous.prefix") + Main.plugin.getConfig().getString("messages.miscellaneous.permission")));
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.plugin.getConfig().getString("messages.miscellaneous.prefix") + Main.plugin.getConfig().getString("messages.miscellaneous.permission")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("test")) {
|
||||||
|
System.out.println(Main.worlds.size());
|
||||||
|
System.out.println(Main.bypassers.size());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,15 @@ public class BedEnterEvent implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerBedEnterEvent(PlayerBedEnterEvent event) {
|
public void onPlayerBedEnterEvent(PlayerBedEnterEvent event) {
|
||||||
|
|
||||||
|
// Sleep blocking feature
|
||||||
|
if (Main.plugin.getConfig().getBoolean("features.blockSleep")) {
|
||||||
|
if (Main.plugin.getConfig().getString("messages.chat.blocked").length() > 0) {
|
||||||
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Main.plugin.getConfig().getString("messages.chat.blocked")));
|
||||||
|
}
|
||||||
|
Main.sendActionbar("sleepingBlocked", null, event.getPlayer());
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// TEMPORARY SOLUTION FOR 1.13.2: CHECK IF BEDENTERRESULT WORKS, IF NOT THEN RUN 1.13.1 CODE
|
// TEMPORARY SOLUTION FOR 1.13.2: CHECK IF BEDENTERRESULT WORKS, IF NOT THEN RUN 1.13.1 CODE
|
||||||
try {
|
try {
|
||||||
if (event.getBedEnterResult() == BedEnterResult.OK) {
|
if (event.getBedEnterResult() == BedEnterResult.OK) {
|
||||||
@ -30,7 +39,7 @@ public class BedEnterEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.getPlayer().hasPermission("harbor.bypass")) {
|
if (!Main.plugin.getConfig().getBoolean("features.bypass") || !event.getPlayer().hasPermission("harbor.bypass")) {
|
||||||
try {
|
try {
|
||||||
Main.worlds.put(event.getPlayer().getWorld(), Integer.valueOf((Main.worlds.get(event.getPlayer().getWorld())).intValue() + 1));
|
Main.worlds.put(event.getPlayer().getWorld(), Integer.valueOf((Main.worlds.get(event.getPlayer().getWorld())).intValue() + 1));
|
||||||
}
|
}
|
||||||
@ -118,4 +127,5 @@ public class BedEnterEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class BedLeaveEvent implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.getPlayer().hasPermission("harbor.bypass")) {
|
if (!Main.plugin.getConfig().getBoolean("features.bypass") || !event.getPlayer().hasPermission("harbor.bypass")) {
|
||||||
Main.worlds.put(event.getPlayer().getWorld(), Integer.valueOf((Main.worlds.get(event.getPlayer().getWorld())).intValue() - 1));
|
Main.worlds.put(event.getPlayer().getWorld(), Integer.valueOf((Main.worlds.get(event.getPlayer().getWorld())).intValue() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import techtoolbox.Harbor.Actionbar.Actionbar;
|
import techtoolbox.Harbor.Actionbar.Actionbar;
|
||||||
@ -30,7 +27,7 @@ import techtoolbox.Harbor.Listeners.QuitEvent;
|
|||||||
|
|
||||||
public class Main extends JavaPlugin implements Listener {
|
public class Main extends JavaPlugin implements Listener {
|
||||||
public static Main plugin;
|
public static Main plugin;
|
||||||
public static String version = "1.4.3";
|
public static String version = "1.4.4";
|
||||||
public static HashMap<World, Integer> worlds = new HashMap<World, Integer>();
|
public static HashMap<World, Integer> worlds = new HashMap<World, Integer>();
|
||||||
public static ArrayList<String> bypassers = new ArrayList<String>();
|
public static ArrayList<String> bypassers = new ArrayList<String>();
|
||||||
public static Actionbar actionbar;
|
public static Actionbar actionbar;
|
||||||
@ -73,7 +70,7 @@ public class Main extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendActionbar(String type, World world) {
|
public static void sendActionbar(String type, World world, Player player) {
|
||||||
if (type.equals("playersInBed")) {
|
if (type.equals("playersInBed")) {
|
||||||
for (Player p : world.getPlayers()) {
|
for (Player p : world.getPlayers()) {
|
||||||
actionbar.sendActionbar(p, plugin.getConfig().getString("messages.actionbar.sleeping")
|
actionbar.sendActionbar(p, plugin.getConfig().getString("messages.actionbar.sleeping")
|
||||||
@ -90,6 +87,9 @@ public class Main extends JavaPlugin implements Listener {
|
|||||||
.replace("[needed]", String.valueOf(Math.max(0, Math.round(world.getPlayers().size() * Float.parseFloat(plugin.getConfig().getString("values.percent")) - bypassers.size() - ((Integer)worlds.get(world)).intValue())))));
|
.replace("[needed]", String.valueOf(Math.max(0, Math.round(world.getPlayers().size() * Float.parseFloat(plugin.getConfig().getString("values.percent")) - bypassers.size() - ((Integer)worlds.get(world)).intValue())))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type.equals("sleepingBlocked")) {
|
||||||
|
actionbar.sendActionbar(player, plugin.getConfig().getString("messages.actionbar.blocked"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupActionbar() {
|
private boolean setupActionbar() {
|
||||||
|
Loading…
Reference in New Issue
Block a user