Solved Creating a World Border Plugin

Discussion in 'Plugin Development' started by DoctorDark, Dec 8, 2013.

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

    DoctorDark

    Hello,
    I would like to create a border plugin. I am aware their are plugins such as WorldBorder; however I'd like to implement this feature in my own plugin as it will be more beneficial for my uses.

    I believe I would have to listen for the PlayerMoveEvent

    I want the border to be at 2500 blocks, if a player goes past those coordinates, for example from 2500 to 2501, they will get teleported back to 2500 blocks and receive 2 hearts of damage along with a lovely message saying "You cannot go past the border".

    Thanks, DoctorDark
     
  2. if you want the border to be square, then just get the spawn position and make your plugin go out to the coordinates that you want the players to be able to go to, and then with an onmove event, check to see if the player is at those coordinates. if so, cancel the event and teleport the player to wherever, and then send them the message

    DoctorDark
    what isnt working exactly?

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

    Wolfey

    Check the players getTo X and see if its above 2500, if it is, teleport them to their getFrom location. Do this with the z too. Then do the same, but check if the getTo is less than -2500.

    Can't get any more simpler.
     
  4. if it was me i would just (saying spawn is at 0,0) do something like
    Location spawn = new Location(0,0);
    int pX = spawn.getX + 2500;
    int nX = spawn.getX - 2500;
    if(p.getLocation().getX().equals(pX) || p.getLocation().getX().equals(nX){
    Then what you want it do do here
    }

    Obviously not real code, but something like that is what i would do. But then again i dont play around with the math function to much. But just to give you ideas.
     
  5. Offline

    Harmings

  6. Offline

    Wolfey

    if(x > 2500 || x < -2500 || z > 2500 || z < -2500) {
    p.sendMessage(ChatColor.RED + "You cannot teleport over the border.");
    }

    You're checking if x is LOWER then 2500, which means they have no choice but to teleport over the border.

    return true;

    Code:java
    1.  
    2. if (cmd.getName().equalsIgnoreCase("tppos")) {
    3. if (sender.hasPermission("dkkits.teleport")) {
    4. Location playerloc = p.getLocation();
    5. Chunk chunk = p.getWorld().getChunkAt(playerloc);
    6. Bukkit.getWorld(p.getWorld().getName()).loadChunk(chunk);
    7. try {
    8. int x = Integer.parseInt(args[0]);
    9. int y = Integer.parseInt(args[1]);
    10. int z = Integer.parseInt(args[2]);
    11. if(x > 2500 || x < -2500 || z > 2500 || z < -2500) {
    12. p.sendMessage(ChatColor.RED + "You cannot teleport over the border.");
    13. return true;
    14. } else {
    15. playerloc = new Location(p.getWorld(), x, y, z);
    16. p.teleport(playerloc);
    17. }
    18. } catch (Exception e) {
    19. sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.GRAY + "/tppos <x> <y> <z>");
    20. }
    21.  
    22. if (args.length > 3) {
    23. sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.GRAY + "/tppos <x> <y> <z>");
    24. return true;
    25. }
    26.  
    27. }
    28.  
    29. }
    30.  


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page