Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package noo.b.game;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- 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.plugin.java.JavaPlugin;
- import com.blitznetwork.blitz.arena.Arena;
- public class NoobMain extends JavaPlugin {
- public final HashMap<String, ArrayList<Block>> blueTeam = new HashMap<String, ArrayList<Block>>();
- public final HashMap<String, ArrayList<Block>> redTeam = new HashMap<String, ArrayList<Block>>();
- public static final HashMap<String, ArrayList<Block>> joinedPlayers = new HashMap<String, ArrayList<Block>>();
- public final HashMap<Location, Block> blueSpawn = new HashMap<Location, Block>();
- int bt;
- int rt;
- int jp;
- public void onEnable(){
- saveDefaultConfig();
- System.out.println("[2v2] Plugin Enabled!");
- getConfig().options().copyDefaults(true);
- getConfig();
- }
- public void onDisable(){
- System.out.println("[2v2] Plugin Disabled!");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]){
- if(cmd.getName().equalsIgnoreCase("tvt")){
- if(!(sender instanceof Player)) {
- sender.sendMessage("You must be a player to use this cmd!");
- }
- Player player = (Player) sender;
- if (args.length >= 1 && args[0].equalsIgnoreCase("setredspawn")) {
- addRedSpawn(player.getLocation());
- return true;
- } else if (args.length >= 1 && args[0].equalsIgnoreCase("teleredspawn")) {
- //again you need to pass the getRedSpawn() method something to find the location with
- player.teleport(this.getRedSpawn(arena));
- }
- }
- return false;
- }
- //adds a spawn to the default config, you'll need to change getName() to your own name for the spawn
- public void addRedSpawn(Location loc)
- {
- if (!this.getConfig().contains("Arenas." + getName() + ".RedSpawn")) {
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn.Counter", Integer.valueOf(2));
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".X", Double.valueOf(loc.getX()));
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Y", Double.valueOf(loc.getY()));
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Z", Double.valueOf(loc.getZ()));
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".World", loc.getWorld().getName());
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Pitch", Float.valueOf(loc.getPitch()));
- this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Yaw", Float.valueOf(loc.getYaw()));
- }
- else {
- this.getConfig().set("Arenas." + getName() + ".RedSpawn.Counter", Integer.valueOf(2));
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".X", Double.valueOf(loc.getX()));
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Y", Double.valueOf(loc.getY()));
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Z", Double.valueOf(loc.getZ()));
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".World", loc.getWorld().getName());
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Pitch", Float.valueOf(loc.getPitch()));
- this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Yaw", Float.valueOf(loc.getYaw()));
- }
- //Not sure if you need to save the default config after modifying but i have a method here to save the configs
- }
- //Needs to be passed something to get the location, I use arena Objects so I pass it an Arena Object
- public Location getRedSpawn(Arena arena)
- {
- if ( this.getConfig().contains("Arenas." + arena.getName() + ".RedSpawn.World")) {
- Location loc = new Location(Bukkit.getWorld( this.getConfig().getString("Arenas." + arena.getName() + ".RedSpawn.World")),
- this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.X"),
- this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Y"),
- this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Z"));
- loc.setPitch((float) this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Pitch"));
- loc.setYaw((float) this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Yaw"));
- return loc;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement