Skip to content

Commit

Permalink
Made call and bring messages actually configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Dec 23, 2012
1 parent 17cc5d4 commit 68f5e78
Showing 1 changed file with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.bukkit.event.player.PlayerTeleportEvent;

import com.sk89q.commandbook.CommandBook;
import com.sk89q.commandbook.CommandBookUtil;
import com.sk89q.commandbook.session.SessionComponent;
import com.sk89q.commandbook.session.SessionFactory;
import com.sk89q.commandbook.util.LegacyBukkitCompat;
Expand Down Expand Up @@ -77,13 +78,13 @@ public LocalConfiguration getConfig() {
}

public static class LocalConfiguration extends ConfigurationBase {
@Setting("call-message.sender") public String callMessageSender = "Teleport request sent.";
@Setting("call-message.sender") public String callMessageSender = "`yTeleport request sent.";
@Setting("call-message.target") public String callMessageTarget =
"**TELEPORT** %s requests a teleport! Use /bring <name> to accept.";
"`c**TELEPORT** %cname%`c requests a teleport! Use /bring <name> to accept.";
@Setting("call-message.too-soon") public String callMessageTooSoon = "Wait a bit before asking again.";
@Setting("bring-message.sender") public String bringMessageSender = "Player teleported.";
@Setting("bring-message.sender") public String bringMessageSender = "`yPlayer teleported.";
@Setting("bring-message.target") public String bringMessageTarget =
"Your teleport request to %s was accepted.";
"`yYour teleport request to %cname%`y was accepted.";
@Setting("bring-message.no-perm") public String bringMessageNoPerm = "That person didn't request a " +
"teleport (recently) and you don't have permission to teleport anyone.";
}
Expand Down Expand Up @@ -226,9 +227,16 @@ public void requestTeleport(CommandContext args, CommandSender sender) throws Co
sessions.getSession(TeleportSession.class, player).checkLastTeleportRequest(target);
sessions.getSession(TeleportSession.class, target).addBringable(player);

sender.sendMessage(ChatColor.YELLOW.toString() + config.callMessageSender);
target.sendMessage(ChatColor.AQUA + String.format(config.callMessageTarget,
PlayerUtil.toColoredName(sender, ChatColor.AQUA)));
String senderMessage = CommandBookUtil.replaceColorMacros(
CommandBookUtil.replaceMacros(sender, config.callMessageSender))
.replaceAll("%ctarget%", PlayerUtil.toColoredName(target, null))
.replaceAll("%target%", PlayerUtil.toName(target));
String targetMessage = CommandBookUtil.replaceColorMacros(
CommandBookUtil.replaceMacros(sender, config.callMessageTarget))
.replaceAll("%ctarget%", PlayerUtil.toColoredName(target, null))
.replaceAll("%target%", PlayerUtil.toName(target));
sender.sendMessage(senderMessage);
target.sendMessage(targetMessage);
}

@Command(aliases = {"bring", "tphere", "summon", "s"}, usage = "<target>", desc = "Bring a player to you", min = 1, max = 1)
Expand All @@ -238,9 +246,16 @@ public void bring(CommandContext args, CommandSender sender) throws CommandExcep
Player target = PlayerUtil.matchSinglePlayer(sender, args.getString(0));

if (sessions.getSession(TeleportSession.class, player).isBringable(target)) {
sender.sendMessage(ChatColor.YELLOW + config.bringMessageSender);
target.sendMessage(ChatColor.YELLOW +
String.format(config.bringMessageTarget, PlayerUtil.toColoredName(sender, ChatColor.YELLOW)));
String senderMessage = CommandBookUtil.replaceColorMacros(
CommandBookUtil.replaceMacros(sender, config.bringMessageSender))
.replaceAll("%ctarget%", PlayerUtil.toColoredName(target, null))
.replaceAll("%target%", target.getName());
String targetMessage = CommandBookUtil.replaceColorMacros(
CommandBookUtil.replaceMacros(sender, config.bringMessageTarget))
.replaceAll("%ctarget%", PlayerUtil.toColoredName(target, null))
.replaceAll("%target%", target.getName());
sender.sendMessage(senderMessage);
target.sendMessage(targetMessage);
target.teleport(player);
} else {
throw new CommandException(config.bringMessageNoPerm);
Expand Down

3 comments on commit 68f5e78

@Mikeygold50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the latest successful build which had the above features added, I now get this error in my Bukkit 1.4.6 R0.3 console,

2013-01-02 21:15:21 [SEVERE] Could not load 'plugins/CommandBook.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/sk89q/minecraft/util/commands/CommandPermissionsException
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.java:239)
at org.bukkit.craftbukkit.v1_4_6.CraftServer.(CraftServer.java:217)
at net.minecraft.server.v1_4_6.PlayerList.(PlayerList.java:52)
at net.minecraft.server.v1_4_6.DedicatedPlayerList.(SourceFile:11)
at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:104)
at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)
at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
Caused by: java.lang.NoClassDefFoundError: com/sk89q/minecraft/util/commands/CommandPermissionsException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.sk89q.minecraft.util.commands.CommandPermissionsException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 12 more

@zml2008
Copy link
Collaborator

@zml2008 zml2008 commented on 68f5e78 Jan 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mikeygold50 You need WorldEdit for CommandBook to work.

@Mikeygold50
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zml2008 Sorry, for my reluctance to look at the installation instructions.

Please sign in to comment.