Permalink
Browse files

pre-alpha test for more than one permissions plugin. Need to fix /whois

  • Loading branch information...
GuntherDW committed Oct 2, 2011
1 parent 92738e1 commit 59882ab323bc7f17609a5f942972a8359223c1b9
View
@@ -1,6 +1,6 @@
name: TweakcraftUtils
main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils
-version: 2.2.5-rc1
+version: 2.2.6-pre-alpha
authors:
- GuntherDW
- Meaglin
@@ -86,8 +86,8 @@ public boolean sendMessage(CommandSender sender, String message) {
Player p = (Player) sender;
// World w = p.getWorld();
rmsg.setField("world", p.getWorld().getName());
- rmsg.setField("prefix", plugin.getPermissionHandler().getUserPrefix(p.getWorld().getName(), p.getName()));
- rmsg.setField("suffix", plugin.getPermissionHandler().getUserSuffix(p.getWorld().getName(), p.getName()));
+ rmsg.setField("prefix", plugin.getPermissionsResolver().getUserPrefix(p.getWorld().getName(), p));
+ rmsg.setField("suffix", plugin.getPermissionsResolver().getUserSuffix(p.getWorld().getName(), p));
}
rmsg.post();
@@ -65,9 +65,10 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
String name = p.getName();
// p.setDisplayName(plugin.getPlayerColor(name, false) + name + ChatColor.WHITE);
String displayName = plugin.getNickWithColors(p.getName());
+ String ldisplayname = displayName.substring(0, displayName.length()-2);
p.setDisplayName(displayName);
- if(displayName.length()<16)
- p.setListName(displayName);
+ if(ldisplayname.length()<16)
+ p.setListName(ldisplayname);
}
plugin.getPlayerListener().reloadInvisTable();
/**
@@ -53,7 +53,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] rea
groups = grouparg.split(",");
for(String gr : groups) {
for(Player p : plugin.getServer().getOnlinePlayers()) {
- if(plugin.getPermissionHandler().getPrimaryGroup("world", p.getName()).equals(gr)) {
+ if(plugin.getPermissionsResolver().inSingleGroup("world", gr, p)) {
if(!recipients.contains(p))
recipients.add(p);
}
@@ -19,6 +19,7 @@
package com.guntherdw.bukkit.tweakcraft.Commands.General;
import com.guntherdw.bukkit.tweakcraft.Commands.iCommand;
+import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
@@ -36,37 +37,65 @@
public class CommandGetSpawn implements iCommand {
@Override
public boolean executeCommand(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin)
- throws PermissionsException, CommandSenderException, CommandUsageException {
+ throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
- if(sender instanceof Player)
- if(!plugin.check((Player)sender, getPermissionSuffix()))
- throw new PermissionsException(command);
ArgumentParser ap = new ArgumentParser(realargs);
String world = ap.getString("w", null);
+ String player = ap.getString("p", null);
String[] args = ap.getNormalArgs();
- float x,y,z;
-
+ String permString = this.getPermissionSuffix();
+
+ float x,y,z;
+ Player pl = player!=null?plugin.findPlayerasPlayer(player):null;
World w = null;
-
- if(world!=null)
- w = plugin.getServer().getWorld(world);
- else {
- if(sender instanceof Player)
- w = ((Player)sender).getWorld();
+ boolean playerMode = pl!=null;
+
+ if(sender instanceof Player) {
+
+ // Default mode : self-spawn
+ if(player==null && world==null) {
+ playerMode = true;
+ pl = (Player) sender;
+ }
+
+ if(playerMode && pl.getName().equals(((Player)sender).getName())) permString+=".self";
+ if(!plugin.check((Player)sender, permString))
+ throw new PermissionsException(command);
+ }
+
+
+ if(!playerMode) {
+ if(world!=null)
+ w = plugin.getServer().getWorld(world);
+ else {
+ if(sender instanceof Player)
+ w = ((Player)sender).getWorld();
+ }
+ }
+
+ if(w==null && pl==null)
+ throw new CommandUsageException("I didn't get a good world/player to fetch?");
+
+ sender.sendMessage(ChatColor.YELLOW + "Spawn position for "+(w!=null?w.getName():pl.getDisplayName()));
+ // Location spawn = w.getSpawnLocation();
+ Location spawn = null;
+ if(w != null) spawn = w.getSpawnLocation();
+ if(pl != null) {
+ spawn = pl.getBedSpawnLocation();
+ if(spawn==null) {// NO BED
+ throw new CommandException("That player doesn't have a custom bed spawn location.");
+ }
}
- if(w==null)
- throw new CommandUsageException("I didn't get a good world to fetch?");
-
- sender.sendMessage(ChatColor.YELLOW + "Spawn position for "+w.getName());
- Location spawn = w.getSpawnLocation();
x = Math.round((float) spawn.getX());
y = Math.round((float) spawn.getY());
z = Math.round((float) spawn.getZ());
sender.sendMessage(ChatColor.YELLOW+ "X:"+x+" Y:"+y+" Z:"+z);
-
+ if(playerMode)
+ sender.sendMessage(ChatColor.YELLOW+"World : "+spawn.getWorld().getName());
+
return true;
}
@@ -24,16 +24,9 @@
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
-import com.nijiko.permissions.Group;
-import com.nijiko.permissions.PermissionHandler;
-import com.nijiko.permissions.User;
-import org.bukkit.ChatColor;
-import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import java.util.List;
-
/**
* @author GuntherDW
*/
@@ -64,24 +57,14 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
boolean online = (who!=null);
if(who==null) { // Is it an offline player? Check permissions
- if(plugin.getPermissionHandler()!=null) {
+ /* if(plugin.getPermissionHandler()!=null) {
// Check for nicks
String pname = args[0];
String findnick = plugin.getPlayerListener().findPlayerNameByNick(pname);
if(findnick != null) pname = findnick;
PermissionHandler handler = plugin.getPermissionHandler();
-
- /* for(World w : plugin.getServer().getWorlds()) {
- String groupw = plugin.getPermissionHandler().getPrimaryGroup(w.getName(), args[0]);
- if(groupw!=null){
- groups+=w.getName()+": "+groupw+",";
- }
- }
- if(groups.length()>0) {
- groups = groups.substring(0, groups.length()-1);
- } */
String wname = plugin.getServer().getWorlds().get(0).getName();
User user = plugin.getPermissionHandler().getUserObject(wname, pname);
// groups = plugin.getPermissionHandler().getPrimaryGroup(wname, args[0]);
@@ -93,15 +76,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
} else {
playername = who.getName();
if(plugin.getPermissionHandler()!=null) {
- /* for(World w : plugin.getServer().getWorlds()) {
- String groupw = plugin.getPermissionHandler().getPrimaryGroup(w.getName(), args[0]);
- if(groupw!=null){
- groups+=w.getName()+": "+groupw+",";
- }
- }
- if(groups.length()>0)
- groups = groups.substring(0, groups.length()-1); */
String wname = plugin.getServer().getWorlds().get(0).getName();
groups = plugin.getPermissionHandler().getPrimaryGroup(wname, playername);
}
@@ -119,7 +94,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
sender.sendMessage(ChatColor.YELLOW + "IP: " + who.getAddress().getAddress().getHostName());
} else {
throw new CommandException("Can't find player!");
- }
+ */ }
} else {
throw new CommandUsageException("I need a player!");
}
@@ -19,6 +19,7 @@
package com.guntherdw.bukkit.tweakcraft.Configuration;
import com.guntherdw.bukkit.tweakcraft.Packages.LockdownLocation;
+import com.guntherdw.bukkit.tweakcraft.Tools.PermissionsResolver;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -75,6 +76,8 @@
public boolean enablemod_InfDura = false;
public boolean enableExperienceOrbsHalt = false;
+ public PermissionsResolver.PermissionResolvingMode permissoinsResolvingMode = null;
+
public boolean enableRespawnHook = false;
public boolean enableRespawnHeal = false;
// public int portalSearchRadius = 128;
@@ -149,6 +152,26 @@ public void reloadConfig() {
plugin.getLogger().info("[TweakcraftUtils] WARNING: Can't find plugin with name "+plist+"! Not adding to the help list.");
}
}
+ /* this.enableBukkitPermissions = plugin.getConfiguration().getBoolean("Permissions.BukkitPerms", false);
+ if(this.enableBukkitPermissions)
+ plugin.getLogger().warning("[TweakcraftUtils] Enabling Bukkit perms resolving, this is an experimental feature, expect bugs!"); */
+ String presolver = plugin.getConfiguration().getString("Permissions.resolver", null);
+ if(presolver==null) presolver = "permissions";
+
+ if(presolver.equals("permissions")) {
+ permissoinsResolvingMode = PermissionsResolver.PermissionResolvingMode.NIJIPERMS;
+ } else if(presolver.equals("permissionsex")) {
+ permissoinsResolvingMode = PermissionsResolver.PermissionResolvingMode.PERMISSIONSEX;
+ } else if(presolver.equals("bukkitperms")) {
+ permissoinsResolvingMode = PermissionsResolver.PermissionResolvingMode.BUKKIT;
+ }
+ plugin.getPermissionsResolver().setMode(permissoinsResolvingMode);
+
+ if(permissoinsResolvingMode!= PermissionsResolver.PermissionResolvingMode.NIJIPERMS) {
+ plugin.getLogger().warning("[TweakcraftUtils] Other permissions resolver selected than Nijokun's Permissiosn plugin, this is experimental!");
+ }
+
+
this.extrahelphide = plugin.getConfiguration().getStringList("extrahelp.hide", null);
if (plugin.getConfiguration().getBoolean("PlayerHistory.enabled", false)) {
plugin.getLogger().info("[TweakcraftUtils] Keeping player history!");
Oops, something went wrong.

0 comments on commit 59882ab

Please sign in to comment.