expanding the abstraction (this is going to happen a lot)

This commit is contained in:
nossr50
2019-02-13 09:02:30 -08:00
parent 4461cfacd2
commit 261d571be1
69 changed files with 158 additions and 106 deletions

View File

@ -1,11 +1,17 @@
package com.gmail.nossr50.core;
import com.gmail.nossr50.core.mcmmo.event.EventCommander;
import com.gmail.nossr50.core.mcmmo.plugin.Plugin;
import com.gmail.nossr50.core.mcmmo.server.Server;
import java.util.logging.Logger;
public class McmmoCore {
//TODO: Wire all this stuff
public static Plugin p;
private static EventCommander eventCommander;
private static Server server;
private static Logger logger;
/**
* Returns our Logger
@ -13,6 +19,14 @@ public class McmmoCore {
*/
public static Logger getLogger()
{
return logger;
}
public static EventCommander getEventCommander() {
return eventCommander;
}
public static Server getServer() {
return server;
}
}

View File

@ -1,17 +1,16 @@
package com.gmail.nossr50.core.chat;
import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.core.events.chat.McMMOAdminChatEvent;
public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
protected AdminChatManager() {
super(Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
}
@Override
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync));
handleChat(new McMMOAdminChatEvent(senderName, displayName, message, isAsync));
}
@Override

View File

@ -1,15 +1,14 @@
package com.gmail.nossr50.core.chat;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.events.chat.McMMOChatEvent;
import com.gmail.nossr50.core.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.events.chat.McMMOChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.core.mcmmo.entity.Player;
public abstract class ChatManager {
protected Plugin plugin;
protected boolean useDisplayNames;
protected String chatPrefix;
@ -17,14 +16,13 @@ public abstract class ChatManager {
protected String displayName;
protected String message;
protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) {
this.plugin = plugin;
protected ChatManager(boolean useDisplayNames, String chatPrefix) {
this.useDisplayNames = useDisplayNames;
this.chatPrefix = chatPrefix;
}
protected void handleChat(McMMOChatEvent event) {
plugin.getServer().getPluginManager().callEvent(event);
McmmoCore.getEventCommander().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -147,7 +147,7 @@ public class McMMOPlayer {
}
public void processUnlockNotifications(PrimarySkillType primarySkillType, int skillLevel) {
RankUtils.executeSkillUnlockNotifications(primarySkillType, skillLevel);
RankUtils.executeSkillUnlockNotifications(this, primarySkillType, skillLevel);
}
public void updateXPBar(PrimarySkillType primarySkillType) {

View File

@ -0,0 +1,16 @@
package com.gmail.nossr50.core.events.chat;
import org.bukkit.plugin.Plugin;
/**
* Called when a chat is sent to the admin chat channel
*/
public class McMMOAdminChatEvent extends McMMOChatEvent {
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
super(plugin, sender, displayName, message);
}
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
super(plugin, sender, displayName, message, isAsync);
}
}

View File

@ -0,0 +1,97 @@
package com.gmail.nossr50.core.events.chat;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
public abstract class McMMOChatEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private Plugin plugin;
private String sender;
private String displayName;
private String message;
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) {
this.plugin = plugin;
this.sender = sender;
this.displayName = displayName;
this.message = message;
}
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
super(isAsync);
this.plugin = plugin;
this.sender = sender;
this.displayName = displayName;
this.message = message;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The plugin responsible for this event, note this can be null
*/
public Plugin getPlugin() {
return plugin;
}
/**
* @return String name of the player who sent the chat, or "Console"
*/
public String getSender() {
return sender;
}
/**
* @return String display name of the player who sent the chat, or "Console"
*/
public String getDisplayName() {
return displayName;
}
/**
* @param displayName String display name of the player who sent the chat
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* @return String message that will be sent
*/
public String getMessage() {
return message;
}
/**
* @param message String message to be sent in chat
*/
public void setMessage(String message) {
this.message = message;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,27 @@
package com.gmail.nossr50.core.events.chat;
import org.bukkit.plugin.Plugin;
/**
* Called when a chat is sent to a party channel
*/
public class McMMOPartyChatEvent extends McMMOChatEvent {
private String party;
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) {
super(plugin, sender, displayName, message);
this.party = party;
}
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) {
super(plugin, sender, displayName, message, isAsync);
this.party = party;
}
/**
* @return String name of the party the message will be sent to
*/
public String getParty() {
return party;
}
}

View File

@ -0,0 +1,78 @@
package com.gmail.nossr50.core.events.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Generic event for mcMMO experience events.
*/
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
protected PrimarySkillType skill;
protected int skillLevel;
protected XPGainReason xpGainReason;
private boolean cancelled;
@Deprecated
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
this.xpGainReason = XPGainReason.UNKNOWN;
}
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
this.xpGainReason = xpGainReason;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The skill involved in this event
*/
public PrimarySkillType getSkill() {
return skill;
}
/**
* @return The skill level of the skill involved in this event
*/
public int getSkillLevel() {
return skillLevel;
}
/**
* @return The combat type involved in this event
*/
public XPGainReason getXpGainReason() {
return xpGainReason;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.core.events.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
/**
* Called when a user levels change
*/
public abstract class McMMOPlayerLevelChangeEvent extends McMMOPlayerExperienceEvent {
@Deprecated
public McMMOPlayerLevelChangeEvent(Player player, PrimarySkillType skill) {
super(player, skill, XPGainReason.UNKNOWN);
}
public McMMOPlayerLevelChangeEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.core.events.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* Called when a user loses levels in a skill
*/
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
private static final HandlerList handlers = new HandlerList();
private int levelsLost;
@Deprecated
public McMMOPlayerLevelDownEvent(Player player, PrimarySkillType skill) {
super(player, skill, XPGainReason.UNKNOWN);
this.levelsLost = 1;
}
@Deprecated
public McMMOPlayerLevelDownEvent(Player player, PrimarySkillType skill, int levelsLost) {
super(player, skill, XPGainReason.UNKNOWN);
this.levelsLost = levelsLost;
}
public McMMOPlayerLevelDownEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.levelsLost = 1;
}
public McMMOPlayerLevelDownEvent(Player player, PrimarySkillType skill, int levelsLost, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.levelsLost = levelsLost;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The number of levels lost in this event
*/
public int getLevelsLost() {
return levelsLost;
}
/**
* @param levelsLost Set the number of levels lost in this event
*/
public void setLevelsLost(int levelsLost) {
this.levelsLost = levelsLost;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.core.events.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* Called when a user levels up in a skill
*/
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
private static final HandlerList handlers = new HandlerList();
private int levelsGained;
@Deprecated
public McMMOPlayerLevelUpEvent(Player player, PrimarySkillType skill) {
super(player, skill, XPGainReason.UNKNOWN);
this.levelsGained = 1;
}
@Deprecated
public McMMOPlayerLevelUpEvent(Player player, PrimarySkillType skill, int levelsGained) {
super(player, skill, XPGainReason.UNKNOWN);
this.levelsGained = levelsGained;
}
public McMMOPlayerLevelUpEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.levelsGained = 1;
}
public McMMOPlayerLevelUpEvent(Player player, PrimarySkillType skill, int levelsGained, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.levelsGained = levelsGained;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The number of levels gained in this event
*/
public int getLevelsGained() {
return levelsGained;
}
/**
* @param levelsGained Set the number of levels gained in this event
*/
public void setLevelsGained(int levelsGained) {
this.levelsGained = levelsGained;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,64 @@
package com.gmail.nossr50.core.events.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
/**
* Called when a player gains XP in a skill
*/
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
private static final HandlerList handlers = new HandlerList();
private float xpGained;
@Deprecated
public McMMOPlayerXpGainEvent(Player player, PrimarySkillType skill, float xpGained) {
super(player, skill, XPGainReason.UNKNOWN);
this.xpGained = xpGained;
}
public McMMOPlayerXpGainEvent(Player player, PrimarySkillType skill, float xpGained, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.xpGained = xpGained;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The amount of experience gained in this event
*/
public float getRawXpGained() {
return xpGained;
}
/**
* @param xpGained int amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/**
* @return int amount of experience gained in this event
*/
@Deprecated
public int getXpGained() {
return (int) xpGained;
}
/**
* @param xpGained int amount of experience gained in this event
*/
@Deprecated
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,14 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
/**
* Called when mcMMO breaks a block due to a special ability.
*/
public class FakeBlockBreakEvent extends BlockBreakEvent {
public FakeBlockBreakEvent(Block theBlock, Player player) {
super(theBlock, player);
}
}

View File

@ -0,0 +1,15 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO damages a block due to a special ability.
*/
public class FakeBlockDamageEvent extends BlockDamageEvent {
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
super(player, block, itemInHand, instaBreak);
}
}

View File

@ -0,0 +1,11 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.block.Block;
import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.inventory.BrewerInventory;
public class FakeBrewEvent extends BrewEvent {
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
super(brewer, contents, fuelLevel);
}
}

View File

@ -0,0 +1,35 @@
package com.gmail.nossr50.core.events.fake;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import java.util.EnumMap;
import java.util.Map;
/**
* Called when mcMMO applies damage from an entity due to special abilities.
*/
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
}
@Deprecated
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, double damage) {
super(damager, damagee, cause, damage);
}
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
for (DamageModifier modifier : modifiers.keySet()) {
modifierFunctions.put(modifier, ZERO);
}
return modifierFunctions;
}
}

View File

@ -0,0 +1,35 @@
package com.gmail.nossr50.core.events.fake;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.EnumMap;
import java.util.Map;
/**
* Called when mcMMO applies damage due to special abilities.
*/
public class FakeEntityDamageEvent extends EntityDamageEvent {
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
}
@Deprecated
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
super(damagee, cause, damage);
}
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
for (DamageModifier modifier : modifiers.keySet()) {
modifierFunctions.put(modifier, ZERO);
}
return modifierFunctions;
}
}

View File

@ -0,0 +1,14 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityTameEvent;
/**
* Called when mcMMO tames an animal via Call of the Wild
*/
public class FakeEntityTameEvent extends EntityTameEvent {
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
super(entity, owner);
}
}

View File

@ -0,0 +1,13 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerAnimationEvent;
/**
* Called when handling extra drops to avoid issues with NoCheat.
*/
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
public FakePlayerAnimationEvent(Player player) {
super(player);
}
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.core.events.fake;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
public class FakePlayerFishEvent extends PlayerFishEvent {
public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) {
super(player, entity, hookEntity, state);
}
}

View File

@ -0,0 +1,69 @@
package com.gmail.nossr50.core.events.hardcore;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import java.util.HashMap;
public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private HashMap<String, Integer> levelChanged;
private HashMap<String, Float> experienceChanged;
private boolean cancelled;
public McMMOPlayerDeathPenaltyEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
super(player);
this.levelChanged = levelChanged;
this.experienceChanged = experienceChanged;
this.cancelled = false;
}
@Deprecated
public McMMOPlayerDeathPenaltyEvent(Player player) {
super(player);
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
public HashMap<String, Integer> getLevelChanged() {
return levelChanged;
}
public void setLevelChanged(HashMap<String, Integer> levelChanged) {
this.levelChanged = levelChanged;
}
public HashMap<String, Float> getExperienceChanged() {
return experienceChanged;
}
public void setExperienceChanged(HashMap<String, Float> experienceChanged) {
this.experienceChanged = experienceChanged;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,41 @@
package com.gmail.nossr50.core.events.hardcore;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
public McMMOPlayerPreDeathPenaltyEvent(Player player) {
super(player);
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,12 @@
package com.gmail.nossr50.core.events.hardcore;
import org.bukkit.entity.Player;
import java.util.HashMap;
public class McMMOPlayerStatLossEvent extends McMMOPlayerDeathPenaltyEvent {
public McMMOPlayerStatLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
super(player, levelChanged, experienceChanged);
}
}

View File

@ -0,0 +1,18 @@
package com.gmail.nossr50.core.events.hardcore;
import org.bukkit.entity.Player;
import java.util.HashMap;
public class McMMOPlayerVampirismEvent extends McMMOPlayerDeathPenaltyEvent {
private boolean isVictim;
public McMMOPlayerVampirismEvent(Player player, boolean isVictim, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
super(player, levelChanged, experienceChanged);
this.isVictim = isVictim;
}
public boolean isVictim() {
return isVictim;
}
}

View File

@ -0,0 +1,76 @@
package com.gmail.nossr50.core.events.items;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
/**
* Called when mcMMO is preparing to drop an item.
*/
public class McMMOItemSpawnEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Location location;
private ItemStack itemStack;
private boolean cancelled;
public McMMOItemSpawnEvent(Location location, ItemStack itemStack) {
this.location = location;
this.itemStack = itemStack;
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return Location where the item will be dropped
*/
public Location getLocation() {
return location;
}
/**
* @param location Location where to drop the item
*/
public void setLocation(Location location) {
this.location = location;
}
/**
* @return ItemStack that will be dropped
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* @param itemStack ItemStack to drop
*/
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,93 @@
package com.gmail.nossr50.core.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String oldAlly;
private String newAlly;
private EventReason reason;
private boolean cancelled;
public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) {
super(player);
if (newAlly != null) {
newAlly = newAlly.replace(":", ".");
}
this.oldAlly = oldAlly;
this.newAlly = newAlly;
this.reason = reason;
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The party being left, or null if the player was not in a party
*/
public String getOldAlly() {
return oldAlly;
}
/**
* @return The party being joined, or null if the player is not joining a new party
*/
public String getNewAlly() {
return newAlly;
}
/**
* @return The reason for the event being fired
*/
public EventReason getReason() {
return reason;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/**
* A list of reasons why the event may have been fired
*/
public enum EventReason {
/**
* Formed an alliance for the first time.
*/
FORMED_ALLIANCE,
/**
* Left a party and did not join a new one.
*/
DISBAND_ALLIANCE,
/**
* Any reason that doesn't fit elsewhere.
*/
CUSTOM;
}
}

View File

@ -0,0 +1,106 @@
package com.gmail.nossr50.core.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Called when a player attempts to join, leave, or change parties.
*/
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String oldParty;
private String newParty;
private EventReason reason;
private boolean cancelled;
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
super(player);
if (newParty != null) {
newParty = newParty.replace(":", ".");
}
this.oldParty = oldParty;
this.newParty = newParty;
this.reason = reason;
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The party being left, or null if the player was not in a party
*/
public String getOldParty() {
return oldParty;
}
/**
* @return The party being joined, or null if the player is not joining a new party
*/
public String getNewParty() {
return newParty;
}
/**
* @return The reason for the event being fired
*/
public EventReason getReason() {
return reason;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/**
* A list of reasons why the event may have been fired
*/
public enum EventReason {
/**
* Joined a party for the first time.
*/
JOINED_PARTY,
/**
* Left a party and did not join a new one.
*/
LEFT_PARTY,
/**
* Was kicked from a party.
*/
KICKED_FROM_PARTY,
/**
* Left one party to join another.
*/
CHANGED_PARTIES,
/**
* Any reason that doesn't fit elsewhere.
*/
CUSTOM;
}
}

View File

@ -0,0 +1,56 @@
package com.gmail.nossr50.core.events.party;
import com.gmail.nossr50.core.datatypes.party.Party;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Party party;
private int levelsChanged;
private boolean cancelled;
public McMMOPartyLevelUpEvent(Party party, int levelsChanged) {
this.party = party;
this.levelsChanged = levelsChanged;
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Party getParty() {
return party;
}
public int getLevelsChanged() {
return levelsChanged;
}
public void setLevelsChanged(int levelsChanged) {
this.levelsChanged = levelsChanged;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,46 @@
package com.gmail.nossr50.core.events.party;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerTeleportEvent;
/**
* Called just before a player teleports using the /ptp command.
*/
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String party;
private Player target;
public McMMOPartyTeleportEvent(Player player, Player target, String party) {
super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND);
this.party = party;
this.target = target;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The party the teleporting player is in
*/
public String getParty() {
return party;
}
/**
* @return The player being teleported to
*/
public Player getTarget() {
return target;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,78 @@
package com.gmail.nossr50.core.events.party;
import com.gmail.nossr50.core.datatypes.party.Party;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class McMMOPartyXpGainEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Party party;
private float xpGained;
private boolean cancelled;
public McMMOPartyXpGainEvent(Party party, float xpGained) {
this.party = party;
this.xpGained = xpGained;
this.cancelled = false;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Party getParty() {
return party;
}
/**
* @return The amount of experience gained in this event
*/
public float getRawXpGained() {
return xpGained;
}
/**
* @param xpGained set amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/**
* @return int amount of experience gained in this event
*/
@Deprecated
public int getXpGained() {
return (int) xpGained;
}
/**
* @param xpGained set int amount of experience gained in this event
*/
@Deprecated
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,95 @@
package com.gmail.nossr50.core.events.scoreboard;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.scoreboard.Scoreboard;
/**
* The parent class of all mcMMO scoreboard events
* All scoreboard events will extend from this
*/
abstract public class McMMOScoreboardEvent extends Event {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
final Scoreboard currentBoard; //Can be null
private final ScoreboardEventReason scoreboardEventReason;
protected Scoreboard targetBoard; //Scoreboard involved in this event
protected Player targetPlayer;
/** GETTER & SETTER BOILERPLATE **/
public McMMOScoreboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
this.scoreboardEventReason = scoreboardEventReason;
this.targetBoard = targetBoard;
this.currentBoard = currentBoard;
this.targetPlayer = targetPlayer;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* This is the scoreboard the player will be assigned to after this event
*
* @return the target board to assign the player after this event fires
*/
public Scoreboard getTargetBoard() {
return targetBoard;
}
/**
* Change the scoreboard that the player will be assigned to after this event fires
*
* @param targetBoard the new board to assign the player to
*/
public void setTargetBoard(Scoreboard targetBoard) {
this.targetBoard = targetBoard;
}
/**
* The player involved in this event (this can be changed)
*
* @return the player involved in this event
*/
public Player getTargetPlayer() {
return targetPlayer;
}
/**
* Change the target player for this event
*
* @param targetPlayer the new target for this event
*/
public void setTargetPlayer(Player targetPlayer) {
this.targetPlayer = targetPlayer;
}
/**
* This is the scoreboard the player is currently assigned to at the time the event was fired
* Grabbed via player.getScoreboard()
*
* @return players current scoreboard
*/
public Scoreboard getCurrentBoard() {
return currentBoard;
}
/**
* The ENUM defining the reason for this event
*
* @return the reason for this event
*/
public ScoreboardEventReason getScoreboardEventReason() {
return scoreboardEventReason;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,15 @@
package com.gmail.nossr50.core.events.scoreboard;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
/**
* This event is called when mcMMO creates its custom boards
* You should not interfere with this event unless you understand our board code thoroughly
* mcMMO relies on using new scoreboards to show players individually catered boards with stats specific to them
*/
public class McMMOScoreboardMakeboardEvent extends McMMOScoreboardEvent {
public McMMOScoreboardMakeboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
super(targetBoard, currentBoard, targetPlayer, scoreboardEventReason);
}
}

View File

@ -0,0 +1,53 @@
package com.gmail.nossr50.core.events.scoreboard;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class McMMOScoreboardObjectiveEvent extends McMMOScoreboardEvent implements Cancellable {
protected final ScoreboardObjectiveEventReason objectiveEventReason;
protected boolean cancelled;
protected Objective targetObjective;
public McMMOScoreboardObjectiveEvent(Objective targetObjective, ScoreboardObjectiveEventReason objectiveEventReason, Scoreboard scoreboard, Scoreboard oldboard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
super(scoreboard, oldboard, targetPlayer, scoreboardEventReason);
this.objectiveEventReason = objectiveEventReason;
this.targetObjective = targetObjective;
cancelled = false;
}
/**
* The objective that will be modified by this event
*
* @return
*/
public Objective getTargetObjective() {
return targetObjective;
}
/**
* Change the target objective for this event
*
* @param newObjective new target objective
*/
public void setTargetObjective(Objective newObjective) {
this.targetObjective = newObjective;
}
public ScoreboardObjectiveEventReason getObjectiveEventReason() {
return objectiveEventReason;
}
/* BOILERPLATE FROM INTERFACES */
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean b) {
cancelled = b;
}
}

View File

@ -0,0 +1,14 @@
package com.gmail.nossr50.core.events.scoreboard;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
/**
* This event is called when mcMMO is attempting to change a players targetBoard back to their previous board
* This is used when an mcMMO board is cleared (removed from the screen), changing back from a temporary board (usually from a delayed scheduled task or our mcscoreboard time command)
*/
public class McMMOScoreboardRevertEvent extends McMMOScoreboardEvent {
public McMMOScoreboardRevertEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
super(targetBoard, currentBoard, targetPlayer, scoreboardEventReason);
}
}

View File

@ -0,0 +1,7 @@
package com.gmail.nossr50.core.events.scoreboard;
public enum ScoreboardEventReason {
CREATING_NEW_SCOREBOARD,
OBJECTIVE,
REVERTING_BOARD,
}

View File

@ -0,0 +1,6 @@
package com.gmail.nossr50.core.events.scoreboard;
public enum ScoreboardObjectiveEventReason {
UNREGISTER_THIS_OBJECTIVE,
REGISTER_NEW_OBJECTIVE,
}

View File

@ -0,0 +1,99 @@
package com.gmail.nossr50.core.events.skills;
import com.gmail.nossr50.core.datatypes.interactions.NotificationType;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* This event is sent for when mcMMO informs a player about various important information
*/
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
protected final NotificationType notificationType;
protected ChatMessageType chatMessageType;
protected TextComponent notificationTextComponent;
private boolean isCancelled;
/*
* Messages can be sent to both places, as configured in advanced.yml
* If isBeingSentToActionBar is false, then messages will ALWAYS be sent to the chat bar
* isMessageAlsoBeingSentToChat just indicates a copy of that message will be sent to chat
*/
private boolean isMessageAlsoBeingSentToChat;
public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) {
super(who);
this.notificationType = notificationType;
this.notificationTextComponent = notificationTextComponent;
this.chatMessageType = chatMessageType;
this.isMessageAlsoBeingSentToChat = isMessageAlsoBeingSentToChat;
isCancelled = false;
}
/*
* Getters & Setters
*/
public static HandlerList getHandlerList() {
return handlers;
}
public boolean isMessageAlsoBeingSentToChat() {
return isMessageAlsoBeingSentToChat;
}
public void setMessageAlsoBeingSentToChat(boolean messageAlsoBeingSentToChat) {
isMessageAlsoBeingSentToChat = messageAlsoBeingSentToChat;
}
public TextComponent getNotificationTextComponent() {
return notificationTextComponent;
}
public void setNotificationTextComponent(TextComponent notificationTextComponent) {
this.notificationTextComponent = notificationTextComponent;
}
public ChatMessageType getChatMessageType() {
return chatMessageType;
}
public void setChatMessageType(ChatMessageType chatMessageType) {
this.chatMessageType = chatMessageType;
}
/*
* Custom Event Boilerplate
*/
/**
* The notification type for this event
*
* @return this event's notification type
*/
public NotificationType getEventNotificationType() {
return notificationType;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/*
* Cancellable Interface Boilerplate
*/
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean b) {
isCancelled = b;
}
}

View File

@ -0,0 +1,48 @@
package com.gmail.nossr50.core.events.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Generic event for mcMMO skill handling.
*/
public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
protected PrimarySkillType skill;
protected int skillLevel;
protected McMMOPlayerSkillEvent(Player player, PrimarySkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @return The skill involved in this event
*/
public PrimarySkillType getSkill() {
return skill;
}
/**
* @return The level of the skill involved in this event
*/
public int getSkillLevel() {
return skillLevel;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,22 @@
package com.gmail.nossr50.core.events.skills.abilities;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
private boolean cancelled;
public McMMOPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) {
super(player, skill);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean value) {
this.cancelled = value;
}
}

View File

@ -0,0 +1,10 @@
package com.gmail.nossr50.core.events.skills.abilities;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
public McMMOPlayerAbilityDeactivateEvent(Player player, PrimarySkillType skill) {
super(player, skill);
}
}

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.core.events.skills.abilities;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
private SuperAbilityType ability;
protected McMMOPlayerAbilityEvent(Player player, PrimarySkillType skill) {
super(player, skill);
ability = skill.getAbility();
}
public SuperAbilityType getAbility() {
return ability;
}
}

View File

@ -0,0 +1,37 @@
package com.gmail.nossr50.core.events.skills.alchemy;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerBrewEvent extends McMMOPlayerSkillEvent implements Cancellable {
private BlockState brewingStand;
private boolean cancelled;
public McMMOPlayerBrewEvent(Player player, BlockState brewingStand) {
super(player, PrimarySkillType.ALCHEMY);
this.brewingStand = brewingStand;
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public Block getBrewingStandBlock() {
return brewingStand.getBlock();
}
public BrewingStand getBrewingStand() {
return (BrewingStand) brewingStand;
}
}

View File

@ -0,0 +1,34 @@
package com.gmail.nossr50.core.events.skills.alchemy;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerCatalysisEvent extends McMMOPlayerSkillEvent implements Cancellable {
private double speed;
private boolean cancelled;
public McMMOPlayerCatalysisEvent(Player player, double speed) {
super(player, PrimarySkillType.ALCHEMY);
this.speed = speed;
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
}

View File

@ -0,0 +1,23 @@
package com.gmail.nossr50.core.events.skills.fishing;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerFishingEvent(Player player) {
super(player, PrimarySkillType.FISHING);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@ -0,0 +1,31 @@
package com.gmail.nossr50.core.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
private ItemStack treasure;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player);
this.treasure = treasure;
this.xp = xp;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
}

View File

@ -0,0 +1,20 @@
package com.gmail.nossr50.core.events.skills.fishing;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Map;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private Map<Enchantment, Integer> enchants;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
super(player, treasure, xp);
this.enchants = enchants;
}
public Map<Enchantment, Integer> getEnchantments() {
return enchants;
}
}

View File

@ -0,0 +1,21 @@
package com.gmail.nossr50.core.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
private ItemStack drop;
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
super(player);
this.drop = drop;
}
public ItemStack getDrop() {
return drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.core.events.skills.repair;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
/**
* Called just before a player repairs an object with mcMMO.
*/
public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implements Cancellable {
private short repairAmount;
private ItemStack repairMaterial;
private ItemStack repairedObject;
private boolean cancelled;
public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) {
super(player, PrimarySkillType.REPAIR);
this.repairAmount = repairAmount;
this.repairMaterial = repairMaterial;
this.repairedObject = repairedObject;
this.cancelled = false;
}
/**
* @return The amount this item will be repaired.
*/
public short getRepairAmount() {
return repairAmount;
}
/**
* @return The material used to repair this item
*/
public ItemStack getRepairMaterial() {
return repairMaterial;
}
/**
* @return The item that was repaired
*/
public ItemStack getRepairedObject() {
return repairedObject;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.core.events.skills.salvage;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
/**
* Called just before a player salvages an item with mcMMO.
*/
public class McMMOPlayerSalvageCheckEvent extends McMMOPlayerSkillEvent implements Cancellable {
private ItemStack salvageItem;
private ItemStack salvageResults;
private ItemStack enchantedBook;
private boolean cancelled;
public McMMOPlayerSalvageCheckEvent(Player player, ItemStack salvageItem, ItemStack salvageResults, ItemStack enchantedBook) {
super(player, PrimarySkillType.SALVAGE);
this.salvageItem = salvageItem;
this.salvageResults = salvageResults;
this.enchantedBook = enchantedBook;
this.cancelled = false;
}
/**
* @return The item that should get salvaged.
*/
public ItemStack getSalvageItem() {
return salvageItem;
}
/**
* @return The results that should be dropped after salvaging.
*/
public ItemStack getSalvageResults() {
return salvageResults;
}
/**
* @return The enchanted book that should drop after salvaging or null if no book should be dropped.
*/
public ItemStack getEnchantedBook() {
return enchantedBook;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.core.events.skills.secondaryabilities;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable {
private SubSkillType subSkillType;
private boolean cancelled = false;
/**
* Only skills using the old system will fire this event
*
* @param player target player
* @param subSkillType target subskill
* @Deprecated Skills will be using a new system stemming from the AbstractSubSkill class so make sure you check for both events, this event will be removed eventually.
*/
@Deprecated
public SubSkillEvent(Player player, SubSkillType subSkillType) {
super(player, PrimarySkillType.bySecondaryAbility(subSkillType));
this.subSkillType = subSkillType;
}
public SubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) {
super(player, abstractSubSkill.getPrimarySkill());
}
/**
* Gets the SubSkillType involved in the event
*
* @return the SubSkillType
*/
public SubSkillType getSubSkillType() {
return subSkillType;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@ -0,0 +1,46 @@
package com.gmail.nossr50.core.events.skills.secondaryabilities;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import org.bukkit.entity.Player;
public class SubSkillRandomCheckEvent extends SubSkillEvent {
private double chance;
public SubSkillRandomCheckEvent(Player player, SubSkillType ability, double chance) {
super(player, ability);
this.chance = chance;
}
public SubSkillRandomCheckEvent(Player player, AbstractSubSkill abstractSubSkill, double chance) {
super(player, abstractSubSkill);
this.chance = chance;
}
/**
* Gets the activation chance of the ability 0D being no chance, 100.0D being 100% chance
*
* @return The activation chance of the ability
*/
public double getChance() {
return chance;
}
/**
* Sets the activation chance of the ability [0D-100.0D]
*
* @param chance The activation chance of the ability
*/
public void setChance(double chance) {
this.chance = chance;
}
/**
* Sets the activation chance of the ability to 100% or 0%
*
* @param success whether it should be successful or not
*/
public void setSuccessful(boolean success) {
this.chance = success ? 100.0D : 0D;
}
}

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.core.events.skills.unarmed;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.events.skills.McMMOPlayerSkillEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
private Player defender;
public McMMOPlayerDisarmEvent(Player defender) {
super(defender, PrimarySkillType.UNARMED);
this.defender = defender;
}
public Player getDefender() {
return defender;
}
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -25,6 +25,6 @@ public enum Color {
Color fromRGB(int r, int g, int b)
{
//TODO: Figure this out later
}
}

View File

@ -4,11 +4,12 @@ import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.mcmmo.Nameable;
import com.gmail.nossr50.core.mcmmo.inventory.InventoryHolder;
import com.gmail.nossr50.core.mcmmo.item.ItemStack;
import com.gmail.nossr50.core.mcmmo.permissions.Permissible;
/**
* Players
*/
public interface Player extends Living, Nameable, InventoryHolder {
public interface Player extends Living, Nameable, InventoryHolder, Permissible {
/**
* Players are not always online

View File

@ -4,5 +4,5 @@ package com.gmail.nossr50.core.mcmmo.entity;
* Represents an entity that can be tamed
*/
public interface Tameable extends Living {
}

View File

@ -0,0 +1,10 @@
package com.gmail.nossr50.core.mcmmo.event;
public interface EventCommander {
/**
* Calls an event
* @param event the event to call
* @return the event after it has been passed around
*/
Event callEvent(Event event);
}

View File

@ -0,0 +1,13 @@
package com.gmail.nossr50.core.mcmmo.permissions;
/**
* A thing that can have Permissions is a Permissible
*/
public interface Permissible {
/**
* Returns whether or not this Permissible has this permission
* @param path the permission nodes full path
* @return true if the permissible has this permission
*/
boolean hasPermission(String path);
}

View File

@ -0,0 +1,27 @@
package com.gmail.nossr50.core.mcmmo.server;
import com.gmail.nossr50.core.mcmmo.entity.Player;
import com.gmail.nossr50.core.mcmmo.world.World;
/**
* Represents the server and its state
*/
public interface Server {
/**
* Broadcasts a msg to every player on the server
* @param msg the message to broadcast
*/
void broadcast(String msg);
/**
* Gets the online players for this server
* @return the online players for this server
*/
Player[] getOnlinePlayers();
/**
* Gets the worlds for this server
* @return the worlds for this server
*/
World[] getWorlds();
}

View File

@ -1,11 +1,13 @@
package com.gmail.nossr50.core.skills;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.core.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.mcmmo.colors.Color;
import com.gmail.nossr50.core.mcmmo.entity.Entity;
import com.gmail.nossr50.core.mcmmo.entity.Player;
import com.gmail.nossr50.core.mcmmo.entity.Tameable;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.skills.child.smelting.SmeltingManager;
import com.gmail.nossr50.core.skills.primary.acrobatics.AcrobaticsManager;
@ -26,9 +28,6 @@ import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import java.util.ArrayList;
import java.util.Collections;
@ -120,7 +119,7 @@ public enum PrimarySkillType {
}
if (!skillName.equalsIgnoreCase("all")) {
mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
McmmoCore.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
}
return null;

View File

@ -1,12 +1,11 @@
package com.gmail.nossr50.core.skills;
import com.gmail.nossr50.core.config.Config;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.core.mcmmo.block.BlockState;
import com.gmail.nossr50.core.mcmmo.entity.Player;
import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
public enum SuperAbilityType {
BERSERK(

View File

@ -1,20 +1,12 @@
package com.gmail.nossr50.core.util;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.core.mcmmo.permissions.Permissible;
import com.gmail.nossr50.core.mcmmo.world.World;
import com.gmail.nossr50.core.skills.ItemType;
import com.gmail.nossr50.core.skills.MaterialType;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
public final class Permissions {
private Permissions() {