TypeItemStack now uses held item. Bugfix for Txt.getItemName
This commit is contained in:
parent
21211b404f
commit
2704b0bd49
@ -1,13 +1,14 @@
|
|||||||
package com.massivecraft.massivecore.command.type;
|
package com.massivecraft.massivecore.command.type;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
import com.massivecraft.massivecore.util.InventoryUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class TypeItemStack extends TypeAbstract<ItemStack>
|
public class TypeItemStack extends TypeAbstract<ItemStack>
|
||||||
@ -32,29 +33,32 @@ public class TypeItemStack extends TypeAbstract<ItemStack>
|
|||||||
@Override
|
@Override
|
||||||
public String getNameInner(ItemStack value)
|
public String getNameInner(ItemStack value)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdInner(ItemStack value)
|
public String getIdInner(ItemStack value)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack read(String arg, CommandSender sender) throws MassiveException
|
|
||||||
{
|
|
||||||
// TODO: Implement
|
|
||||||
throw new MassiveException().addMsg("<b>Not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getTabList(CommandSender sender, String arg)
|
public Collection<String> getTabList(CommandSender sender, String arg)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
return null;
|
||||||
return Collections.emptyList();
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public ItemStack read(String arg, CommandSender sender) throws MassiveException
|
||||||
|
{
|
||||||
|
if ( ! (sender instanceof Player)) throw new MassiveException().addMsg("<b>You must be a player to hold an item in your hand.");
|
||||||
|
Player player = (Player)sender;
|
||||||
|
|
||||||
|
ItemStack ret = player.getItemInHand();
|
||||||
|
if (InventoryUtil.isNothing(ret)) throw new MassiveException().addMsg("<b>You must hold an item in your hand.");
|
||||||
|
ret = new ItemStack(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ public class Txt
|
|||||||
{
|
{
|
||||||
if (InventoryUtil.isNothing(itemStack)) return Txt.parse("<silver><em>Nothing");
|
if (InventoryUtil.isNothing(itemStack)) return Txt.parse("<silver><em>Nothing");
|
||||||
|
|
||||||
ChatColor color = (itemStack.getEnchantments().size() > 0) ? ChatColor.AQUA : ChatColor.RESET;
|
ChatColor color = (itemStack.getEnchantments().size() > 0) ? ChatColor.AQUA : ChatColor.WHITE;
|
||||||
|
|
||||||
if (itemStack.hasItemMeta())
|
if (itemStack.hasItemMeta())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user