Guest User

FakePlayer

a guest
Jan 30th, 2016
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public class FakePlayer {
  2.  
  3. private MinecraftServer server;
  4. private WorldServer world;
  5. private UUID uuid;
  6. private GameProfile profile;
  7. private PlayerInteractManager manager;
  8. private EnumGamemode mode;
  9. private int ping;
  10.  
  11. private EntityPlayer player;
  12.  
  13. public FakePlayer(String name) {
  14. this.server = MinecraftServer.getServer();
  15. this.world = server.getWorldServer(0);
  16. this.uuid = UUID.randomUUID();
  17. this.profile = new GameProfile(uuid, name);
  18. this.manager = new PlayerInteractManager(world);
  19. this.mode = EnumGamemode.SURVIVAL;
  20. this.ping = 0;
  21. }
  22.  
  23. public FakePlayer withName(String name) {
  24. this.profile = new GameProfile(this.profile.getId(), name);
  25. return this;
  26. }
  27. public FakePlayer withUniqueId(UUID id) {
  28. this.uuid = id;
  29. this.profile = new GameProfile(uuid, this.profile.getName());
  30. return this;
  31. }
  32. public FakePlayer withGameMode(EnumGamemode mode) {
  33. this.mode = mode;
  34. return this;
  35. }
  36. public FakePlayer withPing(int ping) {
  37. this.ping = ping;
  38. return this;
  39. }
  40.  
  41. public FakePlayer create() {
  42. this.player = new EntityPlayer(this.server, this.world, this.profile, this.manager);
  43. this.player.a(this.mode);
  44. this.player.ping = this.ping;
  45.  
  46. return this.player;
  47. }
  48. }
Add Comment
Please, Sign In to add comment