Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.DeadEnd78.Youtube;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- public void onEnable() {
- if (getConfig().getStringList("Arenas") == null) {
- getConfig().set("Arenas", getConfig().getStringList("Arenas").add("Arena1"));
- } else {
- // do something
- }
- getConfig().options().copyDefaults();
- saveConfig();
- }
- public void onDisable() {
- getLogger().info("Disabled V 1.0 of One in the Chamber!");
- }
- ArrayList<String> oitc = new ArrayList<String>();
- // BELOW = COMMANDS
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- if (sender instanceof Player) {
- Player player = (Player) sender;
- if (commandLabel.equalsIgnoreCase("oitc")) {
- if (args.length > 0) {
- if (args[0].equalsIgnoreCase("join")) {
- if (!oitc.contains(player.getName())) {
- if (!args[1].isEmpty()){
- if (getConfig().getStringList("Arenas").contains(args[1])) {
- oitc.add(player.getName());
- int playersNeeded = oitc.size() - 2;
- player.sendMessage(ChatColor.GOLD + "[OITC]" + ChatColor.GREEN + " You have joined OITC on arena " + args[1] + " Players needed to start: " + playersNeeded);
- if (oitc.size() >= 2) {
- start(args[1]);
- }
- }
- } else {
- player.sendMessage(ChatColor.GOLD + "[OITC]" + ChatColor.GREEN + "Availible Arenas:");
- List<String> arenas = getConfig().getStringList("Arenas");
- player.sendMessage(ChatColor.BOLD + "Arenas (in no specific order) " + arenas);
- player.sendMessage(ChatColor.BOLD + "There are currently " + arenas.size() + " arenas.");
- }
- } else { // else for if they are already playing
- player.sendMessage(ChatColor.GOLD + "[OITC]" + ChatColor.RED + " You are already playing one in the chamber!");
- }
- }
- if (args[0].equalsIgnoreCase("leave")) {
- if (oitc.contains(player.getName())) {
- oitc.remove(player.getName());
- player.sendMessage("Left One in the Chamber!");
- // TODO tp to lobby
- } else { player.sendMessage("Not in a game!"); }
- }
- if (args[0].equalsIgnoreCase("list")) {
- player.sendMessage("Players: " + oitc.toString());
- player.sendMessage("Yay.");
- }
- if (args[0].equalsIgnoreCase("create")) {
- if (args[1] != null) {
- if (player.getPlayer().isOp() || player.hasPermission("oitc.admin")) {
- player.sendMessage("Attempting to create arena " + args[1]);
- if (!getConfig().getStringList("Arenas").contains(args[1])) {
- getConfig().set("Arenas", getConfig().getStringList("Arenas") + args[1]);
- player.sendMessage("Arena " + args[1] + " has been created successfully. Please set the spawn points using /oitc edit " + args[1] + " setspawn<1,2,3,4>");
- Bukkit.getServer().broadcastMessage(ChatColor.GOLD + "One in the chamber arena " + args[1] + " was created by " + player.getName());
- } else { player.sendMessage("Arena " + args[1] + " already exists. Maybe try " + args[1] + "V2" + " instead?"); }
- } else { player.sendMessage("Incorrect Permissions.... you don't have oitc.admin or aren't op."); }
- } else { player.sendMessage("Incorrect Usage: /oitc create <arena>"); }
- }
- if (args[0].equalsIgnoreCase("start")) {
- if (player.isOp() || player.hasPermission("oitc.admin")) {
- if (args[1] == null) { player.sendMessage("On what arena? /oitc start <arena>"); } else {
- if (getConfig().getStringList("Arenas").contains(args[1])) {
- start(args[1]);
- player.sendMessage("Game started!");
- } else { player.sendMessage("That arena does not exist! Availible Arenas: " + getConfig().getStringList("Arenas")); }
- }
- }
- }
- }
- } else if (commandLabel.equalsIgnoreCase("oneinthechamber")) {
- player.sendMessage(ChatColor.GOLD + "[OITC]" + ChatColor.RED + " /oitc");
- }
- }
- return false;
- }
- private void start(String arenaName) {
- Bukkit.getServer().broadcastMessage("Game of OITC is starting on arena " + arenaName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement