PermissionsHandler was a stupid idea.

This commit is contained in:
GJ 2012-06-13 12:31:20 -04:00
parent c71f4e438b
commit 9f65e5a9ab
3 changed files with 6 additions and 44 deletions

View File

@ -5,19 +5,19 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsManager {
private Player player;
private PlayerProfile profile;
private int skillLevel;
private AcrobaticsPermissionsHandler permHandler;
private Permissions permissionInstance = Permissions.getInstance();
public AcrobaticsManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = profile.getSkillLevel(SkillType.ACROBATICS);
this.permHandler = new AcrobaticsPermissionsHandler(player);
}
/**
@ -26,7 +26,7 @@ public class AcrobaticsManager {
* @param event The event to check
*/
public void rollCheck(EntityDamageEvent event) {
if (!permHandler.hasRollPermissions()) {
if (!permissionInstance.roll(player)) {
return;
}
@ -48,7 +48,7 @@ public class AcrobaticsManager {
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
if (!permHandler.canDodge()) {
if (!permissionInstance.dodge(player)) {
return;
}
@ -72,8 +72,4 @@ public class AcrobaticsManager {
protected int getSkillLevel() {
return skillLevel;
}
protected AcrobaticsPermissionsHandler getPermissionsHandler() {
return permHandler;
}
}

View File

@ -1,35 +0,0 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import com.gmail.nossr50.util.Permissions;
public class AcrobaticsPermissionsHandler {
private Permissions permInstance = Permissions.getInstance();
private boolean canDodge;
private boolean canGracefulRoll;
private boolean canRoll;
protected AcrobaticsPermissionsHandler (Player player) {
this.canDodge = permInstance.dodge(player);
this.canGracefulRoll = permInstance.gracefulRoll(player);
this.canRoll = permInstance.roll(player);
}
protected boolean canDodge() {
return canDodge;
}
protected boolean canGracefulRoll() {
return canGracefulRoll;
}
protected boolean canRoll() {
return canRoll;
}
protected boolean hasRollPermissions() {
return (canRoll || canGracefulRoll);
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
public class RollEventHandler extends AcrobaticsEventHandler {
@ -68,7 +69,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
* Check if this is a graceful roll.
*/
private void isGracefulRoll() {
if (manager.getPermissionsHandler().canGracefulRoll()) {
if (Permissions.getInstance().gracefulRoll(player)) {
this.isGraceful = player.isSneaking();
}
else {