Solved Custom Jail Plugin Problems

Discussion in 'Plugin Development' started by jaybirdpontiac69, Jul 27, 2014.

Thread Status:
Not open for further replies.
  1. So Im making a jail plugin for my server and im not a big fan of the essentials jail. So I thought why not make my own! Im new to java and for some reason ive tried everything to fix the errors with teleporting and i just cant do it.


    Here is the code:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("jail")) {
    2. if (getConfig().getConfigurationSection("jails") == null) {
    3. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Jails" + ChatColor.GRAY + "]" + ChatColor.RED + "No Jail Has Been Set!");
    4. return true;
    5.  
    6. if(args.length == 0){
    7. p.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "Jails" + ChatColor.GRAY + "]" + ChatColor.RED + "Please Specify a Player.");
    8. return true;
    9.  
    10. if (args.length == 1) {
    11. double world = getConfig().getDouble("jail.world");
    12. double x = getConfig().getDouble("jail.x");
    13. double y = getConfig().getDouble("jail.y");
    14. double z = getConfig().getDouble("jail.z");
    15. p.teleport(new Location(world ,x ,y ,z));
    16. p.sendMessage(ChatColor.RED + "You Have Been Jailed For Being Naughty!");
     
  2. Offline

    L33m4n123

    look at line 11 .. the world is no double .. it's an World Object .. :confused:
     
  3. Like I said im pretty new at Java but what would i put instead of a double because if i dont use double it wont work

    after i make everything an object it works but then i still get an error because it says the the whole code is unreachable?

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

    ZodiacTheories

  5. no.
     
  6. Offline

    ZodiacTheories

    jaybirdpontiac69

    Exactly:

    int = basically a number that is not too big or too small that doesn't have a decimal points
    double = a number with a decimal point
    long = A huge number
    byte = Not that big, around -16 to 16
    short = A bit more than byte

    They are called Primitive Data Types. Well, is a world a number or anything? No, a world is a world. So replace double world to World world :)
     
  7. Offline

    Giraffeknee

    jaybirdpontiac69
    Do World world = Bukkit.getWorld(stringFromConfig);

    (You may want to check if it is null).
     
  8. Thanks! But i have a problem where after i put return true i want the command to end. But when i do, everything under it is now unreachable.
     
  9. Offline

    ZodiacTheories

    jaybirdpontiac69

    return true stops the code, you need to do it before you close the boolean
     
  10. Thanks!

    Yes thats to teleport yourself though. I want to be able to do "/jail (player)" and have that player get moved to a spot where they cant /spawn out. Not just "/jail (player)" and teleport yourself.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
    ZodiacTheories likes this.
  11. Offline

    ZodiacTheories

  12. not exactly. With the /jail command i cant jail other players just myself even though i put their name in and ive googled it already. None of the solutions work.
     
  13. Offline

    Pizza371

    jaybirdpontiac69 that's because you need to fetch the player via the argument
     
  14. Offline

    GameplayJDK

    jaybirdpontiac69 You can the getPlayer method of Bukkit:
    (Assuming p is the sender)
    Code:
    String targetPlayerName = args[0];
    Player targetPlayer = Bukkit.getPlayer(targetPlayerName);
    if (targetPlayer != null) {
        targetPlayer.teleport(...)
    }
    // p.teleport teleports you
    You should check if args.length is equal to 1. e.g: if (args.length == 1) { ... rest of your code .. }
    That should solve your problem.
     
  15. Thank you very much for that! That bassically sums up my problems with this! Now bukkit has a new fun jail plugin!
     
  16. Offline

    GameplayJDK

Thread Status:
Not open for further replies.

Share This Page