mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Cleanup on Item.java
This commit is contained in:
parent
b86cfb595c
commit
d10ff590ec
@ -1,26 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of mcMMO.
|
* Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
|
||||||
|
* Copyright (C) 2010-2011 'nossr50'
|
||||||
mcMMO is free software: you can redistribute it and/or modify
|
*
|
||||||
it under the terms of the GNU General Public License as published by
|
* This program is free software: you can redistribute it and/or modify
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
* it under the terms of the GNU General Public License as published by
|
||||||
(at your option) any later version.
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
mcMMO is distributed in the hope that it will be useful,
|
*
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* This program is distributed in the hope that it will be useful,
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
GNU General Public License for more details.
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
*
|
||||||
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.gmail.nossr50;
|
package com.gmail.nossr50;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
@ -28,54 +29,55 @@ import com.gmail.nossr50.config.LoadProperties;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
public static void itemchecks(Player player, Plugin plugin)
|
/**
|
||||||
{
|
* Check for item usage.
|
||||||
ItemStack inhand = player.getItemInHand();
|
*
|
||||||
if(LoadProperties.chimaeraWingEnable && inhand.getTypeId() == LoadProperties.chimaeraId)
|
* @param player Player whose item usage to check
|
||||||
chimaerawing(player, plugin);
|
*/
|
||||||
}
|
public static void itemchecks(Player player) {
|
||||||
|
ItemStack inhand = player.getItemInHand();
|
||||||
public static void chimaerawing(Player player, Plugin plugin)
|
|
||||||
{
|
if (LoadProperties.chimaeraWingEnable && inhand.getTypeId() == LoadProperties.chimaeraId) {
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
chimaerawing(player);
|
||||||
ItemStack is = player.getItemInHand();
|
}
|
||||||
Block block = player.getLocation().getBlock();
|
}
|
||||||
int chimaeraID = LoadProperties.chimaeraId;
|
|
||||||
int itemsUsed = LoadProperties.feathersConsumedByChimaeraWing;
|
private static void chimaerawing(Player player) {
|
||||||
if(mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == chimaeraID)
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
{
|
ItemStack is = player.getItemInHand();
|
||||||
if(Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= itemsUsed)
|
Block block = player.getLocation().getBlock();
|
||||||
{
|
int chimaeraID = LoadProperties.chimaeraId;
|
||||||
Block derp = player.getLocation().getBlock();
|
int itemsUsed = LoadProperties.feathersConsumedByChimaeraWing;
|
||||||
int y = derp.getY();
|
int amount = is.getAmount();
|
||||||
player.setItemInHand(new ItemStack(chimaeraID, is.getAmount() - itemsUsed));
|
|
||||||
|
if (mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == chimaeraID) {
|
||||||
while(y < 127)
|
if (Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && amount >= itemsUsed) {
|
||||||
{
|
player.setItemInHand(new ItemStack(chimaeraID, amount - itemsUsed));
|
||||||
y++;
|
|
||||||
if(player != null)
|
for (int blockY = block.getY(); blockY < 127; blockY++) {
|
||||||
{
|
if (player.getLocation().getWorld().getBlockAt(block.getX(), blockY, block.getZ()).getType() != Material.AIR) {
|
||||||
if(player.getLocation().getWorld().getBlockAt(block.getX(), y, block.getZ()).getType() != Material.AIR)
|
player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail"));
|
||||||
{
|
player.teleport(player.getLocation().getWorld().getBlockAt(block.getX(), (blockY - 1), block.getZ()).getLocation());
|
||||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail")); //$NON-NLS-1$
|
return;
|
||||||
player.teleport(player.getLocation().getWorld().getBlockAt(block.getX(), (y - 1), block.getZ()).getLocation());
|
}
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
}
|
if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK)) {
|
||||||
}
|
player.teleport(player.getBedSpawnLocation());
|
||||||
|
}
|
||||||
if(player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK))
|
else {
|
||||||
player.teleport(player.getBedSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
else
|
}
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
|
||||||
|
player.sendMessage(mcLocale.getString("Item.ChimaeraWingPass"));
|
||||||
player.sendMessage(mcLocale.getString("Item.ChimaeraWingPass")); //$NON-NLS-1$
|
}
|
||||||
}
|
else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= itemsUsed) {
|
||||||
else if (!Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && is.getAmount() >= itemsUsed)
|
player.sendMessage(mcLocale.getString("Item.InjuredWait", new Object[] {Skills.calculateTimeLeft(player, PP.getRecentlyHurt(), 60)}));
|
||||||
player.sendMessage(mcLocale.getString("Item.InjuredWait", new Object[] {Skills.calculateTimeLeft(player, PP.getRecentlyHurt(), 60)})); //$NON-NLS-1$
|
}
|
||||||
else if (is.getTypeId() == LoadProperties.chimaeraId && is.getAmount() <= itemsUsed)
|
else if (is.getTypeId() == LoadProperties.chimaeraId && is.getAmount() <= itemsUsed) {
|
||||||
player.sendMessage(mcLocale.getString("Item.NeedFeathers")); //$NON-NLS-1$
|
player.sendMessage(mcLocale.getString("Item.NeedFeathers"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,9 +255,9 @@ public class mcPlayerListener implements Listener
|
|||||||
* ITEM CHECKS
|
* ITEM CHECKS
|
||||||
*/
|
*/
|
||||||
if(action == Action.RIGHT_CLICK_AIR)
|
if(action == Action.RIGHT_CLICK_AIR)
|
||||||
Item.itemchecks(player, plugin);
|
Item.itemchecks(player);
|
||||||
if(action == Action.RIGHT_CLICK_BLOCK && m.abilityBlockCheck(block))
|
if(action == Action.RIGHT_CLICK_BLOCK && m.abilityBlockCheck(block))
|
||||||
Item.itemchecks(player, plugin);
|
Item.itemchecks(player);
|
||||||
|
|
||||||
if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK))
|
if(player.isSneaking() && mcPermissions.getInstance().taming(player) && (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user