mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-22 22:34:58 +00:00
Allow the default CONSOLE to have senior permissions
This commit is contained in:
parent
7df24c6b86
commit
22b0781020
21 changed files with 75 additions and 79 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -19,4 +19,4 @@ ehthumbs.db
|
|||
Thumbs.db
|
||||
|
||||
# TFM files
|
||||
buildcreator.properties
|
||||
buildcreator.properties
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#Build Number for ANT. Do not edit!
|
||||
#Mon Apr 21 14:37:04 CEST 2014
|
||||
build.number=777
|
||||
#Mon Apr 21 14:50:16 CEST 2014
|
||||
build.number=778
|
||||
|
|
|
@ -129,6 +129,10 @@ protected_areas_enabled: true
|
|||
auto_protect_spawnpoints: true
|
||||
auto_protect_radius: 25.0
|
||||
|
||||
# Give the default CONSOLE senior admin privileges.
|
||||
# Handy in development environments.
|
||||
console_is_senior: true
|
||||
|
||||
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
|
||||
# Make sure these are all lower-case.
|
||||
host_sender_names:
|
||||
|
|
|
@ -10,5 +10,5 @@ public @interface CommandPermissions
|
|||
|
||||
SourceType source();
|
||||
|
||||
boolean block_host_console() default false;
|
||||
boolean blockHostConsole() default false;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
|
||||
public class Command_adminmode extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||
public class Command_deafen extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Kick all non-superadmins on server.", usage = "/<command>")
|
||||
public class Command_kicknoob extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Download the superadmin and permban lists from the main TotalFreedom server.", usage = "/<command>")
|
||||
public class Command_listsync extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Block target's minecraft input. This is evil, and I never should have wrote it.", usage = "/<command> <all | purge | <<partialname> on | off>>")
|
||||
public class Command_lockup extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Attempt to detect \"invisible griefers\" and \"nukers\".", usage = "/<command> <on | off> [range] [blockrate]")
|
||||
public class Command_nonuke extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Manage permanently banned players and IPs.", usage = "/<command> <list | reload>")
|
||||
public class Command_permban extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(
|
||||
description = "Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages.",
|
||||
usage = "/<command> <on | off>")
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Broadcasts the given message. Supports colors.", usage = "/<command> <message>")
|
||||
public class Command_rawsay extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = false)
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = false)
|
||||
@CommandParameters(description = "Remove all blocks of a certain type in the radius of certain players.", usage = "/<command> <block> [radius (default=50)] [player]")
|
||||
public class Command_ro extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, blockHostConsole = true)
|
||||
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
|
||||
public class Command_rollback extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Update server files.", usage = "/<command>")
|
||||
public class Command_tfupdate extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, block_host_console = true)
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||
@CommandParameters(description = "Wipe the flatlands map. Requires manual restart after command is used.", usage = "/<command>")
|
||||
public class Command_wipeflatlands extends TFM_Command
|
||||
{
|
||||
|
|
|
@ -59,81 +59,72 @@ public abstract class TFM_Command
|
|||
|
||||
public boolean senderHasPermission()
|
||||
{
|
||||
CommandPermissions permissions = commandClass.getAnnotation(CommandPermissions.class);
|
||||
if (permissions != null)
|
||||
final CommandPermissions permissions = commandClass.getAnnotation(CommandPermissions.class);
|
||||
|
||||
if (permissions == null)
|
||||
{
|
||||
boolean is_super = TFM_AdminList.isSuperAdmin(this.commandSender);
|
||||
boolean is_senior = false;
|
||||
if (is_super)
|
||||
TFM_Log.warning(commandClass.getName() + " is missing permissions annotation.");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isSuper = TFM_AdminList.isSuperAdmin(commandSender);
|
||||
boolean isSenior = false;
|
||||
|
||||
if (isSuper)
|
||||
{
|
||||
isSenior = TFM_AdminList.isSeniorAdmin(commandSender);
|
||||
}
|
||||
|
||||
final AdminLevel level = permissions.level();
|
||||
final SourceType source = permissions.source();
|
||||
final boolean blockHostConsole = permissions.blockHostConsole();
|
||||
|
||||
if (!(commandSender instanceof Player))
|
||||
{
|
||||
if (source == SourceType.ONLY_IN_GAME)
|
||||
{
|
||||
is_senior = TFM_AdminList.isSeniorAdmin(this.commandSender);
|
||||
return false;
|
||||
}
|
||||
|
||||
AdminLevel level = permissions.level();
|
||||
SourceType source = permissions.source();
|
||||
boolean block_host_console = permissions.block_host_console();
|
||||
|
||||
Player sender_p = null;
|
||||
if (this.commandSender instanceof Player)
|
||||
else if (level == AdminLevel.SENIOR && !isSenior)
|
||||
{
|
||||
sender_p = (Player) this.commandSender;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sender_p == null)
|
||||
else if (blockHostConsole && TFM_Util.isFromHostConsole(commandSender.getName()))
|
||||
{
|
||||
if (source == SourceType.ONLY_IN_GAME)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (level == AdminLevel.SENIOR && !is_senior)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (block_host_console && TFM_Util.isFromHostConsole(this.commandSender.getName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (source == SourceType.ONLY_CONSOLE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (level == AdminLevel.SENIOR)
|
||||
{
|
||||
if (is_senior)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
|
||||
Boolean superadminIdVerified = playerdata.isSuperadminIdVerified();
|
||||
}
|
||||
else
|
||||
{
|
||||
final Player sender_p = (Player) commandSender;
|
||||
|
||||
if (superadminIdVerified != null)
|
||||
{
|
||||
if (!superadminIdVerified.booleanValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (source == SourceType.ONLY_CONSOLE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (level == AdminLevel.SENIOR)
|
||||
{
|
||||
if (isSenior)
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
|
||||
if (!playerdata.isSuperadminIdVerified())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (level == AdminLevel.SUPER && !is_super)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (level == AdminLevel.OP && !sender_p.isOp())
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.warning(commandClass.getName() + " is missing permissions annotation.");
|
||||
else if (level == AdminLevel.SUPER && !isSuper)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (level == AdminLevel.OP && !sender_p.isOp())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class TFM_CommandLoader
|
|||
matcher.group(1).split("_")[1],
|
||||
commandPermissions.level(),
|
||||
commandPermissions.source(),
|
||||
commandPermissions.block_host_console(),
|
||||
commandPermissions.blockHostConsole(),
|
||||
commandParameters.description(),
|
||||
commandParameters.usage(),
|
||||
commandParameters.aliases());
|
||||
|
|
|
@ -33,6 +33,7 @@ public enum TFM_ConfigEntry
|
|||
TWITTERBOT_ENABLED(Boolean.class, "twitterbot_enabled"),
|
||||
HTTPD_ENABLED(Boolean.class, "httpd_enabled"),
|
||||
AUTOKICK_ENABLED(Boolean.class, "autokick_enabled"),
|
||||
CONSOLE_IS_SENIOR(Boolean.class, "console_is_senior"),
|
||||
//
|
||||
AUTO_PROTECT_RADIUS(Double.class, "auto_protect_radius"),
|
||||
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
|
||||
|
|
|
@ -351,9 +351,9 @@ public class TFM_AdminList
|
|||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return consoleAliases.contains(sender.getName());
|
||||
return consoleAliases.contains(sender.getName()) || sender.getName().equals("CONSOLE");
|
||||
}
|
||||
|
||||
|
||||
final TFM_Admin entry = getEntry((Player) sender);
|
||||
if (entry != null)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue