Skip to content

Commit

Permalink
cleanup; removed protocollib as it is not needed since bukkit added w…
Browse files Browse the repository at this point in the history
…hat it was doing to the core api. wrapped debug stuff behind new config option debug.
  • Loading branch information
ProgrammerDan committed Jun 16, 2017
1 parent 619bb26 commit 7ac004a
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 114 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.minelink</groupId>
<artifactId>CombatTagPlus</artifactId>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/github/maxopoly/finale/ConfigParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <Enchantment> 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;
}

Expand Down
11 changes: 1 addition & 10 deletions src/main/java/com/github/maxopoly/finale/Finale.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -45,10 +43,6 @@ public static CombatTagPlusManager getCombatTagPlusManager() {
return ctpManager;
}

public static ProtocolLibManager getProtocolLibManager() {
return protocolLibManager;
}

public String getPluginName() {
return "Finale";
}
Expand All @@ -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);
Expand All @@ -74,9 +68,6 @@ private void initExternalManagers() {
if (plugins.isPluginEnabled("CombatTagPlus")) {
ctpManager = new CombatTagPlusManager();
}
/*if (plugins.isPluginEnabled("ProtocolLib")) {
protocolLibManager = new ProtocolLibManager();
}*/
}

}
14 changes: 7 additions & 7 deletions src/main/java/com/github/maxopoly/finale/FinaleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class FinaleManager {

private boolean debug;
private boolean attackSpeedEnabled;
private double attackSpeed;
private boolean regenHandlerEnabled;
Expand All @@ -17,17 +18,20 @@ public class FinaleManager {
private boolean protocolLibEnabled;
private Collection <Enchantment> disabledEnchantments;

public FinaleManager(boolean attackSpeedEnabled, double attackSpeed, boolean regenHandlerEnabled,
SaturationHealthRegenHandler regenHandler,WeaponModifier weaponModifier, boolean protocolLibEnabled, Collection <Enchantment> disabledEnchants) {
public FinaleManager(boolean debug, boolean attackSpeedEnabled, double attackSpeed, boolean regenHandlerEnabled,
SaturationHealthRegenHandler regenHandler,WeaponModifier weaponModifier, Collection <Enchantment> 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;
}
Expand All @@ -48,10 +52,6 @@ public WeaponModifier getWeaponModifer() {
return weaponModifier;
}

public boolean protocolLibEnabled() {
return protocolLibEnabled;
}

public boolean isDisabledEnchantment(Enchantment enchant) {
return disabledEnchantments.contains(enchant);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ main: com.github.maxopoly.finale.Finale
author: Maxopoly
version: ${project.version}
depend: [CivModCore]
softdepend: [ProtocolLib, CombatTagPlus]
softdepend: [CombatTagPlus]
commands:
permissions:

0 comments on commit 7ac004a

Please sign in to comment.