Skip to content

Commit

Permalink
pre-alpha test for more than one permissions plugin. Need to fix /whois
Browse files Browse the repository at this point in the history
  • Loading branch information
GuntherDW committed Oct 2, 2011
1 parent 92738e1 commit 59882ab
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 138 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TweakcraftUtils name: TweakcraftUtils
main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils
version: 2.2.5-rc1 version: 2.2.6-pre-alpha
authors: authors:
- GuntherDW - GuntherDW
- Meaglin - Meaglin
Expand Down
4 changes: 2 additions & 2 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public boolean sendMessage(CommandSender sender, String message) {
Player p = (Player) sender; Player p = (Player) sender;
// World w = p.getWorld(); // World w = p.getWorld();
rmsg.setField("world", p.getWorld().getName()); rmsg.setField("world", p.getWorld().getName());
rmsg.setField("prefix", plugin.getPermissionHandler().getUserPrefix(p.getWorld().getName(), p.getName())); rmsg.setField("prefix", plugin.getPermissionsResolver().getUserPrefix(p.getWorld().getName(), p));
rmsg.setField("suffix", plugin.getPermissionHandler().getUserSuffix(p.getWorld().getName(), p.getName())); rmsg.setField("suffix", plugin.getPermissionsResolver().getUserSuffix(p.getWorld().getName(), p));
} }
rmsg.post(); rmsg.post();


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
String name = p.getName(); String name = p.getName();
// p.setDisplayName(plugin.getPlayerColor(name, false) + name + ChatColor.WHITE); // p.setDisplayName(plugin.getPlayerColor(name, false) + name + ChatColor.WHITE);
String displayName = plugin.getNickWithColors(p.getName()); String displayName = plugin.getNickWithColors(p.getName());
String ldisplayname = displayName.substring(0, displayName.length()-2);
p.setDisplayName(displayName); p.setDisplayName(displayName);
if(displayName.length()<16) if(ldisplayname.length()<16)
p.setListName(displayName); p.setListName(ldisplayname);
} }
plugin.getPlayerListener().reloadInvisTable(); plugin.getPlayerListener().reloadInvisTable();
/** /**
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] rea
groups = grouparg.split(","); groups = grouparg.split(",");
for(String gr : groups) { for(String gr : groups) {
for(Player p : plugin.getServer().getOnlinePlayers()) { 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)) if(!recipients.contains(p))
recipients.add(p); recipients.add(p);
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.guntherdw.bukkit.tweakcraft.Commands.General; package com.guntherdw.bukkit.tweakcraft.Commands.General;


import com.guntherdw.bukkit.tweakcraft.Commands.iCommand; 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.CommandSenderException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException; import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException; import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
Expand All @@ -36,37 +37,65 @@
public class CommandGetSpawn implements iCommand { public class CommandGetSpawn implements iCommand {
@Override @Override
public boolean executeCommand(CommandSender sender, String command, String[] realargs, TweakcraftUtils plugin) 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); ArgumentParser ap = new ArgumentParser(realargs);
String world = ap.getString("w", null); String world = ap.getString("w", null);
String player = ap.getString("p", null);
String[] args = ap.getNormalArgs(); 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; World w = null;

boolean playerMode = pl!=null;
if(world!=null)
w = plugin.getServer().getWorld(world); if(sender instanceof Player) {
else {
if(sender instanceof Player) // Default mode : self-spawn
w = ((Player)sender).getWorld(); 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()); x = Math.round((float) spawn.getX());
y = Math.round((float) spawn.getY()); y = Math.round((float) spawn.getY());
z = Math.round((float) spawn.getZ()); z = Math.round((float) spawn.getZ());
sender.sendMessage(ChatColor.YELLOW+ "X:"+x+" Y:"+y+" Z:"+z); sender.sendMessage(ChatColor.YELLOW+ "X:"+x+" Y:"+y+" Z:"+z);

if(playerMode)
sender.sendMessage(ChatColor.YELLOW+"World : "+spawn.getWorld().getName());

return true; return true;
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException; import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException; import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils; 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.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;


import java.util.List;

/** /**
* @author GuntherDW * @author GuntherDW
*/ */
Expand Down Expand Up @@ -64,24 +57,14 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
boolean online = (who!=null); boolean online = (who!=null);


if(who==null) { // Is it an offline player? Check permissions if(who==null) { // Is it an offline player? Check permissions
if(plugin.getPermissionHandler()!=null) { /* if(plugin.getPermissionHandler()!=null) {
// Check for nicks // Check for nicks
String pname = args[0]; String pname = args[0];
String findnick = plugin.getPlayerListener().findPlayerNameByNick(pname); String findnick = plugin.getPlayerListener().findPlayerNameByNick(pname);
if(findnick != null) pname = findnick; if(findnick != null) pname = findnick;
PermissionHandler handler = plugin.getPermissionHandler(); 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(); String wname = plugin.getServer().getWorlds().get(0).getName();
User user = plugin.getPermissionHandler().getUserObject(wname, pname); User user = plugin.getPermissionHandler().getUserObject(wname, pname);
// groups = plugin.getPermissionHandler().getPrimaryGroup(wname, args[0]); // groups = plugin.getPermissionHandler().getPrimaryGroup(wname, args[0]);
Expand All @@ -93,15 +76,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
} else { } else {
playername = who.getName(); playername = who.getName();
if(plugin.getPermissionHandler()!=null) { 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(); String wname = plugin.getServer().getWorlds().get(0).getName();
groups = plugin.getPermissionHandler().getPrimaryGroup(wname, playername); groups = plugin.getPermissionHandler().getPrimaryGroup(wname, playername);
} }
Expand All @@ -119,7 +94,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
sender.sendMessage(ChatColor.YELLOW + "IP: " + who.getAddress().getAddress().getHostName()); sender.sendMessage(ChatColor.YELLOW + "IP: " + who.getAddress().getAddress().getHostName());
} else { } else {
throw new CommandException("Can't find player!"); throw new CommandException("Can't find player!");
} */ }
} else { } else {
throw new CommandUsageException("I need a player!"); throw new CommandUsageException("I need a player!");
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.guntherdw.bukkit.tweakcraft.Configuration; package com.guntherdw.bukkit.tweakcraft.Configuration;


import com.guntherdw.bukkit.tweakcraft.Packages.LockdownLocation; import com.guntherdw.bukkit.tweakcraft.Packages.LockdownLocation;
import com.guntherdw.bukkit.tweakcraft.Tools.PermissionsResolver;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils; import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
Expand Down Expand Up @@ -75,6 +76,8 @@ public class ConfigurationHandler {
public boolean enablemod_InfDura = false; public boolean enablemod_InfDura = false;
public boolean enableExperienceOrbsHalt = false; public boolean enableExperienceOrbsHalt = false;


public PermissionsResolver.PermissionResolvingMode permissoinsResolvingMode = null;

public boolean enableRespawnHook = false; public boolean enableRespawnHook = false;
public boolean enableRespawnHeal = false; public boolean enableRespawnHeal = false;
// public int portalSearchRadius = 128; // public int portalSearchRadius = 128;
Expand Down Expand Up @@ -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."); 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); this.extrahelphide = plugin.getConfiguration().getStringList("extrahelp.hide", null);
if (plugin.getConfiguration().getBoolean("PlayerHistory.enabled", false)) { if (plugin.getConfiguration().getBoolean("PlayerHistory.enabled", false)) {
plugin.getLogger().info("[TweakcraftUtils] Keeping player history!"); plugin.getLogger().info("[TweakcraftUtils] Keeping player history!");
Expand Down
Loading

0 comments on commit 59882ab

Please sign in to comment.