Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better sign annotations, added sign content persistence

  • Loading branch information...
commit 147cd6a2c63614a3ab5b51d4d23844336a46e5dd 1 parent 6b5a732
@Philipp15b authored
Showing with 282 additions and 94 deletions.
  1. +17 −0 src/main/java/de/philworld/bukkit/magicsigns/MagicSignInfo.java
  2. +4 −1 src/main/java/de/philworld/bukkit/magicsigns/MagicSigns.java
  3. +9 −5 src/main/java/de/philworld/bukkit/magicsigns/MagicSignsListener.java
  4. +8 −10 src/main/java/de/philworld/bukkit/magicsigns/SignManager.java
  5. +87 −0 src/main/java/de/philworld/bukkit/magicsigns/commands/MagicSignsCommandExecutor.java
  6. +24 −3 src/main/java/de/philworld/bukkit/magicsigns/config/MagicSignSerializationProxy.java
  7. +22 −0 src/main/java/de/philworld/bukkit/magicsigns/economy/Price.java
  8. +0 −9 src/main/java/de/philworld/bukkit/magicsigns/permissions/BuildPermission.java
  9. +0 −9 src/main/java/de/philworld/bukkit/magicsigns/permissions/UsePermission.java
  10. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/ClearSign.java
  11. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/CreativeModeSign.java
  12. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/FeedSign.java
  13. +6 −5 src/main/java/de/philworld/bukkit/magicsigns/signs/HealSign.java
  14. +6 −5 src/main/java/de/philworld/bukkit/magicsigns/signs/HealthSign.java
  15. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/LevelSign.java
  16. +26 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/MagicSign.java
  17. +6 −0 src/main/java/de/philworld/bukkit/magicsigns/signs/PurchasableMagicSign.java
  18. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/RocketSign.java
  19. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/SpeedSign.java
  20. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/SurvivalModeSign.java
  21. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/TeleportSign.java
  22. +9 −6 src/main/java/de/philworld/bukkit/magicsigns/signs/command/CommandSign.java
  23. +6 −4 src/main/java/de/philworld/bukkit/magicsigns/signs/command/ConsoleCommandSign.java
  24. +4 −1 src/main/resources/plugin.yml
