You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combat Tag's current codebase is a mess.
The CombatTag class manages the entire plugin violating the single responsibility principle.
Getters and Setters are missing, the packages don't follow convention, and the code isn't extensible.
I suggest moving to something like CombatTagReloaded, where CombatTagging has an event, that other plugins can hook into.
Compare the combat-tagging code in CombatTag, which handles plugin compatibility, settings, and permissions.
if (plugin.npcm.isNPC(damaged)) {
return;
} //If the damaged player is an npc do nothingif (plugin.ctIncompatible.WarArenaHook(damager) && plugin.ctIncompatible.WarArenaHook(damaged)) {
if (!damager.hasPermission("combattag.ignore")) {
if (plugin.settings.blockCreativeTagging() && damager.getGameMode() == GameMode.CREATIVE) {
damager.sendMessage(ChatColor.RED + "[CombatTag] You can't tag players while in creative mode!");
return;
}
if (plugin.settings.isSendMessageWhenTagged() && !plugin.isInCombat(damager.getUniqueId())) {
StringtagMessage = plugin.settings.getTagMessageDamager();
tagMessage = tagMessage.replace("[player]", "" + damaged.getName());
damager.sendMessage(ChatColor.RED + "[CombatTag] " + tagMessage);
}
plugin.addTagged(damager);
if (plugin.settings.blockFly() && damager.isFlying()) {
damager.sendMessage(ChatColor.RED + "[CombatTag] You can't fly in combat!");
damager.setFlying(false);
}
}
if (!damaged.hasPermission("combattag.ignore") && !plugin.settings.onlyDamagerTagged()) {
if (!plugin.isInCombat(damaged.getUniqueId())) {
if (plugin.settings.isSendMessageWhenTagged()) {
StringtagMessage = plugin.settings.getTagMessageDamaged();
tagMessage = tagMessage.replace("[player]", damager.getName());
damaged.sendMessage(ChatColor.RED + "[CombatTag] " + tagMessage);
}
}
plugin.addTagged(damaged);
if (plugin.settings.blockFly() && damaged.isFlying()) {
damaged.sendMessage(ChatColor.RED + "[CombatTag] Disabling fly!");
damaged.setFlying(false);
}
}
}
}
To the code in combat tag reloaded, which fires an event that other classes and plugins can handle and modify easily:
publicvoidonDamage(EntityDamageByEntityEventevent) {
LivingEntityattacker = Utils.getRootDamager(event.getDamager());
LivingEntitydefender = (LivingEntity) event.getEntity();
if (CombatTagAPI.isNPC(defender) || CombatTagAPI.isNPC(attacker)) return;
if (attackerinstanceofPlayer) onAttack(CombatPlayer.getPlayer((Player)attacker), defender);
if (defenderinstanceofPlayer) onDefend(CombatPlayer.getPlayer((Player)defender), attacker);
}
publicvoidonAttack(CombatPlayerattacker, LivingEntitydefender) {
if (!(defenderinstanceofPlayer) && !Utils.getPlugin().getSettings().isTagMobs()) return;
if (attacker.isTagged()) return;
CombatTagEventevent = newCombatTagEvent(attacker, defender, TagCause.ATTACK);
Utils.fire(event);
if (event.isCancelled()) return;
attacker.tag();
}
publicvoidonDefend(CombatPlayerdefender, LivingEntityattacker) {
if (!(attackerinstanceofPlayer) && !Utils.getPlugin().getSettings().isTagMobs()) return;
if (defender.isTagged()) return;
CombatTagEventevent = newCombatTagEvent(defender, attacker, TagCause.DEFEND);
Utils.fire(event);
if (event.isCancelled()) return;
defender.tag();
}
Of course, I would like @Outfenneced 's opinion on this, as i am proposing a complete rewrite.
The text was updated successfully, but these errors were encountered:
Combat Tag's current codebase is a mess.
The
CombatTag
class manages the entire plugin violating the single responsibility principle.Getters and Setters are missing, the packages don't follow convention, and the code isn't extensible.
I suggest moving to something like CombatTagReloaded, where CombatTagging has an event, that other plugins can hook into.
Compare the combat-tagging code in CombatTag, which handles plugin compatibility, settings, and permissions.
To the code in combat tag reloaded, which fires an event that other classes and plugins can handle and modify easily:
Of course, I would like @Outfenneced 's opinion on this, as i am proposing a complete rewrite.
The text was updated successfully, but these errors were encountered: