From 76f2a6ea446112263c9a355553eb267bcaee07cb Mon Sep 17 00:00:00 2001 From: Michi302 Date: Mon, 30 Jun 2014 21:05:51 +0200 Subject: [PATCH 01/27] Fixed wrong field names --- src/me/confuser/barapi/nms/v1_7.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/me/confuser/barapi/nms/v1_7.java b/src/me/confuser/barapi/nms/v1_7.java index 8fe74df..7aa685e 100644 --- a/src/me/confuser/barapi/nms/v1_7.java +++ b/src/me/confuser/barapi/nms/v1_7.java @@ -49,10 +49,10 @@ public Object getSpawnPacket() { Field motX = Util.getField(Entity, "motX"); motX.set(dragon, getXvel()); - Field motY = Util.getField(Entity, "motX"); + Field motY = Util.getField(Entity, "motY"); motY.set(dragon, getYvel()); - Field motZ = Util.getField(Entity, "motX"); + Field motZ = Util.getField(Entity, "motZ"); motZ.set(dragon, getZvel()); Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[] {}); @@ -191,4 +191,4 @@ public Object getWatcher() { } return watcher; } -} \ No newline at end of file +} From b5b56af57151ca0fe6bcd60da4d988507223280a Mon Sep 17 00:00:00 2001 From: Wout Date: Thu, 14 Aug 2014 11:44:20 +0200 Subject: [PATCH 02/27] Updated to 1.7.10 I guess? It's working ... --- pom.xml | 4 ++-- src/me/confuser/barapi/BarAPI.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 2236beb..8c0258f 100644 --- a/pom.xml +++ b/pom.xml @@ -24,8 +24,8 @@ maven-compiler-plugin 3.1 - 1.6 - 1.6 + 1.7 + 1.7 diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index 72eacc3..d12ce03 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; import org.mcstats.MetricsLite; import java.io.IOException; @@ -285,7 +284,7 @@ public static void setMessage(final Player player, String message, int seconds) cancelTimer(player); - timers.put(player.getUniqueId(), Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() { + timers.put(player.getUniqueId(), Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() { @Override public void run() { From 24893e5846ab4d00043a33c8a73cb105ff040f18 Mon Sep 17 00:00:00 2001 From: woutwoot Date: Thu, 14 Aug 2014 11:52:45 +0200 Subject: [PATCH 03/27] Create README.md --- README.md | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7ca74bf --- /dev/null +++ b/README.md @@ -0,0 +1,127 @@ +== BarAPI == +{{https://dl.dropboxusercontent.com/s/qg69hkk6dmpq8zd/shot_130901_201310.png?token_hash=AAGC7_1B9PDv79DWxGiM_1tWSabZL6OwhGfp8oUb39ZPVQ|}} + +=== Server Owners === +This plugin does nothing on its own. It is simply an API for other plugins to implement with. + + +=== Developers === +Simply add BarAPI.jar to your project build path. + +This plugin makes use of reflection and therefore "shouldn't" break on craftbukkit updates. + +=== Limitations === +The message can not be more than 64 characters. If it is more, BarAPI will automatically cut it to 64 characters to prevent the client from crashing. + +This is a client limitation and cannot be changed. + +=== Examples === +===== BarAPI.setMessage(Player player, String message) ===== + +Set a message for the player. It will remain there until the player logs off or another plugin overrides it. + + + +===== BarAPI.setMessage(Player player, String message, float percent) ===== + +Same as above except you can set the % of the health bar. 100 shows the entire health bar, 50 shows half the health bar and so on. + + + +===== BarAPI.setMessage(final Player player, String message, int seconds) ===== + +Sets a timed message for the player. It will remain until the timer runs out. The health automatically reduces based on how long the timer is. + + + +===== BarAPI.hasBar(Player player) ===== + +Pretty self explanatory, returns a boolean. + + + +===== BarAPI.removeBar(Player player) ===== + +Also pretty self explanatory. + + + +===== BarAPI.setHealth(Player player, float percent) ===== + +Allows you to modify the health of an existing bar. If the player has no bar, this does nothing. + + +=== Tutorials === +[[http://youtu.be/Nb-tLbLrrmM|German]] - [[http://dev.bukkit.org/profiles/DerFeliix/|DerFeliix]] + +=== Source === +[[https://github.com/confuser/BarAPI/|GitHub]] + +=== Maven === +<> + + + confuser-repo + http://ci.frostcast.net/plugin/repository/everything + + + + + + me.confuser + BarAPI + 3.0 + + +<> + +=== Updater === +This plugin contains an auto updater which is enabled by default. If you do not wish to automatically download new updates, edit BarAPI/config.yml and set autoUpdate to false. + +=== To Dos === +* Scroll messages if string is greater than 64 characters. + +=== Plugins Using BarAPI === +[[http://dev.bukkit.org/bukkit-plugins/welcomebar/|WelcomeBar]] + +[[http://dev.bukkit.org/bukkit-plugins/parkour/|Parkour]] + +[[http://dev.bukkit.org/bukkit-plugins/quicksupport/|QuickSupport]] + +[[http://dev.bukkit.org/bukkit-plugins/bossbroadcast/|BossBroadcast]] + +[[http://dev.bukkit.org/bukkit-plugins/bossmessage/|BossMessage]] + +[[http://dev.bukkit.org/bukkit-plugins/pvpgames-automated/|PvPGames Automated]] + +[[http://dev.bukkit.org/bukkit-plugins/bosseventscheduler/|BossEventScheduler]] + +[[http://dev.bukkit.org/bukkit-plugins/infernal-mobs/|Infernal Mobs]] + +[[http://dev.bukkit.org/bukkit-plugins/mythicmobs/|MythicMobs]] + +[[http://dev.bukkit.org/bukkit-plugins/multikill/|MultiKill]] + +[[http://dev.bukkit.org/bukkit-plugins/playerboss/|PlayerBoss]] + +[[http://dev.bukkit.org/bukkit-plugins/bossads/|BossAds]] + +[[http://dev.bukkit.org/bukkit-plugins/item-lore-stats/|Item Lore Stats]] + +[[http://dev.bukkit.org/bukkit-plugins/bossbarpro/|BossBarPro]] + +[[http://dev.bukkit.org/bukkit-plugins/viplobby/|VIPLobby]] + +[[http://dev.bukkit.org/bukkit-plugins/battleofblocks/|Battle Of Blocks]] + +[[http://dev.bukkit.org/bukkit-plugins/bossbroadcaster/|BossBroadcaster]] + +[[http://dev.bukkit.org/bukkit-plugins/silkspawners/|SilkSpawners]] + +[[http://dev.bukkit.org/bukkit-plugins/barjoin/|BarJoin]] + +[[http://dev.bukkit.org/bukkit-plugins/join_messages/|JoinGlobalMessages]] + +=== Metrics === +To determine popularity and usage of BarAPI, plugin installs are automatically tracked by the Metrics plugin tracking system. Your Java version, OS, player count, server country location and plugin & server versions are collected. This is used to determine what environments are using the plugin to ensure full compatibility. This collection is anonymous. If you don't want this tracking, edit plugins/PluginMetrics/config.yml and set opt-out to true. +[[http://mcstats.org/plugin/BarAPI|{{http://api.mcstats.org/signature/BarAPI.png|}}]] From 11ec6f7b636bdcebbcca6aecb2c737625529eab9 Mon Sep 17 00:00:00 2001 From: woutwoot Date: Thu, 14 Aug 2014 11:53:49 +0200 Subject: [PATCH 04/27] Update README.md --- README.md | 197 ++++++++++++++++++++---------------------------------- 1 file changed, 71 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index 7ca74bf..e4b2807 100644 --- a/README.md +++ b/README.md @@ -1,127 +1,72 @@ -== BarAPI == -{{https://dl.dropboxusercontent.com/s/qg69hkk6dmpq8zd/shot_130901_201310.png?token_hash=AAGC7_1B9PDv79DWxGiM_1tWSabZL6OwhGfp8oUb39ZPVQ|}} -=== Server Owners === -This plugin does nothing on its own. It is simply an API for other plugins to implement with. - - -=== Developers === -Simply add BarAPI.jar to your project build path. - -This plugin makes use of reflection and therefore "shouldn't" break on craftbukkit updates. - -=== Limitations === -The message can not be more than 64 characters. If it is more, BarAPI will automatically cut it to 64 characters to prevent the client from crashing. - -This is a client limitation and cannot be changed. - -=== Examples === -===== BarAPI.setMessage(Player player, String message) ===== - -Set a message for the player. It will remain there until the player logs off or another plugin overrides it. - - - -===== BarAPI.setMessage(Player player, String message, float percent) ===== - -Same as above except you can set the % of the health bar. 100 shows the entire health bar, 50 shows half the health bar and so on. - - - -===== BarAPI.setMessage(final Player player, String message, int seconds) ===== - -Sets a timed message for the player. It will remain until the timer runs out. The health automatically reduces based on how long the timer is. - - - -===== BarAPI.hasBar(Player player) ===== - -Pretty self explanatory, returns a boolean. - - - -===== BarAPI.removeBar(Player player) ===== - -Also pretty self explanatory. - - - -===== BarAPI.setHealth(Player player, float percent) ===== - -Allows you to modify the health of an existing bar. If the player has no bar, this does nothing. - - -=== Tutorials === -[[http://youtu.be/Nb-tLbLrrmM|German]] - [[http://dev.bukkit.org/profiles/DerFeliix/|DerFeliix]] - -=== Source === -[[https://github.com/confuser/BarAPI/|GitHub]] - -=== Maven === -<> - - - confuser-repo - http://ci.frostcast.net/plugin/repository/everything - - - - - - me.confuser - BarAPI - 3.0 - - -<> - -=== Updater === -This plugin contains an auto updater which is enabled by default. If you do not wish to automatically download new updates, edit BarAPI/config.yml and set autoUpdate to false. - -=== To Dos === -* Scroll messages if string is greater than 64 characters. - -=== Plugins Using BarAPI === -[[http://dev.bukkit.org/bukkit-plugins/welcomebar/|WelcomeBar]] - -[[http://dev.bukkit.org/bukkit-plugins/parkour/|Parkour]] - -[[http://dev.bukkit.org/bukkit-plugins/quicksupport/|QuickSupport]] - -[[http://dev.bukkit.org/bukkit-plugins/bossbroadcast/|BossBroadcast]] - -[[http://dev.bukkit.org/bukkit-plugins/bossmessage/|BossMessage]] - -[[http://dev.bukkit.org/bukkit-plugins/pvpgames-automated/|PvPGames Automated]] - -[[http://dev.bukkit.org/bukkit-plugins/bosseventscheduler/|BossEventScheduler]] - -[[http://dev.bukkit.org/bukkit-plugins/infernal-mobs/|Infernal Mobs]] - -[[http://dev.bukkit.org/bukkit-plugins/mythicmobs/|MythicMobs]] - -[[http://dev.bukkit.org/bukkit-plugins/multikill/|MultiKill]] - -[[http://dev.bukkit.org/bukkit-plugins/playerboss/|PlayerBoss]] - -[[http://dev.bukkit.org/bukkit-plugins/bossads/|BossAds]] - -[[http://dev.bukkit.org/bukkit-plugins/item-lore-stats/|Item Lore Stats]] - -[[http://dev.bukkit.org/bukkit-plugins/bossbarpro/|BossBarPro]] - -[[http://dev.bukkit.org/bukkit-plugins/viplobby/|VIPLobby]] - -[[http://dev.bukkit.org/bukkit-plugins/battleofblocks/|Battle Of Blocks]] - -[[http://dev.bukkit.org/bukkit-plugins/bossbroadcaster/|BossBroadcaster]] - -[[http://dev.bukkit.org/bukkit-plugins/silkspawners/|SilkSpawners]] - -[[http://dev.bukkit.org/bukkit-plugins/barjoin/|BarJoin]] - -[[http://dev.bukkit.org/bukkit-plugins/join_messages/|JoinGlobalMessages]] - -=== Metrics === -To determine popularity and usage of BarAPI, plugin installs are automatically tracked by the Metrics plugin tracking system. Your Java version, OS, player count, server country location and plugin & server versions are collected. This is used to determine what environments are using the plugin to ensure full compatibility. This collection is anonymous. If you don't want this tracking, edit plugins/PluginMetrics/config.yml and set opt-out to true. -[[http://mcstats.org/plugin/BarAPI|{{http://api.mcstats.org/signature/BarAPI.png|}}]] +

+

Server Owners

+

This plugin does nothing on its own. It is simply an API for other plugins to implement with.

+

Developers

+

Simply add BarAPI.jar to your project build path.

+

This plugin makes use of reflection and therefore "shouldn't" break on craftbukkit updates.

+

Limitations

+

The message can not be more than 64 characters. If it is more, BarAPI will automatically cut it to 64 characters to prevent the client from crashing.

+

This is a client limitation and cannot be changed.

+

Examples

+
BarAPI.setMessage(Player player, String message)
+

Set a message for the player. It will remain there until the player logs off or another plugin overrides it.

+
BarAPI.setMessage(Player player, String message, float percent)
+

Same as above except you can set the % of the health bar. 100 shows the entire health bar, 50 shows half the health bar and so on.

+
BarAPI.setMessage(final Player player, String message, int seconds)
+

Sets a timed message for the player. It will remain until the timer runs out. The health automatically reduces based on how long the timer is.

+
BarAPI.hasBar(Player player)
+

Pretty self explanatory, returns a boolean.

+
BarAPI.removeBar(Player player)
+

Also pretty self explanatory.

+
BarAPI.setHealth(Player player, float percent)
+

Allows you to modify the health of an existing bar. If the player has no bar, this does nothing.

+

Tutorials

+

German - DerFeliix

+

Source

+

GitHub

+

Maven

+
<repositories>
+	<repository>
+		<id>confuser-repo</id>
+		<url>http://ci.frostcast.net/plugin/repository/everything</url>
+	</repository>
+</repositories>
+
+<dependencies>
+	<dependency>
+		<groupId>me.confuser</groupId>
+		<artifactId>BarAPI</artifactId>
+		<version>3.0</version>
+	</dependency>
+</dependencies>
+
+

Updater

+

This plugin contains an auto updater which is enabled by default. If you do not wish to automatically download new updates, edit BarAPI/config.yml and set autoUpdate to false.

+

To Dos

+
  • Scroll messages if string is greater than 64 characters. +
+

Plugins Using BarAPI

+

WelcomeBar

+

Parkour

+

QuickSupport

+

BossBroadcast

+

BossMessage

+

PvPGames Automated

+

BossEventScheduler

+

Infernal Mobs

+

MythicMobs

+

MultiKill

+

PlayerBoss

+

BossAds

+

Item Lore Stats

+

BossBarPro

+

VIPLobby

+

Battle Of Blocks

+

BossBroadcaster

+

SilkSpawners

+

BarJoin

+

JoinGlobalMessages

+

Metrics

+

To determine popularity and usage of BarAPI, plugin installs are automatically tracked by the Metrics plugin tracking system. Your Java version, OS, player count, server country location and plugin & server versions are collected. This is used to determine what environments are using the plugin to ensure full compatibility. This collection is anonymous. If you don't want this tracking, edit plugins/PluginMetrics/config.yml and set opt-out to true. +

From e077e5c6e6717c33ae8859313ede8dd0413f8db5 Mon Sep 17 00:00:00 2001 From: Wout Date: Thu, 14 Aug 2014 12:33:52 +0200 Subject: [PATCH 05/27] Changed java version back to 1.6 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8c0258f..2236beb 100644 --- a/pom.xml +++ b/pom.xml @@ -24,8 +24,8 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.6 + 1.6
From 5743b1393c7974f24fedf2f407b48611902ca42a Mon Sep 17 00:00:00 2001 From: confuser Date: Tue, 16 Sep 2014 15:16:27 +0100 Subject: [PATCH 06/27] Get ready for next version --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 2236beb..4a9de8a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.1 + 3.2-SNAPSHOT BarAPI @@ -74,13 +74,13 @@ org.bukkit bukkit - LATEST + 1.7.10-R0.1-SNAPSHOT provided org.bukkit craftbukkit - LATEST + 1.7.10-R0.1-SNAPSHOT provided From e46860e6b12f598eb81cc336eaa5a561f89ccf86 Mon Sep 17 00:00:00 2001 From: confuser Date: Tue, 16 Sep 2014 15:17:21 +0100 Subject: [PATCH 07/27] Added spigot 1.8 fake protocol compatibility --- config.yml | 4 +- src/me/confuser/barapi/BarAPI.java | 68 +++++++- src/me/confuser/barapi/Util.java | 25 +-- src/me/confuser/barapi/nms/FakeDragon.java | 12 +- src/me/confuser/barapi/nms/v1_8Fake.java | 188 +++++++++++++++++++++ 5 files changed, 273 insertions(+), 24 deletions(-) create mode 100644 src/me/confuser/barapi/nms/v1_8Fake.java diff --git a/config.yml b/config.yml index 5d89cba..e4e93cd 100644 --- a/config.yml +++ b/config.yml @@ -1,3 +1,5 @@ # Set to false to disable the auto updater autoUpdate: true -testMode: false \ No newline at end of file +testMode: false +# For the latest spigot fake protocol hacks +useSpigotHack: false \ No newline at end of file diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index d12ce03..ab80949 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -32,6 +33,8 @@ public class BarAPI extends JavaPlugin implements Listener { private static HashMap timers = new HashMap(); private static BarAPI plugin; + + private static boolean useSpigotHack = false; public void onEnable() { getConfig().options().copyDefaults(true); @@ -66,6 +69,19 @@ public void run() { }, 30L, 300L); } + + useSpigotHack = getConfig().getBoolean("useSpigotHack", false); + + if (useSpigotHack) { + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { + public void run() { + for (UUID uuid : players.keySet()) { + Player p = Bukkit.getPlayer(uuid); + Util.sendPacket(p, players.get(uuid).getTeleportPacket(getDragonLocation(p.getLocation()))); + } + } + }, 0L, 5L); + } } public void onDisable() { @@ -137,6 +153,10 @@ private void quit(Player player) { removeBar(player); } + public static boolean useSpigotHack() { + return useSpigotHack; + } + /** * Set a message for all players.
* It will remain there until the player logs off or another plugin overrides it.
@@ -170,7 +190,7 @@ public static void setMessage(Player player, String message) { FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); - dragon.health = FakeDragon.MAX_HEALTH; + dragon.health = dragon.getMaxHealth(); cancelTimer(player); @@ -222,7 +242,7 @@ public static void setMessage(Player player, String message, float percent) { FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); - dragon.health = (percent / 100f) * FakeDragon.MAX_HEALTH; + dragon.health = (percent / 100f) * dragon.getMaxHealth(); cancelTimer(player); @@ -278,9 +298,9 @@ public static void setMessage(final Player player, String message, int seconds) FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); - dragon.health = FakeDragon.MAX_HEALTH; + dragon.health = dragon.getMaxHealth(); - final float dragonHealthMinus = FakeDragon.MAX_HEALTH / seconds; + final float dragonHealthMinus = dragon.getMaxHealth() / seconds; cancelTimer(player); @@ -348,7 +368,7 @@ public static void setHealth(Player player, float percent) { return; FakeDragon dragon = getDragon(player, ""); - dragon.health = (percent / 100f) * FakeDragon.MAX_HEALTH; + dragon.health = (percent / 100f) * dragon.getMaxHealth(); cancelTimer(player); @@ -406,7 +426,7 @@ private static void cancelTimer(Player player) { private static void sendDragon(FakeDragon dragon, Player player) { Util.sendPacket(player, dragon.getMetaPacket(dragon.getWatcher())); - Util.sendPacket(player, dragon.getTeleportPacket(player.getLocation().add(0, -300, 0))); + Util.sendPacket(player, dragon.getTeleportPacket(getDragonLocation(player.getLocation()))); } private static FakeDragon getDragon(Player player, String message) { @@ -417,7 +437,7 @@ private static FakeDragon getDragon(Player player, String message) { } private static FakeDragon addDragon(Player player, String message) { - FakeDragon dragon = Util.newDragon(message, player.getLocation().add(0, -300, 0)); + FakeDragon dragon = Util.newDragon(message, getDragonLocation(player.getLocation())); Util.sendPacket(player, dragon.getSpawnPacket()); @@ -427,7 +447,7 @@ private static FakeDragon addDragon(Player player, String message) { } private static FakeDragon addDragon(Player player, Location loc, String message) { - FakeDragon dragon = Util.newDragon(message, loc.add(0, -300, 0)); + FakeDragon dragon = Util.newDragon(message, getDragonLocation(loc)); Util.sendPacket(player, dragon.getSpawnPacket()); @@ -435,4 +455,36 @@ private static FakeDragon addDragon(Player player, Location loc, String message) return dragon; } + + private static Location getDragonLocation(Location loc) { + if (!useSpigotHack()) { + loc.subtract(0, 300, 0); + return loc; + } + + float pitch = loc.getPitch(); + + if (pitch >= 55) { + loc.add(0, -300, 0); + } else if (pitch <= -55) { + loc.add(0, 300, 0); + } else { + loc = loc.getBlock().getRelative(getDirection(loc), plugin.getServer().getViewDistance() * 16).getLocation(); + } + + return loc; + } + + private static BlockFace getDirection(Location loc) { + float dir = Math.round(loc.getYaw() / 90); + if (dir == -4 || dir == 0 || dir == 4) + return BlockFace.SOUTH; + if (dir == -1 || dir == 3) + return BlockFace.EAST; + if (dir == -2 || dir == 2) + return BlockFace.NORTH; + if (dir == -3 || dir == 1) + return BlockFace.WEST; + return null; + } } diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index 2908b4f..9ded2d1 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -4,9 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import me.confuser.barapi.nms.FakeDragon; -import me.confuser.barapi.nms.v1_6; -import me.confuser.barapi.nms.v1_7; +import me.confuser.barapi.nms.*; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -28,16 +26,21 @@ public class Util { public static Class fakeDragonClass = v1_6.class; static { - String name = Bukkit.getServer().getClass().getPackage().getName(); - String mcVersion = name.substring(name.lastIndexOf('.') + 1); - String[] versions = mcVersion.split("_"); + if (BarAPI.useSpigotHack()) { + fakeDragonClass = v1_8Fake.class; + version = "v1_7_R4."; + } else { + String name = Bukkit.getServer().getClass().getPackage().getName(); + String mcVersion = name.substring(name.lastIndexOf('.') + 1); + String[] versions = mcVersion.split("_"); + + if (versions[0].equals("v1") && Integer.parseInt(versions[1]) > 6) { + newProtocol = true; + fakeDragonClass = v1_7.class; + } - if (versions[0].equals("v1") && Integer.parseInt(versions[1]) > 6) { - newProtocol = true; - fakeDragonClass = v1_7.class; + version = mcVersion + "."; } - - version = mcVersion + "."; } public static FakeDragon newDragon(String message, Location loc) { diff --git a/src/me/confuser/barapi/nms/FakeDragon.java b/src/me/confuser/barapi/nms/FakeDragon.java index 566505a..cfee43e 100644 --- a/src/me/confuser/barapi/nms/FakeDragon.java +++ b/src/me/confuser/barapi/nms/FakeDragon.java @@ -5,7 +5,7 @@ import org.bukkit.Location; public abstract class FakeDragon { - public static final float MAX_HEALTH = 200; + private float maxHealth = 200; private int x; private int y; private int z; @@ -25,7 +25,7 @@ public FakeDragon(String name, Location loc, int percent) { this.x = loc.getBlockX(); this.y = loc.getBlockY(); this.z = loc.getBlockZ(); - this.health = percent / 100F * MAX_HEALTH; + this.health = percent / 100F * maxHealth; this.world = Util.getHandle(loc.getWorld()); } @@ -38,11 +38,11 @@ public FakeDragon(String name, Location loc) { } public float getMaxHealth() { - return MAX_HEALTH; + return maxHealth; } public void setHealth(int percent) { - this.health = percent / 100F * MAX_HEALTH; + this.health = percent / 100F * maxHealth; } public void setName(String name) { @@ -128,6 +128,10 @@ public Object getWorld() { public void setWorld(Object world) { this.world = world; } + + public void setMaxHealth(float max) { + maxHealth = max; + } public abstract Object getSpawnPacket(); diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java new file mode 100644 index 0000000..e228f9e --- /dev/null +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -0,0 +1,188 @@ +package me.confuser.barapi.nms; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import me.confuser.barapi.Util; + +import org.bukkit.Location; + +/** +* This is the FakeDragon class for BarAPI. +* It is based on the code by SoThatsIt. +* +* http://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar.158018/page-5#post-2053705 +* +* @author James Mortemore +*/ + +public class v1_8Fake extends FakeDragon { + private Object dragon; + private int id; + + public v1_8Fake(String name, Location loc) { + super(name, loc); + } + + @Override + public Object getSpawnPacket() { + Class Entity = Util.getCraftClass("Entity"); + Class EntityLiving = Util.getCraftClass("EntityLiving"); + Class EntityEnderDragon = Util.getCraftClass("EntityEnderDragon"); + Object packet = null; + try { + dragon = EntityEnderDragon.getConstructor(Util.getCraftClass("World")).newInstance(getWorld()); + + Method setLocation = Util.getMethod(EntityEnderDragon, "setLocation", new Class[] { double.class, double.class, double.class, float.class, float.class }); + setLocation.invoke(dragon, getX(), getY(), getZ(), getPitch(), getYaw()); + + Method setInvisible = Util.getMethod(EntityEnderDragon, "setInvisible", new Class[] { boolean.class }); + setInvisible.invoke(dragon, true); + + Method setCustomName = Util.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); + setCustomName.invoke(dragon, name); + + Method setHealth = Util.getMethod(EntityEnderDragon, "setHealth", new Class[] { float.class }); + setHealth.invoke(dragon, health); + + Field motX = Util.getField(Entity, "motX"); + motX.set(dragon, getXvel()); + + Field motY = Util.getField(Entity, "motY"); + motY.set(dragon, getYvel()); + + Field motZ = Util.getField(Entity, "motZ"); + motZ.set(dragon, getZvel()); + + Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[] {}); + this.id = (Integer) getId.invoke(dragon); + + Class PacketPlayOutSpawnEntityLiving = Util.getCraftClass("PacketPlayOutSpawnEntityLiving"); + + packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }).newInstance(dragon); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getDestroyPacket() { + Class PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy"); + + Object packet = null; + try { + packet = PacketPlayOutEntityDestroy.newInstance(); + Field a = PacketPlayOutEntityDestroy.getDeclaredField("a"); + a.setAccessible(true); + a.set(packet, new int[] { id }); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getMetaPacket(Object watcher) { + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Class PacketPlayOutEntityMetadata = Util.getCraftClass("PacketPlayOutEntityMetadata"); + + Object packet = null; + try { + packet = PacketPlayOutEntityMetadata.getConstructor(new Class[] { int.class, DataWatcher, boolean.class }).newInstance(id, watcher, true); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getTeleportPacket(Location loc) { + Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); + Object packet = null; + + try { + packet = PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getWatcher() { + Class Entity = Util.getCraftClass("Entity"); + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Object watcher = null; + try { + watcher = DataWatcher.getConstructor(new Class[] { Entity }).newInstance(dragon); + Method a = Util.getMethod(DataWatcher, "a", new Class[] { int.class, Object.class }); + + a.invoke(watcher, 5, isVisible() ? (byte) 0 : (byte) 0x20); + a.invoke(watcher, 6, (Float) health); + a.invoke(watcher, 7, (Integer) 0); + a.invoke(watcher, 8, (Byte) (byte) 0); + a.invoke(watcher, 10, name); + a.invoke(watcher, 11, (Byte) (byte) 1); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return watcher; + } +} From 245eefb1f6909117b6caa60a17e170d6d70c602d Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Wed, 24 Sep 2014 14:25:24 +0100 Subject: [PATCH 08/27] Disable auto update --- config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.yml b/config.yml index e4e93cd..f72f4e2 100644 --- a/config.yml +++ b/config.yml @@ -1,5 +1,5 @@ # Set to false to disable the auto updater -autoUpdate: true +autoUpdate: false testMode: false # For the latest spigot fake protocol hacks -useSpigotHack: false \ No newline at end of file +useSpigotHack: false From 41c3f3a248970dfa83b92a67965a5dd320201aa8 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Wed, 24 Sep 2014 15:43:57 +0100 Subject: [PATCH 09/27] Fix for latest spigot patch --- src/me/confuser/barapi/nms/v1_8Fake.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java index e228f9e..334ffca 100644 --- a/src/me/confuser/barapi/nms/v1_8Fake.java +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -135,7 +135,7 @@ public Object getTeleportPacket(Location loc) { Object packet = null; try { - packet = PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false); + packet = PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false, false); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { From 29a0f06675d6414fad4ced035d2d293299912686 Mon Sep 17 00:00:00 2001 From: confuser Date: Mon, 10 Nov 2014 22:01:18 +0000 Subject: [PATCH 10/27] Auto detect Spigot 1.8 --- config.yml | 2 +- src/me/confuser/barapi/BarAPI.java | 46 ++++++++++++++---------- src/me/confuser/barapi/Util.java | 4 +++ src/me/confuser/barapi/nms/v1_8Fake.java | 16 +++++++++ 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/config.yml b/config.yml index f72f4e2..95bfdce 100644 --- a/config.yml +++ b/config.yml @@ -1,5 +1,5 @@ # Set to false to disable the auto updater -autoUpdate: false +autoUpdate: true testMode: false # For the latest spigot fake protocol hacks useSpigotHack: false diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index ab80949..28d8786 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -1,6 +1,7 @@ package me.confuser.barapi; import me.confuser.barapi.nms.FakeDragon; +import me.confuser.barapi.nms.v1_8Fake; import net.gravitydevelopment.updater.Updater; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -40,22 +41,44 @@ public void onEnable() { getConfig().options().copyDefaults(true); saveConfig(); - if (getConfig().getBoolean("autoUpdate")) + if (getConfig().getBoolean("autoUpdate")) { new Updater(this, 64876, getFile(), Updater.UpdateType.DEFAULT, false); - + } + try { MetricsLite metrics = new MetricsLite(this); metrics.start(); } catch (IOException e) { // Failed to submit the stats :-( } + + plugin = this; + + useSpigotHack = getConfig().getBoolean("useSpigotHack", false); + + if (!useSpigotHack) { + if (v1_8Fake.isUsable()) { + useSpigotHack = true; + Util.detectVersion(); + getLogger().info("Detected spigot hack, enabling fake 1.8"); + } + } getServer().getPluginManager().registerEvents(this, this); getLogger().info("Loaded"); - - plugin = this; - + + if (useSpigotHack) { + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { + public void run() { + for (UUID uuid : players.keySet()) { + Player p = Bukkit.getPlayer(uuid); + Util.sendPacket(p, players.get(uuid).getTeleportPacket(getDragonLocation(p.getLocation()))); + } + } + }, 0L, 5L); + } + // TestMode if (getConfig().getBoolean("testMode")) { plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { @@ -69,19 +92,6 @@ public void run() { }, 30L, 300L); } - - useSpigotHack = getConfig().getBoolean("useSpigotHack", false); - - if (useSpigotHack) { - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { - public void run() { - for (UUID uuid : players.keySet()) { - Player p = Bukkit.getPlayer(uuid); - Util.sendPacket(p, players.get(uuid).getTeleportPacket(getDragonLocation(p.getLocation()))); - } - } - }, 0L, 5L); - } } public void onDisable() { diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index 9ded2d1..8ec8f87 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -26,6 +26,10 @@ public class Util { public static Class fakeDragonClass = v1_6.class; static { + detectVersion(); + } + + public static void detectVersion() { if (BarAPI.useSpigotHack()) { fakeDragonClass = v1_8Fake.class; version = "v1_7_R4."; diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java index 334ffca..a5da361 100644 --- a/src/me/confuser/barapi/nms/v1_8Fake.java +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -185,4 +185,20 @@ public Object getWatcher() { return watcher; } + + public static boolean isUsable() { + Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); + + try { + PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }); + } catch (IllegalArgumentException e) { + return false; + } catch (SecurityException e) { + return false; + } catch (NoSuchMethodException e) { + return false; + } + + return true; + } } From 5d6240983ae89371953b91c13b5e1b982a9ce34f Mon Sep 17 00:00:00 2001 From: confuser Date: Mon, 10 Nov 2014 22:01:55 +0000 Subject: [PATCH 11/27] Updated to version 3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4a9de8a..b9bb9bc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.2-SNAPSHOT + 3.2 BarAPI From 4a712effffbb307497580081892295539b0e9309 Mon Sep 17 00:00:00 2001 From: confuser Date: Mon, 10 Nov 2014 22:02:57 +0000 Subject: [PATCH 12/27] Get ready for next version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b9bb9bc..41de64d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.2 + 3.3-SNAPSHOT BarAPI From 965c42ccca71ad0d4b96de430902cd66cb05e77c Mon Sep 17 00:00:00 2001 From: confuser Date: Fri, 19 Dec 2014 12:52:38 +0000 Subject: [PATCH 13/27] Added Spigot 1.8 support Fixes issue #42 and fixes issue #45 --- src/me/confuser/barapi/BarAPI.java | 2 +- src/me/confuser/barapi/Util.java | 15 ++- src/me/confuser/barapi/nms/v1_8.java | 180 +++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 src/me/confuser/barapi/nms/v1_8.java diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index 28d8786..cdea414 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -467,7 +467,7 @@ private static FakeDragon addDragon(Player player, Location loc, String message) } private static Location getDragonLocation(Location loc) { - if (!useSpigotHack()) { + if (Util.isBelowGround) { loc.subtract(0, 300, 0); return loc; } diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index 8ec8f87..71ee7fa 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -24,6 +24,7 @@ public class Util { public static boolean newProtocol = false; public static String version; public static Class fakeDragonClass = v1_6.class; + public static boolean isBelowGround = true; static { detectVersion(); @@ -33,14 +34,22 @@ public static void detectVersion() { if (BarAPI.useSpigotHack()) { fakeDragonClass = v1_8Fake.class; version = "v1_7_R4."; + isBelowGround = false; } else { String name = Bukkit.getServer().getClass().getPackage().getName(); String mcVersion = name.substring(name.lastIndexOf('.') + 1); String[] versions = mcVersion.split("_"); - if (versions[0].equals("v1") && Integer.parseInt(versions[1]) > 6) { - newProtocol = true; - fakeDragonClass = v1_7.class; + if (versions[0].equals("v1")) { + int minor = Integer.parseInt(versions[1]); + + if (minor == 7) { + newProtocol = true; + fakeDragonClass = v1_7.class; + } else if (minor == 8) { + fakeDragonClass = v1_8.class; + isBelowGround = false; + } } version = mcVersion + "."; diff --git a/src/me/confuser/barapi/nms/v1_8.java b/src/me/confuser/barapi/nms/v1_8.java new file mode 100644 index 0000000..ff1e3dc --- /dev/null +++ b/src/me/confuser/barapi/nms/v1_8.java @@ -0,0 +1,180 @@ +package me.confuser.barapi.nms; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import me.confuser.barapi.Util; + +import org.bukkit.Location; + +public class v1_8 extends FakeDragon { + private Object dragon; + private int id; + + public v1_8(String name, Location loc) { + super(name, loc); + } + + @Override + public Object getSpawnPacket() { + Class Entity = Util.getCraftClass("Entity"); + Class EntityLiving = Util.getCraftClass("EntityLiving"); + Class EntityEnderDragon = Util.getCraftClass("EntityEnderDragon"); + Object packet = null; + + try { + dragon = EntityEnderDragon.getConstructor(Util.getCraftClass("World")).newInstance(getWorld()); + + Method setLocation = Util.getMethod(EntityEnderDragon, "setLocation", new Class[] { double.class, double.class, double.class, float.class, float.class }); + setLocation.invoke(dragon, getX(), getY(), getZ(), getPitch(), getYaw()); + + Method setInvisible = Util.getMethod(EntityEnderDragon, "setInvisible", new Class[] { boolean.class }); + setInvisible.invoke(dragon, true); + + Method setCustomName = Util.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); + setCustomName.invoke(dragon, name); + + Method setHealth = Util.getMethod(EntityEnderDragon, "setHealth", new Class[] { float.class }); + setHealth.invoke(dragon, health); + + Field motX = Util.getField(Entity, "motX"); + motX.set(dragon, getXvel()); + + Field motY = Util.getField(Entity, "motY"); + motY.set(dragon, getYvel()); + + Field motZ = Util.getField(Entity, "motZ"); + motZ.set(dragon, getZvel()); + + Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[] {}); + this.id = (Integer) getId.invoke(dragon); + + Class PacketPlayOutSpawnEntityLiving = Util.getCraftClass("PacketPlayOutSpawnEntityLiving"); + + packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }).newInstance(dragon); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getDestroyPacket() { + Class PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy"); + + Object packet = null; + try { + packet = PacketPlayOutEntityDestroy.newInstance(); + Field a = PacketPlayOutEntityDestroy.getDeclaredField("a"); + a.setAccessible(true); + a.set(packet, new int[] { id }); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getMetaPacket(Object watcher) { + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Class PacketPlayOutEntityMetadata = Util.getCraftClass("PacketPlayOutEntityMetadata"); + + Object packet = null; + try { + packet = PacketPlayOutEntityMetadata.getConstructor(new Class[] { int.class, DataWatcher, boolean.class }).newInstance(id, watcher, true); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getTeleportPacket(Location loc) { + Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); + Object packet = null; + + try { + packet = PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getWatcher() { + Class Entity = Util.getCraftClass("Entity"); + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Object watcher = null; + try { + watcher = DataWatcher.getConstructor(new Class[] { Entity }).newInstance(dragon); + Method a = Util.getMethod(DataWatcher, "a", new Class[] { int.class, Object.class }); + + a.invoke(watcher, 5, isVisible() ? (byte) 0 : (byte) 0x20); + a.invoke(watcher, 6, (Float) health); + a.invoke(watcher, 7, (Integer) 0); + a.invoke(watcher, 8, (Byte) (byte) 0); + a.invoke(watcher, 10, name); + a.invoke(watcher, 11, (Byte) (byte) 1); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return watcher; + } +} From 2cc78bf8f6d26bf8aea9310d5230b6218c978ca1 Mon Sep 17 00:00:00 2001 From: confuser Date: Fri, 19 Dec 2014 12:56:58 +0000 Subject: [PATCH 14/27] Updated to version 3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41de64d..9e2af70 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.3-SNAPSHOT + 3.3 BarAPI From b71451c75b39f1cf68ae44e16652665825347c3d Mon Sep 17 00:00:00 2001 From: confuser Date: Fri, 19 Dec 2014 12:57:28 +0000 Subject: [PATCH 15/27] Get ready for next version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9e2af70..83bd0bf 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.3 + 3.4-SNAPSHOT BarAPI From b49590a8356dde1cdb7c32e55a5b33ad8661f270 Mon Sep 17 00:00:00 2001 From: confuser Date: Fri, 19 Dec 2014 13:01:40 +0000 Subject: [PATCH 16/27] Removed project file, shouldn't be here --- .project | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index 52727aa..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - BarAPI - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - From 8d07e1d9f0855ec4b72b3474bd78f7ac7dd7f36e Mon Sep 17 00:00:00 2001 From: stefvanschie Date: Wed, 16 Dec 2015 17:24:58 +0100 Subject: [PATCH 17/27] BarAPI.java Automatically remove old bars when new ones are created --- src/me/confuser/barapi/BarAPI.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index cdea414..e825daf 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -197,6 +197,8 @@ public static void setMessage(String message) { * It will be cut to that size automatically. */ public static void setMessage(Player player, String message) { + if (hasBar(player)) + removeBar(player); FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); @@ -249,6 +251,9 @@ public static void setMessage(String message, float percent) { public static void setMessage(Player player, String message, float percent) { Validate.isTrue(0F <= percent && percent <= 100F, "Percent must be between 0F and 100F, but was: ", percent); + if (hasBar(player)) + removeBar(player); + FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); @@ -305,6 +310,9 @@ public static void setMessage(String message, int seconds) { public static void setMessage(final Player player, String message, int seconds) { Validate.isTrue(seconds > 0, "Seconds must be above 1 but was: ", seconds); + if (hasBar(player)) + removeBar(player); + FakeDragon dragon = getDragon(player, message); dragon.name = cleanMessage(message); From 36056ccc0a110f193544934181166ea74fb3a344 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sun, 31 Jan 2016 16:41:31 +0000 Subject: [PATCH 18/27] Bumped updater --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 83bd0bf..ec2d680 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ net.gravitydevelopment.updater updater - 2.1 + 2.3 org.mcstats.bukkit From ebceefc43d327d1993852606eab476dc5ec74a2d Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 13:08:48 +0000 Subject: [PATCH 19/27] Formatting --- .gitattributes | 1 + src/me/confuser/barapi/BarAPI.java | 939 ++++++++++++++--------------- 2 files changed, 464 insertions(+), 476 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index e825daf..3396421 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -25,484 +25,471 @@ /** * Allows plugins to safely set a health bar message. - * + * * @author James Mortemore */ public class BarAPI extends JavaPlugin implements Listener { - private static HashMap players = new HashMap(); - private static HashMap timers = new HashMap(); - - private static BarAPI plugin; - - private static boolean useSpigotHack = false; - - public void onEnable() { - getConfig().options().copyDefaults(true); - saveConfig(); - - if (getConfig().getBoolean("autoUpdate")) { - new Updater(this, 64876, getFile(), Updater.UpdateType.DEFAULT, false); - } - - try { - MetricsLite metrics = new MetricsLite(this); - metrics.start(); - } catch (IOException e) { - // Failed to submit the stats :-( - } - - plugin = this; - - useSpigotHack = getConfig().getBoolean("useSpigotHack", false); - - if (!useSpigotHack) { - if (v1_8Fake.isUsable()) { - useSpigotHack = true; - Util.detectVersion(); - getLogger().info("Detected spigot hack, enabling fake 1.8"); - } - } - - getServer().getPluginManager().registerEvents(this, this); - - getLogger().info("Loaded"); - - if (useSpigotHack) { - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { - public void run() { - for (UUID uuid : players.keySet()) { - Player p = Bukkit.getPlayer(uuid); - Util.sendPacket(p, players.get(uuid).getTeleportPacket(getDragonLocation(p.getLocation()))); - } - } - }, 0L, 5L); - } - - // TestMode - if (getConfig().getBoolean("testMode")) { - plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { - - @Override - public void run() { - for (Player player : plugin.getServer().getOnlinePlayers()) { - BarAPI.setMessage(player, ChatColor.AQUA + "Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI", 10); - } - } - - }, 30L, 300L); - } - } - - public void onDisable() { - for (Player player : plugin.getServer().getOnlinePlayers()) { - quit(player); - } - - players.clear(); - - for (int timerID : timers.values()) { - Bukkit.getScheduler().cancelTask(timerID); - } - - timers.clear(); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void PlayerLoggout(PlayerQuitEvent event) { - quit(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerKick(PlayerKickEvent event) { - quit(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerTeleport(final PlayerTeleportEvent event) { - handleTeleport(event.getPlayer(), event.getTo().clone()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerTeleport(final PlayerRespawnEvent event) { - handleTeleport(event.getPlayer(), event.getRespawnLocation().clone()); - } - - private void handleTeleport(final Player player, final Location loc) { - - if (!hasBar(player)) - return; - - Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { - - @Override - public void run() { - // Check if the player still has a dragon after the two ticks! ;) - if (!hasBar(player)) - return; - - FakeDragon oldDragon = getDragon(player, ""); - - float health = oldDragon.health; - String message = oldDragon.name; - - Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); - - players.remove(player.getUniqueId()); - - FakeDragon dragon = addDragon(player, loc, message); - dragon.health = health; - - sendDragon(dragon, player); - } - - }, 2L); - } - - private void quit(Player player) { - removeBar(player); - } - - public static boolean useSpigotHack() { - return useSpigotHack; - } - - /** - * Set a message for all players.
- * It will remain there until the player logs off or another plugin overrides it.
- * This method will show a full health bar and will cancel any running timers. - * - * @param message - * The message shown.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - * @see BarAPI#setMessage(player, message) - */ - public static void setMessage(String message) { - for (Player player : Bukkit.getOnlinePlayers()) { - setMessage(player, message); - } - } - - /** - * Set a message for the given player.
- * It will remain there until the player logs off or another plugin overrides it.
- * This method will show a full health bar and will cancel any running timers. - * - * @param player - * The player who should see the given message. - * @param message - * The message shown to the player.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - */ - public static void setMessage(Player player, String message) { - if (hasBar(player)) - removeBar(player); - FakeDragon dragon = getDragon(player, message); - - dragon.name = cleanMessage(message); - dragon.health = dragon.getMaxHealth(); - - cancelTimer(player); - - sendDragon(dragon, player); - } - - /** - * Set a message for all players.
- * It will remain there for each player until the player logs off or another plugin overrides it.
- * This method will show a health bar using the given percentage value and will cancel any running timers. - * - * @param message - * The message shown to the player.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - * @param percent - * The percentage of the health bar filled.
- * This value must be between 0F (inclusive) and 100F (inclusive). - * @throws IllegalArgumentException - * If the percentage is not within valid bounds. - * @see BarAPI#setMessage(player, message, percent) - */ - public static void setMessage(String message, float percent) { - for (Player player : Bukkit.getOnlinePlayers()) { - setMessage(player, message, percent); - } - } - - /** - * Set a message for the given player.
- * It will remain there until the player logs off or another plugin overrides it.
- * This method will show a health bar using the given percentage value and will cancel any running timers. - * - * @param player - * The player who should see the given message. - * @param message - * The message shown to the player.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - * @param percent - * The percentage of the health bar filled.
- * This value must be between 0F (inclusive) and 100F (inclusive). - * @throws IllegalArgumentException - * If the percentage is not within valid bounds. - */ - public static void setMessage(Player player, String message, float percent) { - Validate.isTrue(0F <= percent && percent <= 100F, "Percent must be between 0F and 100F, but was: ", percent); - - if (hasBar(player)) - removeBar(player); - - FakeDragon dragon = getDragon(player, message); - - dragon.name = cleanMessage(message); - dragon.health = (percent / 100f) * dragon.getMaxHealth(); - - cancelTimer(player); - - sendDragon(dragon, player); - } - - /** - * Set a message for all players.
- * It will remain there for each player until the player logs off or another plugin overrides it.
- * This method will use the health bar as a decreasing timer, all previously started timers will be cancelled.
- * The timer starts with a full bar.
- * The health bar will be removed automatically if it hits zero. - * - * @param message - * The message shown.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - * @param seconds - * The amount of seconds displayed by the timer.
- * Supports values above 1 (inclusive). - * @throws IllegalArgumentException - * If seconds is zero or below. - * @see BarAPI#setMessage(player, message, seconds) - */ - public static void setMessage(String message, int seconds) { - for (Player player : Bukkit.getOnlinePlayers()) { - setMessage(player, message, seconds); - } - } - - /** - * Set a message for the given player.
- * It will remain there until the player logs off or another plugin overrides it.
- * This method will use the health bar as a decreasing timer, all previously started timers will be cancelled.
- * The timer starts with a full bar.
- * The health bar will be removed automatically if it hits zero. - * - * @param player - * The player who should see the given timer/message. - * @param message - * The message shown to the player.
- * Due to limitations in Minecraft this message cannot be longer than 64 characters.
- * It will be cut to that size automatically. - * @param seconds - * The amount of seconds displayed by the timer.
- * Supports values above 1 (inclusive). - * @throws IllegalArgumentException - * If seconds is zero or below. - */ - public static void setMessage(final Player player, String message, int seconds) { - Validate.isTrue(seconds > 0, "Seconds must be above 1 but was: ", seconds); - - if (hasBar(player)) - removeBar(player); - - FakeDragon dragon = getDragon(player, message); - - dragon.name = cleanMessage(message); - dragon.health = dragon.getMaxHealth(); - - final float dragonHealthMinus = dragon.getMaxHealth() / seconds; - - cancelTimer(player); - - timers.put(player.getUniqueId(), Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() { - - @Override - public void run() { - FakeDragon drag = getDragon(player, ""); - drag.health -= dragonHealthMinus; - - if (drag.health <= 1) { - removeBar(player); - cancelTimer(player); - } else { - sendDragon(drag, player); - } - } - - }, 20L, 20L).getTaskId()); - - sendDragon(dragon, player); - } - - /** - * Checks whether the given player has a bar. - * - * @param player - * The player who should be checked. - * @return True, if the player has a bar, False otherwise. - */ - public static boolean hasBar(Player player) { - return players.get(player.getUniqueId()) != null; - } - - /** - * Removes the bar from the given player.
- * If the player has no bar, this method does nothing. - * - * @param player - * The player whose bar should be removed. - */ - public static void removeBar(Player player) { - if (!hasBar(player)) - return; - - Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); - - players.remove(player.getUniqueId()); - - cancelTimer(player); - } - - /** - * Modifies the health of an existing bar.
- * If the player has no bar, this method does nothing. - * - * @param player - * The player whose bar should be modified. - * @param percent - * The percentage of the health bar filled.
- * This value must be between 0F and 100F (inclusive). - */ - public static void setHealth(Player player, float percent) { - if (!hasBar(player)) - return; - - FakeDragon dragon = getDragon(player, ""); - dragon.health = (percent / 100f) * dragon.getMaxHealth(); - - cancelTimer(player); - - if (percent == 0) { - removeBar(player); - } else { - sendDragon(dragon, player); - } - } - - /** - * Get the health of an existing bar. - * - * @param player - * The player whose bar's health should be returned. - * @return The current absolute health of the bar.
- * If the player has no bar, this method returns -1. - */ - public static float getHealth(Player player) { - if (!hasBar(player)) - return -1; - - return getDragon(player, "").health; - } - - /** - * Get the message of an existing bar. - * - * @param player - * The player whose bar's message should be returned. - * @return The current message displayed to the player.
- * If the player has no bar, this method returns an empty string. - */ - public static String getMessage(Player player) { - if (!hasBar(player)) - return ""; - - return getDragon(player, "").name; - } - - private static String cleanMessage(String message) { - if (message.length() > 64) - message = message.substring(0, 63); - - return message; - } - - private static void cancelTimer(Player player) { - Integer timerID = timers.remove(player.getUniqueId()); - - if (timerID != null) { - Bukkit.getScheduler().cancelTask(timerID); - } - } - - private static void sendDragon(FakeDragon dragon, Player player) { - Util.sendPacket(player, dragon.getMetaPacket(dragon.getWatcher())); - Util.sendPacket(player, dragon.getTeleportPacket(getDragonLocation(player.getLocation()))); - } - - private static FakeDragon getDragon(Player player, String message) { - if (hasBar(player)) { - return players.get(player.getUniqueId()); - } else - return addDragon(player, cleanMessage(message)); - } - - private static FakeDragon addDragon(Player player, String message) { - FakeDragon dragon = Util.newDragon(message, getDragonLocation(player.getLocation())); - - Util.sendPacket(player, dragon.getSpawnPacket()); - - players.put(player.getUniqueId(), dragon); - - return dragon; - } - - private static FakeDragon addDragon(Player player, Location loc, String message) { - FakeDragon dragon = Util.newDragon(message, getDragonLocation(loc)); - - Util.sendPacket(player, dragon.getSpawnPacket()); - - players.put(player.getUniqueId(), dragon); - - return dragon; - } - - private static Location getDragonLocation(Location loc) { - if (Util.isBelowGround) { - loc.subtract(0, 300, 0); - return loc; - } - - float pitch = loc.getPitch(); - - if (pitch >= 55) { - loc.add(0, -300, 0); - } else if (pitch <= -55) { - loc.add(0, 300, 0); - } else { - loc = loc.getBlock().getRelative(getDirection(loc), plugin.getServer().getViewDistance() * 16).getLocation(); - } - - return loc; - } - - private static BlockFace getDirection(Location loc) { - float dir = Math.round(loc.getYaw() / 90); - if (dir == -4 || dir == 0 || dir == 4) - return BlockFace.SOUTH; - if (dir == -1 || dir == 3) - return BlockFace.EAST; - if (dir == -2 || dir == 2) - return BlockFace.NORTH; - if (dir == -3 || dir == 1) - return BlockFace.WEST; - return null; - } + + private static HashMap players = new HashMap(); + private static HashMap timers = new HashMap(); + + private static BarAPI plugin; + + private static boolean useSpigotHack = false; + + public static boolean useSpigotHack() { + return useSpigotHack; + } + + /** + * Set a message for all players.
+ * It will remain there until the player logs off or another plugin overrides it.
+ * This method will show a full health bar and will cancel any running timers. + * + * @param message The message shown.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + * + * @see BarAPI#setMessage(player, message) + */ + public static void setMessage(String message) { + for (Player player : Bukkit.getOnlinePlayers()) { + setMessage(player, message); + } + } + + /** + * Set a message for the given player.
+ * It will remain there until the player logs off or another plugin overrides it.
+ * This method will show a full health bar and will cancel any running timers. + * + * @param player The player who should see the given message. + * @param message The message shown to the player.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + */ + public static void setMessage(Player player, String message) { + if (hasBar(player)) + removeBar(player); + FakeDragon dragon = getDragon(player, message); + + dragon.name = cleanMessage(message); + dragon.health = dragon.getMaxHealth(); + + cancelTimer(player); + + sendDragon(dragon, player); + } + + /** + * Set a message for all players.
+ * It will remain there for each player until the player logs off or another plugin overrides it.
+ * This method will show a health bar using the given percentage value and will cancel any running timers. + * + * @param message The message shown to the player.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + * @param percent The percentage of the health bar filled.
+ * This value must be between 0F (inclusive) and 100F (inclusive). + * + * @throws IllegalArgumentException If the percentage is not within valid bounds. + * @see BarAPI#setMessage(player, message, percent) + */ + public static void setMessage(String message, float percent) { + for (Player player : Bukkit.getOnlinePlayers()) { + setMessage(player, message, percent); + } + } + + /** + * Set a message for the given player.
+ * It will remain there until the player logs off or another plugin overrides it.
+ * This method will show a health bar using the given percentage value and will cancel any running timers. + * + * @param player The player who should see the given message. + * @param message The message shown to the player.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + * @param percent The percentage of the health bar filled.
+ * This value must be between 0F (inclusive) and 100F (inclusive). + * + * @throws IllegalArgumentException If the percentage is not within valid bounds. + */ + public static void setMessage(Player player, String message, float percent) { + Validate.isTrue(0F <= percent && percent <= 100F, "Percent must be between 0F and 100F, but was: ", percent); + + if (hasBar(player)) + removeBar(player); + + FakeDragon dragon = getDragon(player, message); + + dragon.name = cleanMessage(message); + dragon.health = (percent / 100f) * dragon.getMaxHealth(); + + cancelTimer(player); + + sendDragon(dragon, player); + } + + /** + * Set a message for all players.
+ * It will remain there for each player until the player logs off or another plugin overrides it.
+ * This method will use the health bar as a decreasing timer, all previously started timers will be cancelled.
+ * The timer starts with a full bar.
+ * The health bar will be removed automatically if it hits zero. + * + * @param message The message shown.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + * @param seconds The amount of seconds displayed by the timer.
+ * Supports values above 1 (inclusive). + * + * @throws IllegalArgumentException If seconds is zero or below. + * @see BarAPI#setMessage(player, message, seconds) + */ + public static void setMessage(String message, int seconds) { + for (Player player : Bukkit.getOnlinePlayers()) { + setMessage(player, message, seconds); + } + } + + /** + * Set a message for the given player.
+ * It will remain there until the player logs off or another plugin overrides it.
+ * This method will use the health bar as a decreasing timer, all previously started timers will be cancelled.
+ * The timer starts with a full bar.
+ * The health bar will be removed automatically if it hits zero. + * + * @param player The player who should see the given timer/message. + * @param message The message shown to the player.
+ * Due to limitations in Minecraft this message cannot be longer than 64 characters.
+ * It will be cut to that size automatically. + * @param seconds The amount of seconds displayed by the timer.
+ * Supports values above 1 (inclusive). + * + * @throws IllegalArgumentException If seconds is zero or below. + */ + public static void setMessage(final Player player, String message, int seconds) { + Validate.isTrue(seconds > 0, "Seconds must be above 1 but was: ", seconds); + + if (hasBar(player)) + removeBar(player); + + FakeDragon dragon = getDragon(player, message); + + dragon.name = cleanMessage(message); + dragon.health = dragon.getMaxHealth(); + + final float dragonHealthMinus = dragon.getMaxHealth() / seconds; + + cancelTimer(player); + + timers.put(player.getUniqueId(), Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() { + + @Override + public void run() { + FakeDragon drag = getDragon(player, ""); + drag.health -= dragonHealthMinus; + + if (drag.health <= 1) { + removeBar(player); + cancelTimer(player); + } else { + sendDragon(drag, player); + } + } + + }, 20L, 20L).getTaskId()); + + sendDragon(dragon, player); + } + + /** + * Checks whether the given player has a bar. + * + * @param player The player who should be checked. + * + * @return True, if the player has a bar, False otherwise. + */ + public static boolean hasBar(Player player) { + return players.get(player.getUniqueId()) != null; + } + + /** + * Removes the bar from the given player.
+ * If the player has no bar, this method does nothing. + * + * @param player The player whose bar should be removed. + */ + public static void removeBar(Player player) { + if (!hasBar(player)) + return; + + Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); + + players.remove(player.getUniqueId()); + + cancelTimer(player); + } + + /** + * Modifies the health of an existing bar.
+ * If the player has no bar, this method does nothing. + * + * @param player The player whose bar should be modified. + * @param percent The percentage of the health bar filled.
+ * This value must be between 0F and 100F (inclusive). + */ + public static void setHealth(Player player, float percent) { + if (!hasBar(player)) + return; + + FakeDragon dragon = getDragon(player, ""); + dragon.health = (percent / 100f) * dragon.getMaxHealth(); + + cancelTimer(player); + + if (percent == 0) { + removeBar(player); + } else { + sendDragon(dragon, player); + } + } + + /** + * Get the health of an existing bar. + * + * @param player The player whose bar's health should be returned. + * + * @return The current absolute health of the bar.
+ * If the player has no bar, this method returns -1. + */ + public static float getHealth(Player player) { + if (!hasBar(player)) + return -1; + + return getDragon(player, "").health; + } + + /** + * Get the message of an existing bar. + * + * @param player The player whose bar's message should be returned. + * + * @return The current message displayed to the player.
+ * If the player has no bar, this method returns an empty string. + */ + public static String getMessage(Player player) { + if (!hasBar(player)) + return ""; + + return getDragon(player, "").name; + } + + private static String cleanMessage(String message) { + if (message.length() > 64) + message = message.substring(0, 63); + + return message; + } + + private static void cancelTimer(Player player) { + Integer timerID = timers.remove(player.getUniqueId()); + + if (timerID != null) { + Bukkit.getScheduler().cancelTask(timerID); + } + } + + private static void sendDragon(FakeDragon dragon, Player player) { + Util.sendPacket(player, dragon.getMetaPacket(dragon.getWatcher())); + Util.sendPacket(player, dragon.getTeleportPacket(getDragonLocation(player.getLocation()))); + } + + private static FakeDragon getDragon(Player player, String message) { + if (hasBar(player)) { + return players.get(player.getUniqueId()); + } else + return addDragon(player, cleanMessage(message)); + } + + private static FakeDragon addDragon(Player player, String message) { + FakeDragon dragon = Util.newDragon(message, getDragonLocation(player.getLocation())); + + Util.sendPacket(player, dragon.getSpawnPacket()); + + players.put(player.getUniqueId(), dragon); + + return dragon; + } + + private static FakeDragon addDragon(Player player, Location loc, String message) { + FakeDragon dragon = Util.newDragon(message, getDragonLocation(loc)); + + Util.sendPacket(player, dragon.getSpawnPacket()); + + players.put(player.getUniqueId(), dragon); + + return dragon; + } + + private static Location getDragonLocation(Location loc) { + if (Util.isBelowGround) { + loc.subtract(0, 300, 0); + return loc; + } + + float pitch = loc.getPitch(); + + if (pitch >= 55) { + loc.add(0, -300, 0); + } else if (pitch <= -55) { + loc.add(0, 300, 0); + } else { + loc = loc.getBlock().getRelative(getDirection(loc), plugin.getServer().getViewDistance() * 16).getLocation(); + } + + return loc; + } + + private static BlockFace getDirection(Location loc) { + float dir = Math.round(loc.getYaw() / 90); + if (dir == -4 || dir == 0 || dir == 4) + return BlockFace.SOUTH; + if (dir == -1 || dir == 3) + return BlockFace.EAST; + if (dir == -2 || dir == 2) + return BlockFace.NORTH; + if (dir == -3 || dir == 1) + return BlockFace.WEST; + return null; + } + + public void onEnable() { + getConfig().options().copyDefaults(true); + saveConfig(); + + if (getConfig().getBoolean("autoUpdate")) { + new Updater(this, 64876, getFile(), Updater.UpdateType.DEFAULT, false); + } + + try { + MetricsLite metrics = new MetricsLite(this); + metrics.start(); + } catch (IOException e) { + // Failed to submit the stats :-( + } + + plugin = this; + + useSpigotHack = getConfig().getBoolean("useSpigotHack", false); + + if (!useSpigotHack) { + if (v1_8Fake.isUsable()) { + useSpigotHack = true; + Util.detectVersion(); + getLogger().info("Detected spigot hack, enabling fake 1.8"); + } + } + + getServer().getPluginManager().registerEvents(this, this); + + getLogger().info("Loaded"); + + if (useSpigotHack) { + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { + + public void run() { + for (UUID uuid : players.keySet()) { + Player p = Bukkit.getPlayer(uuid); + Util.sendPacket(p, players.get(uuid).getTeleportPacket(getDragonLocation(p.getLocation()))); + } + } + }, 0L, 5L); + } + + // TestMode + if (getConfig().getBoolean("testMode")) { + plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() { + + @Override + public void run() { + for (Player player : plugin.getServer().getOnlinePlayers()) { + BarAPI.setMessage(player, ChatColor.AQUA + "Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI Testing BarAPI", 10); + } + } + + }, 30L, 300L); + } + } + + public void onDisable() { + for (Player player : plugin.getServer().getOnlinePlayers()) { + quit(player); + } + + players.clear(); + + for (int timerID : timers.values()) { + Bukkit.getScheduler().cancelTask(timerID); + } + + timers.clear(); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void PlayerLoggout(PlayerQuitEvent event) { + quit(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerKick(PlayerKickEvent event) { + quit(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerTeleport(final PlayerTeleportEvent event) { + handleTeleport(event.getPlayer(), event.getTo().clone()); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerTeleport(final PlayerRespawnEvent event) { + handleTeleport(event.getPlayer(), event.getRespawnLocation().clone()); + } + + private void handleTeleport(final Player player, final Location loc) { + + if (!hasBar(player)) + return; + + Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { + + @Override + public void run() { + // Check if the player still has a dragon after the two ticks! ;) + if (!hasBar(player)) + return; + + FakeDragon oldDragon = getDragon(player, ""); + + float health = oldDragon.health; + String message = oldDragon.name; + + Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); + + players.remove(player.getUniqueId()); + + FakeDragon dragon = addDragon(player, loc, message); + dragon.health = health; + + sendDragon(dragon, player); + } + + }, 2L); + } + + private void quit(Player player) { + removeBar(player); + } } From 717c34f473846330d662395b5680beca5ff26787 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 15:07:35 +0000 Subject: [PATCH 20/27] Added 1.9 support Fixed #62 --- pom.xml | 192 +++++++++++------------ src/me/confuser/barapi/BarAPI.java | 47 ++++-- src/me/confuser/barapi/Util.java | 6 +- src/me/confuser/barapi/nms/v1_8Fake.java | 4 +- src/me/confuser/barapi/nms/v1_9.java | 58 +++++++ 5 files changed, 198 insertions(+), 109 deletions(-) create mode 100644 src/me/confuser/barapi/nms/v1_9.java diff --git a/pom.xml b/pom.xml index ec2d680..4c0c1be 100644 --- a/pom.xml +++ b/pom.xml @@ -1,98 +1,98 @@ - 4.0.0 - BarAPI - Allows plugins to control the boss health bar message - me.confuser - BarAPI - 3.4-SNAPSHOT - - BarAPI - - - . - true - ${basedir} - - *.yml - - - - src - - - maven-compiler-plugin - 3.1 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-shade-plugin - 1.5 - - - package - - shade - - - true - - - net.gravitydevelopment.updater - me.confuser.barapi.updater - - - org.mcstats - me.confuser.barapi.mcstats - - - - - - - - - - - bukkit-repo - http://repo.bukkit.org/content/groups/public - - - gravity-repo - http://repo.gravitydevelopment.net - - - Plugin Metrics - http://repo.mcstats.org/content/repositories/public - - - - - org.bukkit - bukkit - 1.7.10-R0.1-SNAPSHOT - provided - - - org.bukkit - craftbukkit - 1.7.10-R0.1-SNAPSHOT - provided - - - net.gravitydevelopment.updater - updater - 2.3 - - - org.mcstats.bukkit - metrics-lite - R6 - compile - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + BarAPI + Allows plugins to control the boss health bar message + me.confuser + BarAPI + 3.4-SNAPSHOT + + BarAPI + + + . + true + ${basedir} + + *.yml + + + + src + + + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-shade-plugin + 1.5 + + + package + + shade + + + true + + + net.gravitydevelopment.updater + me.confuser.barapi.updater + + + org.mcstats + me.confuser.barapi.mcstats + + + + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + gravity-repo + http://repo.gravitydevelopment.net + + + Plugin Metrics + http://repo.mcstats.org/content/repositories/snapshots + + + + + org.spigotmc + spigot-api + 1.9-R0.1-SNAPSHOT + provided + + + org.bukkit + bukkit + 1.9-R0.1-SNAPSHOT + provided + + + net.gravitydevelopment.updater + updater + 2.3 + + + org.mcstats.bukkit + metrics-lite + R8-SNAPSHOT + compile + + diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index 3396421..78bbd5c 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -1,13 +1,15 @@ package me.confuser.barapi; import me.confuser.barapi.nms.FakeDragon; -import me.confuser.barapi.nms.v1_8Fake; +import me.confuser.barapi.nms.v1_8fake; +import me.confuser.barapi.nms.v1_9; import net.gravitydevelopment.updater.Updater; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.block.BlockFace; +import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -226,7 +228,13 @@ public static void removeBar(Player player) { if (!hasBar(player)) return; - Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); + FakeDragon dragon = getDragon(player, ""); + + if (dragon instanceof v1_9) { + ((v1_9) dragon).getBar().removePlayer(player); + } else { + Util.sendPacket(player, getDragon(player, "").getDestroyPacket()); + } players.remove(player.getUniqueId()); @@ -303,8 +311,15 @@ private static void cancelTimer(Player player) { } private static void sendDragon(FakeDragon dragon, Player player) { - Util.sendPacket(player, dragon.getMetaPacket(dragon.getWatcher())); - Util.sendPacket(player, dragon.getTeleportPacket(getDragonLocation(player.getLocation()))); + if (dragon instanceof v1_9) { + BossBar bar = ((v1_9) dragon).getBar(); + + bar.addPlayer(player); + bar.setProgress(dragon.health / dragon.getMaxHealth()); + } else { + Util.sendPacket(player, dragon.getMetaPacket(dragon.getWatcher())); + Util.sendPacket(player, dragon.getTeleportPacket(getDragonLocation(player.getLocation()))); + } } private static FakeDragon getDragon(Player player, String message) { @@ -317,7 +332,13 @@ private static FakeDragon getDragon(Player player, String message) { private static FakeDragon addDragon(Player player, String message) { FakeDragon dragon = Util.newDragon(message, getDragonLocation(player.getLocation())); - Util.sendPacket(player, dragon.getSpawnPacket()); + if (dragon instanceof v1_9) { + BossBar bar = ((v1_9) dragon).getBar(); + + bar.addPlayer(player); + } else { + Util.sendPacket(player, dragon.getSpawnPacket()); + } players.put(player.getUniqueId(), dragon); @@ -327,7 +348,13 @@ private static FakeDragon addDragon(Player player, String message) { private static FakeDragon addDragon(Player player, Location loc, String message) { FakeDragon dragon = Util.newDragon(message, getDragonLocation(loc)); - Util.sendPacket(player, dragon.getSpawnPacket()); + if (dragon instanceof v1_9) { + BossBar bar = ((v1_9) dragon).getBar(); + + bar.addPlayer(player); + } else { + Util.sendPacket(player, dragon.getSpawnPacket()); + } players.put(player.getUniqueId(), dragon); @@ -386,7 +413,7 @@ public void onEnable() { useSpigotHack = getConfig().getBoolean("useSpigotHack", false); if (!useSpigotHack) { - if (v1_8Fake.isUsable()) { + if (v1_8fake.isUsable()) { useSpigotHack = true; Util.detectVersion(); getLogger().info("Detected spigot hack, enabling fake 1.8"); @@ -463,6 +490,10 @@ private void handleTeleport(final Player player, final Location loc) { if (!hasBar(player)) return; + final FakeDragon oldDragon = getDragon(player, ""); + + if (oldDragon instanceof v1_9) return; + Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { @Override @@ -471,8 +502,6 @@ public void run() { if (!hasBar(player)) return; - FakeDragon oldDragon = getDragon(player, ""); - float health = oldDragon.health; String message = oldDragon.name; diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index 71ee7fa..e2508a6 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -32,7 +32,7 @@ public class Util { public static void detectVersion() { if (BarAPI.useSpigotHack()) { - fakeDragonClass = v1_8Fake.class; + fakeDragonClass = v1_8fake.class; version = "v1_7_R4."; isBelowGround = false; } else { @@ -49,7 +49,9 @@ public static void detectVersion() { } else if (minor == 8) { fakeDragonClass = v1_8.class; isBelowGround = false; - } + } else if (minor == 9) { + fakeDragonClass = v1_9.class; + } } version = mcVersion + "."; diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java index a5da361..fd638dc 100644 --- a/src/me/confuser/barapi/nms/v1_8Fake.java +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -17,11 +17,11 @@ * @author James Mortemore */ -public class v1_8Fake extends FakeDragon { +public class v1_8fake extends FakeDragon { private Object dragon; private int id; - public v1_8Fake(String name, Location loc) { + public v1_8fake(String name, Location loc) { super(name, loc); } diff --git a/src/me/confuser/barapi/nms/v1_9.java b/src/me/confuser/barapi/nms/v1_9.java new file mode 100644 index 0000000..ef5a811 --- /dev/null +++ b/src/me/confuser/barapi/nms/v1_9.java @@ -0,0 +1,58 @@ +package me.confuser.barapi.nms; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; + +/** + * This is the FakeDragon class for BarAPI. + * It is based on the code by SoThatsIt. + *

+ * http://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar.158018/page-5#post-2053705 + * + * @author James Mortemore + */ + +public class v1_9 extends FakeDragon { + + private Object dragon; + private int id; + private BossBar bar; + + public v1_9(String name, Location loc) { + super(name, loc); + + bar = Bukkit.createBossBar(name, BarColor.PINK, BarStyle.SOLID); + } + + public BossBar getBar() { + return bar; + } + + @Override + public Object getSpawnPacket() { + return null; + } + + @Override + public Object getDestroyPacket() { + return null; + } + + @Override + public Object getMetaPacket(Object watcher) { + return null; + } + + @Override + public Object getTeleportPacket(Location loc) { + return null; + } + + @Override + public Object getWatcher() { + return null; + } +} From b4b770bf501484bde63c00b6ad231b9437959cd2 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 15:09:14 +0000 Subject: [PATCH 21/27] Deprecated all methods --- src/me/confuser/barapi/BarAPI.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index 78bbd5c..9f2f2eb 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -55,6 +55,7 @@ public static boolean useSpigotHack() { * * @see BarAPI#setMessage(player, message) */ + @Deprecated public static void setMessage(String message) { for (Player player : Bukkit.getOnlinePlayers()) { setMessage(player, message); @@ -71,6 +72,7 @@ public static void setMessage(String message) { * Due to limitations in Minecraft this message cannot be longer than 64 characters.
* It will be cut to that size automatically. */ + @Deprecated public static void setMessage(Player player, String message) { if (hasBar(player)) removeBar(player); @@ -98,6 +100,7 @@ public static void setMessage(Player player, String message) { * @throws IllegalArgumentException If the percentage is not within valid bounds. * @see BarAPI#setMessage(player, message, percent) */ + @Deprecated public static void setMessage(String message, float percent) { for (Player player : Bukkit.getOnlinePlayers()) { setMessage(player, message, percent); @@ -118,6 +121,7 @@ public static void setMessage(String message, float percent) { * * @throws IllegalArgumentException If the percentage is not within valid bounds. */ + @Deprecated public static void setMessage(Player player, String message, float percent) { Validate.isTrue(0F <= percent && percent <= 100F, "Percent must be between 0F and 100F, but was: ", percent); @@ -150,6 +154,7 @@ public static void setMessage(Player player, String message, float percent) { * @throws IllegalArgumentException If seconds is zero or below. * @see BarAPI#setMessage(player, message, seconds) */ + @Deprecated public static void setMessage(String message, int seconds) { for (Player player : Bukkit.getOnlinePlayers()) { setMessage(player, message, seconds); @@ -172,6 +177,7 @@ public static void setMessage(String message, int seconds) { * * @throws IllegalArgumentException If seconds is zero or below. */ + @Deprecated public static void setMessage(final Player player, String message, int seconds) { Validate.isTrue(seconds > 0, "Seconds must be above 1 but was: ", seconds); @@ -214,6 +220,7 @@ public void run() { * * @return True, if the player has a bar, False otherwise. */ + @Deprecated public static boolean hasBar(Player player) { return players.get(player.getUniqueId()) != null; } @@ -224,6 +231,7 @@ public static boolean hasBar(Player player) { * * @param player The player whose bar should be removed. */ + @Deprecated public static void removeBar(Player player) { if (!hasBar(player)) return; @@ -249,6 +257,7 @@ public static void removeBar(Player player) { * @param percent The percentage of the health bar filled.
* This value must be between 0F and 100F (inclusive). */ + @Deprecated public static void setHealth(Player player, float percent) { if (!hasBar(player)) return; @@ -273,6 +282,7 @@ public static void setHealth(Player player, float percent) { * @return The current absolute health of the bar.
* If the player has no bar, this method returns -1. */ + @Deprecated public static float getHealth(Player player) { if (!hasBar(player)) return -1; @@ -288,6 +298,7 @@ public static float getHealth(Player player) { * @return The current message displayed to the player.
* If the player has no bar, this method returns an empty string. */ + @Deprecated public static String getMessage(Player player) { if (!hasBar(player)) return ""; From fe48d27fda615a5505538a5965a4247bc4d65b07 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 15:12:14 +0000 Subject: [PATCH 22/27] Fixed case issue --- src/me/confuser/barapi/nms/v1_8Fake.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java index fd638dc..a5da361 100644 --- a/src/me/confuser/barapi/nms/v1_8Fake.java +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -17,11 +17,11 @@ * @author James Mortemore */ -public class v1_8fake extends FakeDragon { +public class v1_8Fake extends FakeDragon { private Object dragon; private int id; - public v1_8fake(String name, Location loc) { + public v1_8Fake(String name, Location loc) { super(name, loc); } From a3a3aa46fe8d5911c8f01cadccbc4bd874a1638b Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 15:13:46 +0000 Subject: [PATCH 23/27] Formatting --- src/me/confuser/barapi/BarAPI.java | 4 +- src/me/confuser/barapi/Util.java | 358 ++++++++++---------- src/me/confuser/barapi/nms/v1_8Fake.java | 394 ++++++++++++----------- 3 files changed, 381 insertions(+), 375 deletions(-) diff --git a/src/me/confuser/barapi/BarAPI.java b/src/me/confuser/barapi/BarAPI.java index 9f2f2eb..53bdafa 100644 --- a/src/me/confuser/barapi/BarAPI.java +++ b/src/me/confuser/barapi/BarAPI.java @@ -1,7 +1,7 @@ package me.confuser.barapi; import me.confuser.barapi.nms.FakeDragon; -import me.confuser.barapi.nms.v1_8fake; +import me.confuser.barapi.nms.v1_8Fake; import me.confuser.barapi.nms.v1_9; import net.gravitydevelopment.updater.Updater; import org.apache.commons.lang.Validate; @@ -424,7 +424,7 @@ public void onEnable() { useSpigotHack = getConfig().getBoolean("useSpigotHack", false); if (!useSpigotHack) { - if (v1_8fake.isUsable()) { + if (v1_8Fake.isUsable()) { useSpigotHack = true; Util.detectVersion(); getLogger().info("Detected spigot hack, enabling fake 1.8"); diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index e2508a6..d391b45 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -1,199 +1,199 @@ package me.confuser.barapi; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import me.confuser.barapi.nms.*; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + /** * This is a utility class for BarAPI. It is based on the code by SoThatsIt. - * + *

* http://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar * .158018/page-2#post-1760928 - * + * * @author James Mortemore */ public class Util { - public static boolean newProtocol = false; - public static String version; - public static Class fakeDragonClass = v1_6.class; - public static boolean isBelowGround = true; - - static { - detectVersion(); - } - - public static void detectVersion() { - if (BarAPI.useSpigotHack()) { - fakeDragonClass = v1_8fake.class; - version = "v1_7_R4."; - isBelowGround = false; - } else { - String name = Bukkit.getServer().getClass().getPackage().getName(); - String mcVersion = name.substring(name.lastIndexOf('.') + 1); - String[] versions = mcVersion.split("_"); - - if (versions[0].equals("v1")) { - int minor = Integer.parseInt(versions[1]); - - if (minor == 7) { - newProtocol = true; - fakeDragonClass = v1_7.class; - } else if (minor == 8) { - fakeDragonClass = v1_8.class; - isBelowGround = false; - } else if (minor == 9) { + + public static boolean newProtocol = false; + public static String version; + public static Class fakeDragonClass = v1_6.class; + public static boolean isBelowGround = true; + + static { + detectVersion(); + } + + public static void detectVersion() { + if (BarAPI.useSpigotHack()) { + fakeDragonClass = v1_8Fake.class; + version = "v1_7_R4."; + isBelowGround = false; + } else { + String name = Bukkit.getServer().getClass().getPackage().getName(); + String mcVersion = name.substring(name.lastIndexOf('.') + 1); + String[] versions = mcVersion.split("_"); + + if (versions[0].equals("v1")) { + int minor = Integer.parseInt(versions[1]); + + if (minor == 7) { + newProtocol = true; + fakeDragonClass = v1_7.class; + } else if (minor == 8) { + fakeDragonClass = v1_8.class; + isBelowGround = false; + } else if (minor == 9) { fakeDragonClass = v1_9.class; } - } - - version = mcVersion + "."; - } - } - - public static FakeDragon newDragon(String message, Location loc) { - FakeDragon fakeDragon = null; - - try { - fakeDragon = (FakeDragon) fakeDragonClass.getConstructor(String.class, Location.class).newInstance(message, loc); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return fakeDragon; - } - - // Reflection Util - public static void sendPacket(Player p, Object packet) { - try { - Object nmsPlayer = getHandle(p); - Field con_field = nmsPlayer.getClass().getField("playerConnection"); - Object con = con_field.get(nmsPlayer); - Method packet_method = getMethod(con.getClass(), "sendPacket"); - packet_method.invoke(con, packet); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } - } - - public static Class getCraftClass(String ClassName) { - String className = "net.minecraft.server." + version + ClassName; - Class c = null; - try { - c = Class.forName(className); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - return c; - } - - public static Object getHandle(World world) { - Object nms_entity = null; - Method entity_getHandle = getMethod(world.getClass(), "getHandle"); - try { - nms_entity = entity_getHandle.invoke(world); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return nms_entity; - } - - public static Object getHandle(Entity entity) { - Object nms_entity = null; - Method entity_getHandle = getMethod(entity.getClass(), "getHandle"); - try { - nms_entity = entity_getHandle.invoke(entity); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return nms_entity; - } - - public static Field getField(Class cl, String field_name) { - try { - Field field = cl.getDeclaredField(field_name); - return field; - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } - return null; - } - - public static Method getMethod(Class cl, String method, Class[] args) { - for (Method m : cl.getMethods()) { - if (m.getName().equals(method) && ClassListEqual(args, m.getParameterTypes())) { - return m; - } - } - return null; - } - - public static Method getMethod(Class cl, String method, Integer args) { - for (Method m : cl.getMethods()) { - if (m.getName().equals(method) && args.equals(new Integer(m.getParameterTypes().length))) { - return m; - } - } - return null; - } - - public static Method getMethod(Class cl, String method) { - for (Method m : cl.getMethods()) { - if (m.getName().equals(method)) { - return m; - } - } - return null; - } - - public static boolean ClassListEqual(Class[] l1, Class[] l2) { - boolean equal = true; - - if (l1.length != l2.length) - return false; - for (int i = 0; i < l1.length; i++) { - if (l1[i] != l2[i]) { - equal = false; - break; - } - } - - return equal; - } + } + + version = mcVersion + "."; + } + } + + public static FakeDragon newDragon(String message, Location loc) { + FakeDragon fakeDragon = null; + + try { + fakeDragon = (FakeDragon) fakeDragonClass.getConstructor(String.class, Location.class).newInstance(message, loc); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return fakeDragon; + } + + // Reflection Util + public static void sendPacket(Player p, Object packet) { + try { + Object nmsPlayer = getHandle(p); + Field con_field = nmsPlayer.getClass().getField("playerConnection"); + Object con = con_field.get(nmsPlayer); + Method packet_method = getMethod(con.getClass(), "sendPacket"); + packet_method.invoke(con, packet); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } + + public static Class getCraftClass(String ClassName) { + String className = "net.minecraft.server." + version + ClassName; + Class c = null; + try { + c = Class.forName(className); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + return c; + } + + public static Object getHandle(World world) { + Object nms_entity = null; + Method entity_getHandle = getMethod(world.getClass(), "getHandle"); + try { + nms_entity = entity_getHandle.invoke(world); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return nms_entity; + } + + public static Object getHandle(Entity entity) { + Object nms_entity = null; + Method entity_getHandle = getMethod(entity.getClass(), "getHandle"); + try { + nms_entity = entity_getHandle.invoke(entity); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return nms_entity; + } + + public static Field getField(Class cl, String field_name) { + try { + Field field = cl.getDeclaredField(field_name); + return field; + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return null; + } + + public static Method getMethod(Class cl, String method, Class[] args) { + for (Method m : cl.getMethods()) { + if (m.getName().equals(method) && ClassListEqual(args, m.getParameterTypes())) { + return m; + } + } + return null; + } + + public static Method getMethod(Class cl, String method, Integer args) { + for (Method m : cl.getMethods()) { + if (m.getName().equals(method) && args.equals(new Integer(m.getParameterTypes().length))) { + return m; + } + } + return null; + } + + public static Method getMethod(Class cl, String method) { + for (Method m : cl.getMethods()) { + if (m.getName().equals(method)) { + return m; + } + } + return null; + } + + public static boolean ClassListEqual(Class[] l1, Class[] l2) { + boolean equal = true; + + if (l1.length != l2.length) + return false; + for (int i = 0; i < l1.length; i++) { + if (l1[i] != l2[i]) { + equal = false; + break; + } + } + + return equal; + } } \ No newline at end of file diff --git a/src/me/confuser/barapi/nms/v1_8Fake.java b/src/me/confuser/barapi/nms/v1_8Fake.java index a5da361..180d37e 100644 --- a/src/me/confuser/barapi/nms/v1_8Fake.java +++ b/src/me/confuser/barapi/nms/v1_8Fake.java @@ -1,204 +1,210 @@ package me.confuser.barapi.nms; +import me.confuser.barapi.Util; +import org.bukkit.Location; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import me.confuser.barapi.Util; - -import org.bukkit.Location; - /** -* This is the FakeDragon class for BarAPI. -* It is based on the code by SoThatsIt. -* -* http://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar.158018/page-5#post-2053705 -* -* @author James Mortemore -*/ + * This is the FakeDragon class for BarAPI. + * It is based on the code by SoThatsIt. + *

+ * http://forums.bukkit.org/threads/tutorial-utilizing-the-boss-health-bar.158018/page-5#post-2053705 + * + * @author James Mortemore + */ public class v1_8Fake extends FakeDragon { - private Object dragon; - private int id; - - public v1_8Fake(String name, Location loc) { - super(name, loc); - } - - @Override - public Object getSpawnPacket() { - Class Entity = Util.getCraftClass("Entity"); - Class EntityLiving = Util.getCraftClass("EntityLiving"); - Class EntityEnderDragon = Util.getCraftClass("EntityEnderDragon"); - Object packet = null; - try { - dragon = EntityEnderDragon.getConstructor(Util.getCraftClass("World")).newInstance(getWorld()); - - Method setLocation = Util.getMethod(EntityEnderDragon, "setLocation", new Class[] { double.class, double.class, double.class, float.class, float.class }); - setLocation.invoke(dragon, getX(), getY(), getZ(), getPitch(), getYaw()); - - Method setInvisible = Util.getMethod(EntityEnderDragon, "setInvisible", new Class[] { boolean.class }); - setInvisible.invoke(dragon, true); - - Method setCustomName = Util.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); - setCustomName.invoke(dragon, name); - - Method setHealth = Util.getMethod(EntityEnderDragon, "setHealth", new Class[] { float.class }); - setHealth.invoke(dragon, health); - - Field motX = Util.getField(Entity, "motX"); - motX.set(dragon, getXvel()); - - Field motY = Util.getField(Entity, "motY"); - motY.set(dragon, getYvel()); - - Field motZ = Util.getField(Entity, "motZ"); - motZ.set(dragon, getZvel()); - - Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[] {}); - this.id = (Integer) getId.invoke(dragon); - - Class PacketPlayOutSpawnEntityLiving = Util.getCraftClass("PacketPlayOutSpawnEntityLiving"); - - packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }).newInstance(dragon); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return packet; - } - - @Override - public Object getDestroyPacket() { - Class PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy"); - - Object packet = null; - try { - packet = PacketPlayOutEntityDestroy.newInstance(); - Field a = PacketPlayOutEntityDestroy.getDeclaredField("a"); - a.setAccessible(true); - a.set(packet, new int[] { id }); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - - return packet; - } - - @Override - public Object getMetaPacket(Object watcher) { - Class DataWatcher = Util.getCraftClass("DataWatcher"); - - Class PacketPlayOutEntityMetadata = Util.getCraftClass("PacketPlayOutEntityMetadata"); - - Object packet = null; - try { - packet = PacketPlayOutEntityMetadata.getConstructor(new Class[] { int.class, DataWatcher, boolean.class }).newInstance(id, watcher, true); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return packet; - } - - @Override - public Object getTeleportPacket(Location loc) { - Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); - Object packet = null; - - try { - packet = PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }).newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc.getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false, false); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return packet; - } - - @Override - public Object getWatcher() { - Class Entity = Util.getCraftClass("Entity"); - Class DataWatcher = Util.getCraftClass("DataWatcher"); - - Object watcher = null; - try { - watcher = DataWatcher.getConstructor(new Class[] { Entity }).newInstance(dragon); - Method a = Util.getMethod(DataWatcher, "a", new Class[] { int.class, Object.class }); - - a.invoke(watcher, 5, isVisible() ? (byte) 0 : (byte) 0x20); - a.invoke(watcher, 6, (Float) health); - a.invoke(watcher, 7, (Integer) 0); - a.invoke(watcher, 8, (Byte) (byte) 0); - a.invoke(watcher, 10, name); - a.invoke(watcher, 11, (Byte) (byte) 1); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } - - return watcher; - } - - public static boolean isUsable() { - Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); - - try { - PacketPlayOutEntityTeleport.getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }); - } catch (IllegalArgumentException e) { - return false; - } catch (SecurityException e) { - return false; - } catch (NoSuchMethodException e) { - return false; - } - - return true; - } + + private Object dragon; + private int id; + + public v1_8Fake(String name, Location loc) { + super(name, loc); + } + + public static boolean isUsable() { + Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); + + try { + PacketPlayOutEntityTeleport + .getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }); + } catch (IllegalArgumentException e) { + return false; + } catch (SecurityException e) { + return false; + } catch (NoSuchMethodException e) { + return false; + } + + return true; + } + + @Override + public Object getSpawnPacket() { + Class Entity = Util.getCraftClass("Entity"); + Class EntityLiving = Util.getCraftClass("EntityLiving"); + Class EntityEnderDragon = Util.getCraftClass("EntityEnderDragon"); + Object packet = null; + try { + dragon = EntityEnderDragon.getConstructor(Util.getCraftClass("World")).newInstance(getWorld()); + + Method setLocation = Util + .getMethod(EntityEnderDragon, "setLocation", new Class[] { double.class, double.class, double.class, float.class, float.class }); + setLocation.invoke(dragon, getX(), getY(), getZ(), getPitch(), getYaw()); + + Method setInvisible = Util.getMethod(EntityEnderDragon, "setInvisible", new Class[] { boolean.class }); + setInvisible.invoke(dragon, true); + + Method setCustomName = Util.getMethod(EntityEnderDragon, "setCustomName", new Class[] { String.class }); + setCustomName.invoke(dragon, name); + + Method setHealth = Util.getMethod(EntityEnderDragon, "setHealth", new Class[] { float.class }); + setHealth.invoke(dragon, health); + + Field motX = Util.getField(Entity, "motX"); + motX.set(dragon, getXvel()); + + Field motY = Util.getField(Entity, "motY"); + motY.set(dragon, getYvel()); + + Field motZ = Util.getField(Entity, "motZ"); + motZ.set(dragon, getZvel()); + + Method getId = Util.getMethod(EntityEnderDragon, "getId", new Class[] {}); + this.id = (Integer) getId.invoke(dragon); + + Class PacketPlayOutSpawnEntityLiving = Util.getCraftClass("PacketPlayOutSpawnEntityLiving"); + + packet = PacketPlayOutSpawnEntityLiving.getConstructor(new Class[] { EntityLiving }).newInstance(dragon); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getDestroyPacket() { + Class PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy"); + + Object packet = null; + try { + packet = PacketPlayOutEntityDestroy.newInstance(); + Field a = PacketPlayOutEntityDestroy.getDeclaredField("a"); + a.setAccessible(true); + a.set(packet, new int[] { id }); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getMetaPacket(Object watcher) { + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Class PacketPlayOutEntityMetadata = Util.getCraftClass("PacketPlayOutEntityMetadata"); + + Object packet = null; + try { + packet = PacketPlayOutEntityMetadata.getConstructor(new Class[] { int.class, DataWatcher, boolean.class }) + .newInstance(id, watcher, true); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getTeleportPacket(Location loc) { + Class PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport"); + Object packet = null; + + try { + packet = PacketPlayOutEntityTeleport + .getConstructor(new Class[] { int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class }) + .newInstance(this.id, loc.getBlockX() * 32, loc.getBlockY() * 32, loc.getBlockZ() * 32, (byte) ((int) loc + .getYaw() * 256 / 360), (byte) ((int) loc.getPitch() * 256 / 360), false, false); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return packet; + } + + @Override + public Object getWatcher() { + Class Entity = Util.getCraftClass("Entity"); + Class DataWatcher = Util.getCraftClass("DataWatcher"); + + Object watcher = null; + try { + watcher = DataWatcher.getConstructor(new Class[] { Entity }).newInstance(dragon); + Method a = Util.getMethod(DataWatcher, "a", new Class[] { int.class, Object.class }); + + a.invoke(watcher, 5, isVisible() ? (byte) 0 : (byte) 0x20); + a.invoke(watcher, 6, (Float) health); + a.invoke(watcher, 7, (Integer) 0); + a.invoke(watcher, 8, (Byte) (byte) 0); + a.invoke(watcher, 10, name); + a.invoke(watcher, 11, (Byte) (byte) 1); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + + return watcher; + } } From 92634712e97cbdb6535c796ca9a9eb6dc8de79ad Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sat, 19 Mar 2016 15:15:24 +0000 Subject: [PATCH 24/27] Updated to 3.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c0c1be..ea24294 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.4-SNAPSHOT + 3.4 BarAPI From acadfaa0dea7f34604be783173a90c88836e28f8 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Fri, 4 Nov 2016 15:36:15 +0000 Subject: [PATCH 25/27] Added 1.10+ support --- src/me/confuser/barapi/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/me/confuser/barapi/Util.java b/src/me/confuser/barapi/Util.java index d391b45..ab0f6e2 100644 --- a/src/me/confuser/barapi/Util.java +++ b/src/me/confuser/barapi/Util.java @@ -49,7 +49,7 @@ public static void detectVersion() { } else if (minor == 8) { fakeDragonClass = v1_8.class; isBelowGround = false; - } else if (minor == 9) { + } else if (minor >= 9) { fakeDragonClass = v1_9.class; } } From b1ab443fa1fafe422d7f259f69e9458623c46b8a Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Fri, 4 Nov 2016 15:36:36 +0000 Subject: [PATCH 26/27] Updated to v3.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea24294..ab283dd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ Allows plugins to control the boss health bar message me.confuser BarAPI - 3.4 + 3.5 BarAPI From c96e13ee9503333124b8530e4d73d9887c3993b8 Mon Sep 17 00:00:00 2001 From: Thomas Windt Date: Thu, 9 Aug 2018 15:00:43 +0200 Subject: [PATCH 27/27] Update README.md Link was not working --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e4b2807..2002436 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@

<repositories>
 	<repository>
 		<id>confuser-repo</id>
-		<url>http://ci.frostcast.net/plugin/repository/everything</url>
+		<url>https://ci.frostcast.net/plugin/repository/everything</url>
 	</repository>
 </repositories>
 
@@ -37,7 +37,7 @@
 	<dependency>
 		<groupId>me.confuser</groupId>
 		<artifactId>BarAPI</artifactId>
-		<version>3.0</version>
+		<version>3.5</version>
 	</dependency>
 </dependencies>