Skip to content

Commit

Permalink
Version 0.4.2 (by C45Y), reconstituted from installed binary (sources…
Browse files Browse the repository at this point in the history
… lost).

Support the concept of "public" warps that can be used without requiring a
permission node and the dynamic registration of new shortcut commands for
players to use these warps.
  • Loading branch information
totemo committed Apr 19, 2016
1 parent f5f6fed commit 73dfbeb
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target/
*.jar
*.class
/classes/
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nu.nerd</groupId>
<artifactId>TPControl</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>
<packaging>jar</packaging>
<name>TPControl</name>
<url>https://github.com/NerdNu/TPControl</url>
Expand Down
14 changes: 10 additions & 4 deletions src/nu/nerd/tpcontrol/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import java.util.TreeMap;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.ConfigurationSection;

public class Configuration {
public static String[] relationships = {"blocked", "default", "friends"};
public static String[] modes = {"deny", "ask", "allow"};

private final TPControl plugin;

public String MIN_GROUP;
public String DEFAULT_MODE;
public int ASK_EXPIRE;
Expand All @@ -35,7 +36,7 @@ public void load() {

MODE_MAP = new HashMap<String, String>();
WARPS = new TreeMap<String, Warp>();

String key;
for(String m : modes) {
for(String r : relationships) {
Expand All @@ -48,7 +49,7 @@ public void load() {
}
}
}

DEFAULT_MODE = plugin.getConfig().getString("default-mode");
MIN_GROUP = plugin.getConfig().getString("min-group");
ASK_EXPIRE = plugin.getConfig().getInt("ask-expire");
Expand Down Expand Up @@ -115,6 +116,11 @@ public void load() {
}

WARPS.put(warpName.toLowerCase(), warp);
for (String shortcut : shortcuts) {
ShortcutCommand shortcutCommand = new ShortcutCommand(shortcut, this.plugin, warp);
this.plugin.registerCommand(new String[]{shortcut});
this.plugin.getCommand(shortcut).setExecutor(shortcutCommand);
}
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/nu/nerd/tpcontrol/ShortcutCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nu.nerd.tpcontrol;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class ShortcutCommand implements CommandExecutor {
protected String name;
protected TPControl plugin;
protected Warp warp;

public ShortcutCommand(String name, TPControl plugin, Warp warp) {
this.name = name;
this.plugin = plugin;
this.warp = warp;
}

public boolean onCommand(CommandSender sender, Command command, String name, String[] args) {
GhostCommand ghostCommand = new GhostCommand("warp");
this.plugin.onCommand(sender, ghostCommand, "warp", new String[] { this.warp.getName() });
return false;
}
}
Loading

1 comment on commit 73dfbeb

@stevommmm
Copy link
Contributor

Choose a reason for hiding this comment

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

not authored by me....

Please sign in to comment.