MinecraftScript.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package me.km.snuviscript;
  2. import java.util.HashSet;
  3. import me.hammerle.code.Script;
  4. import me.hammerle.code.SnuviParser;
  5. import me.km.api.Location;
  6. public class MinecraftScript extends Script
  7. {
  8. private final HashSet<Location> loadedLocations;
  9. private int invCounter;
  10. public MinecraftScript(SnuviParser parser, int id, String name, String code, boolean receiveEventBroadcast)
  11. {
  12. super(parser, id, name, code, receiveEventBroadcast);
  13. loadedLocations = new HashSet<>();
  14. invCounter = 0;
  15. }
  16. // -------------------------------------------------------------------------
  17. // Location Handling für Wait-For-Location
  18. // -------------------------------------------------------------------------
  19. public void addLocation(Location l)
  20. {
  21. l = l.copy();
  22. l.round();
  23. loadedLocations.add(l);
  24. }
  25. public boolean removeLocation(Location l)
  26. {
  27. l = l.copy();
  28. l.round();
  29. return loadedLocations.remove(l);
  30. }
  31. public void clearLocations()
  32. {
  33. loadedLocations.clear();
  34. }
  35. // -------------------------------------------------------------------------
  36. // Für Inventar-IDs
  37. // -------------------------------------------------------------------------
  38. public int getNewId()
  39. {
  40. invCounter++;
  41. return invCounter;
  42. }
  43. }