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.
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.
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.
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.
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 public class ExampleMod extends JavaPlugin implements Listener { @Override public void onEnable() { PluginManager manager = getServer().getPluginManager(); manager.registerEvents(this, this); } @EventHandler public void onPlayerQuitEvent(PlayerQuitEvent event) { Player player = event.getPlayer(); World world = player.getWorld(); // Reset everything player.teleport(world.getSpawnLocation()); player.getInventory().clear(); player.setLevel(0); player.setExp(0); player.setTotalExperience(0); }}
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 @EventHandlerpublic void onPlayerQuitEvent(PlayerQuitEvent event) { event.getPlayer().setHealth(0);} That will handle everything you mentioned.
The really need to come out with something like "PlayerSnap" to where you can get information store, then load it for later.
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
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.