Advertisement
Guest User

Untitled

a guest
Nov 10th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. //CONSOLE LOG (NOTHING UNUSUAL BEFORE)
  2. [16:05:48] [Server thread/INFO] [minecraft/DedicatedServer]: REDACTED_LAMBDA joined the game
  3. [16:05:55] [Server thread/INFO] [STDOUT]: [pl.ytskagamer.ytskascpcore.sponge.commands.Test2Cmd:execute:26]: null
  4.  
  5. //COMMAND CODE:
  6. public class Test2Cmd implements CommandExecutor
  7. {
  8.  
  9. @Override
  10. public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
  11. Player p = (Player) src;
  12. ClassAPI.createClass("reee", "re", "a", "12345678", 1);
  13. if(ClassAPI.getClassUUIDByDiscord("12345678") == null)
  14. {
  15. System.out.println(ClassAPI.getClassUUIDByDiscord("12345678"));
  16. p.sendMessage(Text.of("not working"));
  17. }
  18. else
  19. {
  20. System.out.println(ClassAPI.getClassUUIDByDiscord("12345678"));
  21. p.sendMessage(Text.of(ClassAPI.getClassUUIDByDiscord("12345678")));
  22. }
  23. return CommandResult.success();
  24. }
  25.  
  26. public static CommandSpec spec = CommandSpec.builder()
  27. .executor(new Test2Cmd())
  28. .build();
  29. }
  30.  
  31.  
  32. //FUNCTION
  33. public static String getClassUUIDByDiscord(String discordid)
  34. {
  35. ClassAPI api = new ClassAPI();
  36. ConfigurationNode root = api.node; //the root node of the file
  37. String discordId = discordid; //the discord id you wish to search for
  38. ConfigurationNode classesNode = root.getNode("classes"); //the first child node
  39. Optional<? extends ConfigurationNode> opNode = classesNode.getChildrenList().stream().filter(c -> c.getNode("discordid").getString().equals(discordId)).findFirst();
  40. //Above searches every class node and checks the discord id of that class, if it matches then it uses it
  41. if(!opNode.isPresent()){
  42. return null;
  43. }
  44. ConfigurationNode classNode = opNode.get();
  45. String classId = (String)classNode.getKey();
  46. return classId;
  47. }
  48.  
  49. //CHAT DISPLAY: not working
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement