Skip to content

Commit

Permalink
- Remove deprecated permission checks for old blockID values.
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl committed Nov 7, 2019
1 parent 5246b66 commit 37e1004
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 224 deletions.
25 changes: 0 additions & 25 deletions src/com/palmergames/bukkit/towny/object/TownyWorld.java
Expand Up @@ -499,31 +499,6 @@ public boolean isProtectingExplosionEntity(Entity entity) {

}

/**
* @deprecated Replaced by {@link #getUnclaimedZoneIgnoreMaterials()}
*
* @return - List of blocked materials.
*/
@Deprecated
public List<String> getUnclaimedZoneIgnoreIds() {

if (unclaimedZoneIgnoreBlockMaterials == null)
return TownySettings.getUnclaimedZoneIgnoreMaterials();
else
return unclaimedZoneIgnoreBlockMaterials;
}

/**
* @deprecated Replaced by {@link #isUnclaimedZoneIgnoreMaterial(Material mat)}
*
* @return - true, if it is an ignored material
*/
@Deprecated
public boolean isUnclaimedZoneIgnoreId(String id) {

return getUnclaimedZoneIgnoreMaterials().contains(id);
}

public void setUnclaimedZoneIgnore(List<String> unclaimedZoneIgnoreIds) {

this.unclaimedZoneIgnoreBlockMaterials = unclaimedZoneIgnoreIds;
Expand Down
Expand Up @@ -264,203 +264,4 @@ public boolean has(Player player, String node) {
return false;

}

/*
* Wrappers for backwards compatibility
*/
@Deprecated
public boolean hasWildOverride(TownyWorld world, Player player, int blockId, TownyPermission.ActionType action) {

return hasWildOverride(world, player, blockId, (byte) 0, action);
}

@Deprecated
public boolean hasOwnTownOverride(Player player, int blockId, TownyPermission.ActionType action) {

return hasOwnTownOverride(player, blockId, (byte) 0, action);
}

@Deprecated
public boolean hasAllTownOverride(Player player, int blockId, TownyPermission.ActionType action) {

return hasAllTownOverride(player, blockId, (byte) 0, action);
}

/**
* Test if the player has a wild override to permit this action.
*
* @param world
* @param player
* @param blockId
* @param data
* @param action
* @return true if the action is permitted.
*/
@Deprecated
public boolean hasWildOverride(TownyWorld world, Player player, int blockId, byte data, TownyPermission.ActionType action) {

// check for permissions

String blockPerm = PermissionNodes.TOWNY_WILD_ALL.getNode(action.toString().toLowerCase() + "." + blockId);
String dataPerm = PermissionNodes.TOWNY_WILD_ALL.getNode(action.toString().toLowerCase() + "." + blockId + ":" + data);

boolean dataRegistered = player.isPermissionSet(dataPerm);

boolean hasBlock = has(player, blockPerm);
boolean hasData = has(player, dataPerm);

/*
* If the player has the data node permission registered directly
* or
* the player has the block permission and the data node isn't registered
*/
if ((hasData && dataRegistered) || (hasBlock && !dataRegistered))
return true;

// No node set but we are using permissions so check world settings
// (without UnclaimedIgnoreId's).
switch (action) {

case BUILD:
return world.getUnclaimedZoneBuild();
case DESTROY:
return world.getUnclaimedZoneDestroy();
case SWITCH:
return world.getUnclaimedZoneSwitch();
case ITEM_USE:
return world.getUnclaimedZoneItemUse();
}

return false;
}

@Deprecated
public boolean unclaimedZoneAction(TownyWorld world, int blockId, TownyPermission.ActionType action) {

String mat = BukkitTools.getMaterial(blockId).name();

switch (action) {

case BUILD:
return world.getUnclaimedZoneBuild() || world.isUnclaimedZoneIgnoreId(mat);
case DESTROY:
return world.getUnclaimedZoneDestroy() || world.isUnclaimedZoneIgnoreId(mat);
case SWITCH:
return world.getUnclaimedZoneSwitch() || world.isUnclaimedZoneIgnoreId(mat);
case ITEM_USE:
return world.getUnclaimedZoneItemUse() || world.isUnclaimedZoneIgnoreId(mat);
}

return false;
}

/**
* Test if the player has an own town (or all town) override to permit this action.
*
* @param player
* @param blockId
* @param data
* @param action
* @return true if the action is permitted.
*/
@Deprecated
public boolean hasOwnTownOverride(Player player, int blockId, byte data, TownyPermission.ActionType action) {

//check for permissions
String blockPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("owntown." + action.toString().toLowerCase() + "." + blockId);
String dataPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("owntown." + action.toString().toLowerCase() + "." + blockId + ":" + data);

boolean dataRegistered = player.isPermissionSet(dataPerm);

boolean hasBlock = has(player, blockPerm);
boolean hasData = has(player, dataPerm);

TownyMessaging.sendDebugMsg(player.getName() + " - owntown (Block: " + hasBlock + " - Data: " + hasData + ":" + (dataRegistered ? "Registered" : "None"));

/*
* If the player has the data node permission registered directly
* or
* the player has the block permission and the data node isn't registered
* or
* the player has an All town Override
*/
if ((hasData && dataRegistered) || (hasBlock && !dataRegistered) || hasAllTownOverride(player, blockId, data, action))
return true;

return false;
}

/**
* Test if the player has a 'town owned', 'Own town' or 'all town' override to permit this action.
*
* @param player
* @param blockId
* @param data
* @param action
* @return
*/
@Deprecated
public boolean hasTownOwnedOverride(Player player, int blockId, byte data, TownyPermission.ActionType action) {

//check for permissions
String blockPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("townowned." + action.toString().toLowerCase() + "." + blockId);
String dataPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("townowned." + action.toString().toLowerCase() + "." + blockId + ":" + data);

boolean dataRegistered = player.isPermissionSet(dataPerm);

boolean hasBlock = has(player, blockPerm);
boolean hasData = has(player, dataPerm);

TownyMessaging.sendDebugMsg(player.getName() + " - townowned (Block: " + hasBlock + " - Data: " + hasData + ":" + (dataRegistered ? "Registered" : "None"));

/*
* If the player has the data node permission registered directly
* or
* the player has the block permission and the data node isn't registered
* or
* the player has an Own Town Override
* or
* the player has an All town Override
*/
if ((hasData && dataRegistered) || (hasBlock && !dataRegistered) || hasOwnTownOverride(player, blockId, data, action) || hasAllTownOverride(player, blockId, data, action))
return true;

return false;
}

/**
* Test if the player has an all town override to permit this action.
*
* @param player
* @param blockId
* @param data
* @param action
* @return true if the action is permitted.
*/
@Deprecated
public boolean hasAllTownOverride(Player player, int blockId, byte data, TownyPermission.ActionType action) {

//check for permissions
String blockPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("alltown." + action.toString().toLowerCase() + "." + blockId);
String dataPerm = PermissionNodes.TOWNY_CLAIMED_ALL.getNode("alltown." + action.toString().toLowerCase() + "." + blockId + ":" + data);

//boolean blockRegistered = player.isPermissionSet(blockPerm);
boolean dataRegistered = player.isPermissionSet(dataPerm);

boolean hasBlock = has(player, blockPerm);
boolean hasData = has(player, dataPerm);

TownyMessaging.sendDebugMsg(player.getName() + " - alltown (Block: " + hasBlock + " - Data: " + hasData + ":" + (dataRegistered ? "Registered" : "None"));

/*
* If the player has the data node permission registered directly
* or
* the player has the block permission and the data node isn't registered
*/
if ((hasData && dataRegistered) || (hasBlock && !dataRegistered))
return true;

return false;
}

}

0 comments on commit 37e1004

Please sign in to comment.