mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 14:07:54 +01:00
Fix plan unregister permission check
- If the permission check was false, due to && the deletion would complete. This seems like a thought error when trying to figure out the condition for this if clause. The confusing use of negation was replaced with a more readable if clause that clearly signifies intent of the check. Affects issues: - Fixed #1487
This commit is contained in:
parent
47ef46eb97
commit
f62e76bcf5
@ -116,14 +116,12 @@ public class UnregisterCommand extends CommandNode {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
User presentUser = found.get();
|
User presentUser = found.get();
|
||||||
if (!Objects.equals(playerUUID, presentUser.getLinkedToUUID()) && sender.hasPermission(Permissions.MANAGE_WEB.getPerm())) {
|
boolean linkedToSender = Objects.equals(playerUUID, presentUser.getLinkedToUUID());
|
||||||
|
if (linkedToSender || sender.hasPermission(Permissions.MANAGE_WEB.getPerm())) {
|
||||||
|
deleteUser(sender, database, username);
|
||||||
|
} else {
|
||||||
sender.sendMessage("§c" + locale.getString(CommandLang.USER_NOT_LINKED));
|
sender.sendMessage("§c" + locale.getString(CommandLang.USER_NOT_LINKED));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
|
||||||
database.executeTransaction(new RemoveWebUserTransaction(username))
|
|
||||||
.get(); // Wait for completion
|
|
||||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
errorLogger.log(L.ERROR, this.getClass(), e);
|
errorLogger.log(L.ERROR, this.getClass(), e);
|
||||||
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
sender.sendMessage(locale.getString(ManageLang.PROGRESS_FAIL, e.getMessage()));
|
||||||
@ -131,4 +129,11 @@ public class UnregisterCommand extends CommandNode {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteUser(Sender sender, Database database, String username) throws InterruptedException, java.util.concurrent.ExecutionException {
|
||||||
|
sender.sendMessage(locale.getString(ManageLang.PROGRESS_START));
|
||||||
|
database.executeTransaction(new RemoveWebUserTransaction(username))
|
||||||
|
.get(); // Wait for completion
|
||||||
|
sender.sendMessage(locale.getString(ManageLang.PROGRESS_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user