Add ops-override-perms to the config.
This commit is contained in:
parent
f5430b9101
commit
d29b5e195a
@ -35,3 +35,4 @@ upside-down-check: true
|
||||
seat-occupied-check: true
|
||||
upper-step-check: true
|
||||
per-item-perms: true
|
||||
ops-override-perms: false
|
@ -15,13 +15,15 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_4_6.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Chairs extends JavaPlugin {
|
||||
|
||||
public List<Material> allowedBlocks = new ArrayList<Material>();
|
||||
public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer;
|
||||
public boolean sneaking, autoRotate, signCheck, permissions, notifyplayer, opsOverridePerms;
|
||||
public boolean invertedStairCheck, seatOccupiedCheck, invertedStepCheck, perItemPerms;
|
||||
public double sittingHeight, distance;
|
||||
public int maxChairWidth;
|
||||
@ -36,7 +38,7 @@ public class Chairs extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
pm = this.getServer().getPluginManager();
|
||||
pluginFolder = getDataFolder();
|
||||
configFile = new File(pluginFolder, "config.yml");
|
||||
createConfig();
|
||||
@ -45,7 +47,6 @@ public class Chairs extends JavaPlugin {
|
||||
loadConfig();
|
||||
EventListener eventListener = new EventListener(this);
|
||||
getServer().getPluginManager().registerEvents(eventListener, this);
|
||||
pm = this.getServer().getPluginManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,6 +84,7 @@ public class Chairs extends JavaPlugin {
|
||||
seatOccupiedCheck = getConfig().getBoolean("seat-occupied-check");
|
||||
invertedStepCheck = getConfig().getBoolean("upper-step-check");
|
||||
perItemPerms = getConfig().getBoolean("per-item-perms");
|
||||
opsOverridePerms = getConfig().getBoolean("ops-override-perms");
|
||||
|
||||
for (String type : getConfig().getStringList("allowed-blocks")) {
|
||||
try {
|
||||
@ -96,6 +98,15 @@ public class Chairs extends JavaPlugin {
|
||||
logInfo("ERROR: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (pm.getPermission("chairs.sit") != null) {
|
||||
pm.removePermission("chairs.sit");
|
||||
}
|
||||
if (opsOverridePerms) {
|
||||
pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.OP));
|
||||
} else {
|
||||
pm.addPermission(new Permission("chairs.sit","Allows players to sit on blocks",PermissionDefault.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.material.Stairs;
|
||||
import org.bukkit.material.Step;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
@ -115,21 +116,19 @@ public class EventListener implements Listener {
|
||||
}
|
||||
if (plugin.perItemPerms) {
|
||||
if (plugin.pm.getPermission("chairs.sit." + block.getTypeId()) == null) {
|
||||
plugin.pm.addPermission(new org.bukkit.permissions.Permission(
|
||||
"chairs.sit." + block.getTypeId(),
|
||||
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 org.bukkit.permissions.Permission(
|
||||
"chairs.sit." + block.getType().toString(),
|
||||
plugin.pm.addPermission(new Permission("chairs.sit." + block.getType().toString(),
|
||||
"Allow players to sit on a '" + block.getType().name() + "'",
|
||||
PermissionDefault.FALSE));
|
||||
}
|
||||
}
|
||||
if (plugin.allowedBlocks.contains(block.getType())
|
||||
|| (player.hasPermission("chairs.sit." + block.getTypeId()) && plugin.perItemPerms)
|
||||
|| (player.hasPermission("chairs.sit." + block.getType().toString())&& plugin.perItemPerms) ) {
|
||||
|| (player.hasPermission("chairs.sit." + block.getType().toString()) && plugin.perItemPerms)) {
|
||||
|
||||
int chairwidth = 1;
|
||||
|
||||
@ -227,16 +226,16 @@ public class EventListener implements Listener {
|
||||
plocation.add(0.5D, (sh - 0.5D), 0.5D);
|
||||
switch (stairs.getDescendingDirection()) {
|
||||
case NORTH:
|
||||
plocation.setYaw(90);
|
||||
break;
|
||||
case EAST:
|
||||
plocation.setYaw(180);
|
||||
break;
|
||||
case EAST:
|
||||
plocation.setYaw(-90);
|
||||
break;
|
||||
case SOUTH:
|
||||
plocation.setYaw(270);
|
||||
plocation.setYaw(0);
|
||||
break;
|
||||
case WEST:
|
||||
plocation.setYaw(0);
|
||||
plocation.setYaw(90);
|
||||
}
|
||||
player.teleport(plocation);
|
||||
} else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: Chairs
|
||||
version: 1.13.2
|
||||
version: 1.13.5
|
||||
description: Let players sit on blocks.
|
||||
authors:
|
||||
- spoothie
|
||||
@ -9,7 +9,3 @@ commands:
|
||||
chairs:
|
||||
description: Reloads the Chairs configuration file.
|
||||
usage: /chairs reload
|
||||
permissions:
|
||||
chairs.sit:
|
||||
description: Allows players to sit on blocks.
|
||||
default: false
|
Loading…
Reference in New Issue
Block a user