mirror of
https://github.com/MilkBowl/Vault.git
synced 2025-01-30 12:01:34 +01:00
some more work to GM chat handling, now allows for player
setting/getting of info vars.
This commit is contained in:
parent
7c23cb38d3
commit
af3a3f955d
@ -6,6 +6,8 @@ import net.milkbowl.vault.chat.Chat;
|
|||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
import org.anjocaido.groupmanager.GroupManager;
|
import org.anjocaido.groupmanager.GroupManager;
|
||||||
|
import org.anjocaido.groupmanager.data.User;
|
||||||
|
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -15,7 +17,6 @@ import org.bukkit.event.server.PluginDisableEvent;
|
|||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class Chat_GroupManager extends Chat {
|
public class Chat_GroupManager extends Chat {
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
@ -92,12 +93,24 @@ public class Chat_GroupManager extends Chat {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||||
return perms.getPermissionInteger(playerName, node);
|
OverloadedWorldHolder owh;
|
||||||
|
if (world == null) {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldData(world);
|
||||||
|
}
|
||||||
|
User user = owh.getUser(playerName);
|
||||||
|
if (user == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
Integer val = user.getVariables().getVarInteger(node);
|
||||||
|
return val != null ? val : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
|
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
|
||||||
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
|
setPlayerValue(world, playerName, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,12 +125,24 @@ public class Chat_GroupManager extends Chat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
|
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
|
||||||
return perms.getPermissionDouble(playerName, node);
|
OverloadedWorldHolder owh;
|
||||||
|
if (world == null) {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldData(world);
|
||||||
|
}
|
||||||
|
User user = owh.getUser(playerName);
|
||||||
|
if (user == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
Double val = user.getVariables().getVarDouble(node);
|
||||||
|
return val != null ? val : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
|
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
|
||||||
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
|
setPlayerValue(world, playerName, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -132,12 +157,24 @@ public class Chat_GroupManager extends Chat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
|
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
|
||||||
return perms.getPermissionBoolean(playerName, node);
|
OverloadedWorldHolder owh;
|
||||||
|
if (world == null) {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldData(world);
|
||||||
|
}
|
||||||
|
User user = owh.getUser(playerName);
|
||||||
|
if (user == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
Boolean val = user.getVariables().getVarBoolean(node);
|
||||||
|
return val != null ? val : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
|
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
|
||||||
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
|
setPlayerValue(world, playerName, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,12 +189,24 @@ public class Chat_GroupManager extends Chat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||||
return perms.getPermissionString(playerName, node);
|
OverloadedWorldHolder owh;
|
||||||
|
if (world == null) {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldData(world);
|
||||||
|
}
|
||||||
|
User user = owh.getUser(playerName);
|
||||||
|
if (user == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
String val = user.getVariables().getVarString(node);
|
||||||
|
return val != null ? val : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoString(String world, String playerName, String node, String value) {
|
public void setPlayerInfoString(String world, String playerName, String node, String value) {
|
||||||
throw new UnsupportedOperationException(getName() + " cannot modify permissions.");
|
setPlayerValue(world, playerName, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,4 +261,19 @@ public class Chat_GroupManager extends Chat {
|
|||||||
public String getPrimaryGroup(String world, String playerName) {
|
public String getPrimaryGroup(String world, String playerName) {
|
||||||
return perms.getGroup(playerName);
|
return perms.getGroup(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setPlayerValue(String world, String playerName, String node, Object value) {
|
||||||
|
OverloadedWorldHolder owh;
|
||||||
|
if (world == null) {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
owh = groupManager.getWorldsHolder().getWorldData(world);
|
||||||
|
}
|
||||||
|
User user = owh.getUser(playerName);
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
user.getVariables().addVar(node, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class Permission_GroupManager extends Permission {
|
|||||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||||
OverloadedWorldHolder owh;
|
OverloadedWorldHolder owh;
|
||||||
if (worldName == null) {
|
if (worldName == null) {
|
||||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||||
|
Loading…
Reference in New Issue
Block a user