Portal Teleportation - Getting Started

Discussion in 'Plugin Development' started by Errored, Jun 16, 2012.

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

    Errored

    Hey guys, I'm very new Java and I'm looking to get started with my own plugin. The plugin is for players to create a portal with any blocks and any size then use a tool to "enable" this portal. Later, another portal with the same blocks and size is created elsewhere; have that enabled though the tool then linked with the first. That's the idea at least. I know there are very similar plugins out there but I'd like to really get into Bukkit Java to learn my way around.

    Since I'm a beginner of Bukkit Java I'd like to mention that I don't expect you all to help me through the entire plugin, I'm simply looking for help to get me started. I know JavaScript and PHP but very little Java. I know the syntax of JavaScript is based off Java so at least I know how to work within the syntax. I've been through some tutorials and got Eclipse set up the way its suppose to be, project and all. I even got a simple plugin running.

    I'm trying to do a simple teleport right now. Move me from point 1 to point 2 by a command (/point1). Can anyone help me get started? I'm not worried about catching errors or code explanations, I just want something I can work with then I'll take it from there. I have my main (nothing in it) then I have my class:
    PlayerCommandListener.java
    Code:
    package pck.Errored.DynamicPortals;
     
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerChatEvent;
     
    public class PlayerCommandListener {
    public static DynamicPortals plugin;
    public void onPlayerCommand(PlayerChatEvent event) {
    String[] split = event.getMessage().split(" ");
    Player player = event.getPlayer();
    if (split[0].equalsIgnoreCase("/point1")) {
    // below method does not exist... don't know how to continue
    plugin.toggleTeleport(player);
    }
    }
    }
    
    And that's is about as far as I get. I know about this: http://jd.bukkit.org/doxygen/de/dd5...Entity.html#a2ada63b02fc0e02358bb44aef848db06
    But it doesn't help me figure out the rest of the steps.
     
  2. Offline

    r0306

    Errored
    This is going to be quite a complicated project taking into account that you are new to Java nevertheless Bukkit plugins. To answer your question, saving the points is simply a matter of file writing and data saving. There are many posts on Bukkit regarding the breaking up of locations into coordinates which can then be saved into a file. As for the teleportation aspect, you could do something like this to check if the player is in a portal and so forth.
    Code:
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    Location location = your saved location for the portal;
    if (player.getLocation() == location.add(0,1,0)) {
    player.teleport(destination location);
    }
    }
     
    ZeusAllMighty11 likes this.
Thread Status:
Not open for further replies.

Share This Page