Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. package org.jacob.spigot.plugins.SuperReports;
  2.  
  3. import com.google.common.collect.ImmutableMap;
  4. import org.bukkit.configuration.file.FileConfiguration;
  5. import org.bukkit.configuration.serialization.ConfigurationSerializable;
  6. import org.bukkit.entity.Player;
  7.  
  8. import java.util.Map;
  9.  
  10. public class Report implements ConfigurationSerializable {
  11.  
  12. FileConfiguration data = SuperReports.getInstance().getPlayerData();
  13.  
  14. private int id;
  15.  
  16. private int targetid;
  17.  
  18. private Player target;
  19. private Player reporter;
  20. private String reason;
  21.  
  22. public Report(int id, int targetid, Player target, Player reporter, String reason) {
  23. this.id = id;
  24. this.target = target;
  25. this.reporter = reporter;
  26. this.reason = reason;
  27. }
  28.  
  29. public Map<String, Object> serialize() {
  30. return ImmutableMap.of("id", id, "targetid", targetid, "target", target, "reporter", reporter, "reason", reason );
  31. }
  32. public static Report deserialize(Map<String, Object> map) {
  33. return new Report((int)map.get("id"), (int)map.get("targetid"), (int)map.get("target"), (int)map.get("reporter"), (int)map.get("reason"));
  34. }
  35.  
  36. public void saveToData() {
  37. data.set("reports." + String.valueOf(id) + ".target", target.getName());
  38. data.set("reports." + String.valueOf(id) + ".reporter", reporter.getName());
  39. data.set("reports." + String.valueOf(id) + ".reason", reason);
  40. SuperReports.getInstance().savePlayerData();
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement