use of com.github.sirblobman.combatlogx.api.event.PlayerReTagEvent in project CombatLogX by SirBlobman.
the class CombatManager method tag.
@Override
public boolean tag(Player player, LivingEntity enemy, TagType tagType, TagReason tagReason, long customEndMillis) {
Validate.notNull(player, "player must not be null!");
Validate.notNull(tagType, "tagType must not be null!");
Validate.notNull(tagReason, "tagReason must not be null!");
if (player.hasMetadata("NPC")) {
return false;
}
if (failsPreTagEvent(player, enemy, tagType, tagReason)) {
this.plugin.printDebug("The PlayerPreTagEvent was cancelled.");
return false;
}
boolean alreadyInCombat = isInCombat(player);
this.plugin.printDebug("Previous Combat Status: " + alreadyInCombat);
PluginManager pluginManager = Bukkit.getPluginManager();
if (alreadyInCombat) {
PlayerReTagEvent event = new PlayerReTagEvent(player, enemy, tagType, tagReason, customEndMillis);
pluginManager.callEvent(event);
if (event.isCancelled()) {
return false;
}
customEndMillis = event.getEndTime();
} else {
PlayerTagEvent event = new PlayerTagEvent(player, enemy, tagType, tagReason, customEndMillis);
pluginManager.callEvent(event);
customEndMillis = event.getEndTime();
sendTagMessage(player, enemy, tagType, tagReason);
}
UUID uuid = player.getUniqueId();
this.combatMap.put(uuid, customEndMillis);
if (enemy != null) {
this.enemyMap.put(uuid, enemy);
}
String playerName = player.getName();
this.plugin.printDebug("Successfully put player '" + playerName + "' into combat.");
return true;
}
Aggregations