Merge branch origin/master

This commit is contained in:
Jerom van der Sar 2013-07-12 21:53:04 +02:00
commit 37e78dceec
20 changed files with 263 additions and 511 deletions

View File

@ -1,63 +1,50 @@
# How to contribute
# Contributing to TotalFreedomMod #
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss.
TotalFreedomMod aims to be a fully functional all-op server mod which works in
a large range of configurations. In order to be as flexible as possible on the
server-end, we encourage contributing to TotalFreedomMod by making 'pull-requests'
to this repository.
## Getting Started
For those who wish to contribute, we encourage you to fork the repository and submit pull requests. Below you will find guidelines that will explain this process in further detail.
## Getting Started ##
* Make sure you have a [GitHub account](https://github.com/signup/free)
* If the issue is a bug, submit a ticket for it, assuming one does not already exist.
* Clearly describe the issue including steps to reproduce it.
* Make sure you fill in the earliest version that you know has the issue.
* Fork the repository on GitHub
## Making Changes
## Making Changes ##
* Create a topic branch from where you want to base your work.
* This is usually the master branch.
* Only target release branches if you are certain your addition must be on that
branch.
* To quickly create a topic branch based on master; `git checkout -b contribution`
Please avoid working directly on the `master` branch.
* Only target release branches if you are certain your addition must be on that branch.
* To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch.
* Make changes and commit where necessary.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are in line with those which are already made.
* Make sure your changes build (*and work!*).
* Make sure your changes build (<b>and work!</b>).
## Tips on getting your pull request accepted
## Tips - How To Get Your Pull Request Accepted ##
* Make sure your changes work and compile without difficulty.
* Make sure your change adds something useful, do not add commands to micromanage
the server. (ie: Shorthands for a collection of commands)
* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands)
* __Commands that make use of `org.bukkit.Server.dispatchCommand()` will probably be rejected.__
* Features must be in line the general idea of "Total Freedom".
* Changes must be directed towards the main "TotalFreedom" server. Adding names such
as the name of your own TotalFreedom-like server will get your pull request denied.
* Changes must be directed towards the main "TotalFreedom" server. Adding names such as the name of your own TotalFreedom-like server will get your pull request denied.
* Do not add yourself to the developer list.
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
* Please make sure your changes are written such as other features would be. Eg: commands
have their own class and extend TFM_Command.
* Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).
* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command.
* __Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).__
* Do not increment the version number.
* If you want to add multiple changes, please make one pull request per change. This
way, it's easier to accept your changes faster and won't block the other changes if there
is an issue with a specific line of code.
* If you want to add multiple changes, please make one pull request per change. This way, it's easier to accept your changes faster and won't block the other changes if there is an issue with a specific line of code.
* Please make sure there are no bugs in your code.
* Please avoid having to add files in the main namespace where possible.
* Make sure all changes work before you commit these, this avoids having multiple
unnecessary commits.
* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits.
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
* Please do not spread your addition over several pull-requests.
## Submitting Changes
## Submitting Your Changes ##
* Push your changes to a topic branch in your fork of the repository.
* Submit a pull request to this repository.
* Explain in detail what each one of your commits changes and point out any big changes.
* Wait as a developer evaluates your changes.
# Additional Resources
## Additional Resources ##
* [TotalFreedom information](http://totalfreedom.me)
* [TotalFreedom forums](http://totalfreedom.boards.net)
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)

View File

@ -1,16 +0,0 @@
# Legal
TotalFreedomMod by Madgeek1450 and DarthSalamon is an effort to create an opensource plugin to effectively run a "Total Freedom" like all-Op server. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together with the main server "TotalFreedom" (http://totalfreedom.me) TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feel of openness towards the administrators and the players themselves.
## License
TotalFreedomMod sourcecode is freely available under the GNU GPLv3 License with a few restrictions in place. The license is available here: http://www.gnu.org/licenses/gpl.txt
The few restrictions are in place to make sure that credit is given to the original authors who remain the maintainers of the plugin and it's sourcecode.
These are the restrictions under which the sourcecode is licensed:
* A un-edited copy of this license must always be included with this sourcecode.
* TotalFreedomMod sourcecode and its derrivations are freely distributable between anyone who choses to download it.
* You may not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" and "jeromsar" from any part of the sourcecode.
* However, compiled binaries (*.jar's) are not to be distributed. If you wish to obtain a copy of TotalFreedomMod you must compile the original sourcecode or it's derivations yourself using an IDE like netbeans. Official superadmins and above of the TotalFreedom (totalfreedom.me) server may obtain a compiled libary with the same limitations as described in this document.
* Any conditions on this license may be waived by any of the official developers.

11
LICENSE.md Normal file
View File

@ -0,0 +1,11 @@
# TotalFreedomMod License #
TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt
We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code.
* A un-edited copy of this LICENSE.md shall always be included with this source code.
* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it.
* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "jeromsar" from any part of the source code.
* Compiled binaries (*.jar's) shall not to be distributed.
* If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself.
* The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis.
* Any restrictions listed here may be waived by any of the above mentioned primary developers.

View File

@ -1,6 +1,7 @@
TotalFreedomMod
===============
# TotalFreedomMod #
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
Information about the TotalFreedom server can be found at http://totalfreedom.me/
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).

View File

@ -3,3 +3,4 @@
program.VERSION=2.21
program.BUILDNUM=301
program.BUILDDATE=07/10/2013 11\:58 PM

View File

@ -50,26 +50,24 @@ explosiveRadius: 4.0
#
blocked_commands:
# Disabled commands
- 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.'
- 'n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.'
- 'n:b:/gamemode:Use /creative and /survival to set your gamemode.'
- 'n:b:/ban:_'
- 'n:b:/pardon:_'
- 'n:b:/toggledownfall:_'
- n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.
- n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.
- n:b:/gamemode:Use /creative and /survival to set your gamemode.
- n:b:/ban:_
- n:b:/pardon:_
- n:b:/toggledownfall:_
# Superadmin commands
- 's:b:/kick:_'
- 's:b:/socialspy:_'
- 's:b:/kill:_'
- 's:a:/stop'
- 's:a:/reload'
- 's:a:/nuke'
- 's:a:/save-all'
- 's:a:/save-on'
- 's:a:/save-off'
- 's:a:/clearhistory'
- 's:a:/butcher'
- 's:a://butcher'
- s:b:/kick:_
- s:b:/socialspy:_
- s:b:/kill:_
- s:b:/clearhistory:_
- s:a:/stop
- s:a:/reload
- s:a:/nuke
- s:a:/save-all
- s:a:/save-on
- s:a:/save-off
# Automatically wipe dropped objects:
auto_wipe: true
@ -125,5 +123,8 @@ host_sender_names:
# TwitterBot - Used to allow superadmins to verify themselves using twitter
twitterbot_enabled: false
twitterbot_url: 'http://tftwitter.darthcraft.net/'
twitterbot_secret: ''
twitterbot_url:
twitterbot_secret:
# Pet Protect - Prevent tamed pets from being killed.
pet_protect_enabled: true

View File

@ -102,5 +102,4 @@ public class Command_halt extends TFM_Command
return true;
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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()))
{

View File

@ -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;
}
}
}

View File

@ -427,7 +427,7 @@ public class TFM_PlayerData
player.sendMessage(ChatColor.GRAY + "You are no longer halted.");
}
}
public BukkitTask getLockupScheduleID()

View File

@ -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");
}
}
}
}

View File

@ -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);
}
}
});
*/

View File

@ -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()));

View File

@ -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)

View File

@ -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>();