Guest User

Untitled

a guest
Jul 3rd, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. package com.ruse.model.definitions;
  2.  
  3. import com.google.gson.Gson;
  4. import com.google.gson.JsonObject;
  5. import com.ruse.model.Position;
  6. import com.ruse.util.JsonLoader;
  7. import com.ruse.util.Misc;
  8. import com.ruse.world.content.bots.BotHandler;
  9. import com.ruse.world.content.bots.BotType;
  10. import com.ruse.world.content.bots.impl.ManKillerBot;
  11. import com.ruse.world.content.bots.impl.StallThiefBot;
  12.  
  13. public class BotDefinition {
  14.  
  15. public static JsonLoader parseBots() {
  16. return new JsonLoader() {
  17. @Override
  18. public void load(JsonObject reader, Gson builder) {
  19.  
  20. String username = Misc.formatText(reader.get("username").getAsString());
  21.  
  22. String password = reader.get("password").getAsString();
  23. int setX = reader.get("login_set_x").getAsInt();
  24. int setY = reader.get("login_set_y").getAsInt();
  25.  
  26. BotType botType = BotType.valueOf(reader.get("type").getAsString());
  27. switch(botType) {
  28. case MAN_KILLER:
  29. BotHandler.addBot(new ManKillerBot(username, password, botType, new Position(setX, setY)));
  30. break;
  31. case STALL_THIEF:
  32. BotHandler.addBot(new StallThiefBot(username, password, botType, new Position(setX, setY)));
  33. break;
  34. }
  35. }
  36.  
  37. @Override
  38. public String filePath() {
  39. return "./data/def/json/bots.json";
  40. }
  41. };
  42. }
  43. }
Add Comment
Please, Sign In to add comment