1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-12-18 22:37:36 +01:00

Finalizing 1.5!

This commit is contained in:
BuildTools 2019-05-17 15:45:08 -07:00
parent 519361da02
commit 5b39d2c920
6 changed files with 75 additions and 24 deletions

14
pom.xml
View File

@ -81,6 +81,20 @@
<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.8</artifactId>
<scope>system</scope>
<systemPath>${spigot}/1.8.8.jar</systemPath>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>spigotmc.org</groupId>
<artifactId>spigot-1.8.3</artifactId>
<scope>system</scope>
<systemPath>${spigot}/1.8.3.jar</systemPath>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>spigotmc.org</groupId>

View File

@ -1,8 +1,5 @@
package mykyta.Harbor.Events;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

View File

@ -19,7 +19,6 @@ public class PlayerLeave implements Listener {
new java.util.TimerTask() {
@Override
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);
Util.activity.remove(p);
}

View File

@ -1,21 +1,21 @@
package mykyta.Harbor.NMS;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R2.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;
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_7_R1 implements NMS {
public class NMS_1_8_R2 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);
IChatBaseComponent titleComponent = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', message) + "\"}");
PacketPlayOutChat titlePacket = new PacketPlayOutChat(titleComponent, (byte)2);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(titlePacket);
}
@Override
@ -27,12 +27,12 @@ public class NMS_1_7_R1 implements NMS {
@Override
public void sendTitle(Player player, String top, String bottom) {
/*IChatBaseComponent titleTop = ChatSerializer.a("{\"text\": \"" + ChatColor.translateAlternateColorCodes('&', top) + "\"}");
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);*/
((CraftPlayer) player).getHandle().playerConnection.sendPacket(subtitle);
}
@Override

View File

@ -0,0 +1,42 @@
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) {
}
}

View File

@ -18,8 +18,9 @@ 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_7_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;
@ -47,10 +48,9 @@ public class Util {
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_7_R1")) {nms = new NMS_1_7_R1();}
else if (version.equals("v1_8_R1")) {nms = new NMS_1_8_R1();}
//TODO more 1.8 versions
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();}
@ -99,8 +99,7 @@ public class Util {
* @param world World to fetch count for
*/
public int getNeeded(World w) {
//FIXME make sure to remove excluded players
try {return Math.max(0, (int) Math.ceil(w.getPlayers().size() * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));}
try {return Math.max(0, (int) Math.ceil((w.getPlayers().size() - getExcluded(w).size()) * (config.getDouble("values.percent") / 100) - this.getSleeping(w)));}
catch (NullPointerException e) {return 0;}
}
@ -192,7 +191,7 @@ public class Util {
* @param World to return value for
*/
public void skip(World w) {
if (config.getBoolean("features.skip") && this.getNeeded(w) - this.getExcluded(w).size() == 0) {
if (config.getBoolean("features.skip") && Math.max(0, this.getNeeded(w) - this.getExcluded(w).size()) == 0) {
w.setTime(1000L);
// Set weather to clear