Some questions.

Discussion in 'Plugin Development' started by Randude14, Oct 18, 2012.

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

    Randude14

    I'm developing a Hide and Seek plugin for a server and needs some requested features:

    Request 1: I need to hide the hider and seeker's player tags from each other, though I could also settle on their name tags not showing up at all. I have tried TagAPI by setting the tag to "", and that doesn't work, and setting it to null throws an exception. And I do not know enough about Spout to try it.

    Request 2: I need to edit a player's inventory and teleport them to their original spawn when they get leave the server or get kicked. Not sure about now, but last time I tried teleporting by listeneing to the PlayerLeaveEvent resulted in an error, and I'm editing their inventory and xp would do the same.

    Again I do not know enough about Spout and it's features, but any help on these would be appreciated, thanks.
     
  2. Offline

    HyrulesLegend

    Some type of autosneak maybe? :p
     
  3. Offline

    Randude14

    How would that work? Would it slow player's movement down?
     
  4. Offline

    Armadillo

    For the disabling the changing of the players tags use TagAPI.
     
  5. Offline

    Randude14

    I said I already tried TagAPI, it does not disable it, only let's you edit it.
     
  6. Offline

    Armadillo

    I think Woobie has a plugin called autosneak... It does the thing you want it to.

     
  7. Offline

    Woobie

    I do? :D
    AutoSneak would hide the team names too.

    Randude14
    I might have some code if you need :3
     
  8. Offline

    Comphenix

    PlayerQuitEvent is executed before the player object is saved, so it theory it should work fine. What kind of error/exception did you end up with anyway?

    But I'm pretty sure you could just use setLocation-method on EntityPlayer, if the teleport method still doesn't work. You could do the same for with experience and the inventory, I would presume.

    As for request #1 - there are many sneaking plugins out there. AutoSneak was mentioned above, and there's also PacketSneak. Just use what works best in your case.
     
  9. Offline

    Randude14

    Think threw out an error saying "Player is not online." or something like that.

    Yes, I would appreciate the help.

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

    Woobie

    Did you use ((OfflinePlayer) object?

    Okay, well i'm using my phone atm, so when I get on my computer, i'll try to find it somewhere in my projects

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

    Comphenix

    Actually, it doesn't look like you'll get the "Player is not online" error any more. The following works perfectly on 1.3.1. It's probably been fixed since you last tried it.
    Code:java
    1. public class ExampleMod extends JavaPlugin implements Listener {
    2.  
    3. @Override
    4. public void onEnable() {
    5. PluginManager manager = getServer().getPluginManager();
    6.  
    7. manager.registerEvents(this, this);
    8. }
    9.  
    10. @EventHandler
    11. public void onPlayerQuitEvent(PlayerQuitEvent event) {
    12.  
    13. Player player = event.getPlayer();
    14. World world = player.getWorld();
    15.  
    16. // Reset everything
    17. player.teleport(world.getSpawnLocation());
    18. player.getInventory().clear();
    19. player.setLevel(0);
    20. player.setExp(0);
    21. player.setTotalExperience(0);
    22. }
    23. }
     
  12. Offline

    Woobie

    You forgot health, hunger, fire ticks, air bubbles, armor :D
    EDIT: Potion effects too :3
     
  13. Offline

    Comphenix

    True, but it's just a test plugin.

    Hm, come to think off it - there's an even easier way, provided you're okay with the spawn location:
    Code:java
    1. @EventHandler
    2. public void onPlayerQuitEvent(PlayerQuitEvent event) {
    3. event.getPlayer().setHealth(0);
    4. }

    That will handle everything you mentioned. :p
     
  14. Offline

    Randude14

    The really need to come out with something like "PlayerSnap" to where you can get information store, then load it for later.
     
  15. Offline

    Cirno

    What I would normally do is create a new class, something like "PlayerData" and have it have a constructor for the information I want to store, then store it into an ArrayList. Then again, it's just my preference :3
     
  16. Offline

    Comphenix

    I have an idea. You should be able to read the content of the current player's dat-fil located in the world/players director. If you store that in a byte-array, and then later write it to the dat-file, then that should reset everything back to the point you made the backup. Just make sure to call Player.loadData after you reset the file.
     
  17. Offline

    Randude14

    Actually that is a pretty good idea.
     
Thread Status:
Not open for further replies.

Share This Page