Added Announcer. Resolves #226

Organised onEnable()
Formatting
This commit is contained in:
unknown 2014-08-25 19:49:44 +02:00
parent af97481d11
commit b0aa4a850d
13 changed files with 155 additions and 52 deletions

View file

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Jun 30 19:03:45 CEST 2014
build.number=915
#Mon Aug 25 19:45:03 CEST 2014
build.number=919

View file

@ -36,8 +36,6 @@ allow:
tnt_minecarts: false
explosions: false
explosive_radius: 4.0
# Blocked commands:
#
# How blocked commands work:
@ -114,7 +112,7 @@ blocked_commands:
- 's:a:/restart'
- 's:b:/setblock:_'
# Automatically wipe dropped objects:
# Automatically wipe dropped objects
auto_wipe: true
# Nuking prevention
@ -125,8 +123,9 @@ nukemonitor:
range: 10.0
freecam_trigger_count: 10
explosive_radius: 4.0
# Show all attempted commands in the log, will result in duplicate log messages:
# Show all attempted commands in the log, will result in duplicate log messages
preprocess_log: true
# Disable certain events
@ -135,13 +134,12 @@ disable:
weather: true
# Enable misc. features:
# Enable misc. features
landmines_enabled: false
mp44_enabled: false
tossmob_enabled: false
# Moblimiter:
# Moblimiter
moblimiter:
enabled: true
max: 50
@ -154,7 +152,8 @@ moblimiter:
# Flatlands
flatlands:
generate: true
# Flatlands generation parameters, uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/
# Flatlands generation parameters - Uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/
generate_params: 16,stone,32,dirt,1,grass
# Admin-Only Mode
@ -176,6 +175,21 @@ host_sender_names:
- rcon
- remotebukkit
# Announcer
announcer:
enabled: true
# Interval between announcements, in seconds.
interval: 600
# Prefix for all announcements
prefix: '&5[&eTotalFreedom&5] &b'
announcements:
- 'Be sure to visit our forums at &6http://totalfreedom.boards.net/'
- 'You can always review the server rules here: &6http://totalfreedom.me/'
- 'If you aren''t OP, be sure to ask!'
# Players who cannot be banned by username
unbannable_usernames:
- honeydew
@ -226,7 +240,7 @@ twitterbot:
petprotect:
enabled: true
# Logs Registration
# Logviewer
logs:
url: ''
secret: ''
@ -234,7 +248,7 @@ logs:
# Mojang service checker
service_checker_url: http://status.mojang.com/check
# HTTPD
# HTTPD server
httpd:
enabled: true
port: 28966
@ -243,7 +257,9 @@ httpd:
# Inactivity Auto-Kick (Requires Essentials)
autokick:
enabled: true
# autokick_threshold - Percentage of server player capacity used at which players will be automatically kicked for being inactive. Range: 0.0 - 1.0
threshold: 0.9
# autokick_time - Time, in seconds, after which a player should be kicked when inactive
time: 120

View file

@ -16,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
public class Command_cake extends TFM_Command
{
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.";
private final Random random = new Random();
@Override

View file

@ -28,7 +28,6 @@ public class Command_gadmin extends TFM_Command
CI("ci"),
FR("fr"),
SMITE("smite");
private final String modeName;
private GadminMode(String command)
@ -81,8 +80,7 @@ public class Command_gadmin extends TFM_Command
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
player.getName(),
ChatColor.stripColor(player.getDisplayName()),
hash
));
hash));
}
return true;
}

View file

@ -67,7 +67,6 @@ public class Command_landmine extends TFM_Command
public static class TFM_LandmineData
{
public static final List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
public final Location location;
public final Player player;
public final double radius;

View file

@ -22,7 +22,6 @@ public class Command_nickclean extends TFM_Command
ChatColor.UNDERLINE,
ChatColor.BLACK
};
private static final Pattern REGEX = Pattern.compile("\\u00A7[" + StringUtils.join(BLOCKED, "") + "]");
@Override

View file

@ -112,14 +112,13 @@ public class Command_tag extends TFM_Command
final String inputTag = StringUtils.join(args, " ", 1, args.length);
final String outputTag = TFM_Util.colorize(StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag),
new String[]
{
"" + ChatColor.COLOR_CHAR, "&k"
},
{
"" + ChatColor.COLOR_CHAR, "&k"
},
new String[]
{
"", ""
}
)) + ChatColor.RESET;
{
"", ""
})) + ChatColor.RESET;
if (!TFM_AdminList.isSuperAdmin(sender))
{

View file

@ -18,7 +18,6 @@ public abstract class TFM_Command
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
protected TotalFreedomMod plugin;
protected Server server;
private CommandSender commandSender;

View file

@ -65,6 +65,11 @@ public enum TFM_ConfigEntry
FLATLANDS_GENERATE(Boolean.class, "flatlands.generate"),
FLATLANDS_GENERATE_PARAMS(String.class, "flatlands.generate_params"),
//
ANNOUNCER_ENABLED(Boolean.class, "announcer.enabled"),
ANNOUNCER_INTERVAL(Integer.class, "announcer.interval"),
ANNOUNCER_PREFIX(String.class, "announcer.prefix"),
ANNOUNCER_ANNOUNCEMENTS(List.class, "announcer.announcements"),
//
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
FREECAM_TRIGGER_COUNT(Integer.class, "freecam_trigger_count"),
SERVICE_CHECKER_URL(String.class, "service_checker_url"),

View file

@ -343,7 +343,6 @@ public class TFM_PlayerListener implements Listener
}
}
}
private static final Random RANDOM = new Random();
private static Location randomOffset(Location a, double magnitude)

