Fixing Java naming conventions for constants in mcMMO.java also added

some Javadocs
This commit is contained in:
nossr50 2019-05-03 23:39:49 -07:00
parent 8a312da0f5
commit a919c45b09
24 changed files with 146 additions and 121 deletions

View File

@ -102,11 +102,11 @@ public class McrankCommand implements TabExecutor {
return; return;
} }
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) { if (((Player) sender).hasMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return; return;
} else { } else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mcMMOPlayer.actualizeDatabaseATS();

View File

@ -100,11 +100,11 @@ public class MctopCommand implements TabExecutor {
return; return;
} }
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) { if (((Player) sender).hasMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return; return;
} else { } else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null)); ((Player) sender).setMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
} }
mcMMOPlayer.actualizeDatabaseATS(); mcMMOPlayer.actualizeDatabaseATS();

View File

@ -63,9 +63,9 @@ public class BlockListener implements Listener {
continue; continue;
//TODO: Should just store the amount of drops in the metadata itself and use a loop //TODO: Should just store the amount of drops in the metadata itself and use a loop
if (event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0) { if (event.getBlock().getState().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().removeMetadata(mcMMO.doubleDrops, plugin); event.getBlock().getState().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
} else if (event.getBlock().getState().getMetadata(mcMMO.tripleDrops).size() > 0) { } else if (event.getBlock().getState().getMetadata(mcMMO.tripleDrops).size() > 0) {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
@ -81,9 +81,9 @@ public class BlockListener implements Listener {
{ {
ItemStack is = new ItemStack(item.getItemStack()); ItemStack is = new ItemStack(item.getItemStack());
if(event.getBlock().getMetadata(mcMMO.doubleDrops).size() > 0) if(event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0)
{ {
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops); List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY);
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0); BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value(); Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
@ -93,7 +93,7 @@ public class BlockListener implements Listener {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
} }
event.getBlock().removeMetadata(mcMMO.doubleDrops, plugin); event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
} else { } else {
if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) { if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) {
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops); List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops);
@ -119,9 +119,9 @@ public class BlockListener implements Listener {
{ {
ItemStack is = new ItemStack(item.getItemStack()); ItemStack is = new ItemStack(item.getItemStack());
if(event.getBlock().getMetadata(mcMMO.doubleDrops).size() > 0) if(event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0)
{ {
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops); List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY);
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0); BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value(); Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
@ -131,7 +131,7 @@ public class BlockListener implements Listener {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
} }
event.getBlock().removeMetadata(mcMMO.doubleDrops, plugin); event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
} else { } else {
if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) { if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) {
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops); List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops);
@ -525,7 +525,7 @@ public class BlockListener implements Listener {
} }
private Player getPlayerFromFurnace(Block furnaceBlock) { private Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey); List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY);
if (metadata.isEmpty()) { if (metadata.isEmpty()) {
return null; return null;
@ -644,7 +644,7 @@ public class BlockListener implements Listener {
if (blockState instanceof Furnace) { if (blockState instanceof Furnace) {
Furnace furnace = (Furnace) blockState; Furnace furnace = (Furnace) blockState;
if (furnace.hasMetadata(mcMMO.furnaceMetadataKey)) { if (furnace.hasMetadata(mcMMO.FURNACE_TRACKING_METAKEY)) {
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner"); player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock()); Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock());
if (furnacePlayer != null) { if (furnacePlayer != null) {

View File

@ -54,9 +54,9 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onEntityTransform(EntityTransformEvent event) { public void onEntityTransform(EntityTransformEvent event) {
//Transfer metadata keys from mob-spawned mobs to new mobs //Transfer metadata keys from mob-spawned mobs to new mobs
if (event.getEntity().getMetadata(mcMMO.entityMetadataKey) != null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() >= 1) { if (event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY) != null || event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY).size() >= 1) {
for (Entity entity : event.getTransformedEntities()) { for (Entity entity : event.getTransformedEntities()) {
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
} }
} }
} }
@ -68,8 +68,8 @@ public class EntityListener implements Listener {
//Prevent entities from giving XP if they target endermite //Prevent entities from giving XP if they target endermite
if (event.getTarget() instanceof Endermite) { if (event.getTarget() instanceof Endermite) {
if (event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0) if (event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY) == null || event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY).size() <= 0)
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); event.getEntity().setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
} }
} }
@ -98,11 +98,11 @@ public class EntityListener implements Listener {
ItemStack bow = event.getBow(); ItemStack bow = event.getBow();
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue); projectile.setMetadata(mcMMO.INFINITE_ARROW_METAKEY, mcMMO.metadataValue);
} }
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0))); projectile.setMetadata(mcMMO.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation())); projectile.setMetadata(mcMMO.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -123,12 +123,12 @@ public class EntityListener implements Listener {
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) { if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.BOW_FORCE_METAKEY)) {
return; return;
} }
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0)); projectile.setMetadata(mcMMO.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, 1.0));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation())); projectile.setMetadata(mcMMO.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
} }
/** /**
@ -156,11 +156,11 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity instanceof FallingBlock || entity instanceof Enderman) { if (entity instanceof FallingBlock || entity instanceof Enderman) {
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey); boolean isTracked = entity.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY);
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) { if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
} else if (isTracked) { } else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block); mcMMO.getPlaceStore().setTrue(block);
} }
@ -260,7 +260,7 @@ public class EntityListener implements Listener {
return; return;
} }
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey)) { if (event.getDamager().hasMetadata(mcMMO.SPAWNED_FIREWORKS_METAKEY)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -564,18 +564,18 @@ public class EntityListener implements Listener {
return; return;
} }
if (entity.hasMetadata(mcMMO.customNameKey)) { if (entity.hasMetadata(mcMMO.CUSTOM_NAME_METAKEY)) {
entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString()); entity.setCustomName(entity.getMetadata(mcMMO.CUSTOM_NAME_METAKEY).get(0).asString());
entity.removeMetadata(mcMMO.customNameKey, plugin); entity.removeMetadata(mcMMO.CUSTOM_NAME_METAKEY, plugin);
} }
if (entity.hasMetadata(mcMMO.customVisibleKey)) { if (entity.hasMetadata(mcMMO.NAME_VISIBILITY_METAKEY)) {
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean()); entity.setCustomNameVisible(entity.getMetadata(mcMMO.NAME_VISIBILITY_METAKEY).get(0).asBoolean());
entity.removeMetadata(mcMMO.customVisibleKey, plugin); entity.removeMetadata(mcMMO.NAME_VISIBILITY_METAKEY, plugin);
} }
if (entity.hasMetadata(mcMMO.entityMetadataKey)) { if (entity.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
entity.removeMetadata(mcMMO.entityMetadataKey, plugin); entity.removeMetadata(mcMMO.UNNATURAL_MOB_METAKEY, plugin);
} }
} }
@ -617,18 +617,18 @@ public class EntityListener implements Listener {
case SPAWNER: case SPAWNER:
case SPAWNER_EGG: case SPAWNER_EGG:
if (mcMMO.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP()) { if (mcMMO.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP()) {
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
Entity passenger = entity.getPassenger(); Entity passenger = entity.getPassenger();
if (passenger != null) { if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); passenger.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
} }
} }
return; return;
case BREEDING: case BREEDING:
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.BRED_ANIMAL_TRACKING_METAKEY, mcMMO.metadataValue);
return; return;
default: default:
@ -648,13 +648,13 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.TNT_TRACKING_METAKEY)) {
return; return;
} }
// We can make this assumption because we (should) be the only ones // We can make this assumption because we (should) be the only ones
// using this exact metadata // using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.TNT_TRACKING_METAKEY).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
return; return;
@ -691,13 +691,13 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.TNT_TRACKING_METAKEY)) {
return; return;
} }
// We can make this assumption because we (should) be the only ones // We can make this assumption because we (should) be the only ones
// using this exact metadata // using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.TNT_TRACKING_METAKEY).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
return; return;
@ -735,7 +735,7 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) { if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.SAFE_TNT_METAKEY)) {
return; return;
} }
@ -863,12 +863,12 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) { if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
return; return;
} }
if (mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP()) if (mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP())
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
//Profile not loaded //Profile not loaded
//TODO: Redundant //TODO: Redundant
@ -951,8 +951,8 @@ public class EntityListener implements Listener {
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) { if (event.getEntity().hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); event.getPigZombie().setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
} }
} }
} }

View File

@ -62,8 +62,8 @@ public class InventoryListener implements Listener {
return; return;
} }
if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) if (!furnaceBlock.hasMetadata(mcMMO.FURNACE_TRACKING_METAKEY) && furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY).size() == 0)
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata()); furnaceBlock.setMetadata(mcMMO.FURNACE_TRACKING_METAKEY, UserManager.getPlayer((Player) player).getPlayerMetadata());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -74,7 +74,7 @@ public class InventoryListener implements Listener {
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.FURNACE_TRACKING_METAKEY)) {
return; return;
} }
@ -84,7 +84,7 @@ public class InventoryListener implements Listener {
return; return;
} }
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin); furnaceBlock.removeMetadata(mcMMO.FURNACE_TRACKING_METAKEY, plugin);
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -200,15 +200,15 @@ public class InventoryListener implements Listener {
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock != null) { if (furnaceBlock != null) {
if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0) if (furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY).size() > 0)
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); furnaceBlock.removeMetadata(mcMMO.FURNACE_TRACKING_METAKEY, mcMMO.p);
//Profile not loaded //Profile not loaded
if (UserManager.getPlayer(player) == null) { if (UserManager.getPlayer(player) == null) {
return; return;
} }
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata()); furnaceBlock.setMetadata(mcMMO.FURNACE_TRACKING_METAKEY, UserManager.getPlayer(player).getPlayerMetadata());
} }
} }
@ -436,7 +436,7 @@ public class InventoryListener implements Listener {
final HumanEntity whoClicked = event.getWhoClicked(); final HumanEntity whoClicked = event.getWhoClicked();
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) { if (!whoClicked.hasMetadata(mcMMO.PLAYER_DATA_METAKEY)) {
return; return;
} }
@ -472,7 +472,7 @@ public class InventoryListener implements Listener {
} }
private Player getPlayerFromFurnace(Block furnaceBlock) { private Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey); List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY);
if (metadata.isEmpty()) { if (metadata.isEmpty()) {
return null; return null;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -151,7 +150,7 @@ public class PlayerListener implements Listener {
Player killedPlayer = event.getEntity(); Player killedPlayer = event.getEntity();
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) { if (!killedPlayer.hasMetadata(mcMMO.PLAYER_DATA_METAKEY) || Permissions.hardcoreBypass(killedPlayer)) {
return; return;
} }
@ -231,7 +230,7 @@ public class PlayerListener implements Listener {
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
if (ItemUtils.isSharable(dropStack)) { if (ItemUtils.isSharable(dropStack)) {
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue); drop.setMetadata(mcMMO.DROPPED_ITEM_TRACKING_METAKEY, mcMMO.metadataValue);
} }
SkillUtils.removeAbilityBuff(dropStack); SkillUtils.removeAbilityBuff(dropStack);
@ -441,8 +440,8 @@ public class PlayerListener implements Listener {
Item drop = event.getItem(); Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack(); ItemStack dropStack = drop.getItemStack();
if (drop.hasMetadata(mcMMO.disarmedItemKey)) { if (drop.hasMetadata(mcMMO.DISARMED_ITEM_METAKEY)) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) { if (!player.getName().equals(drop.getMetadata(mcMMO.DISARMED_ITEM_METAKEY).get(0).asString())) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -450,7 +449,7 @@ public class PlayerListener implements Listener {
} }
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) { if (!drop.hasMetadata(mcMMO.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer)); event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
SoundManager.sendSound(player, player.getLocation(), SoundType.POP); SoundManager.sendSound(player, player.getLocation(), SoundType.POP);

View File

@ -52,32 +52,29 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public class mcMMO extends JavaPlugin { public class mcMMO extends JavaPlugin {
public static final String COMPATIBLE_SERVER_SOFTWARE = "Spigot, Paper";
public static final String INCOMPATIBLE_SERVER_SOFTWARE = "CraftBukkit";
public static final String COMPATIBLE_MINECRAFT_VERSIONS = "1.13.2";
/* Metadata Values */ /* Metadata Values */
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker"; public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage"; public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
public final static String entityMetadataKey = "mcMMO: Spawned Entity"; public final static String UNNATURAL_MOB_METAKEY = "mcMMO: Spawned Entity";
public final static String blockMetadataKey = "mcMMO: Piston Tracking"; public final static String PISTON_TRACKING_METAKEY = "mcMMO: Piston Tracking";
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace"; public final static String FURNACE_TRACKING_METAKEY = "mcMMO: Tracked Furnace";
public final static String tntMetadataKey = "mcMMO: Tracked TNT"; public final static String TNT_TRACKING_METAKEY = "mcMMO: Tracked TNT";
public final static String funfettiMetadataKey = "mcMMO: Funfetti"; public final static String SPAWNED_FIREWORKS_METAKEY = "mcMMO: Funfetti";
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT"; public final static String SAFE_TNT_METAKEY = "mcMMO: Safe TNT";
public final static String customNameKey = "mcMMO: Custom Name"; public final static String CUSTOM_NAME_METAKEY = "mcMMO: Custom Name";
public final static String customVisibleKey = "mcMMO: Name Visibility"; public final static String NAME_VISIBILITY_METAKEY = "mcMMO: Name Visibility";
public final static String droppedItemKey = "mcMMO: Tracked Item"; public final static String DROPPED_ITEM_TRACKING_METAKEY = "mcMMO: Tracked Item";
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow"; public final static String INFINITE_ARROW_METAKEY = "mcMMO: Infinite Arrow";
public final static String bowForceKey = "mcMMO: Bow Force"; public final static String BOW_FORCE_METAKEY = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance"; public final static String ARROW_DISTANCE_METAKEY = "mcMMO: Arrow Distance";
public final static String doubleDrops = "mcMMO: Double Drops"; public final static String BONUS_DROPS_METAKEY = "mcMMO: Bonus Drops";
public final static String tripleDrops = "mcMMO: Triple Drops";
//public final static String customDamageKey = "mcMMO: Custom Damage"; //public final static String customDamageKey = "mcMMO: Custom Damage";
public final static String disarmedItemKey = "mcMMO: Disarmed Item"; public final static String DISARMED_ITEM_METAKEY = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data"; public final static String PLAYER_DATA_METAKEY = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb"; public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb";
public final static String databaseCommandKey = "mcMMO: Processing Database Command"; public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal"; public final static String BRED_ANIMAL_TRACKING_METAKEY = "mcMMO: Bred Animal";
public static mcMMO p; public static mcMMO p;
// Jar Stuff // Jar Stuff
public static File mcmmo; public static File mcmmo;
@ -85,7 +82,6 @@ public class mcMMO extends JavaPlugin {
/* Managers */ /* Managers */
private static ChunkManager placeStore; private static ChunkManager placeStore;
private static ConfigManager configManager; private static ConfigManager configManager;
//private static ModManager modManager;
private static DatabaseManager databaseManager; private static DatabaseManager databaseManager;
private static FormulaManager formulaManager; private static FormulaManager formulaManager;
private static MaterialMapStore materialMapStore; private static MaterialMapStore materialMapStore;
@ -349,6 +345,9 @@ public class mcMMO extends JavaPlugin {
return playerLevelUtils; return playerLevelUtils;
} }
/**
* Uses reflection to check for incompatible server software
*/
private void checkForOutdatedAPI() { private void checkForOutdatedAPI() {
try { try {
Class<?> checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); Class<?> checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent");
@ -361,6 +360,11 @@ public class mcMMO extends JavaPlugin {
} }
} }
/**
* Returns a ServerSoftwareType based on version strings
* Custom software is returned as CRAFTBUKKIT
* @return the ServerSoftwareType which likely matches the server
*/
private ServerSoftwareType getServerSoftware() { private ServerSoftwareType getServerSoftware() {
if (Bukkit.getVersion().toLowerCase().contains("paper")) if (Bukkit.getVersion().toLowerCase().contains("paper"))
return ServerSoftwareType.PAPER; return ServerSoftwareType.PAPER;
@ -370,6 +374,10 @@ public class mcMMO extends JavaPlugin {
return ServerSoftwareType.CRAFTBUKKIT; return ServerSoftwareType.CRAFTBUKKIT;
} }
/**
* Gets a string version of ServerSoftwareType
* @return Formatted String of ServerSoftwareType
*/
private String getServerSoftwareStr() { private String getServerSoftwareStr() {
switch (getServerSoftware()) { switch (getServerSoftware()) {
case PAPER: case PAPER:
@ -438,10 +446,18 @@ public class mcMMO extends JavaPlugin {
debug("Was disabled."); // How informative! debug("Was disabled."); // How informative!
} }
/**
* The directory in which override locales are kept
* @return the override locale directory
*/
public static String getLocalesDirectory() { public static String getLocalesDirectory() {
return localesDirectory; return localesDirectory;
} }
/**
* If an XP rate event is currently in place
* @return
*/
public boolean isXPEventEnabled() { public boolean isXPEventEnabled() {
return xpEventEnabled; return xpEventEnabled;
} }
@ -454,14 +470,26 @@ public class mcMMO extends JavaPlugin {
return upgradeManager; return upgradeManager;
}*/ }*/
/**
* Sets the xpEventEnabled boolean
* @param enabled the new boolean state
*/
public void setXPEventEnabled(boolean enabled) { public void setXPEventEnabled(boolean enabled) {
this.xpEventEnabled = enabled; this.xpEventEnabled = enabled;
} }
/**
* Flips the XP events boolean
*/
public void toggleXpEventEnabled() { public void toggleXpEventEnabled() {
xpEventEnabled = !xpEventEnabled; xpEventEnabled = !xpEventEnabled;
} }
/**
* Debug helper method
* Prefixes log entries with [Debug]
* @param message the message to log with a Debug prefix
*/
public void debug(String message) { public void debug(String message) {
getLogger().info("[Debug] " + message); getLogger().info("[Debug] " + message);
} }

View File

@ -12,8 +12,8 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
public MobHealthDisplayUpdaterTask(LivingEntity target) { public MobHealthDisplayUpdaterTask(LivingEntity target) {
if (target.isValid()) { if (target.isValid()) {
this.target = target; this.target = target;
this.oldName = target.getMetadata(mcMMO.customNameKey).get(0).asString(); this.oldName = target.getMetadata(mcMMO.CUSTOM_NAME_METAKEY).get(0).asString();
this.oldNameVisible = target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean(); this.oldNameVisible = target.getMetadata(mcMMO.NAME_VISIBILITY_METAKEY).get(0).asBoolean();
} }
} }
@ -22,8 +22,8 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
if (target != null && target.isValid()) { if (target != null && target.isValid()) {
target.setCustomNameVisible(oldNameVisible); target.setCustomNameVisible(oldNameVisible);
target.setCustomName(oldName); target.setCustomName(oldName);
target.removeMetadata(mcMMO.customNameKey, mcMMO.p); target.removeMetadata(mcMMO.CUSTOM_NAME_METAKEY, mcMMO.p);
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p); target.removeMetadata(mcMMO.NAME_VISIBILITY_METAKEY, mcMMO.p);
} }
} }
} }

