Help me please!

Discussion in 'Plugin Development' started by Corndogoz, Apr 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    BillyBobJoe168

    Corndogoz woops. that line should be:
    Code:java
    1. player.teleport(new Location(player.getWorld(), x, y, z, yaw, pitch));
     
  2. Offline

    Corndogoz

    teleporting is fine, giving the player an item doesnt work, can you please tell me the code to give the player a diamond pickaxe and diamond sword?

    and how do i heal the player?

    sorry you have so much to answer, but how would i do
    Code:java
    1. getConfig().set("player"), player.getName();
    ??? I want it to get put the player in the config

    hmm, the blackout command stopped working, heres the code:
    Code:java
    1. package ericwang.forcorndogoz;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10. import org.bukkit.potion.PotionEffect;
    11. import org.bukkit.potion.PotionEffectType;
    12.  
    13. public class forcorndogoz extends JavaPlugin {
    14.  
    15.  
    16. public void onEnable() {
    17. new PlayerListener(this);
    18. getConfig().options().copyDefaults(true);
    19. saveConfig();
    20. }
    21.  
    22. public void onDisable() {
    23. }
    24.  
    25. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    26. if (cmd.getName().equalsIgnoreCase("troll")) {
    27. Player player = (Player) sender;
    28. int length = args.length;
    29. if (length==0){
    30. player.sendMessage("["+ChatColor.GREEN+"Corndogoz"+ChatColor.RESET+"] Error: You need an arg ps, im a pirate");
    31. }
    32. if (length == 1) {
    33. if (args[0].equalsIgnoreCase("settroll")) {
    34. getConfig().set("troll.x", player.getLocation().getX());
    35. getConfig().set("troll.y", player.getLocation().getY());
    36. getConfig().set("troll.z", player.getLocation().getZ());
    37. getConfig().set("troll.yaw", player.getLocation().getYaw());
    38. getConfig().set("troll.pitch", player.getLocation().getPitch());
    39. saveConfig();
    40. player.sendMessage("Trolling area set!");
    41. }
    42. if (args[0].equalsIgnoreCase("join")) {
    43. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has joined the game");
    44. }
    45. if (args[0].equalsIgnoreCase("leave")) {
    46. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has left the game");
    47. }
    48. if (args[0].equalsIgnoreCase("tptroll")) {
    49. player.teleport(new Location(player.getWorld(),getConfig().getDouble("troll.x"), getConfig().getDouble("troll.y"), getConfig().getDouble("troll.z"), getConfig().getLong("troll.yaw"), getConfig().getLong("troll.pitch")));
    50. }
    51. }
    52. if (cmd.getName().equalsIgnoreCase("blackout")) {
    53. if (length == 0) {
    54. player.sendMessage("["+ChatColor.GREEN+"Corndogoz"+ChatColor.RESET+"] Error: You need an arg ps, im a pirate");
    55. }
    56. if (length == 1) {
    57. if (args[0].equalsIgnoreCase("setblackout")) {
    58. getConfig().set("blackout.x", player.getLocation().getX());
    59. getConfig().set("blackout.y", player.getLocation().getY());
    60. getConfig().set("blackout.z", player.getLocation().getZ());
    61. getConfig().set("blackout.yaw", player.getLocation().getYaw());
    62. getConfig().set("blackout.pitch", player.getLocation().getPitch());
    63. saveConfig();
    64. Bukkit.getServer().broadcastMessage("Blackout spawn has been set, you may now use /blackout join!");
    65. }
    66. // if (args[0].equalsIgnoreCase("join")){
    67. // getConfig().set("player"), player.getName();
    68. // }
    69. if (args[0].equalsIgnoreCase("start")) {
    70. double x = getConfig().getDouble("blackout.x");
    71. double y = getConfig().getDouble("blackout.y");
    72. double z = getConfig().getDouble("blackout.z");
    73. int yaw = getConfig().getInt("blackout.yaw");
    74. int pitch = getConfig().getInt("blackout.pitch");
    75. player.teleport(new Location(player.getWorld(), x, y, z, yaw, pitch));
    76. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 600, 0)); //this sets the blindness effect for 300 ticks
    77. player.setWalkSpeed(5);
    78.  
    79. }
    80. }
    81. }
    82.  
    83.  
    84.  
    85.  
    86. }
    87.  
    88.  
    89. return false;
    90.  
    91. }
    92.  
    93. }
    94.  


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

    Code0

    Corndogoz To heal the player, use player.setHealth(20);

    Corndogoz

    Give Diamond Sword:

    player.getInventory.addItem(new ItemStack(Material.DIAMOND_SWORD,1)

    Give Diamond Pickaxe:

    player.getInventory.addItem(new ItemStack(Material.DIAMOND_PICKAXE,1)

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

    Corndogoz

    ok, i know why the blackout command wont work, my dad is helping fix it, the site is gonna be: http://dev.bukkit.org/bukkit-plugins/cornycraft/

    BillyBobJoe168 code:
    Code:java
    1. package ericwang.forcorndogoz;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.inventory.ItemStack;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12. import org.bukkit.potion.PotionEffect;
    13. import org.bukkit.potion.PotionEffectType;
    14.  
    15. public class forcorndogoz extends JavaPlugin {
    16.  
    17. public void onEnable() {
    18. new PlayerListener(this);
    19. getConfig().options().copyDefaults(true);
    20. saveConfig();
    21. }
    22.  
    23. public void onDisable() {
    24. }
    25.  
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27. if (cmd.getName().equalsIgnoreCase("troll")) {
    28. Player player = (Player) sender;
    29. int length = args.length;
    30. if (length == 0) {
    31. player.sendMessage("[" + ChatColor.GREEN + "Corndogoz" + ChatColor.RESET + "] Error: You need an arg ps, im a pirate");
    32. }
    33. if (length == 1) {
    34. if (args[0].equalsIgnoreCase("settroll")) {
    35. getConfig().set("troll.x", player.getLocation().getX());
    36. getConfig().set("troll.y", player.getLocation().getY());
    37. getConfig().set("troll.z", player.getLocation().getZ());
    38. getConfig().set("troll.yaw", player.getLocation().getYaw());
    39. getConfig().set("troll.pitch", player.getLocation().getPitch());
    40. saveConfig();
    41. player.sendMessage("Trolling area set!");
    42. }
    43. if (args[0].equalsIgnoreCase("join")) {
    44. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has joined the game");
    45. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 0, 0));
    46. }
    47. if (args[0].equalsIgnoreCase("leave")) {
    48. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has left the game");
    49. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 600000000, 0));
    50. }
    51. if (args[0].equalsIgnoreCase("tptroll")) {
    52. player.teleport(new Location(player.getWorld(), getConfig().getDouble("troll.x"), getConfig().getDouble("troll.y"), getConfig().getDouble("troll.z"), getConfig().getLong("troll.yaw"), getConfig().getLong("troll.pitch")));
    53. }
    54. }}
    55. if (cmd.getName().equalsIgnoreCase("blackout")) {
    56. Player player = (Player) sender;
    57. int length = args.length;
    58. if (length == 0) {
    59. player.sendMessage("[" + ChatColor.GREEN + "Corndogoz" + ChatColor.RESET + "] Error: You need an arg ps, im a pirate");
    60. }
    61. if (length == 1) {
    62. if (args[0].equalsIgnoreCase("setblackout")) {
    63. getConfig().set("blackout.x", player.getLocation().getX());
    64. getConfig().set("blackout.y", player.getLocation().getY());
    65. getConfig().set("blackout.z", player.getLocation().getZ());
    66. getConfig().set("blackout.yaw", player.getLocation().getYaw());
    67. getConfig().set("blackout.pitch", player.getLocation().getPitch());
    68. saveConfig();
    69. Bukkit.getServer().broadcastMessage("Blackout spawn has been set, you may now use /blackout join!");
    70. }
    71. // if (args[0].equalsIgnoreCase("join")){
    72. // getConfig().set("player"), player.getName();
    73. // }
    74. if (args[0].equalsIgnoreCase("start")) {
    75. player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE,1));
    76. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD,1));
    77. double x = getConfig().getDouble("blackout.x");
    78. double y = getConfig().getDouble("blackout.y");
    79. double z = getConfig().getDouble("blackout.z");
    80. int yaw = getConfig().getInt("blackout.yaw");
    81. int pitch = getConfig().getInt("blackout.pitch");
    82. player.teleport(new Location(player.getWorld(), x, y, z, yaw, pitch));
    83. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 6000000, 0)); //this sets the blindness effect for 300 ticks
    84. player.setWalkSpeed(5);
    85.  
    86. }
    87. }
    88.  
    89. }
    90.  
    91. return false;
    92.  
    93. }
    94. }


    error:
    Code:
    null
    org.bukkit.command.CommandException: Unhandled exception executing command 'blackout' in plugin ForCorndogoz v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at org.bukkit.craftbukkit.v1_7_R2.CraftServer.dispatchCommand(CraftServer.java:709) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.PlayerConnection.handleCommand(PlayerConnection.java:984) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.PlayerConnection.a(PlayerConnection.java:829) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.PacketPlayInChat.a(PacketPlayInChat.java:28) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.PacketPlayInChat.handle(PacketPlayInChat.java:65) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.NetworkManager.a(NetworkManager.java:148) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.ServerConnection.c(ServerConnection.java:77) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.MinecraftServer.v(MinecraftServer.java:703) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.DedicatedServer.v(DedicatedServer.java:273) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.MinecraftServer.u(MinecraftServer.java:566) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.MinecraftServer.run(MinecraftServer.java:472) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at net.minecraft.server.v1_7_R2.ThreadServerApplication.run(SourceFile:618) [spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
    Caused by: java.lang.IllegalArgumentException: 5.0 is too high
        at org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer.validateSpeed(CraftPlayer.java:1161) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer.setWalkSpeed(CraftPlayer.java:1140) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        at ericwang.forcorndogoz.forcorndogoz.onCommand(forcorndogoz.java:84) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.7.5-R0.1-SNAPSHOT.jar:git-Spigot-1360]
        ... 13 more
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Offline

    BillyBobJoe168

    "Caused by: java.lang.IllegalArgumentException: 5.0 is too high" Apparently 1 is the highest.

    hey btw, I read your plugin page and apparently it says the plugin crashes when you type commands in the config. Next to all the commands you only want players to be able to use, add the code
    && sender instanceof Player

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

    Corndogoz

    Idk where to add that, can you show me and example?
     
  7. Offline

    JBoss925

    This is because of .setWalkSpeed() try doing
    Code:java
    1. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 6000000, 0)); //replace 0 w/ whatever quickness level you want
     
  8. Offline

    BillyBobJoe168

    for ALL your commands currently, it seems like only Players should be able to use these right? Players are the only ones in game and only they should be able to join/leave/set spawns and all that. An example would be:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("troll") && sender instanceof Player) { }
     
  9. Offline

    Corndogoz

    Ok, thx, nice signature

    Ok, I'm not at the computer able to fix it right now, but I will ask questions tonight so I have time to fix it tomorrow, XD, and for /troll leave and /troll join, it says <player> joined/left the game, is their a way to get it to work with console, so Console joined/left the game?

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

    JBoss925

    Do it at the very beginning like:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    2.  
    3.  
    4.  
    5.  
    6.  
    7.  
    8. //HERE HERE HERE HERE HERE
    9. if(!(sender instanceof Player)){
    10. sender.sendMessage("LOL noob only players can use this");
    11. }
    12. //HERE HERE HERE HERE HERE
    13.  
    14.  
    15.  
    16.  
    17.  
    18.  
    19.  
    20. if (cmd.getName().equalsIgnoreCase("troll")) {
    21. Player player = (Player) sender;
    22. int length = args.length;
    23. if (length == 0) {
    24. player.sendMessage("[" + ChatColor.GREEN + "Corndogoz" + ChatColor.RESET + "] Error: You need an arg ps, im a pirate");
    25. }
    26. if (length == 1) {
    27. if (args[0].equalsIgnoreCase("settroll")) {
    28. getConfig().set("troll.x", player.getLocation().getX());
    29. getConfig().set("troll.y", player.getLocation().getY());
    30. getConfig().set("troll.z", player.getLocation().getZ());
    31. getConfig().set("troll.yaw", player.getLocation().getYaw());
    32. getConfig().set("troll.pitch", player.getLocation().getPitch());
    33. saveConfig();
    34. player.sendMessage("Trolling area set!");
    35. }
    36. if (args[0].equalsIgnoreCase("join")) {
    37. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has joined the game");
    38. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 0, 0));
    39. }
    40. if (args[0].equalsIgnoreCase("leave")) {
    41. Bukkit.getServer().broadcastMessage(ChatColor.YELLOW + player.getName() + " has left the game");
    42. player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 600000000, 0));
    43. }
    44. if (args[0].equalsIgnoreCase("tptroll")) {
    45. player.teleport(new Location(player.getWorld(), getConfig().getDouble("troll.x"), getConfig().getDouble("troll.y"), getConfig().getDouble("troll.z"), getConfig().getLong("troll.yaw"), getConfig().getLong("troll.pitch")));
    46. }
    47. }}
    48. if (cmd.getName().equalsIgnoreCase("blackout")) {
    49. Player player = (Player) sender;
    50. int length = args.length;
    51. if (length == 0) {
    52. player.sendMessage("[" + ChatColor.GREEN + "Corndogoz" + ChatColor.RESET + "] Error: You need an arg ps, im a pirate");
    53. }
    54. if (length == 1) {
    55. if (args[0].equalsIgnoreCase("setblackout")) {
    56. getConfig().set("blackout.x", player.getLocation().getX());
    57. getConfig().set("blackout.y", player.getLocation().getY());
    58. getConfig().set("blackout.z", player.getLocation().getZ());
    59. getConfig().set("blackout.yaw", player.getLocation().getYaw());
    60. getConfig().set("blackout.pitch", player.getLocation().getPitch());
    61. saveConfig();
    62. Bukkit.getServer().broadcastMessage("Blackout spawn has been set, you may now use /blackout join!");
    63. }
    64. // if (args[0].equalsIgnoreCase("join")){
    65. // getConfig().set("player"), player.getName();
    66. // }
    67. if (args[0].equalsIgnoreCase("start")) {
    68. player.getInventory().addItem(new ItemStack(Material.DIAMOND_PICKAXE,1));
    69. player.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD,1));
    70. double x = getConfig().getDouble("blackout.x");
    71. double y = getConfig().getDouble("blackout.y");
    72. double z = getConfig().getDouble("blackout.z");
    73. int yaw = getConfig().getInt("blackout.yaw");
    74. int pitch = getConfig().getInt("blackout.pitch");
    75. player.teleport(new Location(player.getWorld(), x, y, z, yaw, pitch));
    76. player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 6000000, 0)); //this sets the blindness effect for 300 ticks
    77. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 6000000, 0));
    78.  
    79. }
    80. }
    81.  
    82. }
    83.  
    84. return false;
    85.  
    86. }
    or use what BillyBobJoe168 said
     
  11. Offline

    BillyBobJoe168

    yes, I agree, JBoss925 is a very wise man lol:D
    Also put the && sender instanceof Player part with your if (cmd.getName().equalsIgnoreCase("blackout")) {} part.
     
  12. Offline

    JBoss925

    Lol thanks
     
  13. Offline

    BillyBobJoe168

    No...And anyways, why would you want the Console to join the game? i just don't get it :p
     
  14. Offline

    Corndogoz

    Lol, ok very weird but simple code :D
     
  15. Offline

    JBoss925

    Lol thanks man. Made the stunning realization and had to share it with the world :p Haha.
     
  16. Offline

    Corndogoz

    Idk, just for fun, :)

    Guys, are we allow to be talkin about this? Its not about the forum topic much anymore

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

    BillyBobJoe168

    :D
    EDIT: On my way to find a wise quote!
    EDIT#2: Just realized JBoss925 was you LOL. Didn't bother to read your username. Oh well.
    It's your thread...:p
    EDIT: Your forum topic is Help Me Please! I think everything we are saying fits under than topic?
     
  18. Offline

    Corndogoz

    OK, I just realized it was jboss also, lol, are you staff boss?
     
  19. Offline

    JBoss925

    Lol it's all good. We've just deviated from the topic a bit.
    Haha tell me when you find one!
    Lol I wish. Staff would be really cool but you gotta work your way up. I'm just someone that feels like helping people when they first start out because nobody helped me when I first started coding and it was really hard so idk I do this haha.
     
    Corndogoz likes this.
  20. Offline

    Corndogoz

    Oh, lol, I didn't know that bukkit allowed people to download my plugin yet JBoss925 :)

    PS, I've coded other simple things in java like guess my number :)

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

    JBoss925

    Haha I remember guess my number games. I made one in every language I know. Python, Java, CPP…ahhh memories. :)
     
  22. Offline

    BillyBobJoe168

    OMG WISE QUOTE: If at first you don't succeed, maybe skydiving is not for you! (Off topic but still kinda on topic...?) Going in my sig!
     
  23. Offline

    Corndogoz

    Lol, nice SIG, and I program guess my number in a lot of languages, even something called scratch
     
  24. Offline

    BillyBobJoe168

    Corndogoz Never programmed a guess my number game:( (totally didn't post this to check out my sig...)
    nvm, can't see my own sig?
     
  25. Offline

    Corndogoz

    PS, I made blackout up myself, its where a lot of people go into an abandon mine, with the blindness potion on, and only a diamond sword and diamond pickaxe, last one standing survives, :) doesnt it sound fun? I really hope you guys enjoy the idea, and help it come along, the people on my server are really waiting for it

    I don't see your sig

    Can we please talk about our program? I put yoouu and am making jboss an author of it, :)

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

    BillyBobJoe168

    oh yay:D What's your server? I want to play on it when the program is finished:D
     
  27. Offline

    Corndogoz

    So umm, I was gonna. Make /watch <player> witch allows u to see from <players> view, do you know how to do it?

    My servers is cortex.corticalcafe.com PS, it lags ALOT

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

    BillyBobJoe168

    no sorryD: I'm not that good what java but I do what I can lol. I'm currently trying to make a minigame with teams and it's coming along pretty well:D
     
  29. Offline

    Gater12

    You can discuss topics in your own private conversation. Please do not bump this post if there is no relevant information to be posted, as it can push down other topics that other developers have created to request help.
     
  30. Offline

    BillyBobJoe168

    ok cool. It's offline now so I'll go on when it's online:D
    Gater12 oops sorry
     
Thread Status:
Not open for further replies.

Share This Page