[Req] I need a simple command plugin.

Discussion in 'Archived: Plugin Requests' started by WC_Shill, Feb 17, 2012.

  1. Offline


    You know, having a command to work only from player is not terrible. Its sometimes intentional. Not knowing what it is about, you should not go around mocking others.

    As the main point was to help WC_Shill, ya might want to comment your code a bit more, so if he can't get it to work, he could figure what part of it causes the problem. He did imply he wanted to learn, not just use.

    So, if the player issued version works, shouldn't server.dispatchCommand((commandSender) player, .... ) work?
    Maybe its the server that is giving the null?

    Just for the heck of it, ya could server = player.getServer(); before the command, tho Wolfys code for the server looked pretty fancy.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  2. Offline


    Having a command work only from a player should only ever be the case if the command only makes sense from the context of a player. Anything else is laziness and bad code.

    As for the plugin, it was a request to code not to teach - however, there really is nothing in my code that is not explained by the names the variables and methods have been given. Even the inner class is pretty much all delegation.


    That is the source -- if there's anything you or WC_Shill are confused about it would be better to ask rather than tell me to guess what you can't understand (I will most certainly guess wrong).

    Edity edity:
    If the console sending a command throws a NullPointerException, you should run away screaming from the plugin [or at least code a fix before you use it on a real-life server]. Just saying.
  3. Offline


    Could you tell me exactly how to edit the config file?

    the command to run is:

    newIsland replace

    It must be run as the user who died.

    I put newIsland replace in the config file. When the player dies I get this on the console screen:

    [DeathCommand] Got message from Command: /newIsland [replace]

    The command does not execute.

    The plugin that the command comes from is called skysmp.

    The command newIsland replace works fine but must be run as the user who died as it replaces that specific users island.
  4. Offline


  5. Offline


    Apologies for not being more clear.
  6. Offline


    So, did you ever check what was giving the null?
  7. Offline


  8. Offline


    That wasn't coming from your code at all. it had something to do with the console command removeIsland <Player>
  9. Offline


    Ah. ok, and it wasn't my code, I was just interested in it since it looked OK, but didn't work.
  10. Offline


    Works to respawn the island now. Thank you very much. I will see what I can do about the inventory problem tomorrow.
  11. Offline


    I know Score_Under has posted DeathCommand (which also works on player death rather than respawn, small distinction from the original request) - but just to update on the OtherDrops option:
        - tool: ANY  # deal with any cause of death
          message: "<optional message to player that died>"
          command: "/!$removeisland %v" 
          # ! means send any messages from command to console
          # $ means perform command as console
          # %v is a variable for the victims playername
    Second part (command as player):

        - tool: ANY  # deal with any cause of death
          message: "<optional message to player that died>"
          command: "/!newIsland %v" # or "/!newIsland replace"? (if you don't want to substitute playername)
          # default command is to send as player
          # ! means send and messaged response to the console, remove it you want the response to go to the player
          # %v is a variable for the victims playername
    kahlilnc likes this.
  12. Offline


    I have no idea how to get this into Eclipse (just got eclipse a couple of days ago.) Could you make it work when or just after the respawn button is pushed? Or give me an idea how to do so? Your code is to efficient it puts the dead player on the new island before he respawns giving him a chance to collect the stuff the chest from the old island drops lol.

    Hi Zarius thank you for your suggestions. When I try to use this it sends an info message to the console. Feeling real dumb about now.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  13. Offline


    Casting a Player object as a CommandSender does nothing because Player is a subclass of CommandSender.

    For example you could always do this: CommandSender sender = player;. This will cause no problems.
  14. Offline


    Not sure what you mean by "sends an info message to the console" - are you using the config I posted along with the OtherDrops plugin? What is the message to the console you get?

    Don't worry about struggling with Eclipse - took me ages when I started too but it's worth it :) It should be possible to register the PlayerRespawnEvent and use the command there rather than the PlayerDeath event.
  15. Offline


    Oh yeah. I usually just do from Sender to Player, not the other way around, probly why I didn't think of it.
  16. Offline


    Yes cut and pasted the config you sent. Rather than issuing the command as the user it shows on the console screen as [INFO] newIsland [replace]

    Copy of the bottom of the config file:
    # Example:
    #    GLASS:
    #        - drop: GLASS
    #        - drop: MONEY
    #          quantity: 3-15
    #          message: You recycled the glass for %q dollars.
        - tool: ANY
          message: "<Oops! Time to start over v%.>"
          command: "/newIsland replace"
  17. Offline


    WC_Shill - very odd, works for me (but says "Unknown command" as I don't have the new island plugin). Try this:

        - tool: ANY
          message: "Running command..."
          command: "/!tell %p It's working!"
    Then go break a dirt block to test it.
  18. Offline


    Cut and pasted this to the end of the otherdrops-drops.yml did nothing on the players screen and nothing on the console.
  19. Offline


    Is OtherDrops loading correctly then - no error messages on startup? Try typing "/od show dirt" - it should show some complicated data on what the drop changes are for dirt.
  20. Offline


    I must not have been holding my tongue right. Now it is sending a note to the player the note is:

    Running command...
  21. Offline


    That's the "message:" part working. You should also see a message in the console and the player that says "It's working!"
  22. Offline


    Haven't seen that message.

    Server Log Follows:

    2012-02-24 10:25:53 [INFO] This server is running CraftBukkit version git-Bukkit-1.1-R4-b1938jnks (MC: 1.1) (Implementing API version 1.1-R4)
    2012-02-24 10:26:13 [INFO] [OtherDrops] Loading OtherDrops v2.3.
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] Events node created.
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] Events loaded: [EXPLOSION, SHEAR, UNSHEAR, SHEARTOGGLE, DYE, TREE, FORCETREE, LIGHTNING, STORM, THUNDER]
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] Loading file: otherdrops-drops.yml
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] Using Bukkit superperms.
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] Couldn't load WorldGuard.
    2012-02-24 10:26:13 [INFO] [OtherDrops:2.3] OtherDrops loaded.
    2012-02-24 10:26:39 [SEVERE] java.lang.NullPointerException
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:34)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:154)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.Packet254GetInfo.handle(SourceFile:16)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:47)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:61)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:537)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:435)
    2012-02-24 10:26:39 [SEVERE]    at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    2012-02-24 10:29:18 [SEVERE] Could not pass event org.bukkit.event.block.BlockBreakEvent to OtherDrops
    org.bukkit.command.CommandException: Unhandled exception executing 'tell WC_Shill It's working!' in org.bukkit.command.defaults.TellCommand@151981a
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:172)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:402)
        at com.gmail.zariust.otherdrops.event.DropRunner.processCommands(DropRunner.java:232)
        at com.gmail.zariust.otherdrops.event.DropRunner.run(DropRunner.java:145)
        at com.gmail.zariust.otherdrops.OtherDrops.scheduleDrop(OtherDrops.java:536)
        at com.gmail.zariust.otherdrops.OtherDrops.performDrop(OtherDrops.java:439)
        at com.gmail.zariust.otherdrops.listener.OdBlockListener.onBlockBreak(OdBlockListener.java:97)
        at org.bukkit.plugin.java.JavaPluginLoader$42.execute(JavaPluginLoader.java:558)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:61)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:460)
        at net.minecraft.server.ItemInWorldManager.breakBlock(ItemInWorldManager.java:216)
        at net.minecraft.server.ItemInWorldManager.a(ItemInWorldManager.java:171)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:517)
        at net.minecraft.server.Packet14BlockDig.handle(SourceFile:43)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:100)
        at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:537)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:435)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    Caused by: java.lang.AbstractMethodError: com.gmail.zariust.otherdrops.PlayerWrapper.canSee(Lorg/bukkit/entity/Player;)Z
        at org.bukkit.command.defaults.TellCommand.execute(TellCommand.java:28)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
        ... 19 more
  23. Offline


    Well, that proves it's working somewhat :D It's trying to run the command but I'm not sure why the error occurred - perhaps incompatibility with your version of Bukkit and my playerwrapper (that pretends to be a player to run the commands).
  24. Offline


    I was thinking the same thing. That version of bukkit seems to be a breaking point for a lot of things. it is 1.1R-4 btw

Share This Page