Compare commits

..

11 Commits
v2.18 ... v2.20

Author SHA1 Message Date
44fb26b27f Updated to Bukkit 1.6 2013-07-02 14:05:29 +02:00
fab341608b Improved mojang service checker, now using xpaw.ru, migrated to /minecraft 2013-07-01 10:04:43 +02:00
4f6a0ca5d3 Blocked TNT Minecarts from being placed 2013-06-23 15:17:12 +02:00
f3684cc2ce Whoops! 2013-06-22 20:12:58 +02:00
772b7e43f7 Added license 2013-06-22 19:59:52 +02:00
c308c9a268 Oopsies. 2013-06-18 19:52:41 +03:00
fcb424a793 Minor changes to CONTRIBUTING.md 2013-06-18 16:34:35 +02:00
be1acb4e03 Disaster839 is without a capital, who knew? 2013-06-11 22:48:38 +03:00
386989fa69 Added contribution info 2013-06-11 17:59:04 +02:00
4c7cd9cb23 Merge pull request #40 from WickedGamingUK/patch-6
Changed madgeek1540 to madgeek1450
2013-06-10 06:46:51 -07:00
1f87c05547 Changed madgeek1540 to madgeek1450
Just noticed a little typing error in the developer's StringList, so I decided to fix it :)
2013-06-10 11:51:55 +02:00
17 changed files with 344 additions and 105 deletions

65
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,65 @@
# How to contribute
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
* 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
* 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.
* 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!*).
## Tips on getting 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)
* 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.
* 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).
* 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.
* 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.
* 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
* 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
* [TotalFreedom information](http://totalfreedom.me)
* [TotalFreedom forums](http://totalfreedom.boards.net)
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
* [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)

16
LICENCE.md Normal file
View File

@ -0,0 +1,16 @@
# 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.

View File

@ -1,5 +1,5 @@
#Mon, 03 Jun 2013 23:08:42 +0200
#Tue, 02 Jul 2013 14:04:59 +0200
program.VERSION=2.18
program.BUILDNUM=216
program.BUILDDATE=06/03/2013 11\:08 PM
program.VERSION=2.20
program.BUILDNUM=238
program.BUILDDATE=07/02/2013 02\:04 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Jun 03 23:08:42 CEST 2013
build.number=217
#Tue Jul 02 14:04:59 CEST 2013
build.number=239

View File

@ -1,4 +1,4 @@
# TotalFreedomMod v2.18 Configuration
# TotalFreedomMod v2.20 Configuration
# by Madgeek1450 and DarthSalamon
# Block placement prevention:
@ -8,6 +8,7 @@ allow_lava_damage: false
allow_lava_place: false
allow_water_place: false
allow_fluid_spread: false
allow_tnt_minecarts: false
# Explosion management:
allow_explosions: false

View File

@ -0,0 +1,25 @@
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

@ -1,41 +1,16 @@
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)
@ -52,59 +27,6 @@ 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

@ -11,7 +11,6 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;

View File

@ -36,7 +36,7 @@ public class TFM_EntityListener implements Listener
@EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event)
{
if (!TotalFreedomMod.allowFireSpread)
if (!TotalFreedomMod.allowExplosions)
{
event.setCancelled(true);
}

View File

@ -45,20 +45,34 @@ public class TFM_PlayerListener implements Listener
{
case WATER_BUCKET:
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
return;
if (!TotalFreedomMod.allowWaterPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
return;
}
}
case LAVA_BUCKET:
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
if (!TotalFreedomMod.allowLavaPlace)
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
return;
}
}
case POTION:
case EXPLOSIVE_MINECART:
{
if (!TotalFreedomMod.allowTntMinecarts)
{
player.getInventory().clear(player.getInventory().getHeldItemSlot());
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
event.setCancelled(true);
}
}
}
break;
}
@ -98,7 +112,6 @@ public class TFM_PlayerListener implements Listener
}
event.setCancelled(true);
return;
}
break;
}

View File

@ -37,7 +37,7 @@ public class TFM_RollbackManager
{
e = new ArrayList<TFM_RollbackEntry>();
}
e.add(entry);
e.add(0, entry);
entries.put(player.getName(), e);
}

View File

@ -5,11 +5,11 @@ import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import java.util.regex.Pattern;
import net.minecraft.server.v1_5_R3.BanEntry;
import net.minecraft.server.v1_5_R3.BanList;
import net.minecraft.server.v1_5_R3.MinecraftServer;
import net.minecraft.server.v1_5_R3.PlayerList;
import net.minecraft.server.v1_5_R3.PropertyManager;
import net.minecraft.server.v1_6_R1.BanEntry;
import net.minecraft.server.v1_6_R1.BanList;
import net.minecraft.server.v1_6_R1.MinecraftServer;
import net.minecraft.server.v1_6_R1.PlayerList;
import net.minecraft.server.v1_6_R1.PropertyManager;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;

View File

@ -0,0 +1,189 @@
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");
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)
{
TFM_Log.severe(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

@ -27,7 +27,7 @@ public class TFM_Util
private static final Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1540", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "Disaster839");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "disaster839");
static
{

View File

@ -30,6 +30,7 @@ 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";
@ -102,10 +103,16 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Util.deleteFolder(new File("./_deleteme"));
// 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, 5 * 20L);
TFM_CommandLoader.getInstance().scan();
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
try
{
@ -201,6 +208,8 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean allowLavaPlace = false;
public static boolean allowWaterPlace = false;
public static Boolean allowExplosions = false;
public static boolean allowFliudSpread = false;
public static boolean allowTntMinecarts = false;
public static double explosiveRadius = 4.0D;
public static boolean autoEntityWipe = true;
public static boolean nukeMonitor = true;
@ -222,7 +231,6 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean tossmobEnabled = false;
public static boolean generateFlatlands = true;
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
public static boolean allowFliudSpread = false;
public static boolean adminOnlyMode = false;
public static boolean protectedAreasEnabled = true;
public static boolean autoProtectSpawnpoints = true;
@ -245,6 +253,7 @@ public class TotalFreedomMod extends JavaPlugin
allowLavaPlace = config.getBoolean("allow_lava_place", allowLavaPlace);
allowWaterPlace = config.getBoolean("allow_water_place", allowWaterPlace);
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);

View File

@ -1,6 +1,6 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 2.18
version: 2.20
description: Plugin for the Total Freedom server.
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]