TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_rock.java

41 lines
1.5 KiB
Java
Raw Normal View History

2019-08-01 00:01:11 +00:00
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
2020-07-03 17:55:46 +00:00
@CommandParameters(description = "You have thrown a rock, but you have also summoned a meteor!", usage = "/<command>")
public class Command_rock extends FreedomCommand
2019-08-01 00:01:11 +00:00
{
2020-07-03 17:55:46 +00:00
public static final String ROCK_LYRICS = ChatColor.BLUE + "You have thrown a rock, but you have also summoned a meteor!";
2019-08-01 00:01:11 +00:00
@Override
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
{
2020-07-03 17:55:46 +00:00
final ItemStack heldItem = new ItemStack(Material.STONE);
2019-08-01 00:01:11 +00:00
final ItemMeta heldItemMeta = heldItem.getItemMeta();
2020-07-03 17:55:46 +00:00
heldItemMeta.setDisplayName(ChatColor.BLUE + "Rock");
2019-08-01 00:01:11 +00:00
heldItem.setItemMeta(heldItemMeta);
for (final Player player : this.server.getOnlinePlayers())
{
final int firstEmpty = player.getInventory().firstEmpty();
if (firstEmpty >= 0)
{
player.getInventory().setItem(firstEmpty, heldItem);
}
}
2020-07-03 17:55:46 +00:00
FUtil.bcastMsg(ROCK_LYRICS);
2019-08-01 00:01:11 +00:00
return true;
}
}