From 4fe85da4bfbc24e03eba4be747bec72e18fd477c Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Wed, 9 Oct 2013 22:14:44 +0100 Subject: [PATCH] Started the create and destroy files, added permissions and a plugin messsages file that makes it easier to change all common messages. --- .../AdvancedPortalsCommand.java | 7 ++++-- .../advancedportals/DestinationCommand.java | 22 +++++++++++++++++-- .../com/sekwah/advancedportals/Listeners.java | 2 +- .../advancedportals/PluginMessages.java | 20 +++++++++++++++++ .../destinations/CreateDestination.java | 5 +++++ .../destinations/DestroyDestination.java | 5 +++++ .../portalcontrolls/CreatePortal.java | 5 +++++ .../portalcontrolls/DestroyPortal.java | 5 +++++ 8 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/PluginMessages.java create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/destinations/CreateDestination.java create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/destinations/DestroyDestination.java create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/CreatePortal.java create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/DestroyPortal.java diff --git a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java index 3fa25a5..95e711d 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java @@ -27,7 +27,7 @@ public class AdvancedPortalsCommand implements CommandExecutor { ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml"); if(args.length > 0){ if(args[0].toLowerCase().equals("wand") || args[0].toLowerCase().equals("selector")){ - if(sender.hasPermission("AdvancedPortals.create")){ + if(sender.hasPermission("AdvancedPortals.CreatePortal")){ PlayerInventory inventory = player.getInventory(); ItemStack regionselector = new ItemStack(Material.IRON_AXE); @@ -41,9 +41,12 @@ public class AdvancedPortalsCommand implements CommandExecutor { sender.sendMessage("§a[§7AdvancedPortals§a] You have been given a §ePortal Region Selector§a!"); } else{ - sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to create portals so you cannot give yourself a §ePortal Region Selector§c!"); + PluginMessages.NoPermission(sender, command); } } + else{ + PluginMessages.UnknownCommand(sender, command); + } } else{ sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n" diff --git a/Advanced Portals/src/com/sekwah/advancedportals/DestinationCommand.java b/Advanced Portals/src/com/sekwah/advancedportals/DestinationCommand.java index 2b7d739..04dca68 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/DestinationCommand.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/DestinationCommand.java @@ -1,8 +1,14 @@ package com.sekwah.advancedportals; +import java.util.Arrays; + +import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.inventory.meta.ItemMeta; public class DestinationCommand implements CommandExecutor { @@ -17,8 +23,20 @@ public class DestinationCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) { - - + if(args.length > 0){ + if(args[0].toLowerCase().equals("create")){ + if(sender.hasPermission("AdvancedPortals.create")){ + + } + else{ + sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to create portals so you cannot give yourself a §ePortal Region Selector§c!"); + } + } + } + else{ + sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n" + + "if you do not know what you can put or would like some help with the commands please type /" + command + " help"); + } return true; } diff --git a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java index a9ae078..128ca85 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java @@ -41,7 +41,7 @@ public class Listeners implements Listener { // also any other detections such as sign interaction or basic block protection Player player = event.getPlayer(); Location blockloc = event.getClickedBlock().getLocation(); - if(player.hasPermission("AdvancedPortals.create")){ + if(player.hasPermission("AdvancedPortals.CreatePortal")){ // UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally, // by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used diff --git a/Advanced Portals/src/com/sekwah/advancedportals/PluginMessages.java b/Advanced Portals/src/com/sekwah/advancedportals/PluginMessages.java new file mode 100644 index 0000000..61c843b --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/PluginMessages.java @@ -0,0 +1,20 @@ +package com.sekwah.advancedportals; + +import org.bukkit.command.CommandSender; + +public class PluginMessages { + + // This class is so then the common messages in commands or just messages over the commands are the same and can be + // easily changed. + + public static void UnknownCommand(CommandSender sender, String command) { + sender.sendMessage("§c[§7AdvancedPortals§c] You need to type something after /" + command + "\n" + + "if you do not know what you can put or would like some help with the commands please type " + '"' + "/" + command + " help" + '"' + " or you can check out the Advanced Portals wiki" + + "\n "); + } + + public static void NoPermission(CommandSender sender, String command) { + sender.sendMessage("§c[§7AdvancedPortals§c] You do not have permission to perform that command!"); + } + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/destinations/CreateDestination.java b/Advanced Portals/src/com/sekwah/advancedportals/destinations/CreateDestination.java new file mode 100644 index 0000000..f7cd3c0 --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/destinations/CreateDestination.java @@ -0,0 +1,5 @@ +package com.sekwah.advancedportals.destinations; + +public class CreateDestination { + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/destinations/DestroyDestination.java b/Advanced Portals/src/com/sekwah/advancedportals/destinations/DestroyDestination.java new file mode 100644 index 0000000..1334e03 --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/destinations/DestroyDestination.java @@ -0,0 +1,5 @@ +package com.sekwah.advancedportals.destinations; + +public class DestroyDestination { + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/CreatePortal.java b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/CreatePortal.java new file mode 100644 index 0000000..86df410 --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/CreatePortal.java @@ -0,0 +1,5 @@ +package com.sekwah.advancedportals.portalcontrolls; + +public class CreatePortal { + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/DestroyPortal.java b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/DestroyPortal.java new file mode 100644 index 0000000..f416fdf --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/DestroyPortal.java @@ -0,0 +1,5 @@ +package com.sekwah.advancedportals.portalcontrolls; + +public class DestroyPortal { + +}