mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
2.1.205
This commit is contained in:
parent
ba1f15b655
commit
8d27e8fccf
@ -1,3 +1,10 @@
|
||||
Version 2.1.205
|
||||
Fixed yet another exception preventing Alchemy from working (thanks NemuruYama)
|
||||
Added some code to cleanup potential memory leaks
|
||||
|
||||
NOTES:
|
||||
Sorry for the delay in this patch, I have had a terrible cold all weekend, feeling better now
|
||||
|
||||
Version 2.1.204
|
||||
Fixed IndexOutOfBounds exception (thanks gecko10000) (related to Alchemy)
|
||||
Added double smelt to copper ingot and netherite scrap (thanks Lyther)
|
||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.204</version>
|
||||
<version>2.1.205</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.api;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -84,7 +84,7 @@ public final class AbilityAPI {
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
if(entity.isValid()) {
|
||||
if(entity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -97,11 +98,11 @@ public class McrankCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -97,11 +98,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
|
||||
if (((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
|
||||
return;
|
||||
} else {
|
||||
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
|
||||
((Player) sender).setMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, new FixedMetadataValue(mcMMO.p, null));
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
|
@ -41,10 +41,7 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.experience.ExperienceBarManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@ -1137,8 +1134,8 @@ public class McMMOPlayer implements Identified {
|
||||
*/
|
||||
public void logout(boolean syncSave) {
|
||||
Player thisPlayer = getPlayer();
|
||||
if(getPlayer().hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
|
||||
if(getPlayer().hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) getPlayer().getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
//Punish a logout
|
||||
ruptureTaskMeta.getRuptureTimerTask().endRupture();
|
||||
|
@ -91,8 +91,8 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(mcMMO.BONUS_DROPS_METAKEY).get(0);
|
||||
if (event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).size() > 0) {
|
||||
BonusDropMeta bonusDropMeta = (BonusDropMeta) event.getBlock().getMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS).get(0);
|
||||
int bonusCount = bonusDropMeta.asInt();
|
||||
|
||||
for (int i = 0; i < bonusCount; i++) {
|
||||
@ -102,8 +102,8 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY))
|
||||
event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin);
|
||||
if(event.getBlock().hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
|
||||
event.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,10 +17,7 @@ import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer;
|
||||
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@ -159,11 +156,11 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (bow != null
|
||||
&& bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_INF_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, Math.min(event.getForce() * mcMMO.p.getAdvancedConfig().getForceMultiplier(), 1.0)));
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
//Cleanup metadata in 1 minute in case normal collection falls through
|
||||
CombatUtils.delayArrowMetaCleanup((Projectile) projectile);
|
||||
}
|
||||
@ -191,11 +188,11 @@ public class EntityListener implements Listener {
|
||||
if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
|
||||
CombatUtils.delayArrowMetaCleanup(projectile); //Cleans up metadata 1 minute from now in case other collection methods fall through
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.bowForceKey))
|
||||
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, new FixedMetadataValue(pluginRef, 1.0));
|
||||
|
||||
if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
if(!projectile.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, new FixedMetadataValue(pluginRef, projectile.getLocation()));
|
||||
|
||||
//Check both hands
|
||||
if(ItemUtils.doesPlayerHaveEnchantmentInHands(player, "piercing")) {
|
||||
@ -203,7 +200,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
||||
projectile.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,12 +237,12 @@ public class EntityListener implements Listener {
|
||||
* It's a headache to read but it works, I'm tempted to just remove it
|
||||
*/
|
||||
if (entity instanceof FallingBlock || entity instanceof Enderman) {
|
||||
boolean isTracked = entity.hasMetadata(mcMMO.travelingBlock);
|
||||
boolean isTracked = entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK);
|
||||
|
||||
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
|
||||
entity.setMetadata(mcMMO.travelingBlock, mcMMO.metadataValue);
|
||||
entity.setMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
else if (isTracked) {
|
||||
mcMMO.getPlaceStore().setTrue(block);
|
||||
@ -254,7 +251,6 @@ public class EntityListener implements Listener {
|
||||
//Redstone ore fire this event and should be ignored
|
||||
}
|
||||
else {
|
||||
|
||||
if (mcMMO.getPlaceStore().isTrue(block)) {
|
||||
mcMMO.getPlaceStore().setFalse(block);
|
||||
}
|
||||
@ -490,8 +486,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
if(event.getEntity().hasMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE)) {
|
||||
event.getEntity().removeMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
@ -666,7 +662,7 @@ public class EntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDeathLowest(EntityDeathEvent event) {
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getEntity());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -773,13 +769,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@ -819,13 +815,13 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
Player player = pluginRef.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@ -1095,4 +1091,6 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
|
||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -427,7 +428,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
final HumanEntity whoClicked = event.getWhoClicked();
|
||||
|
||||
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
|
||||
if (!whoClicked.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||
import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
@ -185,7 +184,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Player killedPlayer = event.getEntity();
|
||||
|
||||
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
if (!killedPlayer.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA) || Permissions.hardcoreBypass(killedPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -273,7 +272,7 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
if (ItemUtils.isSharable(dropStack)) {
|
||||
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
|
||||
drop.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
SkillUtils.removeAbilityBuff(dropStack);
|
||||
@ -404,7 +403,7 @@ public class PlayerListener implements Listener {
|
||||
//Track the hook
|
||||
if(ExperienceConfig.getInstance().isFishingExploitingPrevented())
|
||||
{
|
||||
if(event.getHook().getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() == 0)
|
||||
if(event.getHook().getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() == 0)
|
||||
{
|
||||
fishingManager.setFishHookReference(event.getHook());
|
||||
}
|
||||
@ -515,19 +514,19 @@ public class PlayerListener implements Listener {
|
||||
ItemStack dropStack = drop.getItemStack();
|
||||
|
||||
//Remove tracking
|
||||
if(drop.hasMetadata(mcMMO.trackedArrow)) {
|
||||
drop.removeMetadata(mcMMO.trackedArrow, mcMMO.p);
|
||||
if(drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
drop.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p);
|
||||
}
|
||||
|
||||
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
||||
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
|
||||
if (drop.hasMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM)) {
|
||||
if (!player.getName().equals(drop.getMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM).get(0).asString())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
if (!drop.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ITEM) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@ -574,7 +573,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
//Use a sync save if the server is shutting down to avoid race conditions
|
||||
mcMMOPlayer.logout(mcMMO.isServerShutdownExecuted());
|
||||
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getPlayer());
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,6 +75,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
|
||||
/* Managers */
|
||||
private static PlatformManager platformManager;
|
||||
private static ChunkManager placeStore;
|
||||
@ -129,29 +131,6 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
private static boolean isRetroModeEnabled;
|
||||
|
||||
/* Metadata Values */
|
||||
public static final String REPLANT_META_KEY = "mcMMO: Recently Replanted";
|
||||
public static final String EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
|
||||
public static final String RUPTURE_META_KEY = "mcMMO: RuptureTask";
|
||||
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
|
||||
public static final String DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
|
||||
public static final String travelingBlock = "mcMMO: Traveling Block";
|
||||
public static final String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||
public static final String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||
public static final String customNameKey = "mcMMO: Custom Name";
|
||||
public static final String customVisibleKey = "mcMMO: Name Visibility";
|
||||
public static final String droppedItemKey = "mcMMO: Tracked Item";
|
||||
public static final String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
||||
public static final String trackedArrow = "mcMMO: Tracked Arrow";
|
||||
public static final String bowForceKey = "mcMMO: Bow Force";
|
||||
public static final String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||
public static final String BONUS_DROPS_METAKEY = "mcMMO: Double Drops";
|
||||
public static final String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public static final String playerDataKey = "mcMMO: Player Data";
|
||||
public static final String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
private long purgeTime = 2630000000L;
|
||||
|
||||
private GeneralConfig generalConfig;
|
||||
@ -199,7 +178,7 @@ public class mcMMO extends JavaPlugin {
|
||||
//Filter out any debug messages (if debug/verbose logging is not enabled)
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
|
||||
metadataValue = new FixedMetadataValue(this, true);
|
||||
MetadataConstants.MCMMO_METADATA_VALUE = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@ -13,14 +14,14 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (target.hasMetadata(mcMMO.customNameKey)) {
|
||||
target.setCustomName(target.getMetadata(mcMMO.customNameKey).get(0).asString());
|
||||
target.removeMetadata(mcMMO.customNameKey, mcMMO.p);
|
||||
if (target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY)) {
|
||||
target.setCustomName(target.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY).get(0).asString());
|
||||
target.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY, mcMMO.p);
|
||||
}
|
||||
|
||||
if (target.hasMetadata(mcMMO.customVisibleKey)) {
|
||||
target.setCustomNameVisible(target.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
||||
target.removeMetadata(mcMMO.customVisibleKey, mcMMO.p);
|
||||
if (target.hasMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY)) {
|
||||
target.setCustomNameVisible(target.getMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY).get(0).asBoolean());
|
||||
target.removeMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, mcMMO.p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -33,9 +34,9 @@ public class PistonTrackerTask extends BukkitRunnable {
|
||||
for (Block b : blocks) {
|
||||
Block nextBlock = b.getRelative(direction);
|
||||
|
||||
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
||||
if (nextBlock.hasMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING)) {
|
||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
|
||||
nextBlock.removeMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING, mcMMO.p);
|
||||
}
|
||||
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
|
||||
// Block doesn't have metadatakey but isTrue - set it to false
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.commands;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -37,7 +38,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
((Player) sender).removeMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, mcMMO.p);
|
||||
}
|
||||
|
||||
private void displayChat() {
|
||||
|
@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -42,7 +43,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||
((Player) sender).removeMetadata(MetadataConstants.METADATA_KEY_DATABASE_COMMAND, mcMMO.p);
|
||||
}
|
||||
if(sender instanceof Player)
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
|
@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Chunk;
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.meta.RecentlyReplantedCropMeta;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -171,8 +172,8 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Block cropBlock = cropLoc.getBlock();
|
||||
if(cropBlock.getMetadata(mcMMO.REPLANT_META_KEY).size() > 0)
|
||||
cropBlock.setMetadata(mcMMO.REPLANT_META_KEY, new RecentlyReplantedCropMeta(mcMMO.p, false));
|
||||
if(cropBlock.getMetadata(MetadataConstants.METADATA_KEY_REPLANT).size() > 0)
|
||||
cropBlock.setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -63,7 +64,7 @@ public class RuptureTask extends BukkitRunnable {
|
||||
endRupture();
|
||||
}
|
||||
} else {
|
||||
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
|
||||
targetEntity.removeMetadata(MetadataConstants.METADATA_KEY_RUPTURE, mcMMO.p);
|
||||
this.cancel(); //Task no longer needed
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@ -101,18 +102,18 @@ public class AcrobaticsManager extends SkillManager {
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if(!(attacker instanceof Player)) {
|
||||
//Check to see how many dodge XP rewards this mob has handed out
|
||||
if(attacker.hasMetadata(mcMMO.DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
if(attacker.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
//If Dodge XP has been handed out 5 times then consider it being exploited
|
||||
MetadataValue metadataValue = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0);
|
||||
int count = attacker.getMetadata(mcMMO.DODGE_TRACKER).get(0).asInt();
|
||||
MetadataValue metadataValue = attacker.getMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0);
|
||||
int count = attacker.getMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER).get(0).asInt();
|
||||
|
||||
if(count <= 5) {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
attacker.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, count + 1));
|
||||
}
|
||||
} else {
|
||||
applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVE);
|
||||
attacker.setMetadata(mcMMO.DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, 1));
|
||||
attacker.setMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER, new FixedMetadataValue(mcMMO.p, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public final class AlchemyPotionBrewer {
|
||||
removeIngredient(inventory, player);
|
||||
|
||||
for (AlchemyPotion input : inputList) {
|
||||
if (input == null) continue;;
|
||||
if (input == null) continue;
|
||||
|
||||
AlchemyPotion output = input.getChild(ingredient);
|
||||
|
||||
|
@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
@ -54,10 +55,10 @@ public class ArcheryManager extends SkillManager {
|
||||
*/
|
||||
public double distanceXpBonusMultiplier(LivingEntity target, Entity arrow) {
|
||||
//Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
|
||||
if(!arrow.hasMetadata(mcMMO.arrowDistanceKey))
|
||||
if(!arrow.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE))
|
||||
return 1;
|
||||
|
||||
Location firedLocation = (Location) arrow.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
|
||||
Location firedLocation = (Location) arrow.getMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE).get(0).value();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
if(firedLocation == null || firedLocation.getWorld() == null)
|
||||
@ -76,9 +77,9 @@ public class ArcheryManager extends SkillManager {
|
||||
* @param target The {@link LivingEntity} damaged by the arrow
|
||||
*/
|
||||
public void retrieveArrows(LivingEntity target, Projectile projectile) {
|
||||
if(projectile.hasMetadata(mcMMO.trackedArrow)) {
|
||||
if(projectile.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW)) {
|
||||
Archery.incrementTrackerValue(target);
|
||||
projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile
|
||||
projectile.removeMetadata(MetadataConstants.METADATA_KEY_TRACKED_ARROW, mcMMO.p); //Only 1 entity per projectile
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,10 +100,10 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
public void setFishHookReference(FishHook fishHook)
|
||||
{
|
||||
if(fishHook.getMetadata(mcMMO.FISH_HOOK_REF_METAKEY).size() > 0)
|
||||
if(fishHook.getMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF).size() > 0)
|
||||
return;
|
||||
|
||||
fishHook.setMetadata(mcMMO.FISH_HOOK_REF_METAKEY, mcMMO.metadataValue);
|
||||
fishHook.setMetadata(MetadataConstants.METADATA_KEY_FISH_HOOK_REF, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
this.fishHookReference = fishHook;
|
||||
fishHookSpawnTimestamp = System.currentTimeMillis();
|
||||
fishingRodCastTimestamp = System.currentTimeMillis();
|
||||
|
@ -217,10 +217,10 @@ public class HerbalismManager extends SkillManager {
|
||||
if(blockBreakEvent.getBlock().getBlockData() instanceof Ageable) {
|
||||
Ageable ageableCrop = (Ageable) blockBreakEvent.getBlock().getBlockData();
|
||||
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).size() >= 1) {
|
||||
if(blockBreakEvent.getBlock().getMetadata(mcMMO.REPLANT_META_KEY).get(0).asBoolean()) {
|
||||
if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.METADATA_KEY_REPLANT).size() >= 1) {
|
||||
if(blockBreakEvent.getBlock().getMetadata(MetadataConstants.METADATA_KEY_REPLANT).get(0).asBoolean()) {
|
||||
if(isAgeableMature(ageableCrop)) {
|
||||
blockBreakEvent.getBlock().removeMetadata(mcMMO.REPLANT_META_KEY, mcMMO.p);
|
||||
blockBreakEvent.getBlock().removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
|
||||
} else {
|
||||
//Crop is recently replanted to back out of destroying it
|
||||
blockBreakEvent.setCancelled(true);
|
||||
@ -488,8 +488,8 @@ public class HerbalismManager extends SkillManager {
|
||||
BlockState brokenBlockNewState = blockSnapshot.getBlockRef().getState();
|
||||
|
||||
//Remove metadata from the snapshot of blocks
|
||||
if(brokenBlockNewState.hasMetadata(mcMMO.BONUS_DROPS_METAKEY)) {
|
||||
brokenBlockNewState.removeMetadata(mcMMO.BONUS_DROPS_METAKEY, mcMMO.p);
|
||||
if(brokenBlockNewState.hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS)) {
|
||||
brokenBlockNewState.removeMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, mcMMO.p);
|
||||
}
|
||||
|
||||
//If the block is not AIR that means it wasn't broken
|
||||
@ -744,7 +744,7 @@ public class HerbalismManager extends SkillManager {
|
||||
private void startReplantTask(int desiredCropAge, BlockBreakEvent blockBreakEvent, BlockState cropState, boolean isImmature) {
|
||||
//Mark the plant as recently replanted to avoid accidental breakage
|
||||
new DelayedCropReplant(blockBreakEvent, cropState, desiredCropAge, isImmature).runTaskLater(mcMMO.p, 20 * 2);
|
||||
blockBreakEvent.getBlock().setMetadata(mcMMO.REPLANT_META_KEY, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
blockBreakEvent.getBlock().setMetadata(MetadataConstants.METADATA_KEY_REPLANT, new RecentlyReplantedCropMeta(mcMMO.p, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -91,12 +92,12 @@ public class BlastMining {
|
||||
}
|
||||
|
||||
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
|
||||
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
if (!tnt.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT) || !UserManager.hasPlayerDataKey(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
||||
|
||||
if (!(player != null && player.equals(defender))) {
|
||||
return false;
|
||||
|
@ -121,7 +121,7 @@ public class MiningManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom");
|
||||
//player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
|
||||
tnt.setMetadata(mcMMO.tntMetadataKey, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT, mmoPlayer.getPlayerMetadata());
|
||||
tnt.setFuseTicks(0);
|
||||
if (mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 16, 4)) {
|
||||
tnt.setSource(player);
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.skills.RuptureTask;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@ -66,8 +67,8 @@ public class SwordsManager extends SkillManager {
|
||||
if(!canUseRupture())
|
||||
return;
|
||||
|
||||
if(target.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
|
||||
if(target.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(MetadataConstants.METADATA_KEY_RUPTURE).get(0);
|
||||
|
||||
if(mmoPlayer.isDebugMode()) {
|
||||
mmoPlayer.getPlayer().sendMessage("Rupture task ongoing for target " + target.toString());
|
||||
@ -99,7 +100,7 @@ public class SwordsManager extends SkillManager {
|
||||
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
|
||||
|
||||
ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
|
||||
target.setMetadata(mcMMO.RUPTURE_META_KEY, ruptureTaskMeta);
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_RUPTURE, ruptureTaskMeta);
|
||||
|
||||
// if (mmoPlayer.useChatNotifications()) {
|
||||
// NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
|
||||
|
@ -9,10 +9,7 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
@ -113,7 +110,7 @@ public class UnarmedManager extends SkillManager {
|
||||
Item item = Misc.spawnItem(getPlayer(), defender.getLocation(), defender.getInventory().getItemInMainHand(), ItemSpawnReason.UNARMED_DISARMED_ITEM);
|
||||
|
||||
if (item != null && mcMMO.p.getAdvancedConfig().getDisarmProtected()) {
|
||||
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
item.setMetadata(MetadataConstants.METADATA_KEY_DISARMED_ITEM, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||
}
|
||||
|
||||
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
|
@ -34,9 +34,9 @@ public final class BlockUtils {
|
||||
*/
|
||||
public static void markDropsAsBonus(BlockState blockState, boolean triple) {
|
||||
if (triple)
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(2, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(2, mcMMO.p));
|
||||
else
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(1, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ public final class BlockUtils {
|
||||
* @param amount amount of extra items to drop
|
||||
*/
|
||||
public static void markDropsAsBonus(BlockState blockState, int amount) {
|
||||
blockState.setMetadata(mcMMO.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, mcMMO.p));
|
||||
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(amount, mcMMO.p));
|
||||
}
|
||||
|
||||
/**
|
||||
|
69
src/main/java/com/gmail/nossr50/util/MetadataConstants.java
Normal file
69
src/main/java/com/gmail/nossr50/util/MetadataConstants.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Stores our constants related to metadata
|
||||
*/
|
||||
public class MetadataConstants {
|
||||
/* Metadata Values
|
||||
* Take great care if you ever modify the value of these keys
|
||||
*/
|
||||
public static final @NotNull String METADATA_KEY_REPLANT = "mcMMO: Recently Replanted";
|
||||
public static final @NotNull String METADATA_KEY_EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
|
||||
public static final @NotNull String METADATA_KEY_FISH_HOOK_REF = "mcMMO: Fish Hook Tracker";
|
||||
public static final @NotNull String METADATA_KEY_DODGE_TRACKER = "mcMMO: Dodge Tracker";
|
||||
public static final @NotNull String METADATA_KEY_CUSTOM_DAMAGE = "mcMMO: Custom Damage";
|
||||
public static final @NotNull String METADATA_KEY_TRAVELING_BLOCK = "mcMMO: Traveling Block";
|
||||
public static final @NotNull String METADATA_KEY_PISTON_TRACKING = "mcMMO: Piston Tracking";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_TNT = "mcMMO: Tracked TNT";
|
||||
public static final @NotNull String METADATA_KEY_NAME_VISIBILITY = "mcMMO: Name Visibility";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_ITEM = "mcMMO: Tracked Item";
|
||||
public static final @NotNull String METADATA_KEY_INF_ARROW = "mcMMO: Infinite Arrow";
|
||||
public static final @NotNull String METADATA_KEY_TRACKED_ARROW = "mcMMO: Tracked Arrow";
|
||||
public static final @NotNull String METADATA_KEY_BOW_FORCE = "mcMMO: Bow Force";
|
||||
public static final @NotNull String METADATA_KEY_ARROW_DISTANCE = "mcMMO: Arrow Distance";
|
||||
public static final @NotNull String METADATA_KEY_BONUS_DROPS = "mcMMO: Double Drops";
|
||||
public static final @NotNull String METADATA_KEY_DISARMED_ITEM = "mcMMO: Disarmed Item";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_DATA = "mcMMO: Player Data";
|
||||
public static final @NotNull String METADATA_KEY_DATABASE_COMMAND = "mcMMO: Processing Database Command";
|
||||
public static final @NotNull String METADATA_KEY_FURNACE_UUID_MOST_SIG = "furnace_uuid_most_sig";
|
||||
public static final @NotNull String METADATA_KEY_FURNACE_UUID_LEAST_SIG = "furnace_uuid_least_sig";
|
||||
public static final @NotNull String METADATA_KEY_SUPER_ABILITY_BOOSTED_ITEM = "super_ability_boosted";
|
||||
public static final @NotNull String METADATA_KEY_MOB_SPAWNER_MOB = "mcmmo_mob_spawner_mob";
|
||||
public static final @NotNull String METADATA_KEY_EGG_MOB = "mcmmo_egg_mob";
|
||||
public static final @NotNull String METADATA_KEY_NETHER_PORTAL_MOB = "mcmmo_nethergate_mob";
|
||||
public static final @NotNull String METADATA_KEY_COTW_SUMMONED_MOB = "mcmmo_cotw_summoned_mob";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_BRED_MOB = "mcmmo_player_bred_mob";
|
||||
public static final @NotNull String METADATA_KEY_PLAYER_TAMED_MOB = "mcmmo_player_tamed_mob";
|
||||
public static final @NotNull String METADATA_KEY_VILLAGER_TRADE_ORIGIN_ITEM = "mcmmo_villager_trade_origin_item";
|
||||
public static final @NotNull String METADATA_KEY_EXPLOITED_ENDERMEN = "mcmmo_exploited_endermen";
|
||||
public static final @NotNull String METADATA_KEY_CUSTOM_NAME_KEY = "mcmmo_custom_name";
|
||||
public static final @NotNull String METADATA_KEY_OLD_NAME_KEY = "mcmmo_old_name";
|
||||
public static final @NotNull String METADATA_KEY_RUPTURE = "mcmmo_rupture";
|
||||
|
||||
public static final byte SIMPLE_FLAG_VALUE = (byte) 0x1;
|
||||
|
||||
public static final @NotNull Set<String> MOB_METADATA_KEYS;
|
||||
|
||||
public static FixedMetadataValue MCMMO_METADATA_VALUE;
|
||||
|
||||
static {
|
||||
MOB_METADATA_KEYS = new HashSet<>();
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_RUPTURE);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE);
|
||||
MOB_METADATA_KEYS.add(MetadataConstants.METADATA_KEY_OLD_NAME_KEY);
|
||||
}
|
||||
}
|
@ -54,8 +54,8 @@ public final class MobHealthbarUtils {
|
||||
/*
|
||||
* Store the name in metadata
|
||||
*/
|
||||
if(target.getMetadata(TransientMetadataTools.OLD_NAME_METAKEY).size() <= 0 && originalName != null)
|
||||
target.setMetadata(TransientMetadataTools.OLD_NAME_METAKEY, new OldName(originalName, plugin));
|
||||
if(target.getMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY).size() <= 0)
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY, new OldName(originalName, plugin));
|
||||
|
||||
if (oldName == null) {
|
||||
oldName = "";
|
||||
@ -73,12 +73,12 @@ public final class MobHealthbarUtils {
|
||||
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
|
||||
|
||||
if (updateName) {
|
||||
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, oldName));
|
||||
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY, new FixedMetadataValue(mcMMO.p, oldName));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, oldNameVisible));
|
||||
}
|
||||
else if (!target.hasMetadata(mcMMO.customNameKey)) {
|
||||
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, ""));
|
||||
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, false));
|
||||
else if (!target.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY)) {
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY, new FixedMetadataValue(mcMMO.p, ""));
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
|
||||
}
|
||||
|
||||
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
|
@ -1,48 +1,50 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TransientMetadataTools {
|
||||
public static final String OLD_NAME_METAKEY = TransientMetadataTools.OLD_NAME_METAKEY;
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public TransientMetadataTools(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public void cleanAllLivingEntityMetadata(@NotNull LivingEntity livingEntity) {
|
||||
//Since its not written anywhere, apparently the GC won't touch objects with metadata still present on them
|
||||
if (livingEntity.hasMetadata(mcMMO.customNameKey)) {
|
||||
livingEntity.setCustomName(livingEntity.getMetadata(mcMMO.customNameKey).get(0).asString());
|
||||
livingEntity.removeMetadata(mcMMO.customNameKey, pluginRef);
|
||||
public void cleanLivingEntityMetadata(@NotNull LivingEntity entity) {
|
||||
//Since it's not written anywhere, apparently the GC won't touch objects with metadata still present on them
|
||||
if (entity.hasMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY)) {
|
||||
entity.setCustomName(entity.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY).get(0).asString());
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_NAME_KEY, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(OLD_NAME_METAKEY)) {
|
||||
livingEntity.removeMetadata(OLD_NAME_METAKEY, pluginRef);
|
||||
}
|
||||
// if(entity.hasMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY)) {
|
||||
// CombatUtils.fixNames(entity);
|
||||
// entity.removeMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY, pluginRef);
|
||||
// }
|
||||
|
||||
//Involved in changing mob names to hearts
|
||||
if (livingEntity.hasMetadata(mcMMO.customVisibleKey)) {
|
||||
livingEntity.setCustomNameVisible(livingEntity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
||||
livingEntity.removeMetadata(mcMMO.customVisibleKey, pluginRef);
|
||||
if (entity.hasMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY)) {
|
||||
entity.setCustomNameVisible(entity.getMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY).get(0).asBoolean());
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, pluginRef);
|
||||
}
|
||||
|
||||
//Gets assigned to endermen, potentially doesn't get cleared before this point
|
||||
if(livingEntity.hasMetadata(mcMMO.travelingBlock)) {
|
||||
livingEntity.removeMetadata(mcMMO.travelingBlock, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
|
||||
livingEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, pluginRef);
|
||||
}
|
||||
|
||||
if(livingEntity.hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
|
||||
livingEntity.removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, pluginRef);
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK)) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_TRAVELING_BLOCK, pluginRef);
|
||||
}
|
||||
|
||||
//Cleanup mob metadata
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().removeMobFlags(livingEntity);
|
||||
mcMMO.getCompatibilityManager().getPersistentDataLayer().removeMobFlags(entity);
|
||||
|
||||
//TODO: This loop has some redundancy, this whole method needs to be rewritten
|
||||
for(String key : MetadataConstants.MOB_METADATA_KEYS) {
|
||||
if(entity.hasMetadata(key)) {
|
||||
entity.removeMetadata(key, pluginRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
@ -110,7 +111,7 @@ public final class CommandUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(mcMMO.playerDataKey);
|
||||
boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA);
|
||||
|
||||
if (!hasPlayerDataKey) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.compat.layers.AbstractCompatibilityLayer;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Furnace;
|
||||
@ -25,42 +26,23 @@ public abstract class AbstractPersistentDataLayer extends AbstractCompatibilityL
|
||||
protected final @NotNull NamespacedKey NSK_VILLAGER_TRADE_ORIGIN_ITEM;
|
||||
protected final @NotNull NamespacedKey NSK_EXPLOITED_ENDERMEN;
|
||||
|
||||
//Never change these constants
|
||||
public final @NotNull String STR_SUPER_ABILITY_BOOSTED_ITEM = "super_ability_boosted";
|
||||
public final @NotNull String STR_MOB_SPAWNER_MOB = "mcmmo_mob_spawner_mob";
|
||||
public final @NotNull String STR_EGG_MOB = "mcmmo_egg_mob";
|
||||
public final @NotNull String STR_NETHER_PORTAL_MOB = "mcmmo_nethergate_mob";
|
||||
public final @NotNull String STR_COTW_SUMMONED_MOB = "mcmmo_cotw_summoned_mob";
|
||||
public final @NotNull String STR_PLAYER_BRED_MOB = "mcmmo_player_bred_mob";
|
||||
public final @NotNull String STR_PLAYER_TAMED_MOB = "mcmmo_player_tamed_mob";
|
||||
public final @NotNull String STR_VILLAGER_TRADE_ORIGIN_ITEM = "mcmmo_villager_trade_origin_item";
|
||||
public final @NotNull String STR_EXPLOITED_ENDERMEN = "mcmmo_exploited_endermen";
|
||||
|
||||
/*
|
||||
* Don't modify these keys
|
||||
*/
|
||||
public final @NotNull String STR_FURNACE_UUID_MOST_SIG = "furnace_uuid_most_sig";
|
||||
public final @NotNull String STR_FURNACE_UUID_LEAST_SIG = "furnace_uuid_least_sig";
|
||||
|
||||
protected final @NotNull NamespacedKey NSK_FURNACE_UUID_MOST_SIG;
|
||||
protected final @NotNull NamespacedKey NSK_FURNACE_UUID_LEAST_SIG;
|
||||
|
||||
public final @NotNull String LEGACY_ABILITY_TOOL_LORE = "mcMMO Ability Tool";
|
||||
|
||||
protected static final byte SIMPLE_FLAG_VALUE = (byte) 0x1;
|
||||
|
||||
public AbstractPersistentDataLayer() {
|
||||
NSK_SUPER_ABILITY_BOOSTED_ITEM = getNamespacedKey(STR_SUPER_ABILITY_BOOSTED_ITEM);
|
||||
NSK_MOB_SPAWNER_MOB = getNamespacedKey(STR_MOB_SPAWNER_MOB);
|
||||
NSK_EGG_MOB = getNamespacedKey(STR_EGG_MOB);
|
||||
NSK_NETHER_GATE_MOB = getNamespacedKey(STR_NETHER_PORTAL_MOB);
|
||||
NSK_COTW_SUMMONED_MOB = getNamespacedKey(STR_COTW_SUMMONED_MOB);
|
||||
NSK_PLAYER_BRED_MOB = getNamespacedKey(STR_PLAYER_BRED_MOB);
|
||||
NSK_PLAYER_TAMED_MOB = getNamespacedKey(STR_PLAYER_TAMED_MOB);
|
||||
NSK_VILLAGER_TRADE_ORIGIN_ITEM = getNamespacedKey(STR_VILLAGER_TRADE_ORIGIN_ITEM);
|
||||
NSK_EXPLOITED_ENDERMEN = getNamespacedKey(STR_EXPLOITED_ENDERMEN);
|
||||
NSK_FURNACE_UUID_MOST_SIG = getNamespacedKey(STR_FURNACE_UUID_MOST_SIG);
|
||||
NSK_FURNACE_UUID_LEAST_SIG = getNamespacedKey(STR_FURNACE_UUID_LEAST_SIG);
|
||||
NSK_SUPER_ABILITY_BOOSTED_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_SUPER_ABILITY_BOOSTED_ITEM);
|
||||
NSK_MOB_SPAWNER_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
NSK_EGG_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
NSK_NETHER_GATE_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
NSK_COTW_SUMMONED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
NSK_PLAYER_BRED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
NSK_PLAYER_TAMED_MOB = getNamespacedKey(MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
NSK_VILLAGER_TRADE_ORIGIN_ITEM = getNamespacedKey(MetadataConstants.METADATA_KEY_VILLAGER_TRADE_ORIGIN_ITEM);
|
||||
NSK_EXPLOITED_ENDERMEN = getNamespacedKey(MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
NSK_FURNACE_UUID_MOST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_MOST_SIG);
|
||||
NSK_FURNACE_UUID_LEAST_SIG = getNamespacedKey(MetadataConstants.METADATA_KEY_FURNACE_UUID_LEAST_SIG);
|
||||
|
||||
initializeLayer();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
||||
import com.gmail.nossr50.datatypes.meta.UUIDMeta;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -36,30 +37,15 @@ public class SpigotPersistentDataLayer_1_13 extends AbstractPersistentDataLayer
|
||||
|
||||
private void initMobFlagKeyMap() throws IncompleteNamespacedKeyRegister {
|
||||
for(MobMetaFlagType flagType : MobMetaFlagType.values()) {
|
||||
switch(flagType) {
|
||||
case MOB_SPAWNER_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_MOB_SPAWNER_MOB);
|
||||
break;
|
||||
case EGG_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_EGG_MOB);
|
||||
break;
|
||||
case NETHER_PORTAL_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_NETHER_PORTAL_MOB);
|
||||
break;
|
||||
case COTW_SUMMONED_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_COTW_SUMMONED_MOB);
|
||||
break;
|
||||
case PLAYER_BRED_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_PLAYER_BRED_MOB);
|
||||
break;
|
||||
case PLAYER_TAMED_MOB:
|
||||
mobFlagKeyMap.put(flagType, STR_PLAYER_TAMED_MOB);
|
||||
break;
|
||||
case EXPLOITED_ENDERMEN:
|
||||
mobFlagKeyMap.put(flagType, STR_EXPLOITED_ENDERMEN);
|
||||
break;
|
||||
default:
|
||||
throw new IncompleteNamespacedKeyRegister("Missing flag register for: "+flagType.toString());
|
||||
switch (flagType) {
|
||||
case MOB_SPAWNER_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_MOB_SPAWNER_MOB);
|
||||
case EGG_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_EGG_MOB);
|
||||
case NETHER_PORTAL_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_NETHER_PORTAL_MOB);
|
||||
case COTW_SUMMONED_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_COTW_SUMMONED_MOB);
|
||||
case PLAYER_BRED_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_PLAYER_BRED_MOB);
|
||||
case PLAYER_TAMED_MOB -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_PLAYER_TAMED_MOB);
|
||||
case EXPLOITED_ENDERMEN -> mobFlagKeyMap.put(flagType, MetadataConstants.METADATA_KEY_EXPLOITED_ENDERMEN);
|
||||
default -> throw new IncompleteNamespacedKeyRegister("Missing flag register for: " + flagType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,7 +78,7 @@ public class SpigotPersistentDataLayer_1_13 extends AbstractPersistentDataLayer
|
||||
@Override
|
||||
public void flagMetadata(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||
if(!hasMobFlag(flag, livingEntity)) {
|
||||
livingEntity.setMetadata(mobFlagKeyMap.get(flag), mcMMO.metadataValue);
|
||||
livingEntity.setMetadata(mobFlagKeyMap.get(flag), MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,10 +91,8 @@ public class SpigotPersistentDataLayer_1_13 extends AbstractPersistentDataLayer
|
||||
|
||||
@Override
|
||||
public UUID getFurnaceOwner(@NotNull Furnace furnace) {
|
||||
Metadatable metadatable = (Metadatable) furnace;
|
||||
|
||||
if(metadatable.getMetadata(KEY_FURNACE_OWNER).size() > 0) {
|
||||
UUIDMeta uuidMeta = (UUIDMeta) metadatable.getMetadata(KEY_FURNACE_OWNER).get(0);
|
||||
if(furnace.getMetadata(KEY_FURNACE_OWNER).size() > 0) {
|
||||
UUIDMeta uuidMeta = (UUIDMeta) ((Metadatable) furnace).getMetadata(KEY_FURNACE_OWNER).get(0);
|
||||
return (UUID) uuidMeta.value();
|
||||
} else {
|
||||
return null;
|
||||
@ -117,13 +101,12 @@ public class SpigotPersistentDataLayer_1_13 extends AbstractPersistentDataLayer
|
||||
|
||||
@Override
|
||||
public void setFurnaceOwner(@NotNull Furnace furnace, @NotNull UUID uuid) {
|
||||
Metadatable metadatable = (Metadatable) furnace;
|
||||
|
||||
if(metadatable.getMetadata(KEY_FURNACE_OWNER).size() > 0) {
|
||||
metadatable.removeMetadata(KEY_FURNACE_OWNER, mcMMO.p);
|
||||
if(furnace.getMetadata(KEY_FURNACE_OWNER).size() > 0) {
|
||||
furnace.removeMetadata(KEY_FURNACE_OWNER, mcMMO.p);
|
||||
}
|
||||
|
||||
metadatable.setMetadata(KEY_FURNACE_OWNER, new UUIDMeta(mcMMO.p, uuid));
|
||||
furnace.setMetadata(KEY_FURNACE_OWNER, new UUIDMeta(mcMMO.p, uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
||||
import com.gmail.nossr50.config.PersistentDataConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -101,7 +102,7 @@ public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer
|
||||
if(PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||
if(!hasMobFlag(flag, livingEntity)) {
|
||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, SIMPLE_FLAG_VALUE);
|
||||
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, MetadataConstants.SIMPLE_FLAG_VALUE);
|
||||
}
|
||||
} else {
|
||||
transientLayer.flagMetadata(flag, livingEntity);
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.util.player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -24,7 +25,7 @@ public final class UserManager {
|
||||
* @param mcMMOPlayer the player profile to start tracking
|
||||
*/
|
||||
public static void track(McMMOPlayer mcMMOPlayer) {
|
||||
mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||
mcMMOPlayer.getPlayer().setMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA, new FixedMetadataValue(mcMMO.p, mcMMOPlayer));
|
||||
|
||||
if(playerDataSet == null)
|
||||
playerDataSet = new HashSet<>();
|
||||
@ -45,7 +46,7 @@ public final class UserManager {
|
||||
public static void remove(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = getPlayer(player);
|
||||
mcMMOPlayer.cleanup();
|
||||
player.removeMetadata(mcMMO.playerDataKey, mcMMO.p);
|
||||
player.removeMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA, mcMMO.p);
|
||||
|
||||
if(playerDataSet != null) {
|
||||
playerDataSet.remove(mcMMOPlayer); //Clear sync save tracking
|
||||
@ -131,8 +132,8 @@ public final class UserManager {
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
//Avoid Array Index out of bounds
|
||||
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
|
||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||
if(player != null && player.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA))
|
||||
return (McMMOPlayer) player.getMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA).get(0).value();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
@ -152,6 +153,6 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
public static boolean hasPlayerDataKey(Entity entity) {
|
||||
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
|
||||
return entity != null && entity.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA);
|
||||
}
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public final class CombatUtils {
|
||||
finalDamage+=archeryManager.daze((Player) target); //the cast is checked by the if condition
|
||||
}
|
||||
|
||||
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
|
||||
if (!arrow.hasMetadata(MetadataConstants.METADATA_KEY_INF_ARROW) && archeryManager.canRetrieveArrows()) {
|
||||
archeryManager.retrieveArrows(target, arrow);
|
||||
}
|
||||
|
||||
@ -295,8 +295,8 @@ public final class CombatUtils {
|
||||
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
|
||||
double forceMultiplier = 1.0; //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
|
||||
|
||||
if(arrow.hasMetadata(mcMMO.bowForceKey))
|
||||
forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
|
||||
if(arrow.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE))
|
||||
forceMultiplier = arrow.getMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE).get(0).asDouble();
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
|
||||
@ -453,7 +453,7 @@ public final class CombatUtils {
|
||||
*/
|
||||
public static void fixNames(@NotNull LivingEntity entity)
|
||||
{
|
||||
List<MetadataValue> metadataValue = entity.getMetadata(TransientMetadataTools.OLD_NAME_METAKEY);
|
||||
List<MetadataValue> metadataValue = entity.getMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY);
|
||||
|
||||
if(metadataValue.size() <= 0)
|
||||
return;
|
||||
@ -461,6 +461,8 @@ public final class CombatUtils {
|
||||
OldName oldName = (OldName) metadataValue.get(0);
|
||||
entity.setCustomName(oldName.asString());
|
||||
entity.setCustomNameVisible(false);
|
||||
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_OLD_NAME_KEY, mcMMO.p);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -632,15 +634,15 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
public static void removeIgnoreDamageMetadata(@NotNull LivingEntity target) {
|
||||
target.removeMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.p);
|
||||
target.removeMetadata(MetadataConstants.METADATA_KEY_CUSTOM_DAMAGE, mcMMO.p);
|
||||
}
|
||||
|
||||
public static void applyIgnoreDamageMetadata(@NotNull LivingEntity target) {
|
||||
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_CUSTOM_DAMAGE, MetadataConstants.MCMMO_METADATA_VALUE);
|
||||
}
|
||||
|
||||
public static boolean hasIgnoreDamageMetadata(@NotNull LivingEntity target) {
|
||||
return target.getMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY).size() != 0;
|
||||
return target.getMetadata(MetadataConstants.METADATA_KEY_CUSTOM_DAMAGE).size() != 0;
|
||||
}
|
||||
|
||||
public static void dealNoInvulnerabilityTickDamageRupture(@NotNull LivingEntity target, double damage, Entity attacker, int toolTier) {
|
||||
@ -1047,7 +1049,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasMetadata(mcMMO.playerDataKey)) {
|
||||
if (!player.hasMetadata(MetadataConstants.METADATA_KEY_PLAYER_DATA)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1069,16 +1071,16 @@ public final class CombatUtils {
|
||||
* @param entity projectile
|
||||
*/
|
||||
public static void cleanupArrowMetadata(@NotNull Projectile entity) {
|
||||
if(entity.hasMetadata(mcMMO.infiniteArrowKey)) {
|
||||
entity.removeMetadata(mcMMO.infiniteArrowKey, mcMMO.p);
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_INF_ARROW)) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_INF_ARROW, mcMMO.p);
|
||||
}
|
||||
|
||||
if(entity.hasMetadata(mcMMO.bowForceKey)) {
|
||||
entity.removeMetadata(mcMMO.bowForceKey, mcMMO.p);
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE)) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE, mcMMO.p);
|
||||
}
|
||||
|
||||
if(entity.hasMetadata(mcMMO.arrowDistanceKey)) {
|
||||
entity.removeMetadata(mcMMO.arrowDistanceKey, mcMMO.p);
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE)) {
|
||||
entity.removeMetadata(MetadataConstants.METADATA_KEY_ARROW_DISTANCE, mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.gmail.nossr50.database.flatfile;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.gmail.nossr50.database.FlatFileDatabaseManager;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.gmail.nossr50.database.FlatFileDatabaseManager;
|
||||
import java.util.HashSet;
|
||||
|
||||
class FlatFileDataUtilTest {
|
||||
|
||||
|
@ -1,37 +1,22 @@
|
||||
package com.gmail.nossr50.util.blockmeta;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.compat.CompatibilityManager;
|
||||
import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
|
||||
import com.gmail.nossr50.util.platform.PlatformManager;
|
||||
import com.google.common.io.Files;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Could be a lot better. But some tests are better than none! Tests the major things, still kinda unit-testy. Verifies
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.gmail.nossr50.util.platform;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -12,7 +10,8 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user