MinecraftScript.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. return loadedLocations.remove(l);
  28. }
  29. public void clearLocations()
  30. {
  31. loadedLocations.clear();
  32. }
  33. // -------------------------------------------------------------------------
  34. // Für Inventar-IDs
  35. // -------------------------------------------------------------------------
  36. public int getNewId()
  37. {
  38. invCounter++;
  39. return invCounter;
  40. }
  41. }