mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added saconfig
Moved superadmin lists Added CantFindPlayerException Code cleanup
This commit is contained in:
parent
0a2f7fb4c5
commit
f84f10a7ad
@ -33,8 +33,4 @@ disable_weather: true
|
|||||||
|
|
||||||
# Superadmins: Users that can always log in and use the most powerful commands:
|
# Superadmins: Users that can always log in and use the most powerful commands:
|
||||||
# When online-mode = false, only superadmin_ips will be used.
|
# When online-mode = false, only superadmin_ips will be used.
|
||||||
superadmins:
|
# The superadmin lists have been moved to superadmin.yml
|
||||||
- Madgeek1450
|
|
||||||
- markbyron
|
|
||||||
superadmin_ips:
|
|
||||||
- 127.0.0.1
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
public class CantFindPlayerException extends Exception
|
||||||
|
{
|
||||||
|
public CantFindPlayerException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CantFindPlayerException(String msg)
|
||||||
|
{
|
||||||
|
super("Can't find player: " + msg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,8 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -26,15 +24,14 @@ public class Command_cage extends TFM_Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -21,32 +22,29 @@ public class Command_creative extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!sender.isOp())
|
if (!sender.isOp())
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
p = Bukkit.getPlayerExact(sender.getName());
|
p = sender_p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage("Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
p = matches.get(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Setting " + p.getName() + " to game mode 'Creative'.");
|
sender.sendMessage("Setting " + p.getName() + " to game mode 'Creative'.");
|
||||||
|
@ -29,7 +29,7 @@ public class Command_expel extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
radius = Double.parseDouble(args[0]);
|
radius = Math.max(1.0, Math.min(200.0, Double.parseDouble(args[0])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ public class Command_expel extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
strength = Double.parseDouble(args[1]);
|
strength = Math.max(0.0, Math.min(200.0, Double.parseDouble(args[1])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.explosiveRadius = Double.parseDouble(args[1]);
|
plugin.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
|
@ -37,15 +37,14 @@ public class Command_fr extends TFM_Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage("Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
|
@ -22,15 +22,14 @@ public class Command_gcmd extends TFM_Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String outcommand = "";
|
String outcommand = "";
|
||||||
@ -43,9 +42,9 @@ public class Command_gcmd extends TFM_Command
|
|||||||
}
|
}
|
||||||
outcommand = outcommand_bldr.toString().trim();
|
outcommand = outcommand_bldr.toString().trim();
|
||||||
}
|
}
|
||||||
catch (Exception cmdex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Error building command: " + cmdex.getMessage());
|
sender.sendMessage(ChatColor.GRAY + "Error building command: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -60,9 +59,9 @@ public class Command_gcmd extends TFM_Command
|
|||||||
sender.sendMessage(ChatColor.GRAY + "Unknown error sending command.");
|
sender.sendMessage(ChatColor.GRAY + "Unknown error sending command.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception cmdex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Error sending command: " + cmdex.getMessage());
|
sender.sendMessage(ChatColor.GRAY + "Error sending command: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -24,15 +24,14 @@ public class Command_gtfo extends TFM_Command
|
|||||||
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||||
{
|
{
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage("Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
@ -23,7 +23,7 @@ public class Command_nonuke extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.nukeMonitorRange = Double.parseDouble(args[1]);
|
plugin.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ public class Command_nonuke extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.nukeMonitorCountBreak = Integer.parseInt(args[2]);
|
plugin.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -25,15 +23,14 @@ public class Command_orbit extends TFM_Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
@ -51,11 +48,10 @@ public class Command_orbit extends TFM_Command
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
strength = Double.parseDouble(args[1]);
|
strength = Math.max(1.0, Math.min(150.0, Double.parseDouble(args[1])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
strength = 10.0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,15 +24,14 @@ public class Command_qjail extends TFM_Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
catch (CantFindPlayerException ex)
|
||||||
{
|
{
|
||||||
p = matches.get(0);
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Deop
|
//Deop
|
||||||
|
@ -47,7 +47,7 @@ public class Command_radar extends TFM_Command
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
countmax = Integer.parseInt(args[0]);
|
countmax = Math.max(1, Math.min(64, Integer.parseInt(args[0])));
|
||||||
}
|
}
|
||||||
catch (NumberFormatException nfex)
|
catch (NumberFormatException nfex)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Command_saconfig extends TFM_Command
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
|
{
|
||||||
|
Player p;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p = getPlayer(args[1]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String user_name = p.getName().toLowerCase().trim();
|
||||||
|
String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Adding " + user_name + " as a superadmin, with current IP = " + user_ip);
|
||||||
|
|
||||||
|
if (!plugin.superadmins.contains(user_name))
|
||||||
|
{
|
||||||
|
plugin.superadmins.add(user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.superadmin_ips.contains(user_ip))
|
||||||
|
{
|
||||||
|
plugin.superadmin_ips.add(user_ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileConfiguration sa_config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||||
|
sa_config.set("superadmins", plugin.superadmins);
|
||||||
|
sa_config.set("superadmin_ips", plugin.superadmin_ips);
|
||||||
|
sa_config.save(new File(plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -21,32 +22,29 @@ public class Command_survival extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!sender.isOp())
|
if (!sender.isOp())
|
||||||
{
|
{
|
||||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
p = Bukkit.getPlayerExact(sender.getName());
|
p = sender_p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<Player> matches = Bukkit.matchPlayer(args[0]);
|
try
|
||||||
if (matches.isEmpty())
|
|
||||||
{
|
{
|
||||||
sender.sendMessage("Can't find user " + args[0]);
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
catch (CantFindPlayerException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
p = matches.get(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Setting " + p.getName() + " to game mode 'Survival'.");
|
sender.sendMessage("Setting " + p.getName() + " to game mode 'Survival'.");
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -27,4 +29,17 @@ public class TFM_Command
|
|||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(String partialname) throws CantFindPlayerException
|
||||||
|
{
|
||||||
|
List<Player> matches = Bukkit.matchPlayer(partialname);
|
||||||
|
if (matches.isEmpty())
|
||||||
|
{
|
||||||
|
throw new CantFindPlayerException(partialname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return matches.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class TFM_Heartbeat implements Runnable
|
|||||||
{
|
{
|
||||||
private TotalFreedomMod plugin;
|
private TotalFreedomMod plugin;
|
||||||
|
|
||||||
TFM_Heartbeat(TotalFreedomMod instance)
|
public TFM_Heartbeat(TotalFreedomMod instance)
|
||||||
{
|
{
|
||||||
this.plugin = instance;
|
this.plugin = instance;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
|
|
||||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||||
public static final String CONFIG_FILE = "config.yml";
|
public static final String CONFIG_FILE = "config.yml";
|
||||||
|
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||||
private static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
private static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
||||||
private static final String COMMAND_PREFIX = "Command_";
|
private static final String COMMAND_PREFIX = "Command_";
|
||||||
|
|
||||||
@ -42,7 +43,9 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
loadTFMConfig();
|
loadMainConfig();
|
||||||
|
loadSuperadminConfig();
|
||||||
|
|
||||||
registerEventHandlers();
|
registerEventHandlers();
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||||
@ -93,7 +96,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "Command not loaded: " + cmd.getName(), ex);
|
log.log(Level.SEVERE, "[" + getDescription().getName() + "] Command not loaded: " + cmd.getName(), ex);
|
||||||
sender.sendMessage(ChatColor.RED + "Command Error: Command not loaded: " + cmd.getName());
|
sender.sendMessage(ChatColor.RED + "Command Error: Command not loaded: " + cmd.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -109,7 +112,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "Command Error: " + commandLabel, ex);
|
log.log(Level.SEVERE, "[" + getDescription().getName() + "] Command Error: " + commandLabel, ex);
|
||||||
sender.sendMessage(ChatColor.RED + "Unknown Command Error.");
|
sender.sendMessage(ChatColor.RED + "Unknown Command Error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,13 +135,10 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
public Boolean preprocessLogEnabled = true;
|
public Boolean preprocessLogEnabled = true;
|
||||||
public Boolean disableNight = true;
|
public Boolean disableNight = true;
|
||||||
public Boolean disableWeather = true;
|
public Boolean disableWeather = true;
|
||||||
public List<String> superadmins = new ArrayList<String>();
|
|
||||||
public List<String> superadmin_ips = new ArrayList<String>();
|
|
||||||
|
|
||||||
private void loadTFMConfig()
|
public void loadMainConfig()
|
||||||
{
|
{
|
||||||
TFM_Util.createDefaultConfiguration(CONFIG_FILE, this, getFile());
|
TFM_Util.createDefaultConfiguration(CONFIG_FILE, this, getFile());
|
||||||
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
|
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
|
||||||
|
|
||||||
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
|
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
|
||||||
@ -157,9 +157,18 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled);
|
preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled);
|
||||||
disableNight = config.getBoolean("disable_night", disableNight);
|
disableNight = config.getBoolean("disable_night", disableNight);
|
||||||
disableWeather = config.getBoolean("disable_weather", disableWeather);
|
disableWeather = config.getBoolean("disable_weather", disableWeather);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> superadmins = new ArrayList<String>();
|
||||||
|
public List<String> superadmin_ips = new ArrayList<String>();
|
||||||
|
|
||||||
|
public void loadSuperadminConfig()
|
||||||
|
{
|
||||||
|
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, this, getFile());
|
||||||
|
FileConfiguration sa_config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), SUPERADMIN_FILE));
|
||||||
|
|
||||||
superadmins = new ArrayList<String>();
|
superadmins = new ArrayList<String>();
|
||||||
List<String> superadmins_temp = (List<String>) config.getList("superadmins", null);
|
List<String> superadmins_temp = (List<String>) sa_config.getList("superadmins", null);
|
||||||
if (superadmins_temp == null || superadmins_temp.isEmpty())
|
if (superadmins_temp == null || superadmins_temp.isEmpty())
|
||||||
{
|
{
|
||||||
superadmins.add("Madgeek1450");
|
superadmins.add("Madgeek1450");
|
||||||
@ -174,7 +183,7 @@ public class TotalFreedomMod extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
superadmin_ips = new ArrayList<String>();
|
superadmin_ips = new ArrayList<String>();
|
||||||
List<String> superadmin_ips_temp = (List<String>) config.getList("superadmin_ips", null);
|
List<String> superadmin_ips_temp = (List<String>) sa_config.getList("superadmin_ips", null);
|
||||||
if (superadmin_ips_temp == null || superadmin_ips_temp.isEmpty())
|
if (superadmin_ips_temp == null || superadmin_ips_temp.isEmpty())
|
||||||
{
|
{
|
||||||
superadmin_ips.add("127.0.0.1");
|
superadmin_ips.add("127.0.0.1");
|
||||||
|
@ -95,6 +95,9 @@ commands:
|
|||||||
rd:
|
rd:
|
||||||
description: Remove drops, arrows, primed TNT, and expierence orbs in all worlds.
|
description: Remove drops, arrows, primed TNT, and expierence orbs in all worlds.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
saconfig:
|
||||||
|
description: Owner command - Manage superadmins.
|
||||||
|
usage: /<command> <add> <username>
|
||||||
say:
|
say:
|
||||||
description: Broadcasts the given message as the console, includes sender name.
|
description: Broadcasts the given message as the console, includes sender name.
|
||||||
usage: /<command> <message>
|
usage: /<command> <message>
|
||||||
|
5
src/superadmin.yml
Normal file
5
src/superadmin.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
superadmins:
|
||||||
|
- Madgeek1450
|
||||||
|
- markbyron
|
||||||
|
superadmin_ips:
|
||||||
|
- 127.0.0.1
|
Loading…
Reference in New Issue
Block a user