use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ExpansionManager method enableExpansion.
public void enableExpansion(Expansion expansion) {
State state = expansion.getState();
if (state == State.ENABLED)
return;
ICombatLogX plugin = getPlugin();
Logger logger = plugin.getLogger();
try {
ExpansionDescription description = expansion.getDescription();
String fullName = description.getFullName();
logger.info("Enabling expansion '" + fullName + "'...");
expansion.setState(State.ENABLED);
expansion.onEnable();
} catch (Exception ex) {
logger.log(Level.SEVERE, "An error occurred while enabling an expansion:", ex);
}
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ExpansionManager method disableExpansion.
public void disableExpansion(Expansion expansion) {
State state = expansion.getState();
if (state != State.ENABLED)
return;
ICombatLogX plugin = getPlugin();
Logger logger = plugin.getLogger();
try {
ExpansionDescription description = expansion.getDescription();
String fullName = description.getFullName();
logger.info("Disabling expansion '" + fullName + "'...");
List<Listener> listenerList = expansion.getListeners();
listenerList.forEach(HandlerList::unregisterAll);
listenerList.clear();
expansion.setState(State.DISABLED);
expansion.onDisable();
} catch (Exception ex) {
logger.log(Level.SEVERE, "An error occurred while enabling an expansion:", ex);
}
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class RegionExpansion method onEnable.
@Override
public final void onEnable() {
ICombatLogX plugin = getPlugin();
if (!checkDependencies()) {
Logger logger = getLogger();
logger.info("Some dependencies for this expansion are missing!");
ExpansionManager expansionManager = plugin.getExpansionManager();
expansionManager.disableExpansion(this);
return;
}
new RegionMoveListener(this).register();
new RegionVulnerableListener(this).register();
this.enabledSuccessfully = true;
afterEnable();
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class RegionHandler method sendEntryDeniedMessage.
public final void sendEntryDeniedMessage(Player player, LivingEntity enemy) {
if (player == null)
return;
TagType tagType = getTagType(enemy);
String messagePath = getEntryDeniedMessagePath(tagType);
if (messagePath == null)
return;
UUID playerId = player.getUniqueId();
if (this.cooldownMap.containsKey(playerId)) {
long expireMillis = this.cooldownMap.getOrDefault(playerId, 0L);
long systemMillis = System.currentTimeMillis();
if (systemMillis < expireMillis)
return;
}
ICombatLogX plugin = this.expansion.getPlugin();
String message = plugin.getMessageWithPrefix(player, messagePath, null, true);
plugin.sendMessage(player, message);
long cooldownSeconds = getEntryDeniedMessageCooldown();
long cooldownMillis = TimeUnit.SECONDS.toMillis(cooldownSeconds);
long systemMillis = System.currentTimeMillis();
long expireMillis = (systemMillis + cooldownMillis);
this.cooldownMap.put(playerId, expireMillis);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class RegionMoveListener method onMove.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) {
Location toLocation = e.getTo();
if (toLocation == null) {
return;
}
Player player = e.getPlayer();
ICombatLogX combatLogX = getCombatLogX();
ICombatManager combatManager = combatLogX.getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
LivingEntity enemy = combatManager.getEnemy(player);
TagType tagType = getTagType(enemy);
RegionHandler regionHandler = getRegionHandler();
if (regionHandler.isSafeZone(player, toLocation, tagType)) {
Location fromLocation = e.getFrom();
if (!regionHandler.isSafeZone(player, fromLocation, tagType)) {
regionHandler.preventEntry(e, player, fromLocation, toLocation);
}
}
}
Aggregations