Perf: Equipping the golden shovel.

This commit is contained in:
ryanhamshire 2015-04-26 17:50:51 -07:00
parent 4a3c105294
commit b53ec39fbb
2 changed files with 23 additions and 32 deletions

View File

@ -36,31 +36,34 @@ class EquipShovelProcessingTask implements Runnable
@Override @Override
public void run() public void run()
{ {
//if he logged out, don't do anything
if(!player.isOnline()) return;
//if he's not holding the golden shovel anymore, do nothing //if he's not holding the golden shovel anymore, do nothing
if(player.getItemInHand().getType() != GriefPrevention.instance.config_claims_modificationTool) return; if(player.getItemInHand().getType() != GriefPrevention.instance.config_claims_modificationTool) return;
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()); PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
int remainingBlocks = playerData.getRemainingClaimBlocks(); //reset any work he might have been doing
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
//if in basic claims mode... //always reset to basic claims mode
if(playerData.shovelMode == ShovelMode.Basic) if(playerData.shovelMode != ShovelMode.Basic)
{
playerData.shovelMode = ShovelMode.Basic;
GriefPrevention.sendMessage(player, TextMode.Info, Messages.ShovelBasicClaimMode);
}
//tell him how many claim blocks he has available
int remainingBlocks = playerData.getRemainingClaimBlocks();
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.RemainingBlocks, String.valueOf(remainingBlocks));
//link to a video demo of land claiming, based on world type
if(GriefPrevention.instance.creativeRulesApply(player.getLocation()))
{ {
//tell him how many claim blocks he has available GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.RemainingBlocks, String.valueOf(remainingBlocks)); }
else if(GriefPrevention.instance.claimsEnabledForWorld(player.getLocation().getWorld()))
//link to a video demo of land claiming, based on world type {
if(GriefPrevention.instance.creativeRulesApply(player.getLocation())) GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
{
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.CreativeBasicsVideo2, DataStore.CREATIVE_VIDEO_URL);
}
else
{
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.SurvivalBasicsVideo2, DataStore.SURVIVAL_VIDEO_URL);
}
} }
} }
} }

View File

@ -1233,22 +1233,10 @@ class PlayerEventHandler implements Listener
Player player = event.getPlayer(); Player player = event.getPlayer();
//if he's switching to the golden shovel //if he's switching to the golden shovel
ItemStack newItemStack = player.getInventory().getItem(event.getNewSlot()); int newSlot = event.getNewSlot();
ItemStack newItemStack = player.getInventory().getItem(newSlot);
if(newItemStack != null && newItemStack.getType() == GriefPrevention.instance.config_claims_modificationTool) if(newItemStack != null && newItemStack.getType() == GriefPrevention.instance.config_claims_modificationTool)
{ {
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
//always reset to basic claims mode
if(playerData.shovelMode != ShovelMode.Basic)
{
playerData.shovelMode = ShovelMode.Basic;
GriefPrevention.sendMessage(player, TextMode.Info, Messages.ShovelBasicClaimMode);
}
//reset any work he might have been doing
playerData.lastShovelLocation = null;
playerData.claimResizing = null;
//give the player his available claim blocks count and claiming instructions, but only if he keeps the shovel equipped for a minimum time, to avoid mouse wheel spam //give the player his available claim blocks count and claiming instructions, but only if he keeps the shovel equipped for a minimum time, to avoid mouse wheel spam
if(GriefPrevention.instance.claimsEnabledForWorld(player.getWorld())) if(GriefPrevention.instance.claimsEnabledForWorld(player.getWorld()))
{ {