Remove permissions from code, we will add them to plugin.yml

This commit is contained in:
Shevchik 2013-09-30 11:21:58 +04:00
parent 32e28b1695
commit 8d64101d11
3 changed files with 4 additions and 44 deletions

View File

@ -20,8 +20,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
@ -33,7 +31,7 @@ public class Chairs extends JavaPlugin {
public static ChairEffects chairEffects;
public List<ChairBlock> allowedBlocks;
public List<Material> validSigns;
public boolean autoRotate, signCheck, permissions, notifyplayer, opsOverridePerms;
public boolean autoRotate, signCheck, notifyplayer;
public boolean invertedStairCheck, invertedStepCheck, perItemPerms, ignoreIfBlockInHand;
public boolean sitEffectsEnabled;
public double sittingHeight, sittingHeightAdj, distance;
@ -224,12 +222,10 @@ public class Chairs extends JavaPlugin {
sittingHeightAdj = getConfig().getDouble("sitting-height-adj");
distance = getConfig().getDouble("distance");
maxChairWidth = getConfig().getInt("max-chair-width");
permissions = getConfig().getBoolean("permissions");
notifyplayer = getConfig().getBoolean("notify-player");
invertedStairCheck = getConfig().getBoolean("upside-down-check");
invertedStepCheck = getConfig().getBoolean("upper-step-check");
perItemPerms = getConfig().getBoolean("per-item-perms");
opsOverridePerms = getConfig().getBoolean("ops-override-perms");
ignoreIfBlockInHand = getConfig().getBoolean("ignore-if-block-in-hand");
sitEffectsEnabled = getConfig().getBoolean("sit-effects.enabled", false);
@ -305,16 +301,6 @@ public class Chairs extends JavaPlugin {
pm.removePermission(s);
}
}
PermissionDefault pd;
if (opsOverridePerms) {
pd = PermissionDefault.OP;
} else {
pd = PermissionDefault.FALSE;
}
pm.addPermission(new Permission("chairs.sit","Allow player to sit on a block.",pd));
pm.addPermission(new Permission("chairs.reload","Allow player to reload the Chairs configuration.",pd));
pm.addPermission(new Permission("chairs.self","Allow player to self disable or enable sitting.",pd));
}
public void logInfo(String _message) {

View File

@ -45,7 +45,7 @@ public class ChairsCommand implements CommandExecutor {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args[0].equalsIgnoreCase("on")) {
if (p.hasPermission("chairs.self") || !plugin.permissions) {
if (p.hasPermission("chairs.self")) {
ignoreList.removePlayer(p.getName());
if (!plugin.msgEnabled.isEmpty()) {
p.sendMessage(plugin.msgEnabled);
@ -57,7 +57,7 @@ public class ChairsCommand implements CommandExecutor {
}
}
if (args[0].equalsIgnoreCase("off")) {
if (p.hasPermission("chairs.self") || !plugin.permissions) {
if (p.hasPermission("chairs.self")) {
ignoreList.addPlayer(p.getName());
if (!plugin.msgDisabled.isEmpty()) {
p.sendMessage(plugin.msgDisabled);

View File

@ -19,8 +19,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.material.Stairs;
import org.bukkit.material.Step;
import org.bukkit.material.WoodenStep;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.util.Vector;
public class EventListener implements Listener {
@ -101,33 +99,9 @@ public class EventListener implements Listener {
return false;
}
// Permissions Check
if (plugin.permissions) {
if (!player.hasPermission("chairs.sit")) {
return false;
}
}
if (plugin.perItemPerms) {
if (plugin.pm.getPermission("chairs.sit." + block.getTypeId()) == null) {
plugin.pm.addPermission(new Permission("chairs.sit." + block.getTypeId(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
if (plugin.pm.getPermission("chairs.sit." + block.getType().toString()) == null) {
plugin.pm.addPermission(new Permission("chairs.sit." + block.getType().toString(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
if (plugin.pm.getPermission("chairs.sit." + block.getTypeId() + ":" + block.getData()) == null) {
plugin.pm.addPermission(new Permission("chairs.sit." + block.getTypeId() + ":" + block.getData(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
if (plugin.pm.getPermission("chairs.sit." + block.getType().toString() + ":" + block.getData()) == null) {
plugin.pm.addPermission(new Permission("chairs.sit." + block.getType().toString() + ":" + block.getData(),
"Allow players to sit on a '" + block.getType().name() + "'",
PermissionDefault.FALSE));
}
}
for (ChairBlock cb : plugin.allowedBlocks) {
if (cb.getMat().toString().contains("STAIRS")) {