Stuck-plugin\Help!

Discussion in 'Plugin Development' started by Fosmothegreat, Aug 19, 2011.

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

    Fosmothegreat

    Hey!
    I'm new with developing of Bukkit-Plugins!
    And now i want to start with a Stuck-Plugin.

    Stuck-plugin: Let's say you are stuck underground, you can't get up, then you just take the command /stuck, and it will bring you to the top

    The problem is that i don't know how to make a such plugin.
    If u need more info just leave a comment, and please help me!

    Thank you for reading this!

    -Fosmothegreat
     
  2. Offline

    efstajas

    The plugin "WorldEdit" is open source, pretty huge, but contains a command named "/ascend" which teleports you one layer above. Maybe you could take a look a the source to get the idea. :)

    https://github.com/sk89q/worldedit
     
  3. Offline

    Fosmothegreat

    Thank you! :D
     
    efstajas likes this.
  4. Offline

    Kostronor

    Hey @Fosmothegreat

    At first, i hope, you know something about java and you are using Eclipse (i would recommend that rather than checking the bukkit-api for every single method you call :D )
    Second thing: download the newest bukkit-build (not craftbukkit, use bukkit) here: http://ci.bukkit.org
    if you want your plugin to work with craftbukkit 1060, then you download this one: http://ci.bukkit.org/job/dev-Bukkit/804/
    The next thing is setting up your workspace:
    create a new project in eclipse and asign the bukkit-0.0.1-SNAPSHOT.jar as an external jar to the project, now you can use the bukkit-api.
    Your new project needs a file called plugin.yml to help the server loading it:
    this should look like mine here:
    Code:
    name: BedHeal
    main: me.kostronor.BedHeal.BedHeal
    version: 1.1
    author: Kostronor
    the name is the name of your plugin, in your case "Stuck"
    main is the package you use, i use the package:
    me."myusername"."pluginname"."name of main-class"
    version is your version of the plugin, just start with 1
    author is your username in the bukkit-forums

    there are more things to do with this later, but that is not needed yet

    Here is some code from my Ranks-plugin to show you how your main-class should look like:

    Code:
    package Me.Kostronor.Ranks;
    
    public class Ranks extends JavaPlugin{
    
        Logger log = Logger.getLogger("Minecraft");
    
        public void onEnable(){
            log.info("<-----Ranks starting----->");
            log.info("<-----Ranks enabled----->");
    
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    
     //This is called when a player uses a command
            return false;
        }
    
        public void onDisable(){
            log.info("<-----Ranks disabled----->");
        }
    }
    
    You can now check if the command is for your plugin
    the String commandLabel should equal your command, so if commandLabel.EqualsIgnoreCase("Stuck"); then someone typed "/stuck"
    now you get the player with Player player = (Player)CommandSender
    and you can try altering the players y-coordinate to a point where there is a space of two blocks to get the player unstuck.
     
    efstajas likes this.
  5. Offline

    Fosmothegreat

    Great! Thank you!
     
  6. Offline

    stelar7

    i can probably help you, (in Norwegian) if you want :p
     
  7. Offline

    1fastturtle

    Its says that i have to log in. Help please!
     
  8. Offline

    TheSmallBones

    location loc = sender.getLocation();
    loc.setY(sender.getWorld().getHighestBlockYAt(sender.getLocation()));
    sender.teleport(loc);
    sender.sendMessage("You are now unstuck.");
     
Thread Status:
Not open for further replies.

Share This Page