mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-11 13:33:54 +00:00
Merge branch origin/master
This commit is contained in:
@ -102,5 +102,4 @@ public class Command_halt extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/<command>")
|
||||
public class Command_minecraft extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerMsg("Status of Mojang services:", ChatColor.BLUE);
|
||||
for (String service : TFM_ServiceChecker.getAllStatuses())
|
||||
{
|
||||
playerMsg(service);
|
||||
}
|
||||
playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Enable/disable tamed pet protection.", usage = "/<command> <on | off>")
|
||||
public class Command_petprotect extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TotalFreedomMod.petProtectEnabled = !TFM_Util.isStopCommand(args[0]);
|
||||
|
||||
TFM_Util.adminAction(
|
||||
sender.getName(),
|
||||
"Tamed pet protection is now " + (TotalFreedomMod.petProtectEnabled ? "enabled" : "disabled") + ".",
|
||||
false);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,16 +1,42 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
|
||||
public class Command_status extends TFM_Command
|
||||
{
|
||||
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
|
||||
|
||||
static
|
||||
{
|
||||
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
|
||||
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
|
||||
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
|
||||
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
|
||||
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
|
||||
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -26,6 +52,59 @@ public class Command_status extends TFM_Command
|
||||
playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE);
|
||||
}
|
||||
|
||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL mojang_status = new URL("http://status.mojang.com/check");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
||||
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
|
||||
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
|
||||
|
||||
Iterator status_it = status_json.iterator();
|
||||
while (status_it.hasNext())
|
||||
{
|
||||
JSONObject service = (JSONObject) status_it.next();
|
||||
Iterator service_it = service.entrySet().iterator();
|
||||
while (service_it.hasNext())
|
||||
{
|
||||
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
||||
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
List<String> status_output = new ArrayList<String>();
|
||||
|
||||
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
|
||||
while (output_it.hasNext())
|
||||
{
|
||||
Entry<String, Boolean> pair = output_it.next();
|
||||
String service_name = pair.getKey();
|
||||
boolean service_online = pair.getValue().booleanValue();
|
||||
|
||||
if (SERVICE_MAP.containsKey(service_name))
|
||||
{
|
||||
service_name = SERVICE_MAP.get(service_name);
|
||||
}
|
||||
|
||||
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
|
||||
}
|
||||
|
||||
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "See who has a block and optionally smite", usage = "/<command> <item> [smite]", aliases="wh")
|
||||
@CommandParameters(description = "See who has a block and optionally smite", usage = "/<command> <item> [smite]", aliases = "wh")
|
||||
public class Command_whohas extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
@ -33,7 +32,7 @@ public class Command_whohas extends TFM_Command
|
||||
}
|
||||
|
||||
Material material = Material.matchMaterial(args[0]);
|
||||
|
||||
|
||||
if (material == null)
|
||||
{
|
||||
try
|
||||
@ -67,11 +66,11 @@ public class Command_whohas extends TFM_Command
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
playerMsg("There are no players with that item");
|
||||
playerMsg("There are no players with that item");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Players with item " + material.name() + ": "+ StringUtils.join(players, ", "));
|
||||
playerMsg("Players with item " + material.name() + ": " + StringUtils.join(players, ", "));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -50,6 +50,19 @@ public class TFM_EntityListener implements Listener
|
||||
case LAVA:
|
||||
{
|
||||
if (!TotalFreedomMod.allowLavaDamage)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.petProtectEnabled)
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Tameable)
|
||||
{
|
||||
if (((Tameable) entity).isTamed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -90,7 +90,6 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -679,10 +678,7 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onServerPing(ServerListPingEvent event)
|
||||
{
|
||||
//event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
|
||||
|
||||
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY
|
||||
+ "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());
|
||||
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());
|
||||
|
||||
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
|
||||
{
|
||||
|
@ -9,13 +9,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlocker
|
||||
{
|
||||
|
||||
public static boolean isCommandBlocked(String usedcommand, CommandSender sender)
|
||||
{
|
||||
|
||||
String name = sender.getName();
|
||||
usedcommand = usedcommand.toLowerCase().trim();
|
||||
|
||||
|
||||
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
||||
{
|
||||
String[] parts = blocked_command.split(":");
|
||||
@ -109,7 +108,6 @@ public class TFM_CommandBlocker
|
||||
TELNET("t", 3),
|
||||
SENIOR("c", 4),
|
||||
NOBODY("n", 5);
|
||||
|
||||
private String letter = "n";
|
||||
private int rank = 5;
|
||||
|
||||
@ -162,10 +160,5 @@ public class TFM_CommandBlocker
|
||||
}
|
||||
return SenderRank.NOBODY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ public class TFM_PlayerData
|
||||
|
||||
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BukkitTask getLockupScheduleID()
|
||||
|
@ -121,6 +121,8 @@ public class TFM_ServerInterface
|
||||
|
||||
public static void handlePlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
// this should supersede all other onPlayerLogin authentication on the TFM server.
|
||||
// when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication.
|
||||
|
||||
final Server server = TotalFreedomMod.plugin.getServer();
|
||||
|
||||
@ -135,8 +137,7 @@ public class TFM_ServerInterface
|
||||
|
||||
if (player_name.trim().length() <= 2)
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||
"Your username is too short (must be at least 3 characters long).");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long).");
|
||||
return;
|
||||
}
|
||||
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find())
|
||||
@ -145,8 +146,7 @@ public class TFM_ServerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress()
|
||||
// will return a null until after player login.
|
||||
// not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login.
|
||||
boolean is_superadmin;
|
||||
if (server.getOnlineMode())
|
||||
{
|
||||
@ -171,8 +171,7 @@ public class TFM_ServerInterface
|
||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||
if (ban_entry.getExpires() != null)
|
||||
{
|
||||
kick_message = kick_message + "\nYour ban will be removed on "
|
||||
+ date_format.format(ban_entry.getExpires());
|
||||
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,8 +215,7 @@ public class TFM_ServerInterface
|
||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||
if (ban_entry.getExpires() != null)
|
||||
{
|
||||
kick_message = kick_message + "\nYour ban will be removed on "
|
||||
+ date_format.format(ban_entry.getExpires());
|
||||
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,8 +227,7 @@ public class TFM_ServerInterface
|
||||
{
|
||||
if (test_player.equalsIgnoreCase(player_name))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
|
||||
+ "Your username is permanently banned from this server.");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -239,8 +236,7 @@ public class TFM_ServerInterface
|
||||
{
|
||||
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED
|
||||
+ "Your IP address is permanently banned from this server.");
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -275,21 +271,8 @@ public class TFM_ServerInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
else // if user is superadmin
|
||||
else
|
||||
{
|
||||
// force-allow superadmins to log in
|
||||
event.allow();
|
||||
|
||||
if (isIPBanned(player_ip))
|
||||
{
|
||||
unbanIP(player_ip);
|
||||
}
|
||||
|
||||
if (isNameBanned(player_name))
|
||||
{
|
||||
unbanUsername(player_name);
|
||||
}
|
||||
|
||||
for (Player test_player : server.getOnlinePlayers())
|
||||
{
|
||||
if (test_player.getName().equalsIgnoreCase(player_name))
|
||||
@ -298,22 +281,19 @@ public class TFM_ServerInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
|
||||
boolean can_kick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
|
||||
while (server.getOnlinePlayers().length >= server.getMaxPlayers() && can_kick)
|
||||
{
|
||||
for (Player op : server.getOnlinePlayers())
|
||||
can_kick = false;
|
||||
for (Player test_player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(op))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(test_player))
|
||||
{
|
||||
op.kickPlayer("You have been kicked to free up space for an admin");
|
||||
return;
|
||||
can_kick = true;
|
||||
test_player.kickPlayer("You have been kicked to free up room for an admin.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, this server is full");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,207 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
public class TFM_ServiceChecker
|
||||
{
|
||||
private static final Map<String, String[]> SERVICE_MAP = new HashMap<String, String[]>();
|
||||
public static String check_url = "http://xpaw.ru/mcstatus/status.json";
|
||||
public static String version = "1.0";
|
||||
public static String last_updated = ""; // On xpaw.ru
|
||||
|
||||
static
|
||||
{
|
||||
// <"up", "down", "problem">, <"Online", "Quite Slow", "Error 505", etc>, <String (Uptime percentage)>
|
||||
SERVICE_MAP.put("website", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
SERVICE_MAP.put("session", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
SERVICE_MAP.put("login", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
SERVICE_MAP.put("account", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
SERVICE_MAP.put("skins", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
SERVICE_MAP.put("realms", new String[]
|
||||
{
|
||||
"up", "Online", "100.00"
|
||||
});
|
||||
}
|
||||
public static Runnable checker = new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
runCheck();
|
||||
}
|
||||
};
|
||||
|
||||
public static void runCheck()
|
||||
{
|
||||
TotalFreedomMod.server.getScheduler().runTaskAsynchronously(TotalFreedomMod.plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
/* // Nubcakes be 403'ing us >;o
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(check_url).openStream()));
|
||||
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
*/
|
||||
|
||||
// Well, lets bypass that! >:D
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(check_url).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36");
|
||||
connection.setRequestProperty("Host", "xpaw.ru");
|
||||
connection.setRequestProperty("Accept", "*/*");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(false);
|
||||
InputStream is = connection.getInputStream();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(is));
|
||||
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
connection.disconnect();
|
||||
|
||||
|
||||
|
||||
version = String.valueOf(service_json.get("v"));
|
||||
last_updated = (String) service_json.get("last_updated");
|
||||
|
||||
JSONObject services = (JSONObject) service_json.get("report");
|
||||
for (String service : SERVICE_MAP.keySet())
|
||||
{
|
||||
JSONObject service_info = (JSONObject) services.get(service);
|
||||
SERVICE_MAP.put(service, new String[]
|
||||
{
|
||||
(String) service_info.get("status"),
|
||||
(String) service_info.get("title"),
|
||||
(String) service_info.get("uptime")
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getFormattedStatus(String service_name)
|
||||
{
|
||||
String[] service = SERVICE_MAP.get(service_name);
|
||||
String status = ("up".equals(service[0]) ? ChatColor.GREEN
|
||||
: ("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString();
|
||||
|
||||
status += service[1] + ChatColor.GRAY + " (";
|
||||
|
||||
status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN
|
||||
: (Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED));
|
||||
|
||||
status += service[2] + "%" + ChatColor.GRAY + ")";
|
||||
|
||||
return ChatColor.GRAY + WordUtils.capitalize(service_name) + ChatColor.WHITE + ": " + status;
|
||||
}
|
||||
|
||||
public static List<String> getAllStatuses()
|
||||
{
|
||||
List<String> statuses = new ArrayList<String>();
|
||||
for (String status : SERVICE_MAP.keySet())
|
||||
{
|
||||
statuses.add(getFormattedStatus(status));
|
||||
}
|
||||
return statuses;
|
||||
}
|
||||
}
|
||||
|
||||
/* // Mojang status
|
||||
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
|
||||
|
||||
static
|
||||
{
|
||||
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
|
||||
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
|
||||
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
|
||||
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
|
||||
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
|
||||
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
|
||||
}
|
||||
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL mojang_status = new URL("http://status.mojang.com/check");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
||||
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
|
||||
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
|
||||
|
||||
Iterator status_it = status_json.iterator();
|
||||
while (status_it.hasNext())
|
||||
{
|
||||
JSONObject service = (JSONObject) status_it.next();
|
||||
Iterator service_it = service.entrySet().iterator();
|
||||
while (service_it.hasNext())
|
||||
{
|
||||
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
||||
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
List<String> status_output = new ArrayList<String>();
|
||||
|
||||
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
|
||||
while (output_it.hasNext())
|
||||
{
|
||||
Entry<String, Boolean> pair = output_it.next();
|
||||
String service_name = pair.getKey();
|
||||
boolean service_online = pair.getValue().booleanValue();
|
||||
|
||||
if (SERVICE_MAP.containsKey(service_name))
|
||||
{
|
||||
service_name = SERVICE_MAP.get(service_name);
|
||||
}
|
||||
|
||||
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
|
||||
}
|
||||
|
||||
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
@ -13,8 +12,6 @@ import java.util.jar.JarFile;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.*;
|
||||
@ -305,77 +302,6 @@ public class TFM_Util
|
||||
return TFM_Util.mobtypes.get(mobname);
|
||||
}
|
||||
|
||||
public static void zip(File directory, File zipfile, boolean verbose, CommandSender sender) throws IOException
|
||||
{
|
||||
URI base = directory.toURI();
|
||||
Deque<File> queue = new LinkedList<File>();
|
||||
queue.push(directory);
|
||||
OutputStream out = new FileOutputStream(zipfile);
|
||||
Closeable res = out;
|
||||
try
|
||||
{
|
||||
ZipOutputStream zout = new ZipOutputStream(out);
|
||||
res = zout;
|
||||
while (!queue.isEmpty())
|
||||
{
|
||||
directory = queue.pop();
|
||||
for (File kid : directory.listFiles())
|
||||
{
|
||||
String name = base.relativize(kid.toURI()).getPath();
|
||||
if (kid.isDirectory())
|
||||
{
|
||||
queue.push(kid);
|
||||
name = name.endsWith("/") ? name : name + "/";
|
||||
zout.putNextEntry(new ZipEntry(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
zout.putNextEntry(new ZipEntry(name));
|
||||
copy(kid, zout);
|
||||
zout.closeEntry();
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
sender.sendMessage("Zipping: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void unzip(File zipfile, File directory) throws IOException
|
||||
{
|
||||
ZipFile zfile = new ZipFile(zipfile);
|
||||
Enumeration<? extends ZipEntry> entries = zfile.entries();
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
ZipEntry entry = entries.nextElement();
|
||||
File file = new File(directory, entry.getName());
|
||||
if (entry.isDirectory())
|
||||
{
|
||||
file.mkdirs();
|
||||
}
|
||||
else
|
||||
{
|
||||
file.getParentFile().mkdirs();
|
||||
InputStream in = zfile.getInputStream(entry);
|
||||
try
|
||||
{
|
||||
copy(in, file);
|
||||
}
|
||||
finally
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream in, OutputStream out) throws IOException
|
||||
{
|
||||
byte[] buffer = new byte[1024];
|
||||
@ -969,8 +895,7 @@ public class TFM_Util
|
||||
{
|
||||
if (TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED
|
||||
+ name + ": " + ChatColor.AQUA + message);
|
||||
p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.AQUA + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1035,7 +960,6 @@ public class TFM_Util
|
||||
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final List<ChatColor> COLOR_POOL = Arrays.asList(
|
||||
ChatColor.DARK_BLUE,
|
||||
ChatColor.DARK_GREEN,
|
||||
@ -1049,8 +973,8 @@ public class TFM_Util
|
||||
ChatColor.RED,
|
||||
ChatColor.LIGHT_PURPLE,
|
||||
ChatColor.YELLOW);
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
public static ChatColor randomChatColor()
|
||||
{
|
||||
return COLOR_POOL.get(RANDOM.nextInt(COLOR_POOL.size()));
|
||||
|
@ -2,8 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.bukkit.BukkitServerInterface;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,8 +10,6 @@ import org.bukkit.plugin.Plugin;
|
||||
public class TFM_WorldEditBridge
|
||||
{
|
||||
private WorldEditPlugin worldEditPlugin = null;
|
||||
private WorldEditAPI worldEditAPI = null;
|
||||
private BukkitServerInterface bukkitServerInterface = null;
|
||||
|
||||
private TFM_WorldEditBridge()
|
||||
{
|
||||
@ -23,57 +19,56 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
if (this.worldEditPlugin == null)
|
||||
{
|
||||
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (we != null)
|
||||
try
|
||||
{
|
||||
if (we instanceof WorldEditPlugin)
|
||||
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (we != null)
|
||||
{
|
||||
this.worldEditPlugin = (WorldEditPlugin) we;
|
||||
if (we instanceof WorldEditPlugin)
|
||||
{
|
||||
this.worldEditPlugin = (WorldEditPlugin) we;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
return this.worldEditPlugin;
|
||||
}
|
||||
|
||||
public WorldEditAPI getWorldEditAPI()
|
||||
{
|
||||
if (this.worldEditAPI == null)
|
||||
{
|
||||
WorldEditPlugin wep = getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
this.worldEditAPI = new WorldEditAPI(wep);
|
||||
}
|
||||
}
|
||||
|
||||
return this.worldEditAPI;
|
||||
}
|
||||
|
||||
public BukkitServerInterface getBukkitServerInterface()
|
||||
{
|
||||
if (this.bukkitServerInterface == null)
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
this.bukkitServerInterface = new BukkitServerInterface(wep, Bukkit.getServer());
|
||||
}
|
||||
}
|
||||
|
||||
return this.bukkitServerInterface;
|
||||
}
|
||||
|
||||
public BukkitPlayer getBukkitPlayer(Player p)
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
BukkitServerInterface bsi = this.getBukkitServerInterface();
|
||||
|
||||
if (wep != null && bsi != null)
|
||||
try
|
||||
{
|
||||
return new BukkitPlayer(wep, bsi, p);
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
return wep.wrapPlayer(p);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LocalSession getPlayerSession(Player p)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
return wep.getSession(p);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -81,13 +76,12 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
LocalSession session = getPlayerSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
if (session != null)
|
||||
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
|
||||
if (bukkitPlayer != null)
|
||||
{
|
||||
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||
@ -105,14 +99,10 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
LocalSession session = getPlayerSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
session.setBlockChangeLimit(limit);
|
||||
}
|
||||
session.setBlockChangeLimit(limit);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -28,35 +28,35 @@ import org.mcstats.Metrics;
|
||||
public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
public static final Server server = Bukkit.getServer();
|
||||
|
||||
//
|
||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||
public static final long SERVICE_CHECKER_RATE = 30L;
|
||||
|
||||
//
|
||||
public static final String CONFIG_FILE = "config.yml";
|
||||
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||
public static final String PERMBAN_FILE = "permban.yml";
|
||||
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
|
||||
public static final String SAVED_FLAGS_FILE = "savedflags.dat";
|
||||
|
||||
//
|
||||
public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands";
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
|
||||
//
|
||||
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||
|
||||
//
|
||||
public static boolean allPlayersFrozen = false;
|
||||
public static int freezePurgeEventId = 0;
|
||||
public static int mutePurgeEventId = 0;
|
||||
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
|
||||
|
||||
//
|
||||
public static String pluginVersion = "";
|
||||
public static String buildNumber = "";
|
||||
public static String buildDate = "";
|
||||
public static String pluginName = "";
|
||||
|
||||
//
|
||||
public static TotalFreedomMod plugin = null;
|
||||
public static File plugin_file = null;
|
||||
|
||||
@ -106,13 +106,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
// Heartbeat
|
||||
server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||
|
||||
// Service uptime checker
|
||||
server.getScheduler().scheduleSyncRepeatingTask(this, TFM_ServiceChecker.checker, SERVICE_CHECKER_RATE * 20L, 1 * 20L);
|
||||
|
||||
TFM_CommandLoader.getInstance().scan();
|
||||
|
||||
|
||||
|
||||
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||
try
|
||||
{
|
||||
@ -124,8 +119,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
||||
}
|
||||
|
||||
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "."
|
||||
+ TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
||||
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -169,8 +163,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
try
|
||||
{
|
||||
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX,
|
||||
cmd.getName().toLowerCase())).newInstance();
|
||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
|
||||
dispatcher.setup(this, sender, dispatcher.getClass());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@ -206,7 +199,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
public static boolean allowFirePlace = false;
|
||||
public static Boolean allowFireSpread = false;
|
||||
public static Boolean allowLavaDamage = false;
|
||||
@ -243,8 +236,9 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public static double autoProtectRadius = 25.0D;
|
||||
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
|
||||
public static boolean twitterbotEnabled = false;
|
||||
public static String twitterbotUrl = "http://tftwitter.darthcraft.net/";
|
||||
public static String twitterbotUrl = "";
|
||||
public static String twitterbotSecret = "";
|
||||
public static boolean petProtectEnabled = true;
|
||||
|
||||
public static void loadMainConfig()
|
||||
{
|
||||
@ -291,13 +285,14 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
||||
twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl);
|
||||
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
|
||||
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe("Error loading main config: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@Deprecated
|
||||
public static List<String> superadmins = new ArrayList<String>();
|
||||
@Deprecated
|
||||
@ -318,7 +313,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
public static List<String> permbanned_players = new ArrayList<String>();
|
||||
public static List<String> permbanned_ips = new ArrayList<String>();
|
||||
|
||||
|
Reference in New Issue
Block a user