mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Cleaning up mcMMO.java
This commit is contained in:
parent
72fc3efa78
commit
80163c0d8f
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.MainConfig;
|
import com.gmail.nossr50.config.MainConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -102,11 +103,11 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).hasMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY)) {
|
if (((Player) sender).hasMetadata(MetadataConstants.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.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
|
((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.actualizeDatabaseATS();
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.MainConfig;
|
import com.gmail.nossr50.config.MainConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@ -100,11 +101,11 @@ public class MctopCommand implements TabExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).hasMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY)) {
|
if (((Player) sender).hasMetadata(MetadataConstants.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.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
|
((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.actualizeDatabaseATS();
|
mcMMOPlayer.actualizeDatabaseATS();
|
||||||
|
29
src/main/java/com/gmail/nossr50/core/MetadataConstants.java
Normal file
29
src/main/java/com/gmail/nossr50/core/MetadataConstants.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.gmail.nossr50.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a convenience class which stores the string representations of our metadata keys
|
||||||
|
*/
|
||||||
|
public class MetadataConstants {
|
||||||
|
|
||||||
|
/* Metadata Values */
|
||||||
|
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
||||||
|
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
||||||
|
public final static String UNNATURAL_MOB_METAKEY = "mcMMO: Spawned Entity";
|
||||||
|
public final static String PISTON_TRACKING_METAKEY = "mcMMO: Piston Tracking";
|
||||||
|
public final static String FURNACE_TRACKING_METAKEY = "mcMMO: Tracked Furnace";
|
||||||
|
public final static String TNT_TRACKING_METAKEY = "mcMMO: Tracked TNT";
|
||||||
|
public final static String SPAWNED_FIREWORKS_METAKEY = "mcMMO: Funfetti";
|
||||||
|
public final static String SAFE_TNT_METAKEY = "mcMMO: Safe TNT";
|
||||||
|
public final static String CUSTOM_NAME_METAKEY = "mcMMO: Custom Name";
|
||||||
|
public final static String NAME_VISIBILITY_METAKEY = "mcMMO: Name Visibility";
|
||||||
|
public final static String DROPPED_ITEM_TRACKING_METAKEY = "mcMMO: Tracked Item";
|
||||||
|
public final static String INFINITE_ARROW_METAKEY = "mcMMO: Infinite Arrow";
|
||||||
|
public final static String BOW_FORCE_METAKEY = "mcMMO: Bow Force";
|
||||||
|
public final static String ARROW_DISTANCE_METAKEY = "mcMMO: Arrow Distance";
|
||||||
|
public final static String BONUS_DROPS_METAKEY = "mcMMO: Bonus Drops";
|
||||||
|
public final static String DISARMED_ITEM_METAKEY = "mcMMO: Disarmed Item";
|
||||||
|
public final static String PLAYER_DATA_METAKEY = "mcMMO: Player Data";
|
||||||
|
public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb";
|
||||||
|
public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command";
|
||||||
|
public final static String BRED_ANIMAL_TRACKING_METAKEY = "mcMMO: Bred Animal";
|
||||||
|
}
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners;
|
|||||||
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.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
@ -66,15 +67,15 @@ 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().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
|
if (event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY).size() > 0) {
|
||||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).get(0);
|
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY).get(0);
|
||||||
int bonusCount = bonusDropMeta.asInt();
|
int bonusCount = bonusDropMeta.asInt();
|
||||||
|
|
||||||
for (int i = 0; i < bonusCount; i++) {
|
for (int i = 0; i < bonusCount; i++) {
|
||||||
event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
|
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,7 +455,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Player getPlayerFromFurnace(Block furnaceBlock) {
|
private Player getPlayerFromFurnace(Block furnaceBlock) {
|
||||||
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY);
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY);
|
||||||
|
|
||||||
if (metadata.isEmpty()) {
|
if (metadata.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
@ -573,7 +574,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.FURNACE_TRACKING_METAKEY)) {
|
if (furnace.hasMetadata(MetadataConstants.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) {
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.WorldBlacklist;
|
import com.gmail.nossr50.config.WorldBlacklist;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.meta.OldName;
|
import com.gmail.nossr50.datatypes.meta.OldName;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
@ -54,9 +55,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.UNNATURAL_MOB_METAKEY) != null || event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY).size() >= 1) {
|
if (event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) != null || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() >= 1) {
|
||||||
for (Entity entity : event.getTransformedEntities()) {
|
for (Entity entity : event.getTransformedEntities()) {
|
||||||
entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,8 +69,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.UNNATURAL_MOB_METAKEY) == null || event.getEntity().getMetadata(mcMMO.UNNATURAL_MOB_METAKEY).size() <= 0)
|
if (event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) == null || event.getEntity().getMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY).size() <= 0)
|
||||||
event.getEntity().setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
event.getEntity().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +99,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.INFINITE_ARROW_METAKEY, mcMMO.metadataValue);
|
projectile.setMetadata(MetadataConstants.INFINITE_ARROW_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
projectile.setMetadata(mcMMO.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
||||||
projectile.setMetadata(mcMMO.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@ -123,12 +124,12 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Projectile projectile = event.getEntity();
|
Projectile projectile = event.getEntity();
|
||||||
|
|
||||||
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.BOW_FORCE_METAKEY)) {
|
if (!(projectile instanceof Arrow) || projectile.hasMetadata(MetadataConstants.BOW_FORCE_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
projectile.setMetadata(mcMMO.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, 1.0));
|
projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, 1.0));
|
||||||
projectile.setMetadata(mcMMO.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,11 +157,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.UNNATURAL_MOB_METAKEY);
|
boolean isTracked = entity.hasMetadata(MetadataConstants.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.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
} else if (isTracked) {
|
} else if (isTracked) {
|
||||||
mcMMO.getPlaceStore().setTrue(block);
|
mcMMO.getPlaceStore().setTrue(block);
|
||||||
}
|
}
|
||||||
@ -225,8 +226,8 @@ public class EntityListener implements Listener {
|
|||||||
public void onEntityDamageLowest(EntityDamageByEntityEvent event) {
|
public void onEntityDamageLowest(EntityDamageByEntityEvent event) {
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
|
|
||||||
if (defender.getMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY).size() > 0) {
|
if (defender.getMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY).size() > 0) {
|
||||||
defender.removeMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, plugin);
|
defender.removeMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, plugin);
|
||||||
|
|
||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
LivingEntity defLive = (LivingEntity) defender;
|
LivingEntity defLive = (LivingEntity) defender;
|
||||||
@ -260,7 +261,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getDamager().hasMetadata(mcMMO.SPAWNED_FIREWORKS_METAKEY)) {
|
if (event.getDamager().hasMetadata(MetadataConstants.SPAWNED_FIREWORKS_METAKEY)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -564,18 +565,18 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.hasMetadata(mcMMO.CUSTOM_NAME_METAKEY)) {
|
if (entity.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) {
|
||||||
entity.setCustomName(entity.getMetadata(mcMMO.CUSTOM_NAME_METAKEY).get(0).asString());
|
entity.setCustomName(entity.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY).get(0).asString());
|
||||||
entity.removeMetadata(mcMMO.CUSTOM_NAME_METAKEY, plugin);
|
entity.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.hasMetadata(mcMMO.NAME_VISIBILITY_METAKEY)) {
|
if (entity.hasMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY)) {
|
||||||
entity.setCustomNameVisible(entity.getMetadata(mcMMO.NAME_VISIBILITY_METAKEY).get(0).asBoolean());
|
entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY).get(0).asBoolean());
|
||||||
entity.removeMetadata(mcMMO.NAME_VISIBILITY_METAKEY, plugin);
|
entity.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
|
if (entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||||
entity.removeMetadata(mcMMO.UNNATURAL_MOB_METAKEY, plugin);
|
entity.removeMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,18 +618,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.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
|
|
||||||
Entity passenger = entity.getPassenger();
|
Entity passenger = entity.getPassenger();
|
||||||
|
|
||||||
if (passenger != null) {
|
if (passenger != null) {
|
||||||
passenger.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
passenger.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case BREEDING:
|
case BREEDING:
|
||||||
entity.setMetadata(mcMMO.BRED_ANIMAL_TRACKING_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY, mcMMO.metadataValue);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -648,13 +649,13 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.TNT_TRACKING_METAKEY)) {
|
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.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.TNT_TRACKING_METAKEY).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
@ -691,13 +692,13 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.TNT_TRACKING_METAKEY)) {
|
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.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.TNT_TRACKING_METAKEY).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
return;
|
||||||
@ -735,7 +736,7 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.SAFE_TNT_METAKEY)) {
|
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.SAFE_TNT_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,12 +864,12 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
|
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP())
|
if (mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP())
|
||||||
entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
|
|
||||||
//Profile not loaded
|
//Profile not loaded
|
||||||
//TODO: Redundant
|
//TODO: Redundant
|
||||||
@ -951,8 +952,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.UNNATURAL_MOB_METAKEY)) {
|
if (event.getEntity().hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||||
event.getPigZombie().setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
event.getPigZombie().setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.listeners;
|
|||||||
|
|
||||||
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.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -58,8 +59,8 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!furnaceBlock.hasMetadata(mcMMO.FURNACE_TRACKING_METAKEY) && furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY).size() == 0)
|
if (!furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY) && furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() == 0)
|
||||||
furnaceBlock.setMetadata(mcMMO.FURNACE_TRACKING_METAKEY, UserManager.getPlayer((Player) player).getPlayerMetadata());
|
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, UserManager.getPlayer((Player) player).getPlayerMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@ -70,7 +71,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
|
||||||
|
|
||||||
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.FURNACE_TRACKING_METAKEY)) {
|
if (furnaceBlock == null || furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
furnaceBlock.removeMetadata(mcMMO.FURNACE_TRACKING_METAKEY, plugin);
|
furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -197,15 +198,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.FURNACE_TRACKING_METAKEY).size() > 0)
|
if (furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() > 0)
|
||||||
furnaceBlock.removeMetadata(mcMMO.FURNACE_TRACKING_METAKEY, mcMMO.p);
|
furnaceBlock.removeMetadata(MetadataConstants.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.FURNACE_TRACKING_METAKEY, UserManager.getPlayer(player).getPlayerMetadata());
|
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, UserManager.getPlayer(player).getPlayerMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +434,7 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
final HumanEntity whoClicked = event.getWhoClicked();
|
final HumanEntity whoClicked = event.getWhoClicked();
|
||||||
|
|
||||||
if (!whoClicked.hasMetadata(mcMMO.PLAYER_DATA_METAKEY)) {
|
if (!whoClicked.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,7 +470,7 @@ public class InventoryListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Player getPlayerFromFurnace(Block furnaceBlock) {
|
private Player getPlayerFromFurnace(Block furnaceBlock) {
|
||||||
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.FURNACE_TRACKING_METAKEY);
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY);
|
||||||
|
|
||||||
if (metadata.isEmpty()) {
|
if (metadata.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -5,6 +5,7 @@ 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.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -150,7 +151,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
Player killedPlayer = event.getEntity();
|
Player killedPlayer = event.getEntity();
|
||||||
|
|
||||||
if (!killedPlayer.hasMetadata(mcMMO.PLAYER_DATA_METAKEY) || Permissions.hardcoreBypass(killedPlayer)) {
|
if (!killedPlayer.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +231,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.DROPPED_ITEM_TRACKING_METAKEY, mcMMO.metadataValue);
|
drop.setMetadata(MetadataConstants.DROPPED_ITEM_TRACKING_METAKEY, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillUtils.removeAbilityBuff(dropStack);
|
SkillUtils.removeAbilityBuff(dropStack);
|
||||||
@ -347,7 +348,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
//Track the hook
|
//Track the hook
|
||||||
if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) {
|
if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) {
|
||||||
if (event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0) {
|
if (event.getHook().getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY).size() == 0) {
|
||||||
fishingManager.setFishHookReference(event.getHook());
|
fishingManager.setFishHookReference(event.getHook());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,8 +441,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.DISARMED_ITEM_METAKEY)) {
|
if (drop.hasMetadata(MetadataConstants.DISARMED_ITEM_METAKEY)) {
|
||||||
if (!player.getName().equals(drop.getMetadata(mcMMO.DISARMED_ITEM_METAKEY).get(0).asString())) {
|
if (!player.getName().equals(drop.getMetadata(MetadataConstants.DISARMED_ITEM_METAKEY).get(0).asString())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +450,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!drop.hasMetadata(mcMMO.DROPPED_ITEM_TRACKING_METAKEY) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
if (!drop.hasMetadata(MetadataConstants.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);
|
||||||
|
@ -52,32 +52,9 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
/* Metadata Values */
|
|
||||||
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
|
||||||
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
|
||||||
public final static String UNNATURAL_MOB_METAKEY = "mcMMO: Spawned Entity";
|
|
||||||
public final static String PISTON_TRACKING_METAKEY = "mcMMO: Piston Tracking";
|
|
||||||
public final static String FURNACE_TRACKING_METAKEY = "mcMMO: Tracked Furnace";
|
|
||||||
public final static String TNT_TRACKING_METAKEY = "mcMMO: Tracked TNT";
|
|
||||||
public final static String SPAWNED_FIREWORKS_METAKEY = "mcMMO: Funfetti";
|
|
||||||
public final static String SAFE_TNT_METAKEY = "mcMMO: Safe TNT";
|
|
||||||
public final static String CUSTOM_NAME_METAKEY = "mcMMO: Custom Name";
|
|
||||||
public final static String NAME_VISIBILITY_METAKEY = "mcMMO: Name Visibility";
|
|
||||||
public final static String DROPPED_ITEM_TRACKING_METAKEY = "mcMMO: Tracked Item";
|
|
||||||
public final static String INFINITE_ARROW_METAKEY = "mcMMO: Infinite Arrow";
|
|
||||||
public final static String BOW_FORCE_METAKEY = "mcMMO: Bow Force";
|
|
||||||
public final static String ARROW_DISTANCE_METAKEY = "mcMMO: Arrow Distance";
|
|
||||||
public final static String BONUS_DROPS_METAKEY = "mcMMO: Bonus Drops";
|
|
||||||
//public final static String customDamageKey = "mcMMO: Custom Damage";
|
|
||||||
public final static String DISARMED_ITEM_METAKEY = "mcMMO: Disarmed Item";
|
|
||||||
public final static String PLAYER_DATA_METAKEY = "mcMMO: Player Data";
|
|
||||||
public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb";
|
|
||||||
public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command";
|
|
||||||
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 mcMMOFile;
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
/* Managers */
|
/* Managers */
|
||||||
private static ChunkManager placeStore;
|
private static ChunkManager placeStore;
|
||||||
@ -94,6 +71,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private static String flatFileDirectory;
|
private static String flatFileDirectory;
|
||||||
private static String usersFile;
|
private static String usersFile;
|
||||||
private static String modDirectory;
|
private static String modDirectory;
|
||||||
|
|
||||||
/* Plugin Checks */
|
/* Plugin Checks */
|
||||||
private static boolean healthBarPluginEnabled;
|
private static boolean healthBarPluginEnabled;
|
||||||
// API checks
|
// API checks
|
||||||
@ -101,6 +79,219 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// XP Event Check
|
// XP Event Check
|
||||||
private boolean xpEventEnabled;
|
private boolean xpEventEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Things to be run when the plugin is enabled.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
try {
|
||||||
|
p = this;
|
||||||
|
getLogger().setFilter(new LogFilter(this));
|
||||||
|
|
||||||
|
//DEBUG
|
||||||
|
/*getLogger().info(Bukkit.getBukkitVersion());
|
||||||
|
getLogger().info(Bukkit.getVersion());*/
|
||||||
|
|
||||||
|
metadataValue = new FixedMetadataValue(this, true);
|
||||||
|
|
||||||
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||||
|
|
||||||
|
//upgradeManager = new UpgradeManager();
|
||||||
|
|
||||||
|
setupFilePaths();
|
||||||
|
|
||||||
|
//modManager = new ModManager();
|
||||||
|
|
||||||
|
loadConfigFiles();
|
||||||
|
registerDynamicSettings(); //Do this after configs are loaded
|
||||||
|
|
||||||
|
if (healthBarPluginEnabled) {
|
||||||
|
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
|
||||||
|
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
||||||
|
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
||||||
|
}
|
||||||
|
|
||||||
|
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
||||||
|
|
||||||
|
//Check for the newer API and tell them what to do if its missing
|
||||||
|
checkForOutdatedAPI();
|
||||||
|
|
||||||
|
if (serverAPIOutdated) {
|
||||||
|
Bukkit
|
||||||
|
.getScheduler()
|
||||||
|
.scheduleSyncRepeatingTask(this,
|
||||||
|
() -> getLogger().severe("You are running an outdated version of " + getServerSoftware() + ", mcMMO will not work unless you update to a newer version!"),
|
||||||
|
20, 20 * 60 * 30);
|
||||||
|
|
||||||
|
if (getServerSoftware() == ServerSoftwareType.CRAFTBUKKIT) {
|
||||||
|
Bukkit.getScheduler()
|
||||||
|
.scheduleSyncRepeatingTask(this,
|
||||||
|
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
|
||||||
|
20, 20 * 60 * 30);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
registerEvents();
|
||||||
|
registerCoreSkills();
|
||||||
|
registerCustomRecipes();
|
||||||
|
|
||||||
|
if (getConfigManager().getConfigParty().isPartySystemEnabled())
|
||||||
|
PartyManager.loadParties();
|
||||||
|
|
||||||
|
formulaManager = new FormulaManager();
|
||||||
|
|
||||||
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
|
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||||
|
|
||||||
|
scheduleTasks();
|
||||||
|
CommandRegistrationManager.registerCommands();
|
||||||
|
|
||||||
|
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||||
|
|
||||||
|
if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
|
||||||
|
Permissions.generateWorldTeleportPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Populate Ranked Skill Maps (DO THIS LAST)
|
||||||
|
RankUtils.populateRanks();
|
||||||
|
}
|
||||||
|
|
||||||
|
//If anonymous statistics are enabled then use them
|
||||||
|
if (getConfigManager().getConfigMetrics().isAllowAnonymousUsageStatistics()) {
|
||||||
|
Metrics metrics;
|
||||||
|
metrics = new Metrics(this);
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
|
||||||
|
|
||||||
|
if (!configManager.getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled())
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard"));
|
||||||
|
else
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro"));
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
getLogger().severe("There was an error while enabling mcMMO!");
|
||||||
|
t.printStackTrace();
|
||||||
|
getLogger().severe("End of error report for mcMMO");
|
||||||
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init Material Maps
|
||||||
|
materialMapStore = new MaterialMapStore();
|
||||||
|
|
||||||
|
//Init player level values
|
||||||
|
playerLevelUtils = new PlayerLevelUtils();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
|
||||||
|
WorldGuardManager.getInstance().registerFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Things to be run when the plugin is disabled.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
try {
|
||||||
|
// Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
||||||
|
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||||
|
UserManager.clearAll();
|
||||||
|
PartyManager.saveParties(); // Save our parties
|
||||||
|
|
||||||
|
//TODO: Needed?
|
||||||
|
if (mcMMO.getScoreboardSettings().getScoreboardsEnabled())
|
||||||
|
ScoreboardManager.teardownAll();
|
||||||
|
|
||||||
|
formulaManager.saveFormula();
|
||||||
|
/*holidayManager.saveAnniversaryFiles();*/
|
||||||
|
placeStore.saveAll(); // Save our metadata
|
||||||
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("Canceling all tasks...");
|
||||||
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||||
|
debug("Unregister all events...");
|
||||||
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||||
|
|
||||||
|
if (mcMMO.getConfigManager().getConfigAutomatedBackups().isZipBackupsEnabled()) {
|
||||||
|
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||||
|
try {
|
||||||
|
ZipLibrary.mcMMOBackup();
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe(e.toString());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
if (e instanceof NoClassDefFoundError) {
|
||||||
|
getLogger().severe("Backup class not found!");
|
||||||
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||||
|
} else {
|
||||||
|
getLogger().severe(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
databaseManager.onDisable();
|
||||||
|
|
||||||
|
debug("Was disabled."); // How informative!
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerLevelUtils getPlayerLevelUtils() {
|
||||||
|
return playerLevelUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses reflection to check for incompatible server software
|
||||||
|
*/
|
||||||
|
private void checkForOutdatedAPI() {
|
||||||
|
try {
|
||||||
|
Class<?> checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent");
|
||||||
|
Method newerAPIMethod = checkForClass.getMethod("getItems");
|
||||||
|
Class<?> checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent");
|
||||||
|
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||||
|
serverAPIOutdated = true;
|
||||||
|
String software = getServerSoftwareStr();
|
||||||
|
getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a ServerSoftwareType based on version strings
|
||||||
|
* Custom software is returned as CRAFTBUKKIT
|
||||||
|
*
|
||||||
|
* @return the ServerSoftwareType which likely matches the server
|
||||||
|
*/
|
||||||
|
private ServerSoftwareType getServerSoftware() {
|
||||||
|
if (Bukkit.getVersion().toLowerCase().contains("paper"))
|
||||||
|
return ServerSoftwareType.PAPER;
|
||||||
|
else if (Bukkit.getVersion().toLowerCase().contains("spigot"))
|
||||||
|
return ServerSoftwareType.SPIGOT;
|
||||||
|
else
|
||||||
|
return ServerSoftwareType.CRAFTBUKKIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a string version of ServerSoftwareType
|
||||||
|
*
|
||||||
|
* @return Formatted String of ServerSoftwareType
|
||||||
|
*/
|
||||||
|
private String getServerSoftwareStr() {
|
||||||
|
switch (getServerSoftware()) {
|
||||||
|
case PAPER:
|
||||||
|
return "Paper";
|
||||||
|
case SPIGOT:
|
||||||
|
return "Spigot";
|
||||||
|
default:
|
||||||
|
return "CraftBukkit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static MaterialMapStore getMaterialMapStore() {
|
public static MaterialMapStore getMaterialMapStore() {
|
||||||
return materialMapStore;
|
return materialMapStore;
|
||||||
}
|
}
|
||||||
@ -223,219 +414,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return configManager;
|
return configManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Things to be run when the plugin is enabled.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
try {
|
|
||||||
p = this;
|
|
||||||
getLogger().setFilter(new LogFilter(this));
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
/*getLogger().info(Bukkit.getBukkitVersion());
|
|
||||||
getLogger().info(Bukkit.getVersion());*/
|
|
||||||
|
|
||||||
metadataValue = new FixedMetadataValue(this, true);
|
|
||||||
|
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
|
||||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
|
||||||
|
|
||||||
//upgradeManager = new UpgradeManager();
|
|
||||||
|
|
||||||
setupFilePaths();
|
|
||||||
|
|
||||||
//modManager = new ModManager();
|
|
||||||
|
|
||||||
loadConfigFiles();
|
|
||||||
registerDynamicSettings(); //Do this after configs are loaded
|
|
||||||
|
|
||||||
if (healthBarPluginEnabled) {
|
|
||||||
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
|
|
||||||
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
|
||||||
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
|
||||||
|
|
||||||
//Check for the newer API and tell them what to do if its missing
|
|
||||||
checkForOutdatedAPI();
|
|
||||||
|
|
||||||
if (serverAPIOutdated) {
|
|
||||||
Bukkit
|
|
||||||
.getScheduler()
|
|
||||||
.scheduleSyncRepeatingTask(this,
|
|
||||||
() -> getLogger().severe("You are running an outdated version of " + getServerSoftware() + ", mcMMO will not work unless you update to a newer version!"),
|
|
||||||
20, 20 * 60 * 30);
|
|
||||||
|
|
||||||
if (getServerSoftware() == ServerSoftwareType.CRAFTBUKKIT) {
|
|
||||||
Bukkit.getScheduler()
|
|
||||||
.scheduleSyncRepeatingTask(this,
|
|
||||||
() -> getLogger().severe("We have detected you are using incompatible server software, our best guess is that you are using CraftBukkit. mcMMO requires Spigot or Paper, if you are not using CraftBukkit, you will still need to update your custom server software before mcMMO will work."),
|
|
||||||
20, 20 * 60 * 30);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
registerEvents();
|
|
||||||
registerCoreSkills();
|
|
||||||
registerCustomRecipes();
|
|
||||||
|
|
||||||
if (getConfigManager().getConfigParty().isPartySystemEnabled())
|
|
||||||
PartyManager.loadParties();
|
|
||||||
|
|
||||||
formulaManager = new FormulaManager();
|
|
||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
|
||||||
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
|
||||||
|
|
||||||
scheduleTasks();
|
|
||||||
CommandRegistrationManager.registerCommands();
|
|
||||||
|
|
||||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
|
||||||
|
|
||||||
if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
|
|
||||||
Permissions.generateWorldTeleportPermissions();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Populate Ranked Skill Maps (DO THIS LAST)
|
|
||||||
RankUtils.populateRanks();
|
|
||||||
}
|
|
||||||
|
|
||||||
//If anonymous statistics are enabled then use them
|
|
||||||
if (getConfigManager().getConfigMetrics().isAllowAnonymousUsageStatistics()) {
|
|
||||||
Metrics metrics;
|
|
||||||
metrics = new Metrics(this);
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
|
|
||||||
|
|
||||||
if (!configManager.getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled())
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard"));
|
|
||||||
else
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro"));
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
getLogger().severe("There was an error while enabling mcMMO!");
|
|
||||||
t.printStackTrace();
|
|
||||||
getLogger().severe("End of error report for mcMMO");
|
|
||||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Init Material Maps
|
|
||||||
materialMapStore = new MaterialMapStore();
|
|
||||||
|
|
||||||
//Init player level values
|
|
||||||
playerLevelUtils = new PlayerLevelUtils();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerLevelUtils getPlayerLevelUtils() {
|
|
||||||
return playerLevelUtils;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses reflection to check for incompatible server software
|
|
||||||
*/
|
|
||||||
private void checkForOutdatedAPI() {
|
|
||||||
try {
|
|
||||||
Class<?> checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent");
|
|
||||||
Method newerAPIMethod = checkForClass.getMethod("getItems");
|
|
||||||
Class<?> checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent");
|
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
|
||||||
serverAPIOutdated = true;
|
|
||||||
String software = getServerSoftwareStr();
|
|
||||||
getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a ServerSoftwareType based on version strings
|
|
||||||
* Custom software is returned as CRAFTBUKKIT
|
|
||||||
*
|
|
||||||
* @return the ServerSoftwareType which likely matches the server
|
|
||||||
*/
|
|
||||||
private ServerSoftwareType getServerSoftware() {
|
|
||||||
if (Bukkit.getVersion().toLowerCase().contains("paper"))
|
|
||||||
return ServerSoftwareType.PAPER;
|
|
||||||
else if (Bukkit.getVersion().toLowerCase().contains("spigot"))
|
|
||||||
return ServerSoftwareType.SPIGOT;
|
|
||||||
else
|
|
||||||
return ServerSoftwareType.CRAFTBUKKIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a string version of ServerSoftwareType
|
|
||||||
*
|
|
||||||
* @return Formatted String of ServerSoftwareType
|
|
||||||
*/
|
|
||||||
private String getServerSoftwareStr() {
|
|
||||||
switch (getServerSoftware()) {
|
|
||||||
case PAPER:
|
|
||||||
return "Paper";
|
|
||||||
case SPIGOT:
|
|
||||||
return "Spigot";
|
|
||||||
default:
|
|
||||||
return "CraftBukkit";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
|
|
||||||
WorldGuardManager.getInstance().registerFlags();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Things to be run when the plugin is disabled.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
try {
|
|
||||||
// Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
|
|
||||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
|
||||||
UserManager.clearAll();
|
|
||||||
PartyManager.saveParties(); // Save our parties
|
|
||||||
|
|
||||||
//TODO: Needed?
|
|
||||||
if (mcMMO.getScoreboardSettings().getScoreboardsEnabled())
|
|
||||||
ScoreboardManager.teardownAll();
|
|
||||||
|
|
||||||
formulaManager.saveFormula();
|
|
||||||
/*holidayManager.saveAnniversaryFiles();*/
|
|
||||||
placeStore.saveAll(); // Save our metadata
|
|
||||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("Canceling all tasks...");
|
|
||||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
|
||||||
debug("Unregister all events...");
|
|
||||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
|
||||||
|
|
||||||
if (mcMMO.getConfigManager().getConfigAutomatedBackups().isZipBackupsEnabled()) {
|
|
||||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
|
||||||
try {
|
|
||||||
ZipLibrary.mcMMOBackup();
|
|
||||||
} catch (IOException e) {
|
|
||||||
getLogger().severe(e.toString());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
if (e instanceof NoClassDefFoundError) {
|
|
||||||
getLogger().severe("Backup class not found!");
|
|
||||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
|
||||||
} else {
|
|
||||||
getLogger().severe(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
databaseManager.onDisable();
|
|
||||||
|
|
||||||
debug("Was disabled."); // How informative!
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory in which override locales are kept
|
* The directory in which override locales are kept
|
||||||
*
|
*
|
||||||
@ -492,7 +470,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
* Setup the various storage file paths
|
* Setup the various storage file paths
|
||||||
*/
|
*/
|
||||||
private void setupFilePaths() {
|
private void setupFilePaths() {
|
||||||
mcmmo = getFile();
|
mcMMOFile = getFile();
|
||||||
mainDirectory = getDataFolder().getPath() + File.separator;
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
||||||
localesDirectory = mainDirectory + "locales" + File.separator;
|
localesDirectory = mainDirectory + "locales" + File.separator;
|
||||||
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
||||||
@ -503,7 +481,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
private void fixFilePaths() {
|
private void fixFilePaths() {
|
||||||
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
|
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
|
||||||
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
|
|
||||||
|
|
||||||
if (oldFlatfilePath.exists()) {
|
if (oldFlatfilePath.exists()) {
|
||||||
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
|
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
|
||||||
@ -511,41 +488,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldModPath.exists()) {
|
|
||||||
if (!oldModPath.renameTo(new File(modDirectory))) {
|
|
||||||
getLogger().warning("Failed to rename ModConfigs to mods!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File oldArmorFile = new File(modDirectory + "armor.yml");
|
|
||||||
File oldBlocksFile = new File(modDirectory + "blocks.yml");
|
|
||||||
File oldEntitiesFile = new File(modDirectory + "entities.yml");
|
|
||||||
File oldToolsFile = new File(modDirectory + "tools.yml");
|
|
||||||
|
|
||||||
if (oldArmorFile.exists()) {
|
|
||||||
if (!oldArmorFile.renameTo(new File(modDirectory + "armor.default.yml"))) {
|
|
||||||
getLogger().warning("Failed to rename armor.yml to armor.default.yml!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldBlocksFile.exists()) {
|
|
||||||
if (!oldBlocksFile.renameTo(new File(modDirectory + "blocks.default.yml"))) {
|
|
||||||
getLogger().warning("Failed to rename blocks.yml to blocks.default.yml!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldEntitiesFile.exists()) {
|
|
||||||
if (!oldEntitiesFile.renameTo(new File(modDirectory + "entities.default.yml"))) {
|
|
||||||
getLogger().warning("Failed to rename entities.yml to entities.default.yml!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldToolsFile.exists()) {
|
|
||||||
if (!oldToolsFile.renameTo(new File(modDirectory + "tools.default.yml"))) {
|
|
||||||
getLogger().warning("Failed to rename tools.yml to tools.default.yml!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File currentFlatfilePath = new File(flatFileDirectory);
|
File currentFlatfilePath = new File(flatFileDirectory);
|
||||||
currentFlatfilePath.mkdirs();
|
currentFlatfilePath.mkdirs();
|
||||||
File localesDirectoryPath = new File(localesDirectory);
|
File localesDirectoryPath = new File(localesDirectory);
|
||||||
@ -655,4 +597,4 @@ public class mcMMO extends JavaPlugin {
|
|||||||
SPIGOT,
|
SPIGOT,
|
||||||
CRAFTBUKKIT
|
CRAFTBUKKIT
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -12,8 +13,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.CUSTOM_NAME_METAKEY).get(0).asString();
|
this.oldName = target.getMetadata(MetadataConstants.CUSTOM_NAME_METAKEY).get(0).asString();
|
||||||
this.oldNameVisible = target.getMetadata(mcMMO.NAME_VISIBILITY_METAKEY).get(0).asBoolean();
|
this.oldNameVisible = target.getMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY).get(0).asBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,8 +23,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.CUSTOM_NAME_METAKEY, mcMMO.p);
|
target.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, mcMMO.p);
|
||||||
target.removeMetadata(mcMMO.NAME_VISIBILITY_METAKEY, mcMMO.p);
|
target.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, mcMMO.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -33,9 +34,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.PISTON_TRACKING_METAKEY)) {
|
if (nextBlock.hasMetadata(MetadataConstants.PISTON_TRACKING_METAKEY)) {
|
||||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||||
nextBlock.removeMetadata(mcMMO.PISTON_TRACKING_METAKEY, mcMMO.p);
|
nextBlock.removeMetadata(MetadataConstants.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);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.runnables.commands;
|
package com.gmail.nossr50.runnables.commands;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -36,7 +37,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
|||||||
if (useChat) {
|
if (useChat) {
|
||||||
displayChat();
|
displayChat();
|
||||||
}
|
}
|
||||||
((Player) sender).removeMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p);
|
((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChat() {
|
private void displayChat() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.runnables.commands;
|
package com.gmail.nossr50.runnables.commands;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@ -42,7 +43,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
((Player) sender).removeMetadata(mcMMO.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p);
|
((Player) sender).removeMetadata(MetadataConstants.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"));
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -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.ARROW_DISTANCE_METAKEY).get(0).value();
|
Location firedLocation = (Location) damager.getMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY).get(0).value();
|
||||||
Location targetLocation = target.getLocation();
|
Location targetLocation = target.getLocation();
|
||||||
|
|
||||||
if (firedLocation.getWorld() != targetLocation.getWorld()) {
|
if (firedLocation.getWorld() != targetLocation.getWorld()) {
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.fishing;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -88,10 +89,10 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFishHookReference(FishHook fishHook) {
|
public void setFishHookReference(FishHook fishHook) {
|
||||||
if (fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
|
if (fishHook.getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY).size() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fishHook.setMetadata(mcMMO.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
|
fishHook.setMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
|
||||||
fishHookSpawnTimestamp = System.currentTimeMillis();
|
fishHookSpawnTimestamp = System.currentTimeMillis();
|
||||||
fishingRodCastTimestamp = System.currentTimeMillis();
|
fishingRodCastTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
package com.gmail.nossr50.skills.herbalism;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@ -188,6 +189,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.GREEN_THUMB_METAKEY) && !SkillUtils.cooldownExpired(blockState.getMetadata(mcMMO.GREEN_THUMB_METAKEY).get(0).asInt(), 1);
|
return blockState.hasMetadata(MetadataConstants.GREEN_THUMB_METAKEY) && !SkillUtils.cooldownExpired(blockState.getMetadata(MetadataConstants.GREEN_THUMB_METAKEY).get(0).asInt(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.herbalism;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.MainConfig;
|
import com.gmail.nossr50.config.MainConfig;
|
||||||
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
|
import com.gmail.nossr50.config.treasure.HerbalismTreasureConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -340,7 +341,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.GREEN_THUMB_METAKEY, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
blockState.setMetadata(MetadataConstants.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()) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -88,12 +89,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.TNT_TRACKING_METAKEY) || !UserManager.hasPlayerDataKey(defender)) {
|
if (!tnt.hasMetadata(MetadataConstants.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.TNT_TRACKING_METAKEY).get(0).asString());
|
Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
|
||||||
|
|
||||||
if (!player.equals(defender)) {
|
if (!player.equals(defender)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.mining;
|
|||||||
|
|
||||||
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.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -125,7 +126,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.TNT_TRACKING_METAKEY, mcMMOPlayer.getPlayerMetadata());
|
tnt.setMetadata(MetadataConstants.TNT_TRACKING_METAKEY, mcMMOPlayer.getPlayerMetadata());
|
||||||
tnt.setFuseTicks(0);
|
tnt.setFuseTicks(0);
|
||||||
targetBlock.setType(Material.AIR);
|
targetBlock.setType(Material.AIR);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ 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.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -307,7 +308,7 @@ public class TamingManager extends SkillManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setMetadata(mcMMO.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, mcMMO.metadataValue);
|
||||||
((Tameable) entity).setOwner(player);
|
((Tameable) entity).setOwner(player);
|
||||||
entity.setRemoveWhenFarAway(false);
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.gmail.nossr50.skills.unarmed;
|
package com.gmail.nossr50.skills.unarmed;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -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.DISARMED_ITEM_METAKEY, UserManager.getPlayer(defender).getPlayerMetadata());
|
item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -29,9 +30,9 @@ public final class BlockUtils {
|
|||||||
*/
|
*/
|
||||||
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
|
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
|
||||||
if (triple)
|
if (triple)
|
||||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(2, mcMMO.p));
|
blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, mcMMO.p));
|
||||||
else
|
else
|
||||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(1, mcMMO.p));
|
blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(1, mcMMO.p));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.meta.OldName;
|
import com.gmail.nossr50.datatypes.meta.OldName;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -69,11 +70,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.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, oldName));
|
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, oldName));
|
||||||
target.setMetadata(mcMMO.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
||||||
} else if (!target.hasMetadata(mcMMO.CUSTOM_NAME_METAKEY)) {
|
} else if (!target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) {
|
||||||
target.setMetadata(mcMMO.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, ""));
|
target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, ""));
|
||||||
target.setMetadata(mcMMO.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, false));
|
target.setMetadata(MetadataConstants.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
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.commands;
|
package com.gmail.nossr50.util.commands;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.MainConfig;
|
import com.gmail.nossr50.config.MainConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
@ -124,7 +125,7 @@ public final class CommandUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(mcMMO.PLAYER_DATA_METAKEY);
|
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY);
|
||||||
|
|
||||||
if (!hasPlayerDataKey) {
|
if (!hasPlayerDataKey) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.util.player;
|
package com.gmail.nossr50.util.player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -22,7 +23,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.PLAYER_DATA_METAKEY, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
mcMMOPlayer.getPlayer().setMetadata(MetadataConstants.PLAYER_DATA_METAKEY, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +32,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.PLAYER_DATA_METAKEY, mcMMO.p);
|
player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, mcMMO.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,8 +102,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.PLAYER_DATA_METAKEY))
|
if (player != null && player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY))
|
||||||
return (McMMOPlayer) player.getMetadata(mcMMO.PLAYER_DATA_METAKEY).get(0).value();
|
return (McMMOPlayer) player.getMetadata(MetadataConstants.PLAYER_DATA_METAKEY).get(0).value();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -122,6 +123,6 @@ public final class UserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPlayerDataKey(Entity entity) {
|
public static boolean hasPlayerDataKey(Entity entity) {
|
||||||
return entity != null && entity.hasMetadata(mcMMO.PLAYER_DATA_METAKEY);
|
return entity != null && entity.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.skills;
|
package com.gmail.nossr50.util.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.core.MetadataConstants;
|
||||||
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;
|
||||||
@ -213,7 +214,7 @@ public final class CombatUtils {
|
|||||||
finalDamage += archeryManager.daze((Player) target);
|
finalDamage += archeryManager.daze((Player) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arrow.hasMetadata(mcMMO.INFINITE_ARROW_METAKEY) && archeryManager.canRetrieveArrows()) {
|
if (!arrow.hasMetadata(MetadataConstants.INFINITE_ARROW_METAKEY) && archeryManager.canRetrieveArrows()) {
|
||||||
archeryManager.retrieveArrows(target);
|
archeryManager.retrieveArrows(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +225,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.BOW_FORCE_METAKEY).get(0).asDouble() * distanceMultiplier);
|
startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, arrow.getMetadata(MetadataConstants.BOW_FORCE_METAKEY).get(0).asDouble() * distanceMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,7 +438,7 @@ public final class CombatUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
|
target.setMetadata(MetadataConstants.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
|
||||||
target.damage(damage, attacker);
|
target.damage(damage, attacker);
|
||||||
|
|
||||||
// //IFrame storage
|
// //IFrame storage
|
||||||
@ -573,11 +574,11 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.hasMetadata(mcMMO.UNNATURAL_MOB_METAKEY)) {
|
if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
|
||||||
baseXP *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult();
|
baseXP *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.hasMetadata(mcMMO.BRED_ANIMAL_TRACKING_METAKEY)) {
|
if (target.hasMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY)) {
|
||||||
baseXP *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult();
|
baseXP *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +815,7 @@ public final class CombatUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.hasMetadata(mcMMO.PLAYER_DATA_METAKEY)) {
|
if (!player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user