gistfile1.java
· 2.9 KiB · Java
Raw
package me.coldguy101.bukkit.FFGessentials;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class FFGmain extends JavaPlugin {
21public static Collection<String> joined = new HashSet<String>();
public static HashMap<String, String> team = new HashMap<String, String>();
public static Location spawn = null;
public static Location outspawn = null;
public static Collection<String> Pinfoblockers = new HashSet<String>();
public static FFGmain plugin;
@Override
public void onEnable() {
Listener pplayerListener = new FFGPlayerListener();
getServer().getPluginManager().registerEvents(pplayerListener, this);
}
@Override
public void onDisable() {
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
if (cmd.getName().equalsIgnoreCase("setaspawn") && player.isOp()) {
spawn = player.getLocation();
player.sendMessage(ChatColor.DARK_AQUA + "The Arena spawn has been set to your location");
} else if (cmd.getName().equalsIgnoreCase("setaoutspawn") && player.isOp()) {
outspawn = player.getLocation();
player.sendMessage(ChatColor.DARK_AQUA + "The Arena out spawn has been set to your location");
} else if (cmd.getName().equalsIgnoreCase("ajoin") && player.hasPermission("FFG.*") && spawn != null) {
if (joined.contains(player.getName())) {
player.sendMessage(ChatColor.DARK_AQUA + "You are already in the arena");
} else {
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemStack ga = new ItemStack(Material.GOLDEN_APPLE, 20);
ItemStack h = new ItemStack(Material.IRON_HELMET);
ItemStack c = new ItemStack(Material.IRON_CHESTPLATE);
ItemStack l = new ItemStack(Material.IRON_LEGGINGS);
ItemStack b = new ItemStack(Material.IRON_BOOTS);
joined.add(player.getName());
player.teleport(spawn);
player.sendMessage(ChatColor.DARK_AQUA + "You have just joined the deathmatch arena! To leave type /leave");
player.getEquipment().clear();
player.getEquipment().setBoots(b);
player.getEquipment().setChestplate(c);
player.getEquipment().setLeggings(l);
player.getEquipment().setHelmet(h);
player.getInventory().clear();
player.getInventory().addItem(sword);
player.getInventory().addItem(ga);
}
} else if (cmd.getName().equalsIgnoreCase("aleave") && player.hasPermission("FFG.*") && outspawn != null) {
player.getInventory().clear();
joined.remove(player.getName());
player.teleport(outspawn);
}
return true;
}
}
| 1 | package me.coldguy101.bukkit.FFGessentials; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | |
| 5 | import java.util.HashMap; |
| 6 | |
| 7 | import java.util.HashSet; |
| 8 | |
| 9 | import org.bukkit.ChatColor; |
| 10 | |
| 11 | import org.bukkit.Location; |
| 12 | |
| 13 | import org.bukkit.Material; |
| 14 | |
| 15 | import org.bukkit.World; |
| 16 | |
| 17 | import org.bukkit.block.Block; |
| 18 | |
| 19 | import org.bukkit.command.Command; |
| 20 | |
| 21 | import org.bukkit.command.CommandSender; |
| 22 | |
| 23 | import org.bukkit.entity.Player; |
| 24 | |
| 25 | import org.bukkit.event.Listener; |
| 26 | |
| 27 | import org.bukkit.inventory.ItemStack; |
| 28 | |
| 29 | import org.bukkit.plugin.java.JavaPlugin; |
| 30 | |
| 31 | public class FFGmain extends JavaPlugin { |
| 32 | |
| 33 | 21public static Collection<String> joined = new HashSet<String>(); |
| 34 | public static HashMap<String, String> team = new HashMap<String, String>(); |
| 35 | public static Location spawn = null; |
| 36 | public static Location outspawn = null; |
| 37 | public static Collection<String> Pinfoblockers = new HashSet<String>(); |
| 38 | public static FFGmain plugin; |
| 39 | |
| 40 | @Override |
| 41 | public void onEnable() { |
| 42 | Listener pplayerListener = new FFGPlayerListener(); |
| 43 | getServer().getPluginManager().registerEvents(pplayerListener, this); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public void onDisable() { |
| 48 | |
| 49 | } |
| 50 | |
| 51 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { |
| 52 | Player player = (Player) sender; |
| 53 | if (cmd.getName().equalsIgnoreCase("setaspawn") && player.isOp()) { |
| 54 | spawn = player.getLocation(); |
| 55 | player.sendMessage(ChatColor.DARK_AQUA + "The Arena spawn has been set to your location"); |
| 56 | } else if (cmd.getName().equalsIgnoreCase("setaoutspawn") && player.isOp()) { |
| 57 | outspawn = player.getLocation(); |
| 58 | player.sendMessage(ChatColor.DARK_AQUA + "The Arena out spawn has been set to your location"); |
| 59 | } else if (cmd.getName().equalsIgnoreCase("ajoin") && player.hasPermission("FFG.*") && spawn != null) { |
| 60 | if (joined.contains(player.getName())) { |
| 61 | player.sendMessage(ChatColor.DARK_AQUA + "You are already in the arena"); |
| 62 | } else { |
| 63 | ItemStack sword = new ItemStack(Material.DIAMOND_SWORD); |
| 64 | ItemStack ga = new ItemStack(Material.GOLDEN_APPLE, 20); |
| 65 | ItemStack h = new ItemStack(Material.IRON_HELMET); |
| 66 | ItemStack c = new ItemStack(Material.IRON_CHESTPLATE); |
| 67 | ItemStack l = new ItemStack(Material.IRON_LEGGINGS); |
| 68 | ItemStack b = new ItemStack(Material.IRON_BOOTS); |
| 69 | joined.add(player.getName()); |
| 70 | player.teleport(spawn); |
| 71 | player.sendMessage(ChatColor.DARK_AQUA + "You have just joined the deathmatch arena! To leave type /leave"); |
| 72 | player.getEquipment().clear(); |
| 73 | player.getEquipment().setBoots(b); |
| 74 | player.getEquipment().setChestplate(c); |
| 75 | player.getEquipment().setLeggings(l); |
| 76 | player.getEquipment().setHelmet(h); |
| 77 | player.getInventory().clear(); |
| 78 | player.getInventory().addItem(sword); |
| 79 | player.getInventory().addItem(ga); |
| 80 | } |
| 81 | } else if (cmd.getName().equalsIgnoreCase("aleave") && player.hasPermission("FFG.*") && outspawn != null) { |
| 82 | player.getInventory().clear(); |
| 83 | joined.remove(player.getName()); |
| 84 | player.teleport(outspawn); |
| 85 | } |
| 86 | |
| 87 | return true; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | } |