Added permission level + option for a reduced debug screen

This commit is contained in:
Felix Cravic 2020-05-13 18:43:54 +02:00
parent be0311a874
commit 498384d2f4
2 changed files with 33 additions and 0 deletions

View File

@ -171,6 +171,8 @@ public class PlayerInit {
player.addEventCallback(PlayerLoginEvent.class, event -> {
event.setSpawningInstance(instanceContainer);
player.setPermissionLevel(4);
player.getInventory().addInventoryCondition((p, slot, clickType, inventoryConditionResult) -> {
player.sendMessage("CLICK PLAYER INVENTORY");
System.out.println("slot player: " + slot);

View File

@ -94,6 +94,10 @@ public class Player extends LivingEntity {
*/
private DamageType lastDamageSource;
private int permissionLevel;
private boolean reducedDebugScreenInformation;
// Abilities
private boolean invulnerable;
private boolean flying;
@ -947,6 +951,33 @@ public class Player extends LivingEntity {
playerConnection.sendPacket(positionAndLookPacket);
}
public int getPermissionLevel() {
return permissionLevel;
}
public void setPermissionLevel(int permissionLevel) {
if (permissionLevel < 0 || permissionLevel > 4)
throw new IllegalArgumentException("permissionLevel has to be between 0 and 4");
this.permissionLevel = permissionLevel;
// Magic values: https://wiki.vg/Entity_statuses#Player
byte permissionLevelStatus = (byte) (24 + permissionLevel);
triggerStatus(permissionLevelStatus);
}
public void setReducedDebugScreenInformation(boolean reduced) {
this.reducedDebugScreenInformation = reduced;
// Magic values: https://wiki.vg/Entity_statuses#Player
byte debugScreenStatus = (byte) (reduced ? 22 : 23);
triggerStatus(debugScreenStatus);
}
public boolean hasReducedDebugScreenInformation() {
return reducedDebugScreenInformation;
}
public boolean isInvulnerable() {
return invulnerable;
}