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