View
17 src/main/java/de/philworld/bukkit/magicsigns/MagicSignInfo.java
@@ -0,0 +1,17 @@
+package de.philworld.bukkit.magicsigns;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface MagicSignInfo {
+
+ String friendlyName();
+
+ String description();
+
+ String buildPerm();
+
+ String usePerm();
+
+}
View
5 src/main/java/de/philworld/bukkit/magicsigns/MagicSigns.java
@@ -12,6 +12,7 @@
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
+import de.philworld.bukkit.magicsigns.commands.MagicSignsCommandExecutor;
import de.philworld.bukkit.magicsigns.config.MagicSignSerializationProxy;
import de.philworld.bukkit.magicsigns.signs.ClearSign;
import de.philworld.bukkit.magicsigns.signs.CreativeModeSign;
@@ -41,7 +42,7 @@ public static MagicSigns inst() {
return instance;
}
- public SignManager signManager = new SignManager(getLogger());
+ public SignManager signManager = new SignManager(this);
private FileConfiguration config;
@Override
@@ -75,6 +76,8 @@ public void onEnable() {
"Vault was not found, all signs will be free!");
}
+ getCommand("ms").setExecutor(new MagicSignsCommandExecutor(this));
+
getServer().getPluginManager().registerEvents(
new MagicSignsListener(this), this);
View
14 src/main/java/de/philworld/bukkit/magicsigns/MagicSignsListener.java
@@ -35,6 +35,8 @@ public MagicSignsListener(MagicSigns plugin) {
@EventHandler
public void onSignChange(SignChangeEvent event) {
try {
+ if (manager.containsSign(event.getBlock().getLocation()))
+ manager.removeSign(event.getBlock().getLocation());
manager.registerSign(event.getBlock(), event.getLines(),
event.getPlayer(), event);
} catch (Exception e) {
@@ -73,11 +75,13 @@ public void onPlayerInteract(PlayerInteractEvent event) {
if (sign instanceof PurchasableMagicSign) {
PurchasableMagicSign pSign = (PurchasableMagicSign) sign;
- if (!pSign.withdrawPlayer(event.getPlayer())) {
- MSMsg.NOT_ENOUGH_MONEY.send(event.getPlayer());
- return;
- } else {
- MSMsg.PAID_SIGN.send(event.getPlayer());
+ if (!pSign.isFree()) {
+ if (!pSign.withdrawPlayer(event.getPlayer())) {
+ MSMsg.NOT_ENOUGH_MONEY.send(event.getPlayer());
+ return;
+ } else {
+ MSMsg.PAID_SIGN.send(event.getPlayer());
+ }
}
}
View
18 src/main/java/de/philworld/bukkit/magicsigns/SignManager.java
@@ -17,9 +17,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
import de.philworld.bukkit.magicsigns.permissions.PermissionException;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
import de.philworld.bukkit.magicsigns.signs.MagicSign;
import de.philworld.bukkit.magicsigns.util.MSMsg;
@@ -51,10 +49,10 @@
private Set<Class<? extends MagicSign>> signTypes = new HashSet<Class<? extends MagicSign>>();
private Map<Location, MagicSign> signs = new HashMap<Location, MagicSign>();
- private Logger logger;
+ private MagicSigns plugin;
- public SignManager(Logger logger) {
- this.logger = logger;
+ public SignManager(MagicSigns plugin) {
+ this.plugin = plugin;
}
/**
@@ -121,11 +119,11 @@ public void registerSign(Block sign, String[] lines, Player p,
// check for build permissions
if (p != null) {
- BuildPermission buildPerm = signType
- .getAnnotation(BuildPermission.class);
+ MagicSignInfo signInfo = signType
+ .getAnnotation(MagicSignInfo.class);
- if (buildPerm != null) {
- if (!p.hasPermission(buildPerm.value())) {
+ if (signInfo != null) {
+ if (!p.hasPermission(signInfo.buildPerm())) {
throw new PermissionException();
}
}
@@ -273,6 +271,6 @@ public ConfigurationSection saveConfig(ConfigurationSection section) {
* @return the logger
*/
private Logger getLogger() {
- return logger;
+ return plugin.getLogger();
}
}
View
87 src/main/java/de/philworld/bukkit/magicsigns/commands/MagicSignsCommandExecutor.java
@@ -0,0 +1,87 @@
+package de.philworld.bukkit.magicsigns.commands;
+
+import org.bukkit.ChatColor;
+import org.bukkit.block.Block;
+import org.bukkit.block.Sign;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import de.philworld.bukkit.magicsigns.MagicSigns;
+import de.philworld.bukkit.magicsigns.signs.MagicSign;
+import de.philworld.bukkit.magicsigns.util.MSMsg;
+
+public class MagicSignsCommandExecutor implements CommandExecutor {
+
+ private MagicSigns plugin;
+
+ public MagicSignsCommandExecutor(MagicSigns plugin) {
+ this.plugin = plugin;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label,
+ String[] args) {
+
+ // Determine if the sender is a player (and an op), or the console.
+ boolean isPlayer = (sender instanceof Player);
+
+ // Cast the sender to Player if possible.
+ Player p = (isPlayer) ? (Player) sender : null;
+
+ // no usage from the console cuz we use the player all the time.
+ if (!isPlayer) {
+ sender.sendMessage("Please only use in game!");
+ return true;
+ }
+
+ // Grab the command base and any arguments.
+ String base = (args.length > 0) ? args[0].toLowerCase() : "";
+ String arg1 = (args.length > 1) ? args[1].toLowerCase() : "";
+ String arg2 = (args.length > 2) ? args[2].toLowerCase() : "";
+ String arg3 = (args.length > 3) ? args[3].toLowerCase() : "";
+
+ // INFO COMMAND
+ if (base == "" || base.equalsIgnoreCase("info")) {
+
+ if (!p.hasPermission("magicsigns.command-info")) {
+ MSMsg.NO_PERMISSION.send(p);
+ return true;
+ }
+
+ Block target = p.getTargetBlock(null, 100);
+ if (target == null) {
+ p.sendMessage(ChatColor.RED + "Please point at a sign!");
+ return true;
+ }
+
+ if (!(target.getState() instanceof Sign)) {
+ p.sendMessage(ChatColor.RED + "Please point at a sign!");
+ return true;
+ }
+
+ p.sendMessage(ChatColor.GOLD + "--------------------");
+ p.sendMessage(ChatColor.GOLD + "MagicSigns Sign Info");
+ p.sendMessage(ChatColor.GOLD + "--------------------");
+
+ MagicSign sign = plugin.signManager.getSign(target.getLocation());
+ if (sign == null) {
+ p.sendMessage(ChatColor.GREEN + "This is just a normal sign.");
+ return true;
+ }
+
+ p.sendMessage(ChatColor.AQUA + "Type of this Magic Sign: "
+ + ChatColor.BLUE + sign.getFriendlyName());
+
+ p.sendMessage(ChatColor.BLUE + " - " + sign.getDescription());
+
+ // p.sendMessage("Edit this sign by clicking with another sign on this.");
+ // TODO Implement editing signs
+
+ }
+
+ return false;
+ }
+}
View
27 src/main/java/de/philworld/bukkit/magicsigns/config/MagicSignSerializationProxy.java
@@ -1,6 +1,8 @@
package de.philworld.bukkit.magicsigns.config;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
@@ -22,6 +24,7 @@
private final int y;
private final int z;
private final String type;
+ private final String[] lines;
public MagicSignSerializationProxy(MagicSign magicSign) {
this.world = magicSign.getLocation().getWorld();
@@ -29,6 +32,7 @@ public MagicSignSerializationProxy(MagicSign magicSign) {
this.y = magicSign.getLocation().getBlockY();
this.z = magicSign.getLocation().getBlockZ();
this.type = magicSign.getClass().getName();
+ this.lines = magicSign.lines;
}
public MagicSignSerializationProxy(Map<String, Object> map) {
@@ -37,6 +41,15 @@ public MagicSignSerializationProxy(Map<String, Object> map) {
this.y = (Integer) map.get("y");
this.z = (Integer) map.get("z");
this.type = (String) map.get("type");
+
+ if (map.get("lines") != null) {
+ @SuppressWarnings("unchecked")
+ List<String> linesList = (List<String>) map.get("lines");
+ Object[] linesAsObj = linesList.toArray();
+ this.lines = Arrays.copyOf(linesAsObj, linesAsObj.length, String[].class);
+ } else {
+ this.lines = null;
+ }
}
@Override
@@ -47,6 +60,8 @@ public MagicSignSerializationProxy(Map<String, Object> map) {
map.put("y", this.y);
map.put("z", this.z);
map.put("type", this.type);
+ if (this.lines != null)
+ map.put("lines", Arrays.asList(this.lines));
return map;
}
@@ -57,7 +72,7 @@ public static MagicSignSerializationProxy deserialize(
/**
* Get the Magic Sign behind this proxy.
- *
+ *
* @return MagicSign
* @throws Throwable
* - Error when instantiating new Magic Sign of this type.
@@ -67,8 +82,14 @@ public MagicSign getMagicSign() throws Throwable {
Block block = this.world.getBlockAt(loc);
if (block.getState() instanceof Sign) {
- Sign state = (Sign) block.getState();
- String[] lines = state.getLines();
+
+ String[] lines;
+ if (this.lines == null) {
+ Sign sign = (Sign) block.getState();
+ lines = sign.getLines();
+ } else {
+ lines = this.lines;
+ }
return (MagicSign) Class.forName(this.type)
.getConstructor(Block.class, lines.getClass())
View
22 src/main/java/de/philworld/bukkit/magicsigns/economy/Price.java
@@ -29,6 +29,13 @@ public static Price valueOf(String text) throws IllegalArgumentException {
}
/**
+ * Returns if the sign is free.
+ *
+ * @return True if the sign is free, else false
+ */
+ public abstract boolean isFree();
+
+ /**
* Returns if the player can pay this price.
*
* @param p
@@ -78,6 +85,11 @@ public double getPrice() {
}
@Override
+ public boolean isFree() {
+ return price == 0;
+ }
+
+ @Override
public boolean has(Player p) {
return MagicSigns.economy.has(p.getName(), price);
}
@@ -134,6 +146,11 @@ public ItemStack getItems() {
}
@Override
+ public boolean isFree() {
+ return amount == 0;
+ }
+
+ @Override
public boolean has(Player p) {
return p.getInventory().contains(material, amount);
}
@@ -170,6 +187,11 @@ public Level(int level) {
}
@Override
+ public boolean isFree() {
+ return level == 0;
+ }
+
+ @Override
public boolean has(Player p) {
return p.getLevel() >= level;
}
View
9 src/main/java/de/philworld/bukkit/magicsigns/permissions/BuildPermission.java
@@ -1,9 +0,0 @@
-package de.philworld.bukkit.magicsigns.permissions;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface BuildPermission {
- String value();
-}
View
9 src/main/java/de/philworld/bukkit/magicsigns/permissions/UsePermission.java
@@ -1,9 +0,0 @@
-package de.philworld.bukkit.magicsigns.permissions;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface UsePermission {
- String value();
-}
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/ClearSign.java
@@ -8,8 +8,7 @@
import org.bukkit.inventory.ItemStack;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
@@ -19,8 +18,11 @@
* inventory, otherwise only the hot bar.
*
*/
-@BuildPermission("magicsigns.clear.create")
-@UsePermission("magicsigns.clear.use")
+@MagicSignInfo(
+ friendlyName = "Clear sign",
+ description = "A sign that clears player's inventory.",
+ buildPerm = "magicsigns.clear.create",
+ usePerm = "magicsigns.clear.use")
public class ClearSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/CreativeModeSign.java
@@ -5,11 +5,13 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
-@BuildPermission("magicsigns.creative.create")
-@UsePermission("magicsigns.creative.use")
+@MagicSignInfo(
+ friendlyName = "Creative Mode sign",
+ description = "Sets the player's game mode to Creative Mode.",
+ buildPerm = "magicsigns.creative.create",
+ usePerm = "magicsigns.creative.use")
public class CreativeModeSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/FeedSign.java
@@ -5,15 +5,17 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
* A sign that increases the food level of a player by a certain amount.
*/
-@BuildPermission("magicsigns.feed.create")
-@UsePermission("magicsigns.feed.use")
+@MagicSignInfo(
+ friendlyName = "Feed sign",
+ description = "A sign that increases the food level of a player by a certain amount.",
+ buildPerm = "magicsigns.feed.create",
+ usePerm = "magicsigns.feed.use")
public class FeedSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
View
11 src/main/java/de/philworld/bukkit/magicsigns/signs/HealSign.java
@@ -5,8 +5,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
@@ -14,8 +13,11 @@
*
* @see {@link HealthSign} - Sets the health directly to a value.
*/
-@BuildPermission("magicsigns.heal.create")
-@UsePermission("magicsigns.heal.use")
+@MagicSignInfo(
+ friendlyName = "Heal sign",
+ description = "A sign that adds some health to a player.",
+ buildPerm = "magicsigns.heal.create",
+ usePerm = "magicsigns.heal.use")
public class HealSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
@@ -47,5 +49,4 @@ public void onRightClick(PlayerInteractEvent event) {
MSMsg.HEAL_SUCCESS.send(p);
}
-
}
View
11 src/main/java/de/philworld/bukkit/magicsigns/signs/HealthSign.java
@@ -4,8 +4,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
@@ -14,8 +13,11 @@
* @see {@link HealSign} - Increases the player's health.
*
*/
-@BuildPermission("magicsigns.health.create")
-@UsePermission("magicsigns.health.use")
+@MagicSignInfo(
+ friendlyName = "Health sign",
+ description = "A sign that sets the health of a player to a specific value.",
+ buildPerm = "magicsigns.health.create",
+ usePerm = "magicsigns.health.use")
public class HealthSign extends PurchasableMagicSign {
private int healthNumber = 20;
@@ -39,5 +41,4 @@ public void onRightClick(PlayerInteractEvent event) {
MSMsg.HEAL_SUCCESS.send(event.getPlayer());
}
-
}
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/LevelSign.java
@@ -5,16 +5,18 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
* Adds a specific amount of levels to a player.
*
*/
-@BuildPermission("magicsigns.level.create")
-@UsePermission("magicsigns.level.use")
+@MagicSignInfo(
+ friendlyName = "Level sign",
+ description = "Adds a specific amount of levels to a player.",
+ buildPerm = "magicsigns.level.create",
+ usePerm = "magicsigns.level.use")
public class LevelSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
View
30 src/main/java/de/philworld/bukkit/magicsigns/signs/MagicSign.java
@@ -8,10 +8,10 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.config.ConfigurationBase;
import de.philworld.bukkit.magicsigns.config.MagicSignSerializationProxy;
import de.philworld.bukkit.magicsigns.permissions.PermissionException;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
/**
* Parent class for every magic sign. Uses the Behavior pattern.
@@ -46,6 +46,7 @@ public static void saveConfig(ConfigurationSection section) {
}
public Block sign;
+ public String[] lines;
/**
* Create a new instance of the MagicSign
@@ -56,6 +57,7 @@ public static void saveConfig(ConfigurationSection section) {
*/
public MagicSign(Block sign, String[] lines) throws InvalidSignException {
this.sign = sign;
+ this.lines = lines;
}
/**
@@ -105,10 +107,30 @@ public Location getLocation() {
* @return The use permission.
*/
public String getUsePermission() {
- UsePermission usePerm = getClass().getAnnotation(UsePermission.class);
+ MagicSignInfo signInfo = getClass().getAnnotation(MagicSignInfo.class);
- if (usePerm != null) {
- return usePerm.value();
+ if (signInfo != null) {
+ return signInfo.usePerm();
+ } else {
+ return null;
+ }
+ }
+
+ public String getFriendlyName() {
+ MagicSignInfo signInfo = getClass().getAnnotation(MagicSignInfo.class);
+
+ if (signInfo != null) {
+ return signInfo.friendlyName();
+ } else {
+ return null;
+ }
+ }
+
+ public String getDescription() {
+ MagicSignInfo signInfo = getClass().getAnnotation(MagicSignInfo.class);
+
+ if (signInfo != null) {
+ return signInfo.description();
} else {
return null;
}
View
6 src/main/java/de/philworld/bukkit/magicsigns/signs/PurchasableMagicSign.java
@@ -46,6 +46,12 @@ public Price getPrice() {
return price;
}
+ public boolean isFree() {
+ if(price == null)
+ return true;
+ return price.isFree();
+ }
+
/**
* Withdraws the price of this sign from the bank account of the player.
*
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/RocketSign.java
@@ -6,11 +6,10 @@
import org.bukkit.util.Vector;
import de.philworld.bukkit.magicsigns.InvalidSignException;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.config.ConfigurationBase;
import de.philworld.bukkit.magicsigns.config.Setting;
import de.philworld.bukkit.magicsigns.config.SettingBase;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
@@ -20,8 +19,11 @@
* For example: <code>0,300,0</code> to make a huge jump in the air.
*
*/
-@BuildPermission("magicsigns.rocket.create")
-@UsePermission("magicsigns.rocket.use")
+@MagicSignInfo(
+ friendlyName = "Rocket sign",
+ description = "A sign that can modify player's velocity.",
+ buildPerm = "magicsigns.rocket.create",
+ usePerm = "magicsigns.rocket.use")
public class RocketSign extends PurchasableMagicSign {
public static LocalConfiguration config;
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/SpeedSign.java
@@ -6,8 +6,7 @@
import org.bukkit.potion.PotionEffectType;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
/**
* A sign that applies the speed potion effect to players.
@@ -16,8 +15,11 @@
* amplifier.
*
*/
-@BuildPermission("magicsigns.speed.create")
-@UsePermission("magicsigns.speed.use")
+@MagicSignInfo(
+ friendlyName = "Speed sign",
+ description = "A sign that applies the speed potion effect to players.",
+ buildPerm = "magicsigns.speed.create",
+ usePerm = "magicsigns.speed.use")
public class SpeedSign extends PurchasableMagicSign {
private final int duration;
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/SurvivalModeSign.java
@@ -5,11 +5,13 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
-@BuildPermission("magicsigns.survival.create")
-@UsePermission("magicsigns.survival.use")
+@MagicSignInfo(
+ friendlyName = "Survival Mode sign",
+ description = "A sign that sets the player's game mode to Creative Mode.",
+ buildPerm = "magicsigns.survival.create",
+ usePerm = "magicsigns.survival.use")
public class SurvivalModeSign extends PurchasableMagicSign {
public static boolean takeAction(Block sign, String[] lines) {
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/TeleportSign.java
@@ -5,8 +5,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.util.MSMsg;
/**
@@ -15,8 +14,11 @@
* Line 2 must contain coordinates (comma-separated, e.g. <code>20,20,20</code>)
*
*/
-@BuildPermission("magicsigns.teleport.create")
-@UsePermission("magicsigns.teleport.use")
+@MagicSignInfo(
+ friendlyName = "Teleport sign",
+ description = "Sign that allows teleportation.",
+ buildPerm = "magicsigns.teleport.create",
+ usePerm = "magicsigns.teleport.use")
public class TeleportSign extends PurchasableMagicSign {
private final Location destination;
View
15 src/main/java/de/philworld/bukkit/magicsigns/signs/command/CommandSign.java
@@ -12,10 +12,9 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
import de.philworld.bukkit.magicsigns.MagicSigns;
import de.philworld.bukkit.magicsigns.config.ConfigurationBase;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
import de.philworld.bukkit.magicsigns.signs.PurchasableMagicSign;
/**
@@ -24,8 +23,11 @@
* <code>%p</code> will be replaced with the player's name.
*
*/
-@BuildPermission("magicsigns.command.create")
-@UsePermission("magicsigns.command.use")
+@MagicSignInfo(
+ friendlyName = "Command sign",
+ description = "A sign that executes commands on the sign in the player's context.",
+ buildPerm = "magicsigns.command.create",
+ usePerm = "magicsigns.command.use")
public class CommandSign extends PurchasableMagicSign {
public static final String COMMAND_DELIMITER = " && ";
@@ -74,7 +76,7 @@ public void load(ConfigurationSection section) {
@Override
public ConfigurationSection save(ConfigurationSection section) {
- return section; // nothing to save, just read
+ return section; // nothing changes at runtime
}
}
@@ -88,7 +90,8 @@ public static void loadConfig(ConfigurationSection section) {
* Splits the text by the backslash and replaces macros. Returns a list
* representing all the commands.
*
- * <p>TODO Catch endless loops of self-recalling macros.
+ * <p>
+ * TODO Catch endless loops of self-recalling macros.
*
* @param text
* - The text to format
View
10 src/main/java/de/philworld/bukkit/magicsigns/signs/command/ConsoleCommandSign.java
@@ -5,8 +5,7 @@
import org.bukkit.event.player.PlayerInteractEvent;
import de.philworld.bukkit.magicsigns.InvalidSignException;
-import de.philworld.bukkit.magicsigns.permissions.BuildPermission;
-import de.philworld.bukkit.magicsigns.permissions.UsePermission;
+import de.philworld.bukkit.magicsigns.MagicSignInfo;
/**
* A sign that executes commands in the server's context. Caution!
@@ -16,8 +15,11 @@
* <code>%p</code> will be replaced with the player's name.
*
*/
-@BuildPermission("magicsigns.consolecommand.create")
-@UsePermission("magicsigns.consolecommand.use")
+@MagicSignInfo(
+ friendlyName = "Console Command sign",
+ description = "A sign that executes commands in the server's context. Caution!",
+ buildPerm = "magicsigns.consolecommand.create",
+ usePerm = "magicsigns.consolecommand.use")
public class ConsoleCommandSign extends CommandSign {
public static boolean takeAction(Block sign, String[] lines) {
View
5 src/main/resources/plugin.yml
@@ -1,4 +1,7 @@
name: MagicSigns
main: de.philworld.bukkit.magicsigns.MagicSigns
version: $MAVEN-VERSION-NUMBER$
-softdepend: [Vault]
+softdepend: [Vault]
+commands:
+ ms:
+ description: Base MagicSigns command.
Please sign in to comment.
Something went wrong with that request. Please try again.