Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean canBeModifiedFrom(PlotPermissions _originOfChange)
- {
- if(this.destroy.isPermitOthers() && this.build.isPermitOthers()) //others = anyone can modify
- {
- return true;
- }
- else //others cannot build or destroy
- {
- if(_originOfChange == null) //coming from unclaim
- {
- return false;
- }
- //The other claim allow others to change, we cannot allow it
- if(_originOfChange.build.isPermitOthers() || _originOfChange.destroy.isPermitOthers())
- {
- return false;
- }
- }
- if(this.destroy.isPermitFriends() && this.build.isPermitFriends())
- {
- //The other claim allow friends to change, we must check if its the same owner (for same friends)
- if(_originOfChange.build.isPermitFriends() || _originOfChange.destroy.isPermitFriends())
- {
- //different owner -> different friends, we cannot allow it
- if(this.owner != null && _originOfChange.owner != null && this.owner.getId() != _originOfChange.owner.getId())
- {
- return false;
- }
- }
- }
- else //friends cannot build or destroy
- {
- //The other claim allow friends to change, we cannot allow it
- if(_originOfChange.build.isPermitFriends() || _originOfChange.destroy.isPermitFriends())
- {
- return false;
- }
- }
- if(this.destroy.isPermitGroup() && this.build.isPermitGroup())
- {
- //The other claim allow groups to change, we must check if its the same groups
- if(_originOfChange.build.isPermitGroup() || _originOfChange.destroy.isPermitGroup())
- {
- //different number of groups
- if(this.groups.size() != _originOfChange.groups.size())
- {
- return false;
- }
- boolean foundGroup;
- boolean foundAllGroup = true;
- for(PermissionGroup group : this.groups)
- {
- foundGroup = false;
- for(PermissionGroup otherGroup : _originOfChange.groups)
- {
- if(group.getId() == otherGroup.getId()) //we found this group, we can progress to the next one
- {
- foundGroup = true;
- break;
- }
- }
- if(!foundGroup) //we didn't find this group, meaning people we might don't want can modify, we cannot allow them
- {
- foundAllGroup = false;
- break;
- }
- }
- if(!foundAllGroup)
- {
- return false;
- }
- }
- }
- else //groups cannot build or destroy
- {
- //The other claim allow groups to change, we cannot allow it
- if(_originOfChange.build.isPermitGroup() || _originOfChange.destroy.isPermitGroup())
- {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement