Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. package constitution.permissions;
  2.  
  3. import net.minecraft.command.ICommand;
  4. import net.minecraft.command.ICommandSender;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.server.MinecraftServer;
  8. import net.minecraft.util.math.Vec3d;
  9. import net.minecraft.world.World;
  10. import net.minecraftforge.server.permission.context.ContextKey;
  11. import net.minecraftforge.server.permission.context.IContext;
  12.  
  13. public class PermissionContext implements IContext {
  14.  
  15. private EntityPlayer player;
  16.  
  17. private ICommandSender sender;
  18.  
  19. private ICommand command;
  20.  
  21. private int dimension;
  22.  
  23. private Vec3d sourceLocationStart;
  24.  
  25. private Vec3d sourceLocationEnd;
  26.  
  27. private Vec3d targetLocationStart;
  28.  
  29. private Vec3d targetLocationEnd;
  30.  
  31. private Entity sourceEntity;
  32.  
  33. private Entity targetEntity;
  34.  
  35. public PermissionContext() {
  36. }
  37.  
  38. public PermissionContext(ICommandSender sender) {
  39. this.sender = sender;
  40. if (sender instanceof EntityPlayer) {
  41. EntityPlayer player = (EntityPlayer) sender;
  42. this.player = player;
  43. this.dimension = player.dimension;
  44. this.sourceLocationStart = new Vec3d(player.posX, player.posY, player.posZ);
  45. }
  46. }
  47.  
  48. public PermissionContext(ICommandSender sender, ICommand command) {
  49. this(sender);
  50. this.command = command;
  51. }
  52.  
  53. public ICommandSender getSender() {
  54. return sender;
  55. }
  56.  
  57. public EntityPlayer getPlayer() {
  58. return player;
  59. }
  60.  
  61. public ICommand getCommand() {
  62. return command;
  63. }
  64.  
  65. public int getDimension() {
  66. return dimension;
  67. }
  68.  
  69. public Vec3d getSourceLocationStart() {
  70. return sourceLocationStart;
  71. }
  72.  
  73. public Vec3d getSourceLocationEnd() {
  74. return sourceLocationEnd;
  75. }
  76.  
  77. public Vec3d getTargetLocationStart() {
  78. return targetLocationStart;
  79. }
  80.  
  81. public Vec3d getTargetLocationEnd() {
  82. return targetLocationEnd;
  83. }
  84.  
  85. public Entity getSourceEntity() {
  86. return sourceEntity;
  87. }
  88.  
  89. public Entity getTargetEntity() {
  90. return targetEntity;
  91. }
  92.  
  93. public PermissionContext setSender(ICommandSender sender) {
  94. if (sender instanceof EntityPlayer)
  95. return setPlayer((EntityPlayer) sender);
  96. this.sender = sender;
  97. return this;
  98. }
  99.  
  100. public PermissionContext setPlayer(EntityPlayer player) {
  101. this.sender = this.player = player;
  102. return this;
  103. }
  104.  
  105. public PermissionContext setCommand(ICommand command) {
  106. this.command = command;
  107. return this;
  108. }
  109.  
  110. public PermissionContext setDimension(int dimension) {
  111. this.dimension = dimension;
  112. return this;
  113. }
  114.  
  115. public PermissionContext setSourceStart(Vec3d location) {
  116. this.sourceLocationStart = location;
  117. return this;
  118. }
  119.  
  120. public PermissionContext setSourceEnd(Vec3d location) {
  121. this.sourceLocationEnd = location;
  122. return this;
  123. }
  124.  
  125. public PermissionContext setTargetStart(Vec3d location) {
  126. this.targetLocationStart = location;
  127. return this;
  128. }
  129.  
  130. public PermissionContext setTargetEnd(Vec3d location) {
  131. this.targetLocationEnd = location;
  132. return this;
  133. }
  134.  
  135. public PermissionContext setSource(Entity entity) {
  136. this.sourceEntity = entity;
  137. return this;
  138. }
  139.  
  140. public PermissionContext setTarget(Entity entity) {
  141. this.targetEntity = entity;
  142. return this;
  143. }
  144.  
  145. public boolean isConsole() {
  146. return player == null && (sender == null || sender instanceof MinecraftServer);
  147. }
  148.  
  149. public boolean isPlayer() {
  150. return player instanceof EntityPlayer;
  151. }
  152.  
  153. @Override
  154. public World getWorld() {
  155. // TODO Auto-generated method stub
  156. return null;
  157. }
  158.  
  159. @Override
  160. public <T> T get(ContextKey<T> key) {
  161. // TODO Auto-generated method stub
  162. return null;
  163. }
  164.  
  165. @Override
  166. public boolean has(ContextKey<?> key) {
  167. // TODO Auto-generated method stub
  168. return false;
  169. }
  170.  
  171. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement