Skip to content

Commit

Permalink
Forward skinPerm config to bukkit to check it only if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
games647 committed Sep 27, 2016
1 parent 4b83213 commit 52d7913
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

##### 2.3.3

* Forward skinPerm config to bukkit to check it only if necessary
* Fix missing bungeecord aliases
* Fix forwarding permission checking
* Fix lowercase bungee perm

##### 2.3.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ private void checkPermissions(Player player, ByteArrayDataInput dataInput) {

//continue on success only
String receiverUUID = dataInput.readUTF();
boolean skinPerm = dataInput.readBoolean();
boolean isOp = dataInput.readBoolean();

SkinData targetSkin = new SkinData(encodedData, encodedSignature);
if (isOp || checkBungeePerms(player, UUID.fromString(receiverUUID), targetSkin.getUuid())) {
if (isOp || checkBungeePerms(player, UUID.fromString(receiverUUID), targetSkin.getUuid(), skinPerm)) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PermissionsSuccess");
out.writeInt(skinId);
Expand All @@ -83,13 +84,21 @@ private void checkPermissions(Player player, ByteArrayDataInput dataInput) {
}
}

private boolean checkBungeePerms(Player player, UUID receiverUUID, UUID targetUUID) {
private boolean checkBungeePerms(Player player, UUID receiverUUID, UUID targetUUID, boolean skinPerm) {
if (player.getUniqueId().equals(receiverUUID)) {
return player.hasPermission(plugin.getName().toLowerCase() + ".command.setskin")
&& plugin.checkPermission(player, targetUUID, false);
boolean hasCommandPerm = player.hasPermission(plugin.getName().toLowerCase() + ".command.setskin");
if (skinPerm) {
return hasCommandPerm && plugin.checkPermission(player, targetUUID, false);
} else {
return hasCommandPerm;
}
} else {
return player.hasPermission(plugin.getName().toLowerCase() + ".command.setskin.other")
&& plugin.checkPermission(player, targetUUID, false);
boolean hasCommandPerm = player.hasPermission(plugin.getName().toLowerCase() + ".command.setskin.other");
if (skinPerm) {
return hasCommandPerm && plugin.checkPermission(player, targetUUID, false);
} else {
return hasCommandPerm;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public void run() {
out.writeInt(targetSkin.getSkinId());
out.writeUTF(targetSkin.getEncodedData());
out.writeUTF(targetSkin.getEncodedSignature());

out.writeUTF(receiver.getUniqueId().toString());
out.writeBoolean(plugin.getConfig().getBoolean("skinPermission"));
out.writeBoolean(bukkitOp);

server.sendData(plugin.getName(), out.toByteArray());
return;
}
Expand Down

0 comments on commit 52d7913

Please sign in to comment.