added permissions: ancientgates.use, ancientgates.info, ancientgates.manage
This commit is contained in:
parent
af24d7365a
commit
df6a49ce2c
@ -82,13 +82,6 @@ public class Plugin extends JavaPlugin
|
|||||||
log("Enabled");
|
log("Enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// Test rights
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static boolean hasPermManage(CommandSender sender) {
|
|
||||||
return sender.isOp();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Commands
|
// Commands
|
||||||
|
@ -13,6 +13,9 @@ import org.mcteam.ancientgates.util.TextUtil;
|
|||||||
|
|
||||||
public class BaseCommand
|
public class BaseCommand
|
||||||
{
|
{
|
||||||
|
public static final String permissionInfo = "ancientgates.info";
|
||||||
|
public static final String permissionManage = "ancientgates.manage";
|
||||||
|
|
||||||
public List<String> aliases;
|
public List<String> aliases;
|
||||||
public List<String> requiredParameters;
|
public List<String> requiredParameters;
|
||||||
public List<String> optionalParameters;
|
public List<String> optionalParameters;
|
||||||
@ -112,8 +115,9 @@ public class BaseCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(CommandSender sender) {
|
public boolean hasPermission(CommandSender sender)
|
||||||
return Plugin.hasPermManage(sender);
|
{
|
||||||
|
return false; // make sure to overwrite this in all subclasses!
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandClose extends BaseCommand {
|
public class CommandClose extends BaseCommand
|
||||||
|
{
|
||||||
public CommandClose() {
|
public CommandClose()
|
||||||
|
{
|
||||||
aliases.add("close");
|
aliases.add("close");
|
||||||
|
|
||||||
requiredParameters.add("id");
|
requiredParameters.add("id");
|
||||||
@ -12,12 +14,19 @@ public class CommandClose extends BaseCommand {
|
|||||||
helpDescription = "Close that gate";
|
helpDescription = "Close that gate";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
@Override
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
gate.close();
|
gate.close();
|
||||||
|
|
||||||
sendMessage("The gate was closed.");
|
sendMessage("The gate was closed.");
|
||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandCreate extends BaseCommand {
|
public class CommandCreate extends BaseCommand
|
||||||
public CommandCreate() {
|
{
|
||||||
|
public CommandCreate()
|
||||||
|
{
|
||||||
aliases.add("create");
|
aliases.add("create");
|
||||||
aliases.add("new");
|
aliases.add("new");
|
||||||
|
|
||||||
@ -15,9 +18,12 @@ public class CommandCreate extends BaseCommand {
|
|||||||
helpDescription = "Create a gate";
|
helpDescription = "Create a gate";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
String id = parameters.get(0);
|
String id = parameters.get(0);
|
||||||
if (Gate.exists(id)) {
|
if (Gate.exists(id))
|
||||||
|
{
|
||||||
sendMessage("There gate \"" + id + "\" already exists.");
|
sendMessage("There gate \"" + id + "\" already exists.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -25,8 +31,14 @@ public class CommandCreate extends BaseCommand {
|
|||||||
Gate.create(id);
|
Gate.create(id);
|
||||||
sendMessage("Gate with id \"" + id + "\" was created. Now you should:");
|
sendMessage("Gate with id \"" + id + "\" was created. Now you should:");
|
||||||
sendMessage(new CommandSetFrom().getUsageTemplate(true, true));
|
sendMessage(new CommandSetFrom().getUsageTemplate(true, true));
|
||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Conf;
|
import org.mcteam.ancientgates.Conf;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
import org.mcteam.ancientgates.util.FloodUtil;
|
import org.mcteam.ancientgates.util.FloodUtil;
|
||||||
@ -78,4 +79,11 @@ public class CommandCreateSetFrom extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandDelete extends BaseCommand {
|
public class CommandDelete extends BaseCommand {
|
||||||
@ -15,11 +16,19 @@ public class CommandDelete extends BaseCommand {
|
|||||||
helpDescription = "Delete a gate";
|
helpDescription = "Delete a gate";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform() {
|
public void perform()
|
||||||
|
{
|
||||||
gate.close();
|
gate.close();
|
||||||
sendMessage("Gate with id \"" + gate.getId() + "\" was deleted.");
|
sendMessage("Gate with id \"" + gate.getId() + "\" was deleted.");
|
||||||
Gate.delete(gate.getId());
|
Gate.delete(gate.getId());
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ public class CommandHelp extends BaseCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(CommandSender sender)
|
public boolean hasPermission(CommandSender sender)
|
||||||
{
|
{
|
||||||
return true;
|
return sender.hasPermission(permissionInfo) || sender.hasPermission(permissionManage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandHide extends BaseCommand
|
public class CommandHide extends BaseCommand
|
||||||
@ -21,4 +22,10 @@ public class CommandHide extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
|
|
||||||
@ -48,4 +49,11 @@ public class CommandInfo extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionInfo) || sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Conf;
|
import org.mcteam.ancientgates.Conf;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
import org.mcteam.ancientgates.util.TextUtil;
|
import org.mcteam.ancientgates.util.TextUtil;
|
||||||
@ -213,5 +214,12 @@ public class CommandList extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionInfo) || sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandOpen extends BaseCommand {
|
public class CommandOpen extends BaseCommand {
|
||||||
@ -39,5 +40,12 @@ public class CommandOpen extends BaseCommand {
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
|
|
||||||
@ -39,4 +40,11 @@ public class CommandRename extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Conf;
|
import org.mcteam.ancientgates.Conf;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
import org.mcteam.ancientgates.util.FloodUtil;
|
import org.mcteam.ancientgates.util.FloodUtil;
|
||||||
@ -63,5 +64,12 @@ public class CommandSetFrom extends BaseCommand
|
|||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandSetTo extends BaseCommand {
|
public class CommandSetTo extends BaseCommand {
|
||||||
@ -20,5 +21,11 @@ public class CommandSetTo extends BaseCommand {
|
|||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.mcteam.ancientgates.commands;
|
package org.mcteam.ancientgates.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.mcteam.ancientgates.Gate;
|
import org.mcteam.ancientgates.Gate;
|
||||||
|
|
||||||
public class CommandUnhide extends BaseCommand
|
public class CommandUnhide extends BaseCommand
|
||||||
@ -23,4 +24,11 @@ public class CommandUnhide extends BaseCommand
|
|||||||
|
|
||||||
Gate.save();
|
Gate.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return sender.hasPermission(permissionManage);
|
||||||
|
}
|
||||||
}
|
}
|
@ -28,6 +28,9 @@ public class PluginPlayerListener implements Listener
|
|||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!(event.getPlayer().hasPermission("ancientgates.use") || sender.hasPermission(permissionInfo) || sender.hasPermission(permissionManage)))
|
||||||
|
return;
|
||||||
|
|
||||||
Block blockTo = event.getTo().getBlock();
|
Block blockTo = event.getTo().getBlock();
|
||||||
Block blockToUp = blockTo.getRelative(BlockFace.UP);
|
Block blockToUp = blockTo.getRelative(BlockFace.UP);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user