This commit is contained in:
FrozenCow 2011-03-11 15:18:41 +01:00
parent cbe562d33d
commit 70429dc5a4
2 changed files with 70 additions and 23 deletions

View File

@ -36,6 +36,13 @@
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>com.nijikokun.bukkit.Permissions.Permissions</groupId>
<artifactId>Permissions</artifactId>
<version>2.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/../Permissions.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>

View File

@ -30,6 +30,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.WorldEvent; import org.bukkit.event.world.WorldEvent;
import org.bukkit.event.world.WorldListener; import org.bukkit.event.world.WorldListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.config.Configuration; import org.bukkit.util.config.Configuration;
@ -44,8 +46,28 @@ import org.dynmap.web.handlers.FilesystemHandler;
import org.dynmap.web.handlers.SendMessageHandler; import org.dynmap.web.handlers.SendMessageHandler;
import org.dynmap.web.handlers.SendMessageHandler.Message; import org.dynmap.web.handlers.SendMessageHandler.Message;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
public class DynmapPlugin extends JavaPlugin { public class DynmapPlugin extends JavaPlugin {
public static PermissionHandler Permissions = null;
public void setupPermissions() {
Plugin scrap = this.getServer().getPluginManager().getPlugin("Permissions");
PluginDescriptionFile pdfFile = this.getDescription();
if (this.Permissions == null) {
if (scrap!= null) {
this.getServer().getPluginManager().enablePlugin(scrap);
this.Permissions = ((Permissions) scrap).getHandler();
}
else {
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " not enabled. Permissions not detected");
this.getServer().getPluginManager().disablePlugin(this);
}
}
}
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
public HttpServer webServer = null; public HttpServer webServer = null;
@ -72,6 +94,9 @@ public class DynmapPlugin extends JavaPlugin {
} }
public void onEnable() { public void onEnable() {
setupPermissions();
dataDirectory = this.getDataFolder(); dataDirectory = this.getDataFolder();
configuration = new Configuration(new File(this.getDataFolder(), "configuration.txt")); configuration = new Configuration(new File(this.getDataFolder(), "configuration.txt"));
@ -291,37 +316,52 @@ public class DynmapPlugin extends JavaPlugin {
player = (Player) sender; player = (Player) sender;
if (args.length > 0) { if (args.length > 0) {
if (args[0].equals("render")) { if (args[0].equals("render")) {
if (sender instanceof Player) { if (player == null || DynmapPlugin.Permissions.has((Player) sender, "dynmap.render") || DynmapPlugin.Permissions.has((Player) sender, "dynmap.*")) {
int invalidates = mapManager.touch(((Player) sender).getLocation()); if (sender instanceof Player) {
sender.sendMessage("Queued " + invalidates + " tiles" + (invalidates == 0 ? " (world is not loaded?)" : "...")); int invalidates = mapManager.touch(((Player) sender).getLocation());
sender.sendMessage("Queued " + invalidates + " tiles" + (invalidates == 0 ? " (world is not loaded?)" : "..."));
return true;
}
} else if (player != null) {
player.sendMessage("You don't have permission to use this command!");
return true; return true;
} }
} else if (args[0].equals("hide")) { } else if (args[0].equals("hide")) {
if (args.length == 1 && player != null) { if (player == null || DynmapPlugin.Permissions.has((Player) sender, "dynmap.showhide") || DynmapPlugin.Permissions.has((Player) sender, "dynmap.*")) {
playerList.hide(player.getName()); if (args.length == 1 && player != null) {
sender.sendMessage("You are now hidden on Dynmap."); playerList.hide(player.getName());
return true; sender.sendMessage("You are now hidden on Dynmap.");
} else { return true;
for (int i = 1; i < args.length; i++) { } else {
playerList.hide(args[i]); for (int i = 1; i < args.length; i++) {
sender.sendMessage(args[i] + " is now hidden on Dynmap."); playerList.hide(args[i]);
} sender.sendMessage(args[i] + " is now hidden on Dynmap.");
}
return true;
}
} else if (player != null) {
player.sendMessage("You don't have permission to use this command!");
return true; return true;
} }
} else if (args[0].equals("show")) { } else if (args[0].equals("show")) {
if (args.length == 1 && player != null) { if (player == null || DynmapPlugin.Permissions.has((Player) sender, "dynmap.showhide") || DynmapPlugin.Permissions.has((Player) sender, "dynmap.*")) {
playerList.show(player.getName()); if (args.length == 1 && player != null) {
sender.sendMessage("You are now visible on Dynmap."); playerList.show(player.getName());
return true; sender.sendMessage("You are now visible on Dynmap.");
} else { return true;
for (int i = 1; i < args.length; i++) { } else {
playerList.show(args[i]); for (int i = 1; i < args.length; i++) {
sender.sendMessage(args[i] + " is now visible on Dynmap."); playerList.show(args[i]);
} sender.sendMessage(args[i] + " is now visible on Dynmap.");
}
return true;
}
} else if (player != null) {
player.sendMessage("You don't have permission to use this command!");
return true; return true;
} }
} else if (args[0].equals("fullrender")) { } else if (args[0].equals("fullrender")) {
if (player == null || player.isOp()) { if (player == null || DynmapPlugin.Permissions.has((Player) sender, "dynmap.fullrender") || DynmapPlugin.Permissions.has((Player) sender, "dynmap.*")) {
if (args.length > 1) { if (args.length > 1) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
World w = getServer().getWorld(args[i]); World w = getServer().getWorld(args[i]);
@ -333,7 +373,7 @@ public class DynmapPlugin extends JavaPlugin {
return true; return true;
} }
} else if (player != null) { } else if (player != null) {
player.sendMessage("Only OPs are allowed to use this command!"); player.sendMessage("You don't have permission to use this command!");
return true; return true;
} }
} }