Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.51 KB | None | 0 0
  1. package noo.b.game;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Random;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.Location;
  10. import org.bukkit.World;
  11. import org.bukkit.block.Block;
  12. import org.bukkit.command.Command;
  13. import org.bukkit.command.CommandSender;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.plugin.java.JavaPlugin;
  16.  
  17. import com.blitznetwork.blitz.arena.Arena;
  18.  
  19. public class NoobMain extends JavaPlugin {
  20.  
  21. public final HashMap<String, ArrayList<Block>> blueTeam = new HashMap<String, ArrayList<Block>>();
  22. public final HashMap<String, ArrayList<Block>> redTeam = new HashMap<String, ArrayList<Block>>();
  23. public static final HashMap<String, ArrayList<Block>> joinedPlayers = new HashMap<String, ArrayList<Block>>();
  24. public final HashMap<Location, Block> blueSpawn = new HashMap<Location, Block>();
  25. int bt;
  26. int rt;
  27. int jp;
  28.  
  29.  
  30. public void onEnable(){
  31. saveDefaultConfig();
  32. System.out.println("[2v2] Plugin Enabled!");
  33. getConfig().options().copyDefaults(true);
  34. getConfig();
  35. }
  36. public void onDisable(){
  37.  
  38. System.out.println("[2v2] Plugin Disabled!");
  39. }
  40. @Override
  41. public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]){
  42. if(cmd.getName().equalsIgnoreCase("tvt")){
  43. if(!(sender instanceof Player)) {
  44. sender.sendMessage("You must be a player to use this cmd!");
  45. }
  46.  
  47. Player player = (Player) sender;
  48. if (args.length >= 1 && args[0].equalsIgnoreCase("setredspawn")) {
  49. addRedSpawn(player.getLocation());
  50. return true;
  51. } else if (args.length >= 1 && args[0].equalsIgnoreCase("teleredspawn")) {
  52. //again you need to pass the getRedSpawn() method something to find the location with
  53. player.teleport(this.getRedSpawn(arena));
  54. }
  55.  
  56.  
  57.  
  58.  
  59. }
  60. return false;
  61. }
  62.  
  63. //adds a spawn to the default config, you'll need to change getName() to your own name for the spawn
  64. public void addRedSpawn(Location loc)
  65. {
  66. if (!this.getConfig().contains("Arenas." + getName() + ".RedSpawn")) {
  67. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn.Counter", Integer.valueOf(2));
  68. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".X", Double.valueOf(loc.getX()));
  69. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Y", Double.valueOf(loc.getY()));
  70. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Z", Double.valueOf(loc.getZ()));
  71. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".World", loc.getWorld().getName());
  72. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Pitch", Float.valueOf(loc.getPitch()));
  73. this.getConfig().addDefault("Arenas." + getName() + ".RedSpawn" + ".Yaw", Float.valueOf(loc.getYaw()));
  74. }
  75. else {
  76. this.getConfig().set("Arenas." + getName() + ".RedSpawn.Counter", Integer.valueOf(2));
  77. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".X", Double.valueOf(loc.getX()));
  78. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Y", Double.valueOf(loc.getY()));
  79. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Z", Double.valueOf(loc.getZ()));
  80. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".World", loc.getWorld().getName());
  81. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Pitch", Float.valueOf(loc.getPitch()));
  82. this.getConfig().set("Arenas." + getName() + ".RedSpawn" + ".Yaw", Float.valueOf(loc.getYaw()));
  83. }
  84. //Not sure if you need to save the default config after modifying but i have a method here to save the configs
  85. }
  86.  
  87. //Needs to be passed something to get the location, I use arena Objects so I pass it an Arena Object
  88. public Location getRedSpawn(Arena arena)
  89. {
  90. if ( this.getConfig().contains("Arenas." + arena.getName() + ".RedSpawn.World")) {
  91. Location loc = new Location(Bukkit.getWorld( this.getConfig().getString("Arenas." + arena.getName() + ".RedSpawn.World")),
  92. this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.X"),
  93. this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Y"),
  94. this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Z"));
  95. loc.setPitch((float) this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Pitch"));
  96. loc.setYaw((float) this.getConfig().getDouble("Arenas." + arena.getName() + ".RedSpawn.Yaw"));
  97. return loc;
  98. }
  99. return null;
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement