Handle client security checks properly

This commit is contained in:
Mike Primm 2020-08-16 01:01:52 -05:00
parent c39cb2d3e7
commit 2c4f5c6b9f
6 changed files with 41 additions and 21 deletions

View File

@ -18,7 +18,7 @@ allprojects {
apply plugin: 'java'
group = 'us.dynmap'
version = '3.1-beta-3'
version = '3.1-SNAPSHOT'
}

View File

@ -455,7 +455,7 @@ public class DynmapPlugin
private boolean hasPerm(EntityPlayer psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
@ -463,7 +463,7 @@ public class DynmapPlugin
private boolean hasPermNode(EntityPlayer psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
@ -1594,8 +1594,12 @@ public class DynmapPlugin
{
dsender = new ForgeCommandSender(sender);
}
try {
core.processCommand(dsender, cmd, cmd, args);
} catch (Exception x) {
dsender.sendMessage("Command internal error: " + x.getMessage());
Log.severe("Error with command: " + cmd + Arrays.deepToString(args), x);
}
}
private DynmapLocation toLoc(World worldObj, double x, double y, double z)

View File

@ -481,7 +481,7 @@ public class DynmapPlugin
private boolean hasPerm(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
@ -489,7 +489,7 @@ public class DynmapPlugin
private boolean hasPermNode(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
@ -1620,8 +1620,12 @@ public class DynmapPlugin
{
dsender = new ForgeCommandSender(sender);
}
try {
core.processCommand(dsender, cmd, cmd, args);
} catch (Exception x) {
dsender.sendMessage("Command internal error: " + x.getMessage());
Log.severe("Error with command: " + cmd + Arrays.deepToString(args), x);
}
}
private DynmapLocation toLoc(World worldObj, double x, double y, double z)

View File

@ -482,7 +482,7 @@ public class DynmapPlugin
private boolean hasPerm(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
@ -490,7 +490,7 @@ public class DynmapPlugin
private boolean hasPermNode(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
if((psender != null) && (ph != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
@ -1620,8 +1620,12 @@ public class DynmapPlugin
{
dsender = new ForgeCommandSender(sender);
}
try {
core.processCommand(dsender, cmd, cmd, args);
} catch (Exception x) {
dsender.sendMessage("Command internal error: " + x.getMessage());
Log.severe("Error with command: " + cmd + Arrays.deepToString(args), x);
}
}
private DynmapLocation toLoc(World worldObj, double x, double y, double z)

View File

@ -479,7 +479,7 @@ public class DynmapPlugin
private boolean hasPerm(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
if ((psender != null) && (ph != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
@ -487,7 +487,7 @@ public class DynmapPlugin
private boolean hasPermNode(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
if ((psender != null) && (ph != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
@ -1617,8 +1617,12 @@ public class DynmapPlugin
{
dsender = new ForgeCommandSender(sender);
}
try {
core.processCommand(dsender, cmd, cmd, args);
} catch (Exception x) {
dsender.sendMessage("Command internal error: " + x.getMessage());
Log.severe("Error with command: " + cmd + Arrays.deepToString(args), x);
}
}
private DynmapLocation toLoc(World worldObj, double x, double y, double z)

View File

@ -489,7 +489,7 @@ public class DynmapPlugin
private boolean hasPerm(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) {
if ((psender != null) && (ph != null) && ph.hasPermission(psender.getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
@ -497,7 +497,7 @@ public class DynmapPlugin
private boolean hasPermNode(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) {
if ((psender != null) && (ph != null) && ph.hasPermissionNode(psender.getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
@ -1627,8 +1627,12 @@ public class DynmapPlugin
{
dsender = new ForgeCommandSender(sender);
}
try {
core.processCommand(dsender, cmd, cmd, args);
} catch (Exception x) {
dsender.sendMessage("Command internal error: " + x.getMessage());
Log.severe("Error with command: " + cmd + Arrays.deepToString(args), x);
}
}
private DynmapLocation toLoc(World worldObj, double x, double y, double z)