View file

@ -0,0 +1,87 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import org.bukkit.scheduler.BukkitRunnable;
public class TFM_Announcer
{
private static final List<String> ANNOUNCEMENTS = new ArrayList<String>();
private static boolean enabled;
private static long interval;
private static String prefix;
private static BukkitRunnable announcer;
public static void load()
{
stop();
ANNOUNCEMENTS.clear();
for (Object announcement : TFM_ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
{
ANNOUNCEMENTS.add(TFM_Util.colorize((String) announcement));
}
enabled = TFM_ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
interval = TFM_ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
prefix = TFM_Util.colorize(TFM_ConfigEntry.ANNOUNCER_PREFIX.getString());
if (enabled)
{
start();
}
}
public static boolean isStarted()
{
return announcer != null;
}
public static void start()
{
if (isStarted())
{
return;
}
announcer = new BukkitRunnable()
{
private int current = 0;
@Override
public void run()
{
current++;
if (current >= ANNOUNCEMENTS.size())
{
current = 0;
}
TFM_Util.bcastMsg(prefix + ANNOUNCEMENTS.get(current));
}
};
announcer.runTaskTimer(TotalFreedomMod.plugin, interval, interval);
}
public static void stop()
{
if (announcer == null)
{
return;
}
try
{
announcer.cancel();
}
finally
{
announcer = null;
}
}
}

View file

@ -31,8 +31,7 @@ public class TFM_Heartbeat extends BukkitRunnable
{
lastRan = System.currentTimeMillis();
final boolean doAwayKickCheck
= TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
final boolean doAwayKickCheck = TFM_ConfigEntry.AUTOKICK_ENABLED.getBoolean()
&& TFM_EssentialsBridge.isEssentialsEnabled()
&& ((server.getOnlinePlayers().length / server.getMaxPlayers()) > TFM_ConfigEntry.AUTOKICK_THRESHOLD.getDouble());

View file

@ -70,8 +70,6 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.info("Made by Madgeek1450 and DarthSalamon");
TFM_Log.info("Compiled " + buildDate + " by " + buildCreator);
TFM_Util.deleteCoreDumps();
if (!TFM_ServerInterface.COMPILE_NMS_VERSION.equals(TFM_Util.getNmsVersion()))
{
TFM_Log.warning(pluginName + " is compiled for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " but the server is running "
@ -79,19 +77,27 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.warning("This might result in unexpected behaviour!");
}
// Admin list
TFM_Util.deleteCoreDumps();
TFM_Util.deleteFolder(new File("./_deleteme"));
// Create backups
TFM_Util.createBackups(SUPERADMIN_FILE);
TFM_AdminList.load();
// Permban list
TFM_Util.createBackups(PERMBAN_FILE);
TFM_PermbanList.load();
// Playerlist and bans
// Load services
TFM_AdminList.load();
TFM_PermbanList.load();
TFM_PlayerList.load();
TFM_BanManager.load();
TFM_Announcer.load();
TFM_Util.deleteFolder(new File("./_deleteme"));
// Protect area
// TODO: Refractor to single .load() method
if (TFM_ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
TFM_ProtectedArea.loadProtectedAreas();
TFM_ProtectedArea.autoAddSpawnpoints();
}
final PluginManager pm = server.getPluginManager();
pm.registerEvents(new TFM_EntityListener(), plugin);
@ -107,6 +113,7 @@ public class TotalFreedomMod extends JavaPlugin
}
catch (Exception ex)
{
TFM_Log.warning("Could not load world: Flatlands");
}
try
@ -115,6 +122,7 @@ public class TotalFreedomMod extends JavaPlugin
}
catch (Exception ex)
{
TFM_Log.warning("Could not load world: AdminWorld");
}
// Initialize game rules
@ -127,6 +135,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
TFM_GameRuleHandler.commitGameRules();
// Disable weather
if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
{
for (World world : server.getWorlds())
@ -138,16 +147,17 @@ public class TotalFreedomMod extends JavaPlugin
}
}
if (TFM_ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
TFM_ProtectedArea.loadProtectedAreas();
TFM_ProtectedArea.autoAddSpawnpoints();
}
// Heartbeat
new TFM_Heartbeat(plugin).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
// Start services
TFM_ServiceChecker.start();
TFM_HTTPD_Manager.start();
TFM_FrontDoor.start();
TFM_Log.info("Version " + pluginVersion + " for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " enabled");
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
try
{
final Metrics metrics = new Metrics(plugin);
@ -158,13 +168,7 @@ public class TotalFreedomMod extends JavaPlugin
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
}
TFM_ServiceChecker.start();
TFM_HTTPD_Manager.start();
TFM_FrontDoor.start();
TFM_Log.info("Version " + pluginVersion + " for " + TFM_ServerInterface.COMPILE_NMS_VERSION + " enabled");
// Delayed Start:
// Load commands later
new BukkitRunnable()
{
@Override