Add ops-override-perms to the config.
This commit is contained in:
parent
f5430b9101
commit
d29b5e195a
@ -34,4 +34,5 @@ notify-player: true
|
|||||||
upside-down-check: true
|
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 {
|
||||||
@ -73,10 +74,10 @@ public class EventListener implements Listener {
|
|||||||
plugin.sit.remove(pName);
|
plugin.sit.remove(pName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDestroy(BlockBreakEvent event) {
|
public void onBlockDestroy(BlockBreakEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (!plugin.sit.isEmpty()) {
|
if (!plugin.sit.isEmpty()) {
|
||||||
ArrayList<String> standList = new ArrayList<String>();
|
ArrayList<String> standList = new ArrayList<String>();
|
||||||
for (String s : plugin.sit.keySet()) {
|
for (String s : plugin.sit.keySet()) {
|
||||||
@ -89,13 +90,13 @@ public class EventListener implements Listener {
|
|||||||
plugin.sendStand(player);
|
plugin.sendStand(player);
|
||||||
}
|
}
|
||||||
standList.clear();
|
standList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.hasBlock() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
Stairs stairs = null;
|
Stairs stairs = null;
|
||||||
Step step = null;
|
Step step = null;
|
||||||
double sh = plugin.sittingHeight;
|
double sh = plugin.sittingHeight;
|
||||||
@ -113,24 +114,22 @@ public class EventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
// Check if block beneath chair is solid.
|
// Check if block beneath chair is solid.
|
||||||
@ -140,10 +139,10 @@ public class EventListener implements Listener {
|
|||||||
if (block.getRelative(BlockFace.DOWN).isEmpty()) {
|
if (block.getRelative(BlockFace.DOWN).isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!net.minecraft.server.v1_4_6.Block.byId[block.getTypeId()].material.isSolid()) {
|
if (!net.minecraft.server.v1_4_6.Block.byId[block.getTypeId()].material.isSolid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is sitting.
|
// Check if player is sitting.
|
||||||
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
if (plugin.sit.containsKey(event.getPlayer().getName())) {
|
||||||
plugin.sit.remove(player.getName());
|
plugin.sit.remove(player.getName());
|
||||||
@ -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 {
|
||||||
@ -253,7 +252,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
long delay = 1 * 2000;
|
long delay = 1 * 2000;
|
||||||
timer.schedule(new sendSitTask(), delay);
|
timer.schedule(new sendSitTask(), delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -8,8 +8,4 @@ main: net.spoothie.chairs.Chairs
|
|||||||
commands:
|
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