mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-06-30 02:51:40 +00:00
Reformat
This commit is contained in:
parent
ad13062117
commit
dde0b20775
380 changed files with 38917 additions and 46821 deletions
|
@ -1,14 +1,9 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.Potions;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -16,78 +11,63 @@ import org.bukkit.inventory.meta.PotionMeta;
|
|||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class Commandpotion extends EssentialsCommand
|
||||
{
|
||||
public Commandpotion()
|
||||
{
|
||||
super("potion");
|
||||
}
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final ItemStack stack = user.getBase().getItemInHand();
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
final Set<String> potionslist = new TreeSet<String>();
|
||||
for (Map.Entry<String, PotionEffectType> entry : Potions.entrySet())
|
||||
{
|
||||
final String potionName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (potionslist.contains(potionName) || (user.isAuthorized("essentials.potion." + potionName)))
|
||||
{
|
||||
potionslist.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
throw new NotEnoughArgumentsException(tl("potions", StringUtil.joinList(potionslist.toArray())));
|
||||
}
|
||||
public class Commandpotion extends EssentialsCommand {
|
||||
public Commandpotion() {
|
||||
super("potion");
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.POTION)
|
||||
{
|
||||
PotionMeta pmeta = (PotionMeta)stack.getItemMeta();
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
pmeta.clearCustomEffects();
|
||||
stack.setItemMeta(pmeta);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("apply") && user.isAuthorized("essentials.potion.apply"))
|
||||
{
|
||||
for (PotionEffect effect : pmeta.getCustomEffects())
|
||||
{
|
||||
effect.apply(user.getBase());
|
||||
}
|
||||
}
|
||||
else if (args.length < 3)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else
|
||||
{
|
||||
final MetaItemStack mStack = new MetaItemStack(stack);
|
||||
for (String arg : args)
|
||||
{
|
||||
mStack.addPotionMeta(user.getSource(), true, arg, ess);
|
||||
}
|
||||
if (mStack.completePotion())
|
||||
{
|
||||
pmeta = (PotionMeta)mStack.getItemStack().getItemMeta();
|
||||
stack.setItemMeta(pmeta);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(tl("invalidPotion"));
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getBase().getItemInHand();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(tl("holdPotion"));
|
||||
}
|
||||
}
|
||||
if (args.length == 0) {
|
||||
final Set<String> potionslist = new TreeSet<String>();
|
||||
for (Map.Entry<String, PotionEffectType> entry : Potions.entrySet()) {
|
||||
final String potionName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
|
||||
if (potionslist.contains(potionName) || (user.isAuthorized("essentials.potion." + potionName))) {
|
||||
potionslist.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
throw new NotEnoughArgumentsException(tl("potions", StringUtil.joinList(potionslist.toArray())));
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.POTION) {
|
||||
PotionMeta pmeta = (PotionMeta) stack.getItemMeta();
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("clear")) {
|
||||
pmeta.clearCustomEffects();
|
||||
stack.setItemMeta(pmeta);
|
||||
} else if (args[0].equalsIgnoreCase("apply") && user.isAuthorized("essentials.potion.apply")) {
|
||||
for (PotionEffect effect : pmeta.getCustomEffects()) {
|
||||
effect.apply(user.getBase());
|
||||
}
|
||||
} else if (args.length < 3) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
} else {
|
||||
final MetaItemStack mStack = new MetaItemStack(stack);
|
||||
for (String arg : args) {
|
||||
mStack.addPotionMeta(user.getSource(), true, arg, ess);
|
||||
}
|
||||
if (mStack.completePotion()) {
|
||||
pmeta = (PotionMeta) mStack.getItemStack().getItemMeta();
|
||||
stack.setItemMeta(pmeta);
|
||||
} else {
|
||||
user.sendMessage(tl("invalidPotion"));
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Exception(tl("holdPotion"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue