.

Discussion in 'Plugin Development' started by elementalgodz11, Oct 18, 2013.

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

    elementalgodz11

  2. Offline

    Blah1

    I would recommend starting off with something easier. If you are brand new to java and bukkit, a warp plugin probably isnt a good idea yet. But, just so you know, learn about schedulers (delayed task in this case), events (EntityDamageByEntityEvent), and you would probably have to make and save your own warps for this since essentials has its own way of doing it.

    Side note: args zero is reffering to the argument you put after the command (ex /hello <arg0> <arg1>) ps (im not sure if that's how you intended it to be)
     
  3. Offline

    Aengo

    1)Is the package that ClearInventory.java is in called clearinv.d0jo.yark? If not change the code to match the package.
    3)Also add a } right at the bottom.
    2)Also, for the warping. Unless you can hook directly into a plugin that has a warp event, just use a teleport event and check if the teleport cause is a plugin. EG:
    Code:java
    1. @EventHandler
    2. public void Warp(PlayerTeleportEvent e){
    3. if(!(e.getCause()==TeleportCause.PLUGIN)){
    4. return;
    5. }
    6. //Has warped
    7. }

    Please bare in mind that that is untested and may not work ^.
     
  4. Offline

    Sweatyyyy

    elementalgodz11
    args[0] refers to the argument after the first one,
    so: /warp spawn
    "spawn" would be args[0].

    Use if(args.length == 0) - instead, as that refers to the first argument, which in this case would be "Warp"
     
    elementalgodz11 likes this.
  5. Offline

    Aengo

    You would also have to check the lengh of args to prevent errors.
     
  6. Offline

    sgavster

    elementalgodz11
    if(cmd.getName().equalsIgnoreCase("warp) {
    doing
    if(args[0].equalsIgnoreCase("warp") {
    it would be like
    /command warp
    so if you wanted to list a warp, for example pvp:
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("warp") {
    2. if(args.length == 0) {
    3. } else {
    4. if(args[0].equalsIgnoreCase("pvp") {
    5. p.getInventory().clear();
    6. p.getInventory().setArmorContents(null);
    7. }
    8. }
    9. }

    :)
     
  7. Offline

    drtshock

  8. Offline

    sgavster

    elementalgodz11... "It gave me a bunch of errors" What errors? -.- I also told you how to do it. onCommand.

    elementalgodz11 onCommand that's what I coded it for, on your onCommand, so when they do it it clears when they do that warp, learn java before you start bukkit.

    elementalgodz11 Again, learn java..
    Player p = (Player) sender;

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

    Dread9Nought

    In your main class(The one with onEnable and onDisable )

    Put this in the onEnable method..
    Code:
    void onEnable() {
            getCommand("warp").setExecutor(new onCommand());
            info("plugin enabled");
    }
    
     
  10. Offline

    sgavster

  11. Offline

    Dread9Nought


    I'm assuming you're also running essentials which is going to cause a command conflict with two plugins wanting to use the "warp" command, i would suggest using the CommandPreProcessEvent to listen for "/warp pvp"
     
  12. Offline

    22vortex22

    To remove the potion effect do this:

    for (PotionEffect effect : player.getActivePotionEffects()){
    player.removePotionEffect(effect.getType());
    }

    Change the command for the warp. Maybe /go or something because /warp messes with essentials and make sure your plugin.yml is correct.
     
  13. Offline

    Aengo

    People have to learn somewhere, and this is where we can help them.
     
  14. Offline

    sgavster

    elementalgodz11 ...
    then do
    Code:java
    1. else if(args[0].equalsIgnoreCase("otherwarp") {
    2. //ect


    check if a sign has text when they click it, and clear their inv.
    add another command for /spawn.
     
  15. Offline

    TehVoyager

    Prepare for stupidity:
    Make a chat event and test for the commands
    Add Them to an array list
    Use async task of some sort and wait 3 seconds
    Check if they're in the array list and if they are clear their inv and remove them from the list
    On entity damage event check if the entity is a player and if they're in the array list
    If they are remove them
     
  16. Offline

    DrTURTLE2

    *****Sigh****** I know I was once like this but really, I had the common sense to know that I needed to know basic stuff before coming on here.
     
  17. Offline

    sgavster

    elementalgodz11
    Or you could do:
    Code:java
    1. //playerchatblah
    2. String w = e.getMessage();
    3. String[] args = w.split(" ");
    4. if(args[0].equalsIgnoreCase("warp") && args[1].equalsIgnoreCase("WARPNAME")) {
    5. inv.clear();
    6. //ect
    7. }
    8. else if(args[0].equalsIgnoreCase("spawn")) {
    9. inv.clear();
    10. }
    11.  


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

Share This Page