Color jumper Minigame plugin request!

Discussion in 'Archived: Plugin Requests' started by coreymichealroy, Oct 19, 2013.

?

Is this a cool plugin

  1. Yes! please someone make one!

    22 vote(s)
    84.6%
  2. No, I think this plugin is WORTHLESS!

    4 vote(s)
    15.4%
  1. Offline

    megasaad44

    Someone....Has...To...Release....This... o-o
     
  2. Offline

    slowbuild

    megasaad44 I'm working on it, but it'll take some time..
     
    super292 and megasaad44 like this.
  3. Offline

    jokie666

    I already thought that, because of no replies to contacting, I placed the link in the other (simular) topic, the only other thing in that plugin is that it creates a new world doesn't it?
     
  4. Offline

    coreymichealroy

    Thanks slowbuild

    I got contacted the developer he's working on the plugin friday through saturday

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  5. Offline

    slowbuild

    @coreymichealroyl ok, do you mean by that, that I should stop working on it??
    Who is he? If he already does something like this I will modify my concept a little.
     
  6. Offline

    coreymichealroy

    It's fine you can work on one too :p, I think it'll be interesting to have two versions of this plugin :p
     
  7. Offline

    CopyableCougar4

    Okay here's the most recent version (file should be attached to this post).

    Changelog:
    - updated configuration method (getConfig())
    - made it so configuration file/plugin folder load

    Let me know with every error message as knowing errors speeds up the debugging process :)
     

    Attached Files:

  8. Offline

    15987632

    isnt attached
     
  9. Offline

    CopyableCougar4

    Ok thanks for telling me I'll put up a dropbox link: LINK
     
  10. Offline

    15987632

  11. Offline

    Pippiter69

    -b2918jnks (MC: 1.6.4) (Implementing API version 1.6.4-R2.0)
    17:03:09 [SEVERE] Could not load 'plugins\Color Jumper.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError
    : main/Main : Unsupported major.minor version 51.0
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:184)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:230)
    at org.bukkit.craftbukkit.v1_6_R3.CraftServer.loadPlugins(CraftServer.ja
    va:241)
    at org.bukkit.craftbukkit.v1_6_R3.CraftServer.<init>(CraftServer.java:21
    9)
    at net.minecraft.server.v1_6_R3.PlayerList.<init>(PlayerList.java:56)
    at net.minecraft.server.v1_6_R3.DedicatedPlayerList.<init>(SourceFile:11
    )
    at net.minecraft.server.v1_6_R3.DedicatedServer.init(DedicatedServer.jav
    a:107)
    at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java
    :393)
    at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:5
    83)
    Caused by: java.lang.UnsupportedClassVersionError: main/Main : Unsupported major
    .minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader
    .java:80)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:53)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:173)

    ... 9 more
     
  12. Offline

    CopyableCougar4

    Ok from what I am reading that is just meaning ClassNotFoundException. Let me know if this is better :) LINK
     
  13. Offline

    coreymichealroy

    still tons of errors
     
  14. Offline

    CopyableCougar4

    coreymichealroy Please print error logs without error logs I don't know where to look to fix stuff.

    I have decided to treat Color Jumper like Linux or PHP and post the source code to speed up the debugging process. If you are an experienced developer and would like to make a change, please do so :)

    Main.java:
    Show Spoiler

    Code:java
    1. package main;
    2.  
    3. import java.io.File;
    4. import java.io.FileWriter;
    5. import java.io.IOException;
    6. import java.util.*;
    7.  
    8. import org.bukkit.*;
    9. import org.bukkit.block.Sign;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.configuration.file.FileConfiguration;
    13. import org.bukkit.configuration.file.YamlConfiguration;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.block.Action;
    18. import org.bukkit.event.player.*;
    19. import org.bukkit.material.Wool;
    20. import org.bukkit.plugin.java.JavaPlugin;
    21.  
    22. public class Main extends JavaPlugin implements Listener{
    23.  
    24. HashMap<Player, String> whereTheyAre = new HashMap<Player, String>();
    25. HashMap<String, HashMap<Player, Integer>> activePlayers = new HashMap<String, HashMap<Player, Integer>>();
    26. HashMap<String, String> currentColors = new HashMap<String, String>();
    27. HashMap<String, Location> spawns;
    28.  
    29. @Override
    30. public FileConfiguration getConfig(){
    31. return YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + "/config.yml"));
    32. }
    33.  
    34. public void onEnable() {
    35. checkForConfig();
    36. loadSpawns();
    37. getLogger().info("Color Jumper has been enabled! By: CopyableCougar4");
    38. }
    39.  
    40. public void checkForConfig(){
    41. File f = new File(this.getDataFolder() + "/config.yml");
    42. File g = new File(this.getDataFolder().toString());
    43. if(!g.exists()){
    44. g.mkdir();
    45. getLogger().info("Generating plugin folder...");
    46. }
    47. if(!f.exists()){
    48. try {
    49. f.createNewFile();
    50. getLogger().info("Generating configuration file...");
    51. FileWriter fw = new FileWriter(f);
    52. fw.write("chat-color: WHITE # contact CopyableCougar4 if a color doesn't work");
    53. fw.close();
    54. } catch (IOException e) {
    55. e.printStackTrace();
    56. }
    57. }
    58.  
    59. }
    60.  
    61. public void loadSpawns(){
    62. getLogger().info("Loading arena spawns...");
    63. for(int a = 0; a < getConfig().getStringList("arenas").size(); a++){
    64. spawns.put((String) getConfig().getStringList("arenas").toArray()[a],
    65. new Location(Bukkit.getWorld(getConfig().getString("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".world")),
    66. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".x"),
    67. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".y"),
    68. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".z")));
    69. }
    70. getLogger().info("Arena spawns loaded!");
    71. }
    72.  
    73. public void onDisable() {
    74. getLogger().info("Color Jumper has been disabled! By: CopyableCougar4");
    75. }
    76.  
    77. @EventHandler
    78. public void onInteract(final PlayerInteractEvent event) {
    79. if(event.getClickedBlock().getType() == Material.SIGN){
    80. Sign sign = (Sign) event.getClickedBlock();
    81. if(sign.getLine(1) == "[Color Jumper]" && sign.getLine(2) == "Join"){
    82. addPlayer(event.getPlayer(), sign.getLine(3));
    83. }
    84. } else {
    85. if((event.getAction() == Action.PHYSICAL) && (whereTheyAre.get(event.getPlayer()) != null)){
    86. Timer t = new Timer();
    87. t.schedule(new TimerTask(){
    88. public void run(){
    89. String arena = whereTheyAre.get(event.getPlayer());
    90. String color = currentColors.get(arena); // correct color
    91. DyeColor dc;
    92. switch(color){
    93. case "BLACK": dc = DyeColor.BLACK;
    94. case "BLUE": dc = DyeColor.BLUE;
    95. case "BROWN": dc = DyeColor.BROWN;
    96. case "CYAN": dc = DyeColor.CYAN;
    97. case "GRAY": dc = DyeColor.GRAY;
    98. case "GREEN": dc = DyeColor.GREEN;
    99. case "LIGHT_BLUE": dc = DyeColor.LIGHT_BLUE;
    100. case "LIME": dc = DyeColor.LIME;
    101. case "MAGENTA": dc = DyeColor.MAGENTA;
    102. case "ORANGE": dc = DyeColor.ORANGE;
    103. case "PINK": dc = DyeColor.PINK;
    104. case "PURPLE": dc = DyeColor.PURPLE;
    105. case "RED": dc = DyeColor.RED;
    106. case "SILVER": dc = DyeColor.SILVER;
    107. case "YELLOW": dc = DyeColor.YELLOW;
    108. default: dc = DyeColor.WHITE;
    109. }
    110. Wool w = new Wool(dc); // correct block to be on
    111. if((event.getClickedBlock().getType() != w.getItemType())){
    112. //they aren't where they should be
    113. event.getPlayer().sendMessage(ChatColor.RED + "You should be on a " + color.toLowerCase() + " wool block!");
    114. playerLost(event.getPlayer(), arena);
    115. }
    116. }
    117. }, 10000);
    118.  
    119. } else {
    120. return;
    121. }
    122. }
    123. }
    124.  
    125. public void playerLost(Player player, String arena){
    126. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + player.getName() + " has lost his match! Arena: " + arena);
    127. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    128. playersLeft.remove(player);
    129. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + playersLeft.size() + " player(s) remain! Arena: " + arena);
    130. whereTheyAre.remove(player);
    131. if(playersLeft.size() == 1){
    132. //there is only one player left
    133. endGame(arena);
    134. }
    135. }
    136.  
    137. public void endGame(String arena){
    138. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Match ended! Arena: " + arena);
    139. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    140. playersLeft.clear();
    141. }
    142.  
    143. public void addPlayer(Player player, String arena) {
    144. HashMap<Player, Integer> arenaSize = activePlayers.get(arena);
    145. int currentSize = arenaSize.size();
    146. arenaSize.put(player, currentSize + 1);
    147. player.sendMessage(ChatColor.GOLD + "[Color Jumper] You have joined the arena: " + arena);
    148. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] " + player.getName() + " has joined ColorJumper! Arena: " + arena);
    149. if(currentSize == 1){
    150. startGame(arena);
    151. }
    152. whereTheyAre.put(player, arena);
    153.  
    154. }
    155.  
    156. public void startGame(String arena){
    157. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] ColorJumper has started! Arena: " + arena);
    158. HashMap<Player, Integer> toTeleport = activePlayers.get(arena);
    159. Player[] people = (Player[]) toTeleport.keySet().toArray();
    160. int arenaX = Main.this.getConfig().getInt(arena + ".x");
    161. int arenaY = Main.this.getConfig().getInt(arena + ".y");
    162. int arenaZ = Main.this.getConfig().getInt(arena + ".z");
    163. World arenaW = Bukkit.getWorld(Main.this.getConfig().getString(arena + ".world"));
    164. for(int a = 0; a < people.length; a++){
    165. people[a].teleport(new Location(arenaW, arenaX, arenaY, arenaZ));
    166. }
    167. runCountDown(arena);
    168. }
    169.  
    170. int currentCount = 0;
    171.  
    172. public void runMatch(final String arena){
    173. Timer t = new Timer();
    174. t.schedule(new TimerTask(){
    175. public void run(){
    176. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] New color in " + (5 - currentCount) + " second(s)!");
    177. if(currentCount == 5){
    178. newColor(arena);
    179. currentCount = 0;
    180. } else {
    181. currentCount += 1;
    182. }
    183. }
    184. }, 1000);
    185. }
    186.  
    187. int currentCountDown = 0;
    188.  
    189. public void runCountDown(final String arena){
    190. Timer t = new Timer();
    191. t.schedule(new TimerTask(){
    192. public void run(){
    193. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Starting in " + (10 - currentCountDown) + " second(s)! Arena: " + arena);
    194. if(currentCountDown == 10){
    195. runMatch(arena);
    196. } else {
    197. currentCountDown += 1;
    198. }
    199. }
    200. }, 1000);
    201. }
    202.  
    203. public void newColor(String arena){
    204. List<String> colors = Main.this.getConfig().getStringList("colors");
    205. int listLength = colors.size();
    206. int chosenValue = (int) Math.ceil(Math.random() * listLength) - 1;
    207. String chosen = colors.get(chosenValue);
    208. currentColors.put(arena, chosen.toUpperCase());
    209. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] Stand on " + chosen + " in the next 10 seconds! Arena: " + arena);
    210. }
    211.  
    212. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    213. if(cmd.getName().equalsIgnoreCase("cjump") || cmd.getName().equalsIgnoreCase("colorjump")){
    214. if(args[0].equalsIgnoreCase("create")){
    215. getConfig().createSection(args[1].toString());
    216. getConfig().getStringList("arenas").add(args[1].toString());
    217. ChatColor pref = (ChatColor) getConfig().get("chat-color");
    218. sender.sendMessage(pref + "Arena " + args[1].toString() + " created!");
    219. }
    220. else if(args[0].equalsIgnoreCase("reload")){
    221. loadSpawns();
    222. }
    223. else if(args[0].equalsIgnoreCase("set-spawn")){
    224. getConfig().set("arenas." + args[1].toString() + ".x", ((Player) sender).getLocation().getX());
    225. getConfig().set("arenas." + args[1].toString() + ".y", ((Player) sender).getLocation().getY());
    226. getConfig().set("arenas." + args[1].toString() + ".z", ((Player) sender).getLocation().getZ());
    227. getConfig().set("arenas." + args[1].toString() + ".world", ((Player) sender).getLocation().getWorld().toString());
    228. }
    229. else if(args[0].equalsIgnoreCase("delete")){
    230. getConfig().getStringList("arenas").remove(args[1].toString());
    231. ChatColor pref = (ChatColor) getConfig().get("chat-color");
    232. sender.sendMessage(pref + "Arena " + args[1].toString() + " removed!");
    233. }
    234. return true;
    235. }
    236. else if(cmd.getName().equalsIgnoreCase("join")){
    237. addPlayer((Player) sender, args[0].toString());
    238. }
    239. return false;
    240. }
    241.  
    242. }
    243.  



    Plugin.yml:
    Show Spoiler

    Code:
    name: Color Jumper
    main: main.Main
    version: 1.0
    author: CopyableCougar4
    description: A minigame where you jump on colored wool!
    commands:
      cjump:
        description: Color Jumper Admin Command
        permission: colorjumper.admin
        permission-message: You don't have <permission>!
      join:
        description: Join a Color Jumper Game
        permission: colorjumper.user
        permission-message: You don't have <permission>!
    permissions:
      colorjumper.admin:
        default: op
      colorjumper.user:
        default: true
    


    Config.yml:
    Show Spoiler

    Code:
    # Color Jumper configuration:
    chat-color: WHITE # contact CopyableCougar4 if a color doesn't work


    As I stated above, please respond with any suggestions or changes (only if you actually know what you are talking about)

    Bug posting format:
    Code:
    Line numbers:
    Problem:
    Fix:
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  15. Offline

    slowbuild

    CopyableCougar4 the code looks good :) But I won't test it, because I'm still working on my own version of this plugin .
    I think that my plugin will be eventually ready tomorrow to test it. Do you think, it'll be bad, if we make two versions of one plugin? If you think so I'll change a few gameplay things like obstacles to make it different?
     
  16. Offline

    15987632

    slowbuild CopyableCougar4 i think that its fine to make two versions because there are multiple versions of the same plugins out there but i will be looking forward to test these things :)
     
  17. Offline

    CopyableCougar4

    I don't think it would be bad, in fact I think that would be good :) Two perspectives on the same idea broadens the possibilities :)
     
  18. Offline

    coreymichealroy

    I still can't do commands with your version.
     
  19. Offline

    CopyableCougar4

    I'll keep working on it :)
    --------------------------------
    Note: If anybody has errors and is able to copy/paste error logs into messages, please do so as this speeds up debugging.
     
  20. Offline

    coreymichealroy

    Here's the error I get:

    Code:
    12:04:15 [INFO] vortex25565 issued server command: /cjump create test
    12:04:15 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'cjum
    p' in plugin Color Jumper v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    2)
            at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServe
    r.java:528)
            at net.minecraft.server.v1_6_R3.PlayerConnection.handleCommand(PlayerCon
    nection.java:968)
            at net.minecraft.server.v1_6_R3.PlayerConnection.chat(PlayerConnection.j
    ava:886)
            at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java
    :837)
            at net.minecraft.server.v1_6_R3.Packet3Chat.handle(SourceFile:49)
            at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296
    )
            at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java
    :116)
            at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
            at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:3
    0)
            at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:5
    92)
            at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:2
    27)
            at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:4
    88)
            at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java
    :421)
            at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:5
    83)
    Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.
    bukkit.ChatColor
            at main.Main.onCommand(Main.java:217)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
            ... 15 more
    >
     
  21. Offline

    slowbuild

    coreymichealroy The problem is this
    ChatColor pref = (ChatColor) getConfig().get("chat-color");
    to test if it works you could use
    ChatColor pref = ChatColor.GREEN;
    If you want to read it from the config you will have to do something like
    ChatColor pref;
    switch(getConfig().get("chat-color"))
    {
    case "green":
    pref = ChatColor.GREEN;
    break;
    }
    and so on...
     
  22. Offline

    CopyableCougar4

    slowbuild Thanks for catching that :) coreymichealroy Here's an updated jar
    LINK

    Updated copy of the source :)
    Show Spoiler

    Code:text
    1.  
    2. package main;
    3.  
    4. import java.io.File;
    5. import java.io.FileWriter;
    6. import java.io.IOException;
    7. import java.util.*;
    8.  
    9. import org.bukkit.*;
    10. import org.bukkit.block.Sign;
    11. import org.bukkit.command.Command;
    12. import org.bukkit.command.CommandSender;
    13. import org.bukkit.configuration.file.FileConfiguration;
    14. import org.bukkit.configuration.file.YamlConfiguration;
    15. import org.bukkit.entity.Player;
    16. import org.bukkit.event.EventHandler;
    17. import org.bukkit.event.Listener;
    18. import org.bukkit.event.block.Action;
    19. import org.bukkit.event.player.*;
    20. import org.bukkit.material.Wool;
    21. import org.bukkit.plugin.java.JavaPlugin;
    22.  
    23. public class Main extends JavaPlugin implements Listener{
    24.  
    25. HashMap<Player, String> whereTheyAre = new HashMap<Player, String>();
    26. HashMap<String, HashMap<Player, Integer>> activePlayers = new HashMap<String, HashMap<Player, Integer>>();
    27. HashMap<String, String> currentColors = new HashMap<String, String>();
    28. HashMap<String, Location> spawns;
    29.  
    30. @Override
    31. public FileConfiguration getConfig(){
    32. return YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + "/config.yml"));
    33. }
    34.  
    35. public void onEnable() {
    36. checkForConfig();
    37. loadSpawns();
    38. getLogger().info("Color Jumper has been enabled! By: CopyableCougar4");
    39. }
    40.  
    41. public void checkForConfig(){
    42. File f = new File(this.getDataFolder() + "/config.yml");
    43. File g = new File(this.getDataFolder().toString());
    44. if(!g.exists()){
    45. g.mkdir();
    46. getLogger().info("Generating plugin folder...");
    47. }
    48. if(!f.exists()){
    49. try {
    50. f.createNewFile();
    51. getLogger().info("Generating configuration file...");
    52. FileWriter fw = new FileWriter(f);
    53. fw.write("chat-color: WHITE # contact CopyableCougar4 if a color doesn't work");
    54. fw.close();
    55. } catch (IOException e) {
    56. e.printStackTrace();
    57. }
    58. }
    59.  
    60. }
    61.  
    62. public void loadSpawns(){
    63. getLogger().info("Loading arena spawns...");
    64. for(int a = 0; a < getConfig().getStringList("arenas").size(); a++){
    65. spawns.put((String) getConfig().getStringList("arenas").toArray()[a],
    66. new Location(Bukkit.getWorld(getConfig().getString("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".world")),
    67. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".x"),
    68. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".y"),
    69. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".z")));
    70. }
    71. getLogger().info("Arena spawns loaded!");
    72. }
    73.  
    74. public void onDisable() {
    75. getLogger().info("Color Jumper has been disabled! By: CopyableCougar4");
    76. }
    77.  
    78. @EventHandler
    79. public void onInteract(final PlayerInteractEvent event) {
    80. if(event.getClickedBlock().getType() == Material.SIGN){
    81. Sign sign = (Sign) event.getClickedBlock();
    82. if(sign.getLine(1) == "[Color Jumper]" && sign.getLine(2) == "Join"){
    83. addPlayer(event.getPlayer(), sign.getLine(3));
    84. }
    85. } else {
    86. if((event.getAction() == Action.PHYSICAL) && (whereTheyAre.get(event.getPlayer()) != null)){
    87. Timer t = new Timer();
    88. t.schedule(new TimerTask(){
    89. public void run(){
    90. String arena = whereTheyAre.get(event.getPlayer());
    91. String color = currentColors.get(arena); // correct color
    92. DyeColor dc;
    93. switch(color){
    94. case "BLACK": dc = DyeColor.BLACK;
    95. case "BLUE": dc = DyeColor.BLUE;
    96. case "BROWN": dc = DyeColor.BROWN;
    97. case "CYAN": dc = DyeColor.CYAN;
    98. case "GRAY": dc = DyeColor.GRAY;
    99. case "GREEN": dc = DyeColor.GREEN;
    100. case "LIGHT_BLUE": dc = DyeColor.LIGHT_BLUE;
    101. case "LIME": dc = DyeColor.LIME;
    102. case "MAGENTA": dc = DyeColor.MAGENTA;
    103. case "ORANGE": dc = DyeColor.ORANGE;
    104. case "PINK": dc = DyeColor.PINK;
    105. case "PURPLE": dc = DyeColor.PURPLE;
    106. case "RED": dc = DyeColor.RED;
    107. case "SILVER": dc = DyeColor.SILVER;
    108. case "YELLOW": dc = DyeColor.YELLOW;
    109. default: dc = DyeColor.WHITE;
    110. }
    111. Wool w = new Wool(dc); // correct block to be on
    112. if((event.getClickedBlock().getType() != w.getItemType())){
    113. //they aren't where they should be
    114. event.getPlayer().sendMessage(ChatColor.RED + "You should be on a " + color.toLowerCase() + " wool block!");
    115. playerLost(event.getPlayer(), arena);
    116. }
    117. }
    118. }, 10000);
    119.  
    120. } else {
    121. return;
    122. }
    123. }
    124. }
    125.  
    126. public void playerLost(Player player, String arena){
    127. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + player.getName() + " has lost his match! Arena: " + arena);
    128. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    129. playersLeft.remove(player);
    130. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + playersLeft.size() + " player(s) remain! Arena: " + arena);
    131. whereTheyAre.remove(player);
    132. if(playersLeft.size() == 1){
    133. //there is only one player left
    134. endGame(arena);
    135. }
    136. }
    137.  
    138. public void endGame(String arena){
    139. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Match ended! Arena: " + arena);
    140. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    141. playersLeft.clear();
    142. }
    143.  
    144. public void addPlayer(Player player, String arena) {
    145. HashMap<Player, Integer> arenaSize = activePlayers.get(arena);
    146. int currentSize = arenaSize.size();
    147. arenaSize.put(player, currentSize + 1);
    148. player.sendMessage(ChatColor.GOLD + "[Color Jumper] You have joined the arena: " + arena);
    149. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] " + player.getName() + " has joined ColorJumper! Arena: " + arena);
    150. if(currentSize == 1){
    151. startGame(arena);
    152. }
    153. whereTheyAre.put(player, arena);
    154.  
    155. }
    156.  
    157. public void startGame(String arena){
    158. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] ColorJumper has started! Arena: " + arena);
    159. HashMap<Player, Integer> toTeleport = activePlayers.get(arena);
    160. Player[] people = (Player[]) toTeleport.keySet().toArray();
    161. int arenaX = Main.this.getConfig().getInt(arena + ".x");
    162. int arenaY = Main.this.getConfig().getInt(arena + ".y");
    163. int arenaZ = Main.this.getConfig().getInt(arena + ".z");
    164. World arenaW = Bukkit.getWorld(Main.this.getConfig().getString(arena + ".world"));
    165. for(int a = 0; a < people.length; a++){
    166. people[a].teleport(new Location(arenaW, arenaX, arenaY, arenaZ));
    167. }
    168. runCountDown(arena);
    169. }
    170.  
    171. int currentCount = 0;
    172.  
    173. public void runMatch(final String arena){
    174. Timer t = new Timer();
    175. t.schedule(new TimerTask(){
    176. public void run(){
    177. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] New color in " + (5 - currentCount) + " second(s)!");
    178. if(currentCount == 5){
    179. newColor(arena);
    180. currentCount = 0;
    181. } else {
    182. currentCount += 1;
    183. }
    184. }
    185. }, 1000);
    186. }
    187.  
    188. int currentCountDown = 0;
    189.  
    190. public void runCountDown(final String arena){
    191. Timer t = new Timer();
    192. t.schedule(new TimerTask(){
    193. public void run(){
    194. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Starting in " + (10 - currentCountDown) + " second(s)! Arena: " + arena);
    195. if(currentCountDown == 10){
    196. runMatch(arena);
    197. } else {
    198. currentCountDown += 1;
    199. }
    200. }
    201. }, 1000);
    202. }
    203.  
    204. public void newColor(String arena){
    205. List<String> colors = Main.this.getConfig().getStringList("colors");
    206. int listLength = colors.size();
    207. int chosenValue = (int) Math.ceil(Math.random() * listLength) - 1;
    208. String chosen = colors.get(chosenValue);
    209. currentColors.put(arena, chosen.toUpperCase());
    210. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] Stand on " + chosen + " in the next 10 seconds! Arena: " + arena);
    211. }
    212.  
    213. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    214. if(cmd.getName().equalsIgnoreCase("cjump") || cmd.getName().equalsIgnoreCase("colorjump")){
    215. if(args[0].equalsIgnoreCase("create")){
    216. getConfig().createSection(args[1].toString());
    217. getConfig().getStringList("arenas").add(args[1].toString());
    218. String pref = getConfig().getString("chat-color");
    219. pref = ChatColor.translateAlternateColorCodes('&', pref);
    220. sender.sendMessage(pref + "Arena " + args[1].toString() + " created!");
    221. }
    222. else if(args[0].equalsIgnoreCase("reload")){
    223. loadSpawns();
    224. }
    225. else if(args[0].equalsIgnoreCase("set-spawn")){
    226. getConfig().set("arenas." + args[1].toString() + ".x", ((Player) sender).getLocation().getX());
    227. getConfig().set("arenas." + args[1].toString() + ".y", ((Player) sender).getLocation().getY());
    228. getConfig().set("arenas." + args[1].toString() + ".z", ((Player) sender).getLocation().getZ());
    229. getConfig().set("arenas." + args[1].toString() + ".world", ((Player) sender).getLocation().getWorld().toString());
    230. }
    231. else if(args[0].equalsIgnoreCase("delete")){
    232. getConfig().getStringList("arenas").remove(args[1].toString());
    233. ChatColor pref = (ChatColor) getConfig().get("chat-color");
    234. sender.sendMessage(pref + "Arena " + args[1].toString() + " removed!");
    235. }
    236. return true;
    237. }
    238. else if(cmd.getName().equalsIgnoreCase("join")){
    239. addPlayer((Player) sender, args[0].toString());
    240. }
    241. return false;
    242. }
    243.  
    244. }
    245.  

     
  23. Offline

    coreymichealroy

    Now it's not even working, It's not showing up when I do /pl and it's not generating any configeration file
     
  24. Offline

    CopyableCougar4

    Okay here's an updated jar. There is handling for not enough arguments, it actually loads, and should generate config if it doesn't exist.
    LINK

    As I have done before, here's the source for it in case anybody wants to tailor it for themselves :)

    Show Spoiler

    Code:
    package main;
    
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.*;
    
    import org.bukkit.*;
    import org.bukkit.block.Sign;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.*;
    import org.bukkit.material.Wool;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener{
        
        HashMap<Player, String> whereTheyAre = new HashMap<Player, String>();
        HashMap<String, HashMap<Player, Integer>> activePlayers = new HashMap<String, HashMap<Player, Integer>>(); 
        HashMap<String, String> currentColors = new HashMap<String, String>();
        HashMap<String, Location> spawns;
    
        public void onEnable() {
            loadSpawns();
            getLogger().info("Color Jumper has been enabled! By: CopyableCougar4");
            File f = new File(this.getDataFolder() + "/config.yml");
            if(!f.exists()) this.saveDefaultConfig();
        }
        
        public void loadSpawns(){
            getLogger().info("Loading arena spawns...");
            for(int a = 0; a < getConfig().getStringList("arenas").size(); a++){
                spawns.put((String) getConfig().getStringList("arenas").toArray()[a], 
                        new Location(Bukkit.getWorld(getConfig().getString("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".world")),
                        getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".x"),
                        getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".y"),
                        getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".z")));
            }
            getLogger().info("Arena spawns loaded!");
        }
        
        public void onDisable() {
            getLogger().info("Color Jumper has been disabled! By: CopyableCougar4");
        }
        
        @EventHandler
        public void onInteract(final PlayerInteractEvent event) {
            if(event.getClickedBlock().getType() == Material.SIGN){
                Sign sign = (Sign) event.getClickedBlock();
                if(sign.getLine(1) == "[Color Jumper]" && sign.getLine(2) == "Join"){
                    addPlayer(event.getPlayer(), sign.getLine(3));
                }
            } else {
                if((event.getAction() == Action.PHYSICAL) && (whereTheyAre.get(event.getPlayer()) != null)){
                    Timer t = new Timer();
                    t.schedule(new TimerTask(){
                        public void run(){
                            String arena = whereTheyAre.get(event.getPlayer());
                            String color = currentColors.get(arena); // correct color
                            DyeColor dc;
                            switch(color){
                                case "BLACK": dc = DyeColor.BLACK;
                                case "BLUE": dc = DyeColor.BLUE;
                                case "BROWN": dc = DyeColor.BROWN;
                                case "CYAN": dc = DyeColor.CYAN;
                                case "GRAY": dc = DyeColor.GRAY;
                                case "GREEN": dc = DyeColor.GREEN;
                                case "LIGHT_BLUE": dc = DyeColor.LIGHT_BLUE;
                                case "LIME": dc = DyeColor.LIME;
                                case "MAGENTA": dc = DyeColor.MAGENTA;
                                case "ORANGE": dc = DyeColor.ORANGE;
                                case "PINK": dc = DyeColor.PINK;
                                case "PURPLE": dc = DyeColor.PURPLE;
                                case "RED": dc = DyeColor.RED;
                                case "SILVER": dc = DyeColor.SILVER;
                                case "YELLOW": dc = DyeColor.YELLOW;
                                default: dc = DyeColor.WHITE;
                            }
                            Wool w = new Wool(dc); // correct block to be on
                            if((event.getClickedBlock().getType() != w.getItemType())){
                                //they aren't where they should be
                                event.getPlayer().sendMessage(ChatColor.RED + "You should be on a " + color.toLowerCase() + " wool block!");
                                playerLost(event.getPlayer(), arena);
                            }
                        }
                    }, 10000);
                    
                } else {
                    return;
                }
            }
        }
        
        public void playerLost(Player player, String arena){
            Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + player.getName() + " has lost his match! Arena: " + arena);
            HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
            playersLeft.remove(player);
            Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + playersLeft.size() + " player(s) remain! Arena: " + arena);
            whereTheyAre.remove(player);
            if(playersLeft.size() == 1){
                //there is only one player left
                endGame(arena);
            }
        }
        
        public void endGame(String arena){
            Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Match ended! Arena: " + arena);
            HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
            playersLeft.clear();
        }
        
        public void addPlayer(Player player, String arena) {
            HashMap<Player, Integer> arenaSize = activePlayers.get(arena);
            int currentSize = arenaSize.size();
            arenaSize.put(player, currentSize + 1);
            player.sendMessage(ChatColor.GOLD + "[Color Jumper] You have joined the arena: " + arena);
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] " + player.getName() + " has joined ColorJumper! Arena: " + arena);
            if(currentSize == 1){
                startGame(arena);
            }
            whereTheyAre.put(player, arena);
            
        }
        
        public void startGame(String arena){
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] ColorJumper has started! Arena: " + arena);
            HashMap<Player, Integer> toTeleport = activePlayers.get(arena);
            Player[] people = (Player[]) toTeleport.keySet().toArray();
            int arenaX = Main.this.getConfig().getInt(arena + ".x");
            int arenaY = Main.this.getConfig().getInt(arena + ".y");
            int arenaZ = Main.this.getConfig().getInt(arena + ".z");
            World arenaW = Bukkit.getWorld(Main.this.getConfig().getString(arena + ".world"));
            for(int a = 0; a < people.length; a++){
                people[a].teleport(new Location(arenaW, arenaX, arenaY, arenaZ));
            }
            runCountDown(arena);
        }
        
        int currentCount = 0;
        
        public void runMatch(final String arena){
            Timer t = new Timer();
            t.schedule(new TimerTask(){
                public void run(){
                    Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] New color in " + (5 - currentCount) + " second(s)!");
                    if(currentCount == 5){
                        newColor(arena);
                        currentCount = 0;
                    } else {
                        currentCount += 1;
                    }
                }
            }, 1000);
        }
        
        int currentCountDown = 0;
        
        public void runCountDown(final String arena){
            Timer t = new Timer();
            t.schedule(new TimerTask(){
                public void run(){
                    Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Starting in " + (10 - currentCountDown) + " second(s)! Arena: " + arena);
                    if(currentCountDown == 10){
                        runMatch(arena);
                    } else {
                        currentCountDown += 1;
                    }
                }
            }, 1000);
        }
        
        public void newColor(String arena){
            List<String> colors = Main.this.getConfig().getStringList("colors");
            int listLength = colors.size();
            int chosenValue = (int) Math.ceil(Math.random() * listLength)  - 1;
            String chosen = colors.get(chosenValue);
            currentColors.put(arena, chosen.toUpperCase());
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] Stand on " + chosen + " in the next 10 seconds! Arena: " + arena);
        }
        
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("cjump") || cmd.getName().equalsIgnoreCase("colorjump")){
                if(args.length == 0){
                    sender.sendMessage(ChatColor.RED + "Usage:\n/cjump create {arena} - create an arena\n/cjump reload - reload arena spawns\n/cjump set-spawn {arena} - set the spawn for an arena\n/cjump delete {arena} - delete an arena");
                } else {
                    if(args[0].equalsIgnoreCase("create")){
                        getConfig().createSection(args[1].toString());
                        getConfig().getStringList("arenas").add(args[1].toString());
                        String pref = getConfig().getString("chat-color");
                        pref = ChatColor.translateAlternateColorCodes('&', pref);
                        sender.sendMessage(pref + "Arena " + args[1].toString() + " created!");
                    }
                    else if(args[0].equalsIgnoreCase("reload")){
                        loadSpawns();
                    }
                    else if(args[0].equalsIgnoreCase("set-spawn")){
                        getConfig().set("arenas." + args[1].toString() + ".x", ((Player) sender).getLocation().getX());
                        getConfig().set("arenas." + args[1].toString() + ".y", ((Player) sender).getLocation().getY());
                        getConfig().set("arenas." + args[1].toString() + ".z", ((Player) sender).getLocation().getZ());
                        getConfig().set("arenas." + args[1].toString() + ".world", ((Player) sender).getLocation().getWorld().toString());
                    }
                    else if(args[0].equalsIgnoreCase("delete")){
                        getConfig().getStringList("arenas").remove(args[1].toString());
                        ChatColor pref = (ChatColor) getConfig().get("chat-color");
                        sender.sendMessage(pref + "Arena " + args[1].toString() + " removed!");
                    }
                }
                return true;
            }
            else if(cmd.getName().equalsIgnoreCase("join")){
                if(args.length == 0) {
                    //no argument
                    sender.sendMessage(ChatColor.RED + "Usage: /join {arena}");
                } else {
                    addPlayer((Player) sender, args[0].toString());
                }
            }
            return false;
        }
            
    }
    
    
     
  25. Offline

    PieMan456

    I can't wait till this plugin is all debugged and ready to use!
     
  26. Offline

    coreymichealroy

    Your almost there! Your able to create the arenas, but your not able to set the spawns, and you can't join arenas. You also can't delete arenas
     
  27. Offline

    CopyableCougar4

    Okay I edited it again. I think the only issue for creating, deleting, and setting spawns was saving the config to the folder with
    Code:java
    1. this.saveConfig();


    Anyways, updated link: HERE

    More copies of the code :)
    Show Spoiler

    Code:java
    1. package main;
    2.  
    3. import java.io.File;
    4. import java.io.FileWriter;
    5. import java.io.IOException;
    6. import java.util.*;
    7.  
    8. import org.bukkit.*;
    9. import org.bukkit.block.Sign;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.configuration.file.FileConfiguration;
    13. import org.bukkit.configuration.file.YamlConfiguration;
    14. import org.bukkit.entity.Player;
    15. import org.bukkit.event.EventHandler;
    16. import org.bukkit.event.Listener;
    17. import org.bukkit.event.block.Action;
    18. import org.bukkit.event.player.*;
    19. import org.bukkit.material.Wool;
    20. import org.bukkit.plugin.java.JavaPlugin;
    21.  
    22. public class Main extends JavaPlugin implements Listener{
    23.  
    24. HashMap<Player, String> whereTheyAre = new HashMap<Player, String>();
    25. HashMap<String, HashMap<Player, Integer>> activePlayers = new HashMap<String, HashMap<Player, Integer>>();
    26. HashMap<String, String> currentColors = new HashMap<String, String>();
    27. HashMap<String, Location> spawns;
    28.  
    29. public void onEnable() {
    30. loadSpawns();
    31. getLogger().info("Color Jumper has been enabled! By: CopyableCougar4");
    32. File f = new File(this.getDataFolder() + "/config.yml");
    33. if(!f.exists()) this.saveDefaultConfig();
    34. }
    35.  
    36. public void loadSpawns(){
    37. getLogger().info("Loading arena spawns...");
    38. for(int a = 0; a < getConfig().getStringList("arenas").size(); a++){
    39. spawns.put((String) getConfig().getStringList("arenas").toArray()[a],
    40. new Location(Bukkit.getWorld(getConfig().getString("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".world")),
    41. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".x"),
    42. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".y"),
    43. getConfig().getInt("arenas." + getConfig().getStringList("arenas").toArray()[a] + ".z")));
    44. }
    45. getLogger().info("Arena spawns loaded!");
    46. }
    47.  
    48. public void onDisable() {
    49. getLogger().info("Color Jumper has been disabled! By: CopyableCougar4");
    50. }
    51.  
    52. @EventHandler
    53. public void onInteract(final PlayerInteractEvent event) {
    54. if(event.getClickedBlock().getType() == Material.SIGN){
    55. Sign sign = (Sign) event.getClickedBlock();
    56. if(sign.getLine(1) == "[Color Jumper]" && sign.getLine(2) == "Join"){
    57. addPlayer(event.getPlayer(), sign.getLine(3));
    58. }
    59. } else {
    60. if((event.getAction() == Action.PHYSICAL) && (whereTheyAre.get(event.getPlayer()) != null)){
    61. Timer t = new Timer();
    62. t.schedule(new TimerTask(){
    63. public void run(){
    64. String arena = whereTheyAre.get(event.getPlayer());
    65. String color = currentColors.get(arena); // correct color
    66. DyeColor dc;
    67. switch(color){
    68. case "BLACK": dc = DyeColor.BLACK;
    69. case "BLUE": dc = DyeColor.BLUE;
    70. case "BROWN": dc = DyeColor.BROWN;
    71. case "CYAN": dc = DyeColor.CYAN;
    72. case "GRAY": dc = DyeColor.GRAY;
    73. case "GREEN": dc = DyeColor.GREEN;
    74. case "LIGHT_BLUE": dc = DyeColor.LIGHT_BLUE;
    75. case "LIME": dc = DyeColor.LIME;
    76. case "MAGENTA": dc = DyeColor.MAGENTA;
    77. case "ORANGE": dc = DyeColor.ORANGE;
    78. case "PINK": dc = DyeColor.PINK;
    79. case "PURPLE": dc = DyeColor.PURPLE;
    80. case "RED": dc = DyeColor.RED;
    81. case "SILVER": dc = DyeColor.SILVER;
    82. case "YELLOW": dc = DyeColor.YELLOW;
    83. default: dc = DyeColor.WHITE;
    84. }
    85. Wool w = new Wool(dc); // correct block to be on
    86. if((event.getClickedBlock().getType() != w.getItemType())){
    87. //they aren't where they should be
    88. event.getPlayer().sendMessage(ChatColor.RED + "You should be on a " + color.toLowerCase() + " wool block!");
    89. playerLost(event.getPlayer(), arena);
    90. }
    91. }
    92. }, 10000);
    93.  
    94. } else {
    95. return;
    96. }
    97. }
    98. }
    99.  
    100. public void playerLost(Player player, String arena){
    101. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + player.getName() + " has lost his match! Arena: " + arena);
    102. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    103. playersLeft.remove(player);
    104. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] " + playersLeft.size() + " player(s) remain! Arena: " + arena);
    105. whereTheyAre.remove(player);
    106. if(playersLeft.size() == 1){
    107. //there is only one player left
    108. endGame(arena);
    109. }
    110. }
    111.  
    112. public void endGame(String arena){
    113. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Match ended! Arena: " + arena);
    114. HashMap<Player, Integer> playersLeft = activePlayers.get(arena);
    115. playersLeft.clear();
    116. }
    117.  
    118. public void addPlayer(Player player, String arena) {
    119. HashMap<Player, Integer> arenaSize = activePlayers.get(arena);
    120. int currentSize = arenaSize.size();
    121. arenaSize.put(player, currentSize + 1);
    122. player.sendMessage(ChatColor.GOLD + "[Color Jumper] You have joined the arena: " + arena);
    123. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] " + player.getName() + " has joined ColorJumper! Arena: " + arena);
    124. if(currentSize == 1){
    125. startGame(arena);
    126. }
    127. whereTheyAre.put(player, arena);
    128.  
    129. }
    130.  
    131. public void startGame(String arena){
    132. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] ColorJumper has started! Arena: " + arena);
    133. HashMap<Player, Integer> toTeleport = activePlayers.get(arena);
    134. Player[] people = (Player[]) toTeleport.keySet().toArray();
    135. int arenaX = Main.this.getConfig().getInt(arena + ".x");
    136. int arenaY = Main.this.getConfig().getInt(arena + ".y");
    137. int arenaZ = Main.this.getConfig().getInt(arena + ".z");
    138. World arenaW = Bukkit.getWorld(Main.this.getConfig().getString(arena + ".world"));
    139. for(int a = 0; a < people.length; a++){
    140. people[a].teleport(new Location(arenaW, arenaX, arenaY, arenaZ));
    141. }
    142. runCountDown(arena);
    143. }
    144.  
    145. int currentCount = 0;
    146.  
    147. public void runMatch(final String arena){
    148. Timer t = new Timer();
    149. t.schedule(new TimerTask(){
    150. public void run(){
    151. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] New color in " + (5 - currentCount) + " second(s)!");
    152. if(currentCount == 5){
    153. newColor(arena);
    154. currentCount = 0;
    155. } else {
    156. currentCount += 1;
    157. }
    158. }
    159. }, 1000);
    160. }
    161.  
    162. int currentCountDown = 0;
    163.  
    164. public void runCountDown(final String arena){
    165. Timer t = new Timer();
    166. t.schedule(new TimerTask(){
    167. public void run(){
    168. Bukkit.broadcastMessage(ChatColor.RED + "[Color Jumper] Starting in " + (10 - currentCountDown) + " second(s)! Arena: " + arena);
    169. if(currentCountDown == 10){
    170. runMatch(arena);
    171. } else {
    172. currentCountDown += 1;
    173. }
    174. }
    175. }, 1000);
    176. }
    177.  
    178. public void newColor(String arena){
    179. List<String> colors = Main.this.getConfig().getStringList("colors");
    180. int listLength = colors.size();
    181. int chosenValue = (int) Math.ceil(Math.random() * listLength) - 1;
    182. String chosen = colors.get(chosenValue);
    183. currentColors.put(arena, chosen.toUpperCase());
    184. Bukkit.broadcastMessage(ChatColor.YELLOW + "[Color Jumper] Stand on " + chosen + " in the next 10 seconds! Arena: " + arena);
    185. }
    186.  
    187. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    188. if(cmd.getName().equalsIgnoreCase("cjump") || cmd.getName().equalsIgnoreCase("colorjump")){
    189. if(args.length == 0){
    190. sender.sendMessage(ChatColor.RED + "Usage:\n/cjump create {arena} - create an arena\n/cjump reload - reload arena spawns\n/cjump set-spawn {arena} - set the spawn for an arena\n/cjump delete {arena} - delete an arena");
    191. } else {
    192. if(args[0].equalsIgnoreCase("create")){
    193. getConfig().createSection(args[1].toString());
    194. getConfig().getStringList("arenas").add(args[1].toString());
    195. String pref = getConfig().getString("chat-color");
    196. pref = ChatColor.translateAlternateColorCodes('&', pref);
    197. sender.sendMessage(pref + "Arena " + args[1].toString() + " created!");
    198. this.saveConfig();
    199. }
    200. else if(args[0].equalsIgnoreCase("reload")){
    201. loadSpawns();
    202. }
    203. else if(args[0].equalsIgnoreCase("set-spawn")){
    204. getConfig().set("arenas." + args[1].toString() + ".x", ((Player) sender).getLocation().getX());
    205. getConfig().set("arenas." + args[1].toString() + ".y", ((Player) sender).getLocation().getY());
    206. getConfig().set("arenas." + args[1].toString() + ".z", ((Player) sender).getLocation().getZ());
    207. getConfig().set("arenas." + args[1].toString() + ".world", ((Player) sender).getLocation().getWorld().toString());
    208. this.saveConfig();
    209. }
    210. else if(args[0].equalsIgnoreCase("delete")){
    211. getConfig().getStringList("arenas").remove(args[1].toString());
    212. ChatColor pref = (ChatColor) getConfig().get("chat-color");
    213. sender.sendMessage(pref + "Arena " + args[1].toString() + " removed!");
    214. this.saveConfig();
    215. }
    216. }
    217. return true;
    218. }
    219. else if(cmd.getName().equalsIgnoreCase("join")){
    220. if(args.length == 0) {
    221. //no argument
    222. sender.sendMessage(ChatColor.RED + "Usage: /join {arena}");
    223. } else {
    224. addPlayer((Player) sender, args[0].toString());
    225. }
    226. }
    227. return false;
    228. }
    229.  
    230. }
    231.  

     
  28. Offline

    coreymichealroy

    Still having the same problems.
     
  29. Offline

    slowbuild

    My plugin is working now a little, so that you can play the game!
    I'm working on it now, and when I fixed a few little errors I expect to make a testserver tomorrow;)
     
  30. Offline

    15987632

    if you need a person to help test it i can test in give or take around this time tomorrow just PM me if you want to
     

Share This Page