View File

@ -33,9 +33,9 @@ public class PistonTrackerTask extends BukkitRunnable {
for (Block b : blocks) { for (Block b : blocks) {
Block nextBlock = b.getRelative(direction); Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) { if (nextBlock.hasMetadata(mcMMO.PISTON_TRACKING_METAKEY)) {
mcMMO.getPlaceStore().setTrue(nextBlock); mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p); nextBlock.removeMetadata(mcMMO.PISTON_TRACKING_METAKEY, mcMMO.p);
} else if (mcMMO.getPlaceStore().isTrue(nextBlock)) { } else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
// Block doesn't have metadatakey but isTrue - set it to false // Block doesn't have metadatakey but isTrue - set it to false
mcMMO.getPlaceStore().setFalse(nextBlock); mcMMO.getPlaceStore().setFalse(nextBlock);

View File

@ -36,7 +36,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
if (useChat) { if (useChat) {
displayChat(); displayChat();
} }
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p); ((Player) sender).removeMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p);
} }
private void displayChat() { private void displayChat() {

View File

@ -42,7 +42,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
} }
if (sender instanceof Player) { if (sender instanceof Player) {
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p); ((Player) sender).removeMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p);
} }
if (sender instanceof Player) if (sender instanceof Player)
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));

View File

@ -52,7 +52,7 @@ public class ArcheryManager extends SkillManager {
* @param damager The {@link Entity} who shot the arrow * @param damager The {@link Entity} who shot the arrow
*/ */
public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) { public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) {
Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value(); Location firedLocation = (Location) damager.getMetadata(mcMMO.ARROW_DISTANCE_METAKEY).get(0).value();
Location targetLocation = target.getLocation(); Location targetLocation = target.getLocation();
if (firedLocation.getWorld() != targetLocation.getWorld()) { if (firedLocation.getWorld() != targetLocation.getWorld()) {

View File

@ -188,6 +188,6 @@ public class Herbalism {
* @return true if the block is recently regrown, false otherwise * @return true if the block is recently regrown, false otherwise
*/ */
public static boolean isRecentlyRegrown(BlockState blockState) { public static boolean isRecentlyRegrown(BlockState blockState) {
return blockState.hasMetadata(mcMMO.greenThumbDataKey) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.greenThumbDataKey).get(0).asInt(), 1); return blockState.hasMetadata(mcMMO.GREEN_THUMB_METAKEY) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.GREEN_THUMB_METAKEY).get(0).asInt(), 1);
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.herbalism; package com.gmail.nossr50.skills.herbalism;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig; import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
@ -341,7 +340,7 @@ public class HerbalismManager extends SkillManager {
private boolean handleBlockState(BlockState blockState, boolean greenTerra) { private boolean handleBlockState(BlockState blockState, boolean greenTerra) {
int greenThumbStage = getGreenThumbStage(); int greenThumbStage = getGreenThumbStage();
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); blockState.setMetadata(mcMMO.GREEN_THUMB_METAKEY, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
Ageable crops = (Ageable) blockState.getBlockData(); Ageable crops = (Ageable) blockState.getBlockData();
switch (blockState.getType()) { switch (blockState.getType()) {

View File

@ -88,12 +88,12 @@ public class BlastMining {
} }
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) { public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !UserManager.hasPlayerDataKey(defender)) { if (!tnt.hasMetadata(mcMMO.TNT_TRACKING_METAKEY) || !UserManager.hasPlayerDataKey(defender)) {
return false; return false;
} }
// We can make this assumption because we (should) be the only ones using this exact metadata // We can make this assumption because we (should) be the only ones using this exact metadata
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.TNT_TRACKING_METAKEY).get(0).asString());
if (!player.equals(defender)) { if (!player.equals(defender)) {
return false; return false;

View File

@ -128,7 +128,7 @@ public class MiningManager extends SkillManager {
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom");
//player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); //player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata()); tnt.setMetadata(mcMMO.TNT_TRACKING_METAKEY, mcMMOPlayer.getPlayerMetadata());
tnt.setFuseTicks(0); tnt.setFuseTicks(0);
targetBlock.setType(Material.AIR); targetBlock.setType(Material.AIR);

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainReason;
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;
@ -308,7 +307,7 @@ public class TamingManager extends SkillManager {
continue; continue;
} }
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
((Tameable) entity).setOwner(player); ((Tameable) entity).setOwner(player);
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);

View File

@ -107,7 +107,7 @@ public class UnarmedManager extends SkillManager {
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) { if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata()); item.setMetadata(mcMMO.DISARMED_ITEM_METAKEY, UserManager.getPlayer(defender).getPlayerMetadata());
} }
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));

View File

@ -29,7 +29,7 @@ public final class BlockUtils {
if (triple) if (triple)
blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue); blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue);
else else
blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue); blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, mcMMO.metadataValue);
} }
/** /**

View File

@ -69,11 +69,11 @@ public final class MobHealthbarUtils {
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName)); boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
if (updateName) { if (updateName) {
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, oldName)); target.setMetadata(mcMMO.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, oldName));
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible)); target.setMetadata(mcMMO.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, oldNameVisible));
} else if (!target.hasMetadata(mcMMO.customNameKey)) { } else if (!target.hasMetadata(mcMMO.CUSTOM_NAME_METAKEY)) {
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, "")); target.setMetadata(mcMMO.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, ""));
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, false)); target.setMetadata(mcMMO.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, false));
} }
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds

View File

@ -124,7 +124,7 @@ public final class CommandUtils {
return false; return false;
} }
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(mcMMO.playerDataKey); boolean hasPlayerDataKey = ((Player) sender).hasMetadata(mcMMO.PLAYER_DATA_METAKEY);
if (!hasPlayerDataKey) { if (!hasPlayerDataKey) {
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded")); sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));

View File

@ -22,7 +22,7 @@ public final class UserManager {
* @param mcMMOPlayer the player profile to start tracking * @param mcMMOPlayer the player profile to start tracking
*/ */
public static void track(McMMOPlayer mcMMOPlayer) { public static void track(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer)); mcMMOPlayer.getPlayer().setMetadata(mcMMO.PLAYER_DATA_METAKEY, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
} }
/** /**
@ -31,7 +31,7 @@ public final class UserManager {
* @param player The Player object * @param player The Player object
*/ */
public static void remove(Player player) { public static void remove(Player player) {
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p); player.removeMetadata(mcMMO.PLAYER_DATA_METAKEY, mcMMO.p);
} }
/** /**
@ -101,8 +101,8 @@ public final class UserManager {
*/ */
public static McMMOPlayer getPlayer(Player player) { public static McMMOPlayer getPlayer(Player player) {
//Avoid Array Index out of bounds //Avoid Array Index out of bounds
if (player != null && player.hasMetadata(mcMMO.playerDataKey)) if (player != null && player.hasMetadata(mcMMO.PLAYER_DATA_METAKEY))
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value(); return (McMMOPlayer) player.getMetadata(mcMMO.PLAYER_DATA_METAKEY).get(0).value();
else else
return null; return null;
} }
@ -122,6 +122,6 @@ public final class UserManager {
} }
public static boolean hasPlayerDataKey(Entity entity) { public static boolean hasPlayerDataKey(Entity entity) {
return entity != null && entity.hasMetadata(mcMMO.playerDataKey); return entity != null && entity.hasMetadata(mcMMO.PLAYER_DATA_METAKEY);
} }
} }

View File

@ -213,7 +213,7 @@ public final class CombatUtils {
finalDamage += archeryManager.daze((Player) target); finalDamage += archeryManager.daze((Player) target);
} }
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) { if (!arrow.hasMetadata(mcMMO.INFINITE_ARROW_METAKEY) && archeryManager.canRetrieveArrows()) {
archeryManager.retrieveArrows(target); archeryManager.retrieveArrows(target);
} }
@ -224,7 +224,7 @@ public final class CombatUtils {
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow); double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble() * distanceMultiplier); startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, arrow.getMetadata(mcMMO.BOW_FORCE_METAKEY).get(0).asDouble() * distanceMultiplier);
} }
/** /**
@ -573,11 +573,11 @@ public final class CombatUtils {
} }
} }
if (target.hasMetadata(mcMMO.entityMetadataKey)) { if (target.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
baseXP *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult(); baseXP *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult();
} }
if (target.hasMetadata(mcMMO.bredMetadataKey)) { if (target.hasMetadata(mcMMO.BRED_ANIMAL_TRACKING_METAKEY)) {
baseXP *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult(); baseXP *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult();
} }
@ -814,7 +814,7 @@ public final class CombatUtils {
return; return;
} }
if (!player.hasMetadata(mcMMO.playerDataKey)) { if (!player.hasMetadata(mcMMO.PLAYER_DATA_METAKEY)) {
return; return;
} }

View File

@ -97,7 +97,7 @@ public final class ParticleEffectUtils {
location.setPitch(-90); location.setPitch(-90);
Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK); Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
firework.setMetadata(mcMMO.funfettiMetadataKey, new FixedMetadataValue(mcMMO.p, null)); firework.setMetadata(mcMMO.SPAWNED_FIREWORKS_METAKEY, new FixedMetadataValue(mcMMO.p, null));
FireworkMeta fireworkMeta = firework.getFireworkMeta(); FireworkMeta fireworkMeta = firework.getFireworkMeta();
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((MainConfig.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build(); FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((MainConfig.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build();
fireworkMeta.addEffect(effect); fireworkMeta.addEffect(effect);