mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Static Abuse Cleanup - EventUtils -> EventManager
This commit is contained in:
parent
fc9942fdc4
commit
4c4732695b
@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,7 +35,7 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
pluginRef.getEventManager().tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -40,7 +40,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
|
pluginRef.getEventManager().tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -137,7 +137,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.tryLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
|
pluginRef.getEventManager().tryLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||||
|
@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
@ -93,7 +93,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Commencing", warmup));
|
teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Commencing", warmup));
|
||||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(pluginRef, 20 * warmup);
|
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(pluginRef, 20 * warmup);
|
||||||
} else {
|
} else {
|
||||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
pluginRef.getEventManager().handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.datatypes.party;
|
package com.gmail.nossr50.datatypes.party;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
@ -203,7 +203,7 @@ public class Party {
|
|||||||
* @param xp Experience amount to add
|
* @param xp Experience amount to add
|
||||||
*/
|
*/
|
||||||
public void applyXpGain(double xp) {
|
public void applyXpGain(double xp) {
|
||||||
if (!EventUtils.handlePartyXpGainEvent(this, xp)) {
|
if (!pluginRef.getEventManager().handlePartyXpGainEvent(this, xp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ public class Party {
|
|||||||
levelsGained++;
|
levelsGained++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
|
if (!pluginRef.getEventManager().handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
|||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||||
@ -581,7 +581,7 @@ public class McMMOPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleXpGainEvent(player, primarySkillType, xp, xpGainReason)) {
|
if (!pluginRef.getEventManager().handleXpGainEvent(player, primarySkillType, xp, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ public class McMMOPlayer {
|
|||||||
levelsGained++;
|
levelsGained++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EventUtils.tryLevelChangeEvent(player, primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
if (pluginRef.getEventManager().tryLevelChangeEvent(player, primarySkillType, levelsGained, xpRemoved, true, xpGainReason)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +867,7 @@ public class McMMOPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
if (pluginRef.getEventManager().callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||||
@ -59,14 +59,14 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
EntityDamageEvent entityDamageEvent = (EntityDamageEvent) event;
|
EntityDamageEvent entityDamageEvent = (EntityDamageEvent) event;
|
||||||
|
|
||||||
//Make sure a real player was damaged in this event
|
//Make sure a real player was damaged in this event
|
||||||
if (!EventUtils.isRealPlayerDamaged(entityDamageEvent))
|
if (!pluginRef.getEventManager().isRealPlayerDamaged(entityDamageEvent))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (entityDamageEvent.getCause()) {
|
switch (entityDamageEvent.getCause()) {
|
||||||
case FALL:
|
case FALL:
|
||||||
|
|
||||||
//Grab the player
|
//Grab the player
|
||||||
McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
|
McMMOPlayer mcMMOPlayer = pluginRef.getEventManager().getMcMMOPlayer(entityDamageEvent.getEntity());
|
||||||
|
|
||||||
if (mcMMOPlayer == null)
|
if (mcMMOPlayer == null)
|
||||||
break;
|
break;
|
||||||
|
@ -18,7 +18,7 @@ import com.gmail.nossr50.skills.repair.Repair;
|
|||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -546,15 +546,15 @@ public class BlockListener implements Listener {
|
|||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
||||||
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
|
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||||
} else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
} else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
|
||||||
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||||
blockState.update();
|
blockState.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
} else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (statLossEnabled || (killer != null && vampirismEnabled)) {
|
if (statLossEnabled || (killer != null && vampirismEnabled)) {
|
||||||
if (EventUtils.callPreDeathPenaltyEvent(killedPlayer).isCancelled()) {
|
if (pluginRef.getEventManager().callPreDeathPenaltyEvent(killedPlayer).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +760,7 @@ public class PlayerListener implements Listener {
|
|||||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||||
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
||||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processGreenThumbBlocks(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ public class PlayerListener implements Listener {
|
|||||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processShroomThumb(blockState) && pluginRef.getEventManager().simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private LocaleManager localeManager;
|
private LocaleManager localeManager;
|
||||||
private ChatManager chatManager;
|
private ChatManager chatManager;
|
||||||
private MobHealthBarManager mobHealthBarManager;
|
private MobHealthBarManager mobHealthBarManager;
|
||||||
|
private EventManager eventManager;
|
||||||
|
|
||||||
/* File Paths */
|
/* File Paths */
|
||||||
private String mainDirectory;
|
private String mainDirectory;
|
||||||
@ -181,6 +182,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Put all manager init somewhere nice and tidy
|
||||||
|
|
||||||
//Init Material Maps
|
//Init Material Maps
|
||||||
materialMapStore = new MaterialMapStore();
|
materialMapStore = new MaterialMapStore();
|
||||||
|
|
||||||
@ -195,6 +198,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Init Mob Health Bar Manager
|
//Init Mob Health Bar Manager
|
||||||
mobHealthBarManager = new MobHealthBarManager(this);
|
mobHealthBarManager = new MobHealthBarManager(this);
|
||||||
|
|
||||||
|
//Init Event Manager
|
||||||
|
eventManager = new EventManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -629,4 +635,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public MobHealthBarManager getMobHealthBarManager() {
|
public MobHealthBarManager getMobHealthBarManager() {
|
||||||
return mobHealthBarManager;
|
return mobHealthBarManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EventManager getEventManager() {
|
||||||
|
return eventManager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.runnables.items;
|
package com.gmail.nossr50.runnables.items;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -48,6 +48,6 @@ public class TeleportationWarmup extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
pluginRef.getEventManager().handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.runnables.skills;
|
|||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@ -43,7 +43,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventUtils.callAbilityDeactivateEvent(player, ability);
|
pluginRef.getEventManager().callAbilityDeactivateEvent(player, ability);
|
||||||
|
|
||||||
mcMMOPlayer.setAbilityMode(ability, false);
|
mcMMOPlayer.setAbilityMode(ability, false);
|
||||||
mcMMOPlayer.setAbilityInformed(ability, false);
|
mcMMOPlayer.setAbilityInformed(ability, false);
|
||||||
|
@ -183,7 +183,7 @@ public class FishingManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EventUtils.simulateBlockBreak(block, player, false);
|
return pluginRef.getEventManager().simulateBlockBreak(block, player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +237,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recast in the new spot
|
// Recast in the new spot
|
||||||
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
pluginRef.getEventManager().callFakeFishEvent(getPlayer(), hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void masterAngler(FishHook hook) {
|
public void masterAngler(FishHook hook) {
|
||||||
@ -289,7 +289,7 @@ public class FishingManager extends SkillManager {
|
|||||||
enchants = handleMagicHunter(treasureDrop);
|
enchants = handleMagicHunter(treasureDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
|
McMMOPlayerFishingTreasureEvent event = pluginRef.getEventManager().callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
treasureDrop = event.getTreasure();
|
treasureDrop = event.getTreasure();
|
||||||
|
@ -227,7 +227,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
for (HylianTreasure treasure : treasures) {
|
for (HylianTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()
|
if (skillLevel >= treasure.getDropLevel()
|
||||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(treasure.getDropChance(), getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))) {
|
||||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
if (!pluginRef.getEventManager().simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
|
@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
|||||||
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||||
@ -111,7 +111,7 @@ public class MiningManager extends SkillManager {
|
|||||||
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||||
|
|
||||||
//Blast mining cooldown check needs to be first so the player can be messaged
|
//Blast mining cooldown check needs to be first so the player can be messaged
|
||||||
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true)) {
|
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !pluginRef.getEventManager().simulateBlockBreak(targetBlock, player, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
@ -130,7 +130,7 @@ public class SalvageManager extends SkillManager {
|
|||||||
ItemStack salvageResults = new ItemStack(salvageable.getSalvagedItemMaterial(), lotteryResults);
|
ItemStack salvageResults = new ItemStack(salvageable.getSalvagedItemMaterial(), lotteryResults);
|
||||||
|
|
||||||
//Call event
|
//Call event
|
||||||
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
|
if (pluginRef.getEventManager().callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -95,7 +95,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public void disarmCheck(Player defender) {
|
public void disarmCheck(Player defender) {
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_DISARM, getPlayer()) && !hasIronGrip(defender)) {
|
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_DISARM, getPlayer()) && !hasIronGrip(defender)) {
|
||||||
if (EventUtils.callDisarmEvent(defender).isCancelled()) {
|
if (pluginRef.getEventManager().callDisarmEvent(defender).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
for (BlockState blockState : treeFellerBlocks) {
|
for (BlockState blockState : treeFellerBlocks) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
|
|
||||||
if (!EventUtils.simulateBlockBreak(block, player, true)) {
|
if (!pluginRef.getEventManager().simulateBlockBreak(block, player, true)) {
|
||||||
break; // TODO: Shouldn't we use continue instead?
|
break; // TODO: Shouldn't we use continue instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
|||||||
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
|
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
||||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -53,10 +54,13 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* This class is meant to help make event related code less boilerplate
|
* This class is meant to help make event related code less boilerplate
|
||||||
*/
|
*/
|
||||||
public class EventUtils {
|
public class EventManager {
|
||||||
/*
|
|
||||||
* Quality of Life methods
|
private mcMMO pluginRef;
|
||||||
*/
|
|
||||||
|
public EventManager(mcMMO pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if damage is from natural sources
|
* Checks to see if damage is from natural sources
|
||||||
@ -65,7 +69,7 @@ public class EventUtils {
|
|||||||
* @param event this event
|
* @param event this event
|
||||||
* @return true if damage is NOT from an unnatural mcMMO skill (such as bleed DOTs)
|
* @return true if damage is NOT from an unnatural mcMMO skill (such as bleed DOTs)
|
||||||
*/
|
*/
|
||||||
public static boolean isDamageFromMcMMOComplexBehaviour(Event event) {
|
public boolean isDamageFromMcMMOComplexBehaviour(Event event) {
|
||||||
if (event instanceof FakeEntityDamageEvent) {
|
if (event instanceof FakeEntityDamageEvent) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -78,7 +82,7 @@ public class EventUtils {
|
|||||||
* @param entity target entity
|
* @param entity target entity
|
||||||
* @return the associated McMMOPlayer for this entity
|
* @return the associated McMMOPlayer for this entity
|
||||||
*/
|
*/
|
||||||
public static McMMOPlayer getMcMMOPlayer(Entity entity) {
|
public McMMOPlayer getMcMMOPlayer(Entity entity) {
|
||||||
return UserManager.getPlayer((Player) entity);
|
return UserManager.getPlayer((Player) entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +99,7 @@ public class EventUtils {
|
|||||||
* @param entityDamageEvent
|
* @param entityDamageEvent
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent) {
|
public boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent) {
|
||||||
//Make sure the damage is above 0
|
//Make sure the damage is above 0
|
||||||
double damage = entityDamageEvent.getDamage();
|
double damage = entityDamageEvent.getDamage();
|
||||||
double finalDamage = entityDamageEvent.getFinalDamage();
|
double finalDamage = entityDamageEvent.getFinalDamage();
|
||||||
@ -163,7 +167,7 @@ public class EventUtils {
|
|||||||
* Others
|
* Others
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) {
|
public McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) {
|
||||||
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, skill);
|
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, skill);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -178,7 +182,7 @@ public class EventUtils {
|
|||||||
* @return the event after it has been fired
|
* @return the event after it has been fired
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType) {
|
public SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType) {
|
||||||
SubSkillEvent event = new SubSkillEvent(player, subSkillType);
|
SubSkillEvent event = new SubSkillEvent(player, subSkillType);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -192,20 +196,20 @@ public class EventUtils {
|
|||||||
* @param abstractSubSkill target subskill
|
* @param abstractSubSkill target subskill
|
||||||
* @return the event after it has been fired
|
* @return the event after it has been fired
|
||||||
*/
|
*/
|
||||||
public static SubSkillEvent callSubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) {
|
public SubSkillEvent callSubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) {
|
||||||
SubSkillEvent event = new SubSkillEvent(player, abstractSubSkill);
|
SubSkillEvent event = new SubSkillEvent(player, abstractSubSkill);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callFakeArmSwingEvent(Player player) {
|
public void callFakeArmSwingEvent(Player player) {
|
||||||
FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player);
|
FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) {
|
public boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) {
|
||||||
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
|
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -221,7 +225,7 @@ public class EventUtils {
|
|||||||
return isCancelled;
|
return isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tryLevelEditEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason, int oldLevel) {
|
public boolean tryLevelEditEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason, int oldLevel) {
|
||||||
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged - oldLevel, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
|
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged - oldLevel, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ public class EventUtils {
|
|||||||
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
|
||||||
* @return true if the event wasn't cancelled, false otherwise
|
* @return true if the event wasn't cancelled, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) {
|
public boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) {
|
||||||
PluginManager pluginManager = pluginRef.getServer().getPluginManager();
|
PluginManager pluginManager = pluginRef.getServer().getPluginManager();
|
||||||
|
|
||||||
// Support for NoCheat
|
// Support for NoCheat
|
||||||
@ -262,7 +266,7 @@ public class EventUtils {
|
|||||||
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
|
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
public void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||||
|
|
||||||
if (mcMMOPlayer == null)
|
if (mcMMOPlayer == null)
|
||||||
@ -283,7 +287,7 @@ public class EventUtils {
|
|||||||
mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse();
|
mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handlePartyXpGainEvent(Party party, double xpGained) {
|
public boolean handlePartyXpGainEvent(Party party, double xpGained) {
|
||||||
McMMOPartyXpGainEvent event = new McMMOPartyXpGainEvent(party, xpGained);
|
McMMOPartyXpGainEvent event = new McMMOPartyXpGainEvent(party, xpGained);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -296,7 +300,7 @@ public class EventUtils {
|
|||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handlePartyLevelChangeEvent(Party party, int levelsChanged, double xpRemoved) {
|
public boolean handlePartyLevelChangeEvent(Party party, int levelsChanged, double xpRemoved) {
|
||||||
McMMOPartyLevelUpEvent event = new McMMOPartyLevelUpEvent(party, levelsChanged);
|
McMMOPartyLevelUpEvent event = new McMMOPartyLevelUpEvent(party, levelsChanged);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -311,7 +315,7 @@ public class EventUtils {
|
|||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleXpGainEvent(Player player, PrimarySkillType skill, double xpGained, XPGainReason xpGainReason) {
|
public boolean handleXpGainEvent(Player player, PrimarySkillType skill, double xpGained, XPGainReason xpGainReason) {
|
||||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -325,7 +329,7 @@ public class EventUtils {
|
|||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Double> experienceChanged) {
|
public boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Double> experienceChanged) {
|
||||||
if (UserManager.getPlayer(player) == null)
|
if (UserManager.getPlayer(player) == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -359,7 +363,7 @@ public class EventUtils {
|
|||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean handleVampirismEvent(Player killer, Player victim, HashMap<String, Integer> levelChanged, HashMap<String, Double> experienceChanged) {
|
public boolean handleVampirismEvent(Player killer, Player victim, HashMap<String, Integer> levelChanged, HashMap<String, Double> experienceChanged) {
|
||||||
McMMOPlayerVampirismEvent eventKiller = new McMMOPlayerVampirismEvent(killer, false, levelChanged, experienceChanged);
|
McMMOPlayerVampirismEvent eventKiller = new McMMOPlayerVampirismEvent(killer, false, levelChanged, experienceChanged);
|
||||||
McMMOPlayerVampirismEvent eventVictim = new McMMOPlayerVampirismEvent(victim, true, levelChanged, experienceChanged);
|
McMMOPlayerVampirismEvent eventVictim = new McMMOPlayerVampirismEvent(victim, true, levelChanged, experienceChanged);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(eventKiller);
|
pluginRef.getServer().getPluginManager().callEvent(eventKiller);
|
||||||
@ -409,47 +413,47 @@ public class EventUtils {
|
|||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callAbilityDeactivateEvent(Player player, SuperAbilityType ability) {
|
public void callAbilityDeactivateEvent(Player player, SuperAbilityType ability) {
|
||||||
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkillType.byAbility(ability));
|
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkillType.byAbility(ability));
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map<Enchantment, Integer> enchants) {
|
public McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map<Enchantment, Integer> enchants) {
|
||||||
McMMOPlayerFishingTreasureEvent event = enchants.isEmpty() ? new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp) : new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
|
McMMOPlayerFishingTreasureEvent event = enchants.isEmpty() ? new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp) : new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callFakeFishEvent(Player player, FishHook hook) {
|
public void callFakeFishEvent(Player player, FishHook hook) {
|
||||||
FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING);
|
FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerRepairCheckEvent callRepairCheckEvent(Player player, short durability, ItemStack repairMaterial, ItemStack repairedObject) {
|
public McMMOPlayerRepairCheckEvent callRepairCheckEvent(Player player, short durability, ItemStack repairMaterial, ItemStack repairedObject) {
|
||||||
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, durability, repairMaterial, repairedObject);
|
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, durability, repairMaterial, repairedObject);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerPreDeathPenaltyEvent callPreDeathPenaltyEvent(Player player) {
|
public McMMOPlayerPreDeathPenaltyEvent callPreDeathPenaltyEvent(Player player) {
|
||||||
McMMOPlayerPreDeathPenaltyEvent event = new McMMOPlayerPreDeathPenaltyEvent(player);
|
McMMOPlayerPreDeathPenaltyEvent event = new McMMOPlayerPreDeathPenaltyEvent(player);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerDisarmEvent callDisarmEvent(Player defender) {
|
public McMMOPlayerDisarmEvent callDisarmEvent(Player defender) {
|
||||||
McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender);
|
McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) {
|
public McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) {
|
||||||
McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook);
|
McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook);
|
||||||
pluginRef.getServer().getPluginManager().callEvent(event);
|
pluginRef.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -463,7 +467,7 @@ public class EventUtils {
|
|||||||
* @param textComponent text component used for the message
|
* @param textComponent text component used for the message
|
||||||
* @return the McMMOPlayerNotificationEvent after its been fired
|
* @return the McMMOPlayerNotificationEvent after its been fired
|
||||||
*/
|
*/
|
||||||
public static McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, TextComponent textComponent) {
|
public McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, TextComponent textComponent) {
|
||||||
//Init event
|
//Init event
|
||||||
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), textComponent);
|
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), textComponent);
|
||||||
|
|
||||||
@ -479,7 +483,7 @@ public class EventUtils {
|
|||||||
* @param message string used for the message
|
* @param message string used for the message
|
||||||
* @return the McMMOPlayerNotificationEvent after its been fired
|
* @return the McMMOPlayerNotificationEvent after its been fired
|
||||||
*/
|
*/
|
||||||
public static McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, String message) {
|
public McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, String message) {
|
||||||
//Init event
|
//Init event
|
||||||
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), message);
|
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), message);
|
||||||
|
|
@ -59,7 +59,7 @@ public final class HardcoreManager {
|
|||||||
totalLevelsLost += levelsLost;
|
totalLevelsLost += levelsLost;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleStatsLossEvent(player, levelChanged, experienceChanged)) {
|
if (!pluginRef.getEventManager().handleStatsLossEvent(player, levelChanged, experienceChanged)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public final class HardcoreManager {
|
|||||||
totalLevelsStolen += levelsStolen;
|
totalLevelsStolen += levelsStolen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EventUtils.handleVampirismEvent(killer, victim, levelChanged, experienceChanged)) {
|
if (!pluginRef.getEventManager().handleVampirismEvent(killer, victim, levelChanged, experienceChanged)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
|
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.TextComponentFactory;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
@ -67,7 +67,7 @@ public class NotificationManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
TextComponent textComponent = TextComponentFactory.getNotificationTextComponentFromLocale(key);
|
TextComponent textComponent = TextComponentFactory.getNotificationTextComponentFromLocale(key);
|
||||||
McMMOPlayerNotificationEvent customEvent = EventUtils.createAndCallNotificationEvent(player, notificationType, textComponent);
|
McMMOPlayerNotificationEvent customEvent = pluginRef.getEventManager().createAndCallNotificationEvent(player, notificationType, textComponent);
|
||||||
|
|
||||||
sendNotification(customEvent);
|
sendNotification(customEvent);
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class NotificationManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
TextComponent textComponent = buildTextComponent(key, values);
|
TextComponent textComponent = buildTextComponent(key, values);
|
||||||
McMMOPlayerNotificationEvent customEvent = EventUtils.createAndCallNotificationEvent(player, notificationType, textComponent);
|
McMMOPlayerNotificationEvent customEvent = pluginRef.getEventManager().createAndCallNotificationEvent(player, notificationType, textComponent);
|
||||||
|
|
||||||
sendNotification(customEvent);
|
sendNotification(customEvent);
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ public class NotificationManager {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
|
TextComponent levelUpTextComponent = TextComponentFactory.getNotificationLevelUpTextComponent(skillName, levelsGained, newLevel);
|
||||||
McMMOPlayerNotificationEvent customEvent = EventUtils.createAndCallNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, levelUpTextComponent);
|
McMMOPlayerNotificationEvent customEvent = pluginRef.getEventManager().createAndCallNotificationEvent(mcMMOPlayer.getPlayer(), NotificationType.LEVEL_UP_MESSAGE, levelUpTextComponent);
|
||||||
|
|
||||||
sendNotification(customEvent);
|
sendNotification(customEvent);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,7 +35,7 @@ public class RandomChanceUtil {
|
|||||||
case RANDOM_STATIC_CHANCE:
|
case RANDOM_STATIC_CHANCE:
|
||||||
return checkRandomStaticChanceExecutionSuccess(player, subSkillType);
|
return checkRandomStaticChanceExecutionSuccess(player, subSkillType);
|
||||||
case ALWAYS_FIRES:
|
case ALWAYS_FIRES:
|
||||||
SubSkillEvent event = EventUtils.callSubSkillEvent(player, subSkillType);
|
SubSkillEvent event = pluginRef.getEventManager().callSubSkillEvent(player, subSkillType);
|
||||||
return !event.isCancelled();
|
return !event.isCancelled();
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -487,7 +487,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
EventUtils.callFakeArmSwingEvent(attacker);
|
pluginRef.getEventManager().callFakeArmSwingEvent(attacker);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SWORDS:
|
case SWORDS:
|
||||||
|
Loading…
Reference in New Issue
Block a user