diff --git a/pom.xml b/pom.xml
index 662890f..b01f6cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,11 +44,6 @@
1.6.0
provided
-
- com.comphenix.protocol
- ProtocolLib
- 4.3.0-SNAPSHOT
-
net.minelink
CombatTagPlus
diff --git a/src/main/java/com/github/maxopoly/finale/ConfigParser.java b/src/main/java/com/github/maxopoly/finale/ConfigParser.java
index 716f2a5..5752b3c 100644
--- a/src/main/java/com/github/maxopoly/finale/ConfigParser.java
+++ b/src/main/java/com/github/maxopoly/finale/ConfigParser.java
@@ -35,6 +35,7 @@ public FinaleManager parse() {
plugin.reloadConfig();
FileConfiguration config = plugin.getConfig();
// Attack Speed modification for all players
+ boolean debug = config.getBoolean("debug", false);
boolean attackEnabled = config.getBoolean("alterAttack.enabled", true);
double attackSpeed = config.getDouble("alterAttack.speed", 9.4);
// Food Health Regen modifications for all players
@@ -44,13 +45,11 @@ public FinaleManager parse() {
// Pearl cooldown changes
this.pearlEnabled = parsePearls(config.getConfigurationSection("pearls"));
WeaponModifier weapMod = parseWeaponModification(config.getConfigurationSection("weaponModification"));
- // Flags
- boolean protocolLibEnabled = Bukkit.getPluginManager().isPluginEnabled("ProtocolLib");
Collection disabledEnchants = parseDisableEnchantments(config);
// Initialize the manager
- manager = new FinaleManager(attackEnabled, attackSpeed, regenEnabled, regenhandler, weapMod, protocolLibEnabled, disabledEnchants);
+ manager = new FinaleManager(debug, attackEnabled, attackSpeed, regenEnabled, regenhandler, weapMod, disabledEnchants);
return manager;
}
diff --git a/src/main/java/com/github/maxopoly/finale/Finale.java b/src/main/java/com/github/maxopoly/finale/Finale.java
index 2934b6b..06e309f 100644
--- a/src/main/java/com/github/maxopoly/finale/Finale.java
+++ b/src/main/java/com/github/maxopoly/finale/Finale.java
@@ -4,7 +4,6 @@
import org.bukkit.plugin.PluginManager;
import com.github.maxopoly.finale.external.CombatTagPlusManager;
-import com.github.maxopoly.finale.external.ProtocolLibManager;
import com.github.maxopoly.finale.listeners.EnchantmentDisableListener;
import com.github.maxopoly.finale.listeners.PearlCoolDownListener;
import com.github.maxopoly.finale.listeners.PlayerListener;
@@ -17,7 +16,6 @@ public class Finale extends ACivMod {
private static Finale instance;
private static FinaleManager manager;
private static CombatTagPlusManager ctpManager;
- private static ProtocolLibManager protocolLibManager;
private ConfigParser config;
@@ -45,10 +43,6 @@ public static CombatTagPlusManager getCombatTagPlusManager() {
return ctpManager;
}
- public static ProtocolLibManager getProtocolLibManager() {
- return protocolLibManager;
- }
-
public String getPluginName() {
return "Finale";
}
@@ -58,7 +52,7 @@ private void registerListener() {
if (manager.isAttackSpeedEnabled() || manager.isRegenHandlerEnabled()) {
Bukkit.getPluginManager().registerEvents(new PlayerListener(manager), this);
}
- // So far the pearl listener, CTP manager and ProtocolLib manager are only needed if pearl cooldown changes are enabled.
+ // So far the pearl listener, CTP manager only needed if pearl cooldown changes are enabled.
if (config.isPearlEnabled()) {
Bukkit.getPluginManager().registerEvents(
new PearlCoolDownListener(config.getPearlCoolDown(), config.combatTagOnPearl(), ctpManager, config.refundBlockedPearls()), this);
@@ -74,9 +68,6 @@ private void initExternalManagers() {
if (plugins.isPluginEnabled("CombatTagPlus")) {
ctpManager = new CombatTagPlusManager();
}
- /*if (plugins.isPluginEnabled("ProtocolLib")) {
- protocolLibManager = new ProtocolLibManager();
- }*/
}
}
diff --git a/src/main/java/com/github/maxopoly/finale/FinaleManager.java b/src/main/java/com/github/maxopoly/finale/FinaleManager.java
index 6aaee7c..5d762f6 100644
--- a/src/main/java/com/github/maxopoly/finale/FinaleManager.java
+++ b/src/main/java/com/github/maxopoly/finale/FinaleManager.java
@@ -9,6 +9,7 @@
public class FinaleManager {
+ private boolean debug;
private boolean attackSpeedEnabled;
private double attackSpeed;
private boolean regenHandlerEnabled;
@@ -17,17 +18,20 @@ public class FinaleManager {
private boolean protocolLibEnabled;
private Collection disabledEnchantments;
- public FinaleManager(boolean attackSpeedEnabled, double attackSpeed, boolean regenHandlerEnabled,
- SaturationHealthRegenHandler regenHandler,WeaponModifier weaponModifier, boolean protocolLibEnabled, Collection disabledEnchants) {
+ public FinaleManager(boolean debug, boolean attackSpeedEnabled, double attackSpeed, boolean regenHandlerEnabled,
+ SaturationHealthRegenHandler regenHandler,WeaponModifier weaponModifier, Collection disabledEnchants) {
this.attackSpeedEnabled = attackSpeedEnabled;
this.attackSpeed = attackSpeed;
this.regenHandlerEnabled = regenHandlerEnabled;
this.regenHandler = regenHandler;
- this.protocolLibEnabled = protocolLibEnabled;
this.weaponModifier = weaponModifier;
this.disabledEnchantments = disabledEnchants;
}
+ public boolean isDebug() {
+ return debug;
+ }
+
public boolean isAttackSpeedEnabled() {
return attackSpeedEnabled;
}
@@ -48,10 +52,6 @@ public WeaponModifier getWeaponModifer() {
return weaponModifier;
}
- public boolean protocolLibEnabled() {
- return protocolLibEnabled;
- }
-
public boolean isDisabledEnchantment(Enchantment enchant) {
return disabledEnchantments.contains(enchant);
}
diff --git a/src/main/java/com/github/maxopoly/finale/external/ProtocolLibManager.java b/src/main/java/com/github/maxopoly/finale/external/ProtocolLibManager.java
deleted file mode 100644
index 6b7f8a4..0000000
--- a/src/main/java/com/github/maxopoly/finale/external/ProtocolLibManager.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.github.maxopoly.finale.external;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.bukkit.entity.Player;
-
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.ProtocolLibrary;
-import com.comphenix.protocol.ProtocolManager;
-import com.comphenix.protocol.events.ListenerPriority;
-import com.comphenix.protocol.events.PacketAdapter;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.events.PacketEvent;
-import com.github.maxopoly.finale.Finale;
-import com.github.maxopoly.finale.listeners.PearlCoolDownListener;
-
-public class ProtocolLibManager {
-
- private ProtocolManager protocolManager;
- //no clue how to make this, so we snatch it from a normal packet
- private Object pearlModifierObjectExample;
-
- public ProtocolLibManager() {
- this.protocolManager = ProtocolLibrary.getProtocolManager();
- registerPacketListener();
- }
-
- private void registerPacketListener() {
- //pearl cooldown
- protocolManager.addPacketListener(new PacketAdapter(Finale.getPlugin(),
- ListenerPriority.NORMAL, PacketType.Play.Server.SET_COOLDOWN) {
- @Override
- public void onPacketSending(PacketEvent event) {
- if (event.getPacketType() != PacketType.Play.Server.SET_COOLDOWN) {
- return;
- }
- Player p = event.getPlayer();
- PacketContainer packet = event.getPacket();
- //ensure we are dealing with pearl cooldowns
- if (packet.getModifier().read(0).getClass().getSimpleName().equals("ItemEnderPearl")) {
- if (pearlModifierObjectExample == null) {
- pearlModifierObjectExample = packet.getModifier().read(0);
- }
- if (PearlCoolDownListener.getPearlCoolDown(p.getUniqueId()) != packet.getIntegers().read(0)) {
- //not our cooldown, so fuck it
- event.setCancelled(true);
- }
- }
- }
- });
- }
-
- public void sendPacketWithCoolDown(long coolDown, Player p) {
- PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_COOLDOWN);
- packet.getIntegers().write(0, (int) coolDown);
- packet.getModifier().write(0, pearlModifierObjectExample);
- try {
- protocolManager.sendServerPacket(p, packet);
- } catch (InvocationTargetException e) {
- Finale.getPlugin().warning("Failed to send pearl cd package to " + p.getName());
- e.printStackTrace();
- }
- }
-
-}
diff --git a/src/main/java/com/github/maxopoly/finale/listeners/PearlCoolDownListener.java b/src/main/java/com/github/maxopoly/finale/listeners/PearlCoolDownListener.java
index 58c2697..29aced9 100644
--- a/src/main/java/com/github/maxopoly/finale/listeners/PearlCoolDownListener.java
+++ b/src/main/java/com/github/maxopoly/finale/listeners/PearlCoolDownListener.java
@@ -15,7 +15,6 @@
import com.github.maxopoly.finale.Finale;
import com.github.maxopoly.finale.external.CombatTagPlusManager;
-import com.github.maxopoly.finale.external.ProtocolLibManager;
import vg.civcraft.mc.civmodcore.util.cooldowns.TickCoolDownHandler;
diff --git a/src/main/java/com/github/maxopoly/finale/listeners/PlayerListener.java b/src/main/java/com/github/maxopoly/finale/listeners/PlayerListener.java
index b6f6f0e..610a829 100644
--- a/src/main/java/com/github/maxopoly/finale/listeners/PlayerListener.java
+++ b/src/main/java/com/github/maxopoly/finale/listeners/PlayerListener.java
@@ -55,31 +55,37 @@ public void healthRegen(EntityRegainHealthEvent e) {
double spigotRegenExhaustion = ((net.minecraft.server.v1_12_R1.World) ( (org.bukkit.craftbukkit.v1_12_R1.CraftWorld) p.getWorld()).getHandle()).spigotConfig.regenExhaustion;
float newExhaustion = (float) (p.getExhaustion() - e.getAmount() * spigotRegenExhaustion);
- StringBuffer alterHealth = new StringBuffer("SATIATED: " + p.getName());
- alterHealth.append(":").append(p.getHealth()).append("<").append(p.getMaxHealth());
- alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
- alterHealth.append(":").append(p.getFoodLevel());
-
+ StringBuffer alterHealth = null;
+ if (manager.isDebug()) {
+ alterHealth = new StringBuffer("SATIATED: " + p.getName());
+ alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);
+ alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
+ alterHealth.append(":").append(p.getFoodLevel());
+ }
if(newExhaustion < 0) // not 100% sure this is correct route; intention was restoring what spigot takes, but we'll roll with it
newExhaustion = 0;
p.setExhaustion(newExhaustion);
- alterHealth.append(" TO ").append(p.getHealth()).append("<").append(p.getMaxHealth());
- alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
- alterHealth.append(":").append(p.getFoodLevel());
- Finale.getPlugin().getLogger().info(alterHealth.toString());
+ if (manager.isDebug()) {
+ alterHealth.append(" TO ").append(p.getHealth()).append("<").append(p.getMaxHealth());
+ alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
+ alterHealth.append(":").append(p.getFoodLevel());
+ Finale.getPlugin().getLogger().info(alterHealth.toString());
+ }
e.setCancelled(true);
return;
}
if (e.getRegainReason() == RegainReason.EATING && manager.getPassiveRegenHandler().blockFoodHealthRegen()) {
Player p = (Player) e.getEntity();
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
- StringBuffer alterHealth = new StringBuffer("EATING:" + p.getName());
- alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);
- alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
- alterHealth.append(":").append(p.getFoodLevel());
- Finale.getPlugin().getLogger().info(alterHealth.toString());
+ if (manager.isDebug()) {
+ StringBuffer alterHealth = new StringBuffer("EATING:" + p.getName());
+ alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);
+ alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
+ alterHealth.append(":").append(p.getFoodLevel());
+ Finale.getPlugin().getLogger().info(alterHealth.toString());
+ }
e.setCancelled(true);
}
}
diff --git a/src/main/java/com/github/maxopoly/finale/misc/SaturationHealthRegenHandler.java b/src/main/java/com/github/maxopoly/finale/misc/SaturationHealthRegenHandler.java
index 74411e4..6ef7c01 100644
--- a/src/main/java/com/github/maxopoly/finale/misc/SaturationHealthRegenHandler.java
+++ b/src/main/java/com/github/maxopoly/finale/misc/SaturationHealthRegenHandler.java
@@ -77,18 +77,24 @@ public void run() {
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
if (p.getFoodLevel() >= minimumFood && p.getHealth() < maxHealth) {
- StringBuffer alterHealth = new StringBuffer(p.getName());
- alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);
- alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
- alterHealth.append(":").append(p.getFoodLevel());
+ StringBuffer alterHealth = null;
+
+ if (Finale.getManager().isDebug()) {
+ alterHealth = new StringBuffer(p.getName());
+ alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);
+ alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
+ alterHealth.append(":").append(p.getFoodLevel());
+ }
double newHealth = p.getHealth() + healthPerCycle;
newHealth = Math.min(newHealth, maxHealth);
p.setExhaustion(p.getExhaustion() + exhaustionPerHeal);
p.setHealth(newHealth);
- alterHealth.append(" TO ").append(p.getHealth()).append("<").append(maxHealth);
- alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
- alterHealth.append(":").append(p.getFoodLevel());
- Finale.getPlugin().getLogger().info(alterHealth.toString());
+ if (Finale.getManager().isDebug()) {
+ alterHealth.append(" TO ").append(p.getHealth()).append("<").append(maxHealth);
+ alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
+ alterHealth.append(":").append(p.getFoodLevel());
+ Finale.getPlugin().getLogger().info(alterHealth.toString());
+ }
}
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index ab78753..fac635e 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,6 +3,6 @@ main: com.github.maxopoly.finale.Finale
author: Maxopoly
version: ${project.version}
depend: [CivModCore]
-softdepend: [ProtocolLib, CombatTagPlus]
+softdepend: [CombatTagPlus]
commands:
permissions: