Posts by james1bow

    looking for a method in the API to trigger a player animation. only thing i can find that allows anything to do with animations has to do with custom items. is there a way to do this int he API that i may be overlooking?

    Small plugin i use to test GUI functions for my plugin. can also be used when you have a plugins GUI open and the mouse pointer goes away

    just press p to show/hide the mouse pointer

    I'm learning to code. These are just a small plugin's that are part of a larger plugin i am working on. I figured someone may like to use them.


    Potions: Crafted in the workbench


    There are currently 4 potions:

    Health Potion: adds 50 points to health thirst and hunger

    Hermes Potion: add 75 percent to your sprint speed for 2 minutes

    Day Potion: turns it day

    Night Potion: turns it night


    **Day and Night potions have a 1 hour cool down to prevent spamming




    Weapons: Crafted in the anvil


    There are currently 4 swords and 4 axes (Spears to come!)

    Currently there are 4 variants of each.


    *They are a little over powered atm but would like input for this.

    **Sorry about the icons i will be fixing them.


    Install: unzip the file and copy the Potions or Weapons folder to your plugins folder


    **not sure if they works for linux/mac os?


    will be working on cooking, decor, and economy (perhaps cross server auctions) Plugins in the near future.

    Files

    • potions.zip

      (243.03 kB, downloaded 1,313 times, last: )
    • weapons.zip

      (1.41 MB, downloaded 1,469 times, last: )

    ive been tinkering with adding abilities to custom weapons for java. temp is one ive been messing with. was thinking of making a fridge for food so maybe something like an air conditioner/furnace that will cover a set amount of blocks. add snow to an ice box wood to fireplace for a primitive lvl. have a potion planned for traveling into hot areas and a hand warmer for cold areas

    a friends is trying to play unity but it loads to white screen then crashes, couldnt find logs in local only local low.

    Files

    • Player.log

      (31.75 kB, downloaded 291 times, last: )

    bit of an update. the /ap command when run from player command causes the ap listener to stop responding as well as my on listeners.

    this was my fix in the case that this is ever useful to anyone else.


    Code
    else if (event.getKeyCode() == KeyInput.KEY_Y && player.hasAttribute("noap") == (true)){
    PlayerCommandEvent showareas = new PlayerCommandEvent(player, "/showareas");
    player.setAttribute("ap", "ap");
    player.deleteAttribute("noap");
    triggerEvent(showareas);
    }else if (event.getKeyCode() == KeyInput.KEY_Y && player.hasAttribute("ap") == (true)){
    PlayerCommandEvent hideareas = new PlayerCommandEvent(player, "/hideareas");
    player.deleteAttribute("ap");
    player.setAttribute("noap", "noap");
    triggerEvent(hideareas);

    Untested code - just done this in notepad.


    i can confirm this does work. thank you guys for the help. mind if i use the code?

    Hehe that could be the smallest plugin ever :monocle:




    Edit: Just thought I would add this. It's probably better to use keyboard shortcuts for this as opposed to a GUI. Because using a GUI by definition will create an extra step. The player will have to open the GUI to open pnb or ap. With a keyboard shortcut (I've just used F keys in my example) the player can get straight to pnb or ap - and isn't that the objective?

    I agree with the hot keys instead of gui. Finaly understand what red was talking about with the command event, still learning. As for smallest plugin. I just made one just to enable the mouse pointer for stuck open gui's.

    I looked at doing this before, but figured it was not possible.


    Would be interested to see if there was a hack to get this to work :)


    There is one other option, you could always decompile the pnb and ap jar files. Then add an event listener (maybe a keyboard key) to launch the UI and then recompile?

    i beleive this can be achieved byt using the import (

    import java.awt.Robot;

    import java.awt.event.KeyEvent;)

    edit. works on single player but not multiplayer. i must be missing something.

    try {

    robot = new Robot();

    robot.setAutoDelay(125);

    robot.keyPress(KeyEvent.VK_T);

    robot.keyRelease(KeyEvent.VK_T);

    robot.keyPress(KeyEvent.VK_SLASH);

    robot.keyRelease(KeyEvent.VK_SLASH);

    robot.keyPress(KeyEvent.VK_A);

    robot.keyRelease(KeyEvent.VK_A);

    robot.keyPress(KeyEvent.VK_P);

    robot.keyRelease(KeyEvent.VK_P);

    robot.keyPress(KeyEvent.VK_ENTER);

    robot.keyRelease(KeyEvent.VK_ENTER);

    }catch (AWTException e){e.printStackTrace();

    I looked at doing this before, but figured it was not possible.


    Would be interested to see if there was a hack to get this to work :)


    There is one other option, you could always decompile the pnb and ap jar files. Then add an event listener (maybe a keyboard key) to launch the UI and then recompile?

    thought about it but didnt feel rite messing with others code.

    There is unfortunately no showChat method in the Java version, but it will be part of the new plugin API ;)


    If you want to send a chat message to a player, you can use the sendTextMessage() method.


    The PlayerChatEvent you've linked, however, is an event, as mentioned by Minotorious : It gets triggered by the game as soon as a player sends a chat message (i.e. after he presses the Return key). At this stage, it's not visible in chat yet, so you can manipulate the chat message through the API (or cancel the event if you don't want the chat message to show up). The message from the PlayerChatEvent will be broadcasted to all players (unless you cancel the event).

    thank you, was trying to make it so players didnt have type commands for /ap /pnb.

    trying to build a gui for players to make plugin commands clickable. will have gui with button assigned to some plugins (/ap, /pnb).

    when using the setChat() method, does it just display in chat or does it enter it into chat as if typing the command and pressing enter?

    This would take a lot of work, as you'd have to add in something to the code where it can communicate between servers. Though, I believe the code for communication between servers is already in some other plugin? Maybe they can shed more light on this. :thinking:

    or a central location to store a database for all servers running the plugin? as you know im just starting to learn the whole java thing. that being said, i do have some more hardware should anyone be interested in the idea enough.

    Getting the transactions to work between them, and saving data shouldn't be too much of an issue. One way this can be done, is use Databases to Save Transactions, as well as use Databases to also handle transactions. However, using a Database to handle transactions might not be so performance friendly in the long run, unless you have it programmed so once the transaction has been handled, that entry gets cleared out of the database

    now that i think about it, to be more performance friendly...if the coin is spawned(forged) its an item that can be swapped for another item(1 coin trade 1 apple). database would only be needed to know whats in the chest and at what prices.