mcMMO now supports WorldGuard, added "mcmmo" and "mcmmo-xp" flags!

This commit is contained in:
nossr50 2019-01-22 16:40:54 -08:00
parent c0dde01f3e
commit 0ad1530505
10 changed files with 377 additions and 24 deletions

View File

@ -18,6 +18,7 @@ Version 2.1.0
+ Certain elements of mcMMO's UI have been restyled
+ Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
+ You can now disable mcMMO completely for specific worlds via world_blacklist.txt in /plugins/mcMMO/
+ (WorldGuard) mcMMO now supports worldguard, you can use the flags "mcmmo" and "mcmmo-xp" on regions (they default to on unless otherwise specified)
! (Scoreboards) Scoreboards are now disabled by default, I don't like them. You can turn them back on in config.yml
+ (Sounds) Rolling now plays a sound (Graceful Roll has a different sound :) )
+ (Sounds) Activating Super abilities plays a sound (other plays can hear this)

View File

@ -0,0 +1,9 @@
package com.gmail.nossr50;
import com.sk89q.worldguard.protection.flags.StateFlag;
public class WorldGuardFlags {
// StateFlag with the name "my-custom-flag", which defaults to "allow"
public static final StateFlag MCMMO_ENABLE_WG_FLAG = new StateFlag("mcmmo", true);
public static final StateFlag MCMMO_XP_WG_FLAG = new StateFlag("mcmmo-xp", true);
}

View File

@ -1,39 +1,87 @@
package com.gmail.nossr50;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import static org.bukkit.Bukkit.getServer;
public class WorldGuardManager {
// StateFlag with the name "my-custom-flag", which defaults to "allow"
public static final Flag MCMMO_DISABLE_WG_FLAG = new StateFlag("mcmmo-off", false);
public static final Flag MCMMO_XPOFF_WG_FLAG = new StateFlag("mcmmo-noxp", false);
private static WorldGuardPlugin worldGuardPlugin;
private static WorldGuardManager instance;
private Plugin worldGuardPluginRef;
private boolean flagsRegistered = false;
/*public static boolean isWgFlagActive(Location location)
public WorldGuardManager()
{
instance = this;
init();
}
public void init()
{
if(getWorldGuard() != null)
{
worldGuardPluginRef = getWorldGuard();
registerFlags();
}
}
public boolean hasMainFlag(Player player)
{
BukkitPlayer localPlayer = BukkitAdapter.adapt(player);
com.sk89q.worldedit.util.Location loc = localPlayer.getLocation();
if(flagsRegistered)
{
if(getWorldGuard() != null)
{
WorldGuardPlugin worldGuard = getWorldGuard();
//WorldGuardPlugin worldGuard = getWorldGuard();
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions();
//ApplicableRegionSet set = query.getApplicableRegions(loc);
*//* if (!query.testState(location, (LocalPlayer)null, MCMMO_DISABLE_WG_FLAG)) {
// Can't build
}*//*
return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
}
}
//Return False if these fail
mcMMO.p.getLogger().severe("Failed to detect WG flags, is WG running properly?");
return false;
}
private static WorldGuardPlugin getWorldGuard() {
if(worldGuardPlugin != null)
return worldGuardPlugin;
public boolean hasXPFlag(Player player)
{
BukkitPlayer localPlayer = BukkitAdapter.adapt(player);
com.sk89q.worldedit.util.Location loc = localPlayer.getLocation();
if(flagsRegistered)
{
if(getWorldGuard() != null)
{
//WorldGuardPlugin worldGuard = getWorldGuard();
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
//ApplicableRegionSet set = query.getApplicableRegions(loc);
return query.testState(loc, WorldGuardPlugin.inst().wrapPlayer(player), WorldGuardFlags.MCMMO_XP_WG_FLAG);
}
}
//Return False if these fail
mcMMO.p.getLogger().severe("Failed to detect WG flags, is WG running properly?");
return false;
}
private WorldGuardPlugin getWorldGuard() {
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
// WorldGuard may not be loaded
@ -41,11 +89,10 @@ public class WorldGuardManager {
return null; // Maybe you want throw an exception instead
}
worldGuardPlugin = (WorldGuardPlugin) plugin;
return worldGuardPlugin;
return (WorldGuardPlugin) plugin;
}
private static void registerFlags()
private void registerFlags()
{
if(getWorldGuard() == null)
return;
@ -53,7 +100,8 @@ public class WorldGuardManager {
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
// register our flag with the registry
registry.register(MCMMO_DISABLE_WG_FLAG);
registry.register(WorldGuardFlags.MCMMO_ENABLE_WG_FLAG);
registry.register(WorldGuardFlags.MCMMO_XP_WG_FLAG);
flagsRegistered = true;
} catch (FlagConflictException e) {
e.printStackTrace();
@ -62,5 +110,9 @@ public class WorldGuardManager {
// could cause issues with saved flags in region files. it's better
// to print a message to let the server admin know of the conflict
}
}*/
}
public static WorldGuardManager getInstance() {
return instance;
}
}

View File

@ -0,0 +1,25 @@
package com.gmail.nossr50;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import org.bukkit.plugin.Plugin;
import static org.bukkit.Bukkit.getServer;
public class WorldGuardUtils {
public static boolean isWorldGuardLoaded()
{
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
try {
// WorldGuard may not be loaded
if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
return false; // Maybe you want throw an exception instead
}
} catch (Exception e) {
//Silently Fail
mcMMO.p.getLogger().severe("Failed to detect worldguard.");
}
return true;
}
}

View File

@ -1,6 +1,9 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
@ -41,6 +44,17 @@ public class PtpCommand implements TabExecutor {
Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return true;
}
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true;
if (!UserManager.hasPlayerDataKey(player)) {
return true;
}

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldBlacklist;
@ -241,6 +243,13 @@ public class BlockListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockBreakEvent) {
return;
}
@ -326,6 +335,13 @@ public class BlockListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockBreakEvent) {
return;
}
@ -382,6 +398,13 @@ public class BlockListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockDamageEvent) {
return;
}
@ -452,6 +475,13 @@ public class BlockListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockDamageEvent) {
return;
}

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
@ -58,6 +60,18 @@ public class EntityListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
Entity projectile = event.getProjectile();
if (!(projectile instanceof Arrow)) {
@ -80,6 +94,18 @@ public class EntityListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
Projectile projectile = event.getEntity();
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) {
@ -163,6 +189,18 @@ public class EntityListener implements Listener {
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
if(attacker instanceof Player)
{
Player player = (Player) attacker;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
if (damage <= 0) {
if (defender instanceof Player && attacker instanceof Player) {
Player defendingPlayer = (Player) defender;
@ -284,6 +322,17 @@ public class EntityListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
/*
* Process Registered Interactions
*/
@ -351,6 +400,17 @@ public class EntityListener implements Listener {
Tameable pet = (Tameable) livingEntity;
AnimalTamer owner = pet.getOwner();
if(owner instanceof Player)
{
Player player = (Player) owner;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
if (Taming.canPreventDamage(pet, owner)) {
Player player = (Player) owner;
Wolf wolf = (Wolf) pet;
@ -533,6 +593,13 @@ public class EntityListener implements Listener {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
@ -566,6 +633,13 @@ public class EntityListener implements Listener {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
@ -615,6 +689,13 @@ public class EntityListener implements Listener {
Player player = (Player) entity;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@ -709,6 +790,14 @@ public class EntityListener implements Listener {
}
Player player = (Player) event.getOwner();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
@ -739,6 +828,14 @@ public class EntityListener implements Listener {
}
Player player = (Player) target;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
Tameable tameable = (Tameable) entity;
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -95,6 +97,13 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
return;
}
@ -117,6 +126,13 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) {
return;
}
@ -138,6 +154,13 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return;
}
@ -171,6 +194,14 @@ public class InventoryListener implements Listener {
}
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
BrewingStand stand = (BrewingStand) holder;
ItemStack clicked = event.getCurrentItem();
ItemStack cursor = event.getCursor();
@ -283,6 +314,13 @@ public class InventoryListener implements Listener {
if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
@ -377,6 +415,15 @@ public class InventoryListener implements Listener {
return;
}
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
}

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager;
@ -66,6 +68,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || Config.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
return;
}
@ -90,6 +99,13 @@ public class PlayerListener implements Listener {
String deathMessage = event.getDeathMessage();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getEntity()))
return;
}
if (deathMessage == null) {
return;
}
@ -129,6 +145,13 @@ public class PlayerListener implements Listener {
Player killer = killedPlayer.getKiller();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(killedPlayer))
return;
}
if (statLossEnabled || (killer != null && vampirismEnabled)) {
if (EventUtils.callPreDeathPenaltyEvent(killedPlayer).isCancelled()) {
return;
@ -182,6 +205,13 @@ public class PlayerListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack();
@ -208,6 +238,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
@ -267,6 +304,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
@ -312,6 +356,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
@ -433,6 +484,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
@ -529,6 +587,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
@ -657,10 +722,6 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) {

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.WorldGuardManager;
import com.gmail.nossr50.WorldGuardUtils;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -68,6 +70,21 @@ public class SelfListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill();
//WorldGuard XP Check
if(event.getXpGainReason() == XPGainReason.PVE ||
event.getXpGainReason() == XPGainReason.PVP ||
event.getXpGainReason() == XPGainReason.SHARED_PVE ||
event.getXpGainReason() == XPGainReason.SHARED_PVP)
{
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasXPFlag(player))
event.setRawXpGained(0);
event.setCancelled(true);
}
}
if (event.getXpGainReason() == XPGainReason.COMMAND)
{
return;