Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package com.ulfric.plots.plot;
  2.  
  3. import com.ulfric.lib.api.math.strategy.MathStrategy;
  4.  
  5. public class AllowancePriority {
  6.  
  7. public AllowancePriority(boolean overrideEqualTo)
  8. {
  9. this.strategy = overrideEqualTo ? MathStrategy.GREATER_THAN_OR_EQUAL : MathStrategy.GREATER_THAN;
  10. }
  11.  
  12. private MathStrategy strategy;
  13.  
  14. private boolean allowed;
  15. public boolean isAllowed()
  16. {
  17. return this.allowed;
  18. }
  19. public boolean isNotAllowed()
  20. {
  21. return !this.allowed;
  22. }
  23.  
  24. private int lastAllowance;
  25. public void setAllowed(boolean allow, int priority)
  26. {
  27. if (!this.strategy.matches(this.lastAllowance, priority)) return;
  28.  
  29. this.lastAllowance = priority;
  30.  
  31. this.allowed = allow;
  32. }
  33. public void forceSetAllowed(boolean allow)
  34. {
  35. this.allowed = allow;
  36. }
  37. public void forceSetAllowed(boolean allow, int priority)
  38. {
  39. this.forceSetAllowed(allow);
  40.  
  41. this.lastAllowance = priority;
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement