Added weather

This commit is contained in:
Steven Lawson 2011-10-14 01:31:21 -04:00
parent d5d0bd1a26
commit 5aaab9ff1e
10 changed files with 269 additions and 71 deletions

View File

@ -24,6 +24,9 @@ preprocess_log: true
# Disable nighttime:
disable_night: true
# Disable weather:
disable_weather: true
# Superadmins: Users that can always log in and use the most powerful commands:
# When online-mode = false, only superadmin_ips will be used.
superadmins:

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
@ -20,9 +21,8 @@ import org.bukkit.util.Vector;
public class TFM_Cmds_Admin implements CommandExecutor
{
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
public TFM_Cmds_Admin(TotalFreedomMod plugin)
{
this.plugin = plugin;
@ -45,7 +45,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
senderIsConsole = true;
log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TFM_Util.implodeStringList(" ", Arrays.asList(args))));
}
if (cmd.getName().equalsIgnoreCase("fr"))
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
@ -126,7 +126,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
//Undo WorldEdits:
Bukkit.getServer().dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName()));
@ -168,6 +168,74 @@ public class TFM_Cmds_Admin implements CommandExecutor
return true;
}
else if (cmd.getName().equalsIgnoreCase("tfsmite"))
{
if (args.length != 1)
{
return false;
}
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{
List<Player> targets = new ArrayList<Player>();
if (args[0].equalsIgnoreCase("all"))
{
targets = Arrays.asList(Bukkit.getOnlinePlayers());
}
else
{
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage("Can't find user " + args[0]);
return true;
}
else
{
targets.add(matches.get(0));
}
}
for (Player p : targets)
{
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
//Deop
p.setOp(false);
//Set gamemode to survival:
p.setGameMode(GameMode.SURVIVAL);
//Clear inventory:
p.getInventory().clear();
//Flag for insta-kill:
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
playerdata.setForcedDeath(true);
}
//Strike with lightning effect:
final Location target_pos = p.getLocation();
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
target_pos.getWorld().strikeLightning(strike_pos);
}
}
}
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("gadmin"))
{
if (args.length == 0)
@ -327,7 +395,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
plugin.nukeMonitor = false;
sender.sendMessage("Nuke monitor is disabled.");
}
// FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILE));
// config.set("nuke_monitor", plugin.nukeMonitor);
// config.set("nuke_monitor_range", plugin.nukeMonitorRange);
@ -360,7 +428,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
plugin.preprocessLogEnabled = false;
sender.sendMessage("Command preprocess logging is now disabled.");
}
// FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILE));
// config.set("preprocess_log", plugin.preprocessLogEnabled);
// config.save(new File(plugin.getDataFolder(), TotalFreedomMod.CONFIG_FILE));
@ -408,7 +476,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
return false;
}
Player p;
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
@ -420,7 +488,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
p = matches.get(0);
}
String outcommand = "";
try
{
@ -435,7 +503,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
sender.sendMessage(ChatColor.GRAY + "Error building command: " + cmdex.getMessage());
}
try
{
sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand);
@ -468,19 +536,19 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
return false;
}
Player p;
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
return true;
}
else
{
p = matches.get(0);
}
//Deop
p.setOp(false);
@ -500,10 +568,10 @@ public class TFM_Cmds_Admin implements CommandExecutor
target_pos.getWorld().strikeLightning(strike_pos);
}
}
//Send to jail "mgjail":
Bukkit.getServer().dispatchCommand(sender, String.format("tjail %s mgjail", p.getName()));
TFM_Util.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED);
}
else
@ -523,18 +591,18 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
p.sendMessage(ChatColor.GRAY + "You have been undisguised by an administrator.");
}
MobDisguiseAPI.undisguisePlayer(p);
MobDisguiseAPI.undisguisePlayerAsPlayer(p, "");
}
sender.sendMessage(ChatColor.GRAY + "All players have been undisguised.");
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("csay"))
@ -542,27 +610,27 @@ public class TFM_Cmds_Admin implements CommandExecutor
if (senderIsConsole)
{
String sender_name = sender.getName();
if (sender_name.equalsIgnoreCase("remotebukkit"))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
sender_name = sender_name.split("-")[0];
StringBuilder outmessage_bldr = new StringBuilder();
for (int i = 0; i < args.length; i++)
{
outmessage_bldr.append(args[i]).append(" ");
}
TFM_Util.tfm_broadcastMessage(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender_name, outmessage_bldr.toString().trim()));
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("cage"))
@ -573,26 +641,26 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
return false;
}
Player p;
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
return true;
}
else
{
p = matches.get(0);
}
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
}
Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR;
if (args.length >= 2)
@ -613,7 +681,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
}
}
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
@ -625,7 +693,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
cage_material_inner = Material.STATIONARY_LAVA;
}
}
Location target_pos = p.getLocation().add(0, 1, 0);
playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner);
playerdata.regenerateHistory();
@ -633,16 +701,16 @@ public class TFM_Cmds_Admin implements CommandExecutor
TFM_Util.buildHistory(target_pos, 2, playerdata);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(0));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(1));
p.setGameMode(GameMode.SURVIVAL);
TFM_Util.tfm_broadcastMessage(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW);
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("orbit"))
@ -653,32 +721,32 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
return false;
}
Player p;
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
return true;
}
else
{
p = matches.get(0);
}
double strength = 100.0;
if (args.length >= 2)
{
strength = Double.parseDouble(args[1]);
}
p.setVelocity(new Vector(0, strength, 0));
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
}
@ -686,7 +754,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
log.severe("Exception in TFM_Cmds_Admin.onCommand(): " + ex.getMessage());
}
return false;
}
}

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -47,6 +48,25 @@ public class TFM_EntityListener extends EntityListener
@Override
public void onEntityDamage(EntityDamageEvent event)
{
if (event.getEntity() instanceof Player)
{
Player p = (Player) event.getEntity();
if (p != null)
{
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
if (playerdata.getForcedDeath())
{
event.setCancelled(false);
event.setDamage(p.getHealth() + 1);
playerdata.setForcedDeath(false);
return;
}
}
}
}
if (event.getCause() == DamageCause.LAVA && !plugin.allowLavaDamage)
{
event.setCancelled(true);

View File

@ -1,5 +1,6 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -41,5 +42,22 @@ public class TFM_Heartbeat implements Runnable
}
}
}
if (plugin.disableWeather)
{
for (World world : Bukkit.getWorlds())
{
if (world.getWeatherDuration() > 0)
{
world.setThundering(false);
world.setWeatherDuration(0);
}
else if (world.getThunderDuration() > 0)
{
world.setStorm(false);
world.setThunderDuration(0);
}
}
}
}
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -135,6 +136,14 @@ class TFM_PlayerListener extends PlayerListener
playerdata.incrementMsgCount();
plugin.userinfo.put(p, playerdata);
}
if (Pattern.compile("\\sbe\\s.*admin").matcher(event.getMessage().toLowerCase()).find())
{
log.info("Kicked " + p.getName() + " for being annoying.");
p.kickPlayer("No, bitch.");
event.setCancelled(true);
return;
}
}
@Override
@ -152,14 +161,14 @@ class TFM_PlayerListener extends PlayerListener
boolean block_command = false;
if (command.matches("^/stop"))
if (command.matches("^/stop.*"))
{
if (!TFM_Util.isUserSuperadmin(player, plugin))
{
block_command = true;
}
}
else if (command.matches("^/reload"))
else if (command.matches("^/reload.*"))
{
if (!TFM_Util.isUserSuperadmin(player, plugin))
{

View File

@ -14,6 +14,8 @@ public class TFM_UserInfo
private int freecam_destroy_count = 0;
private int freecam_place_count = 0;
private boolean forced_death = false;
// -- Start Cage
private boolean user_caged = false;
@ -92,6 +94,16 @@ public class TFM_UserInfo
}
// -- End Cage
public boolean getForcedDeath()
{
return this.forced_death;
}
void setForcedDeath(boolean forced_death)
{
this.forced_death = forced_death;
}
public boolean isFrozen()
{

View File

@ -22,11 +22,11 @@ import org.bukkit.entity.*;
public class TFM_Util
{
private static final Logger log = Logger.getLogger("Minecraft");
public TFM_Util()
{
}
public static void tfm_broadcastMessage(String message, ChatColor color)
{
log.info(message);
@ -129,14 +129,14 @@ public class TFM_Util
}
}
}
public static void setWorldTime(World world, long ticks)
{
long time = world.getTime();
time -= time % 24000;
world.setTime(time + 24000 + ticks);
}
public static void createDefaultConfiguration(String name, TotalFreedomMod tfm, File plugin_file)
{
File actual = new File(tfm.getDataFolder(), name);
@ -207,7 +207,7 @@ public class TFM_Util
}
}
}
public static boolean isUserSuperadmin(CommandSender user, TotalFreedomMod tfm)
{
try
@ -266,4 +266,27 @@ public class TFM_Util
}
return removed;
}
public static boolean deleteFolder(File file)
{
if (file.exists())
{
if (file.isDirectory())
{
for (File f : file.listFiles())
{
if (!TFM_Util.deleteFolder(f))
{
return false;
}
}
}
file.delete();
return !file.exists();
}
else
{
return false;
}
}
}

View File

@ -0,0 +1,33 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.event.weather.*;
class TFM_WeatherListener extends WeatherListener
{
private TotalFreedomMod plugin;
public TFM_WeatherListener(TotalFreedomMod instance)
{
this.plugin = instance;
}
@Override
public void onThunderChange(ThunderChangeEvent event)
{
if (event.toThunderState() && plugin.disableWeather)
{
event.setCancelled(true);
return;
}
}
@Override
public void onWeatherChange(WeatherChangeEvent event)
{
if (event.toWeatherState() && plugin.disableWeather)
{
event.setCancelled(true);
return;
}
}
}

View File

@ -41,6 +41,8 @@ public class TotalFreedomMod extends JavaPlugin
Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
log.log(Level.INFO, "[" + getDescription().getName() + "] - Enabled! - Version: " + getDescription().getVersion() + " by Madgeek1450");
TFM_Util.deleteFolder(new File("./_deleteme"));
}
@Override
@ -64,6 +66,7 @@ public class TotalFreedomMod extends JavaPlugin
public int freecamTriggerCount = 10;
public Boolean preprocessLogEnabled = true;
public Boolean disableNight = true;
public Boolean disableWeather = true;
public List<String> superadmins = new ArrayList<String>();
public List<String> superadmin_ips = new ArrayList<String>();
@ -87,6 +90,7 @@ public class TotalFreedomMod extends JavaPlugin
freecamTriggerCount = config.getInt("freecam_trigger_count", freecamTriggerCount);
preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled);
disableNight = config.getBoolean("disable_night", disableNight);
disableWeather = config.getBoolean("disable_weather", disableWeather);
superadmins = (List<String>) config.getList("superadmins", null);
if (superadmins == null)
@ -107,6 +111,7 @@ public class TotalFreedomMod extends JavaPlugin
private final TFM_EntityListener entityListener = new TFM_EntityListener(this);
private final TFM_BlockListener blockListener = new TFM_BlockListener(this);
private final TFM_PlayerListener playerListener = new TFM_PlayerListener(this);
private final TFM_WeatherListener weatherListener = new TFM_WeatherListener(this);
private void registerEventHandlers()
{
@ -126,6 +131,9 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this);
}
private TFM_Cmds_OP OPCommands = new TFM_Cmds_OP(this);
@ -136,48 +144,49 @@ public class TotalFreedomMod extends JavaPlugin
private void registerCommands()
{
this.getCommand("opme").setExecutor(OPCommands);
this.getCommand("opall").setExecutor(OPCommands);
this.getCommand("deopall").setExecutor(OPCommands);
this.getCommand("qop").setExecutor(OPCommands);
this.getCommand("opall").setExecutor(OPCommands);
this.getCommand("opme").setExecutor(OPCommands);
this.getCommand("qdeop").setExecutor(OPCommands);
this.getCommand("qop").setExecutor(OPCommands);
this.getCommand("creative").setExecutor(GeneralCommands);
this.getCommand("survival").setExecutor(GeneralCommands);
this.getCommand("status").setExecutor(GeneralCommands);
this.getCommand("radar").setExecutor(GeneralCommands);
this.getCommand("mp").setExecutor(GeneralCommands);
this.getCommand("rd").setExecutor(GeneralCommands);
this.getCommand("flatlands").setExecutor(GeneralCommands);
this.getCommand("skylands").setExecutor(GeneralCommands);
this.getCommand("nether").setExecutor(GeneralCommands);
this.getCommand("banlist").setExecutor(GeneralCommands);
this.getCommand("creative").setExecutor(GeneralCommands);
this.getCommand("flatlands").setExecutor(GeneralCommands);
this.getCommand("ipbanlist").setExecutor(GeneralCommands);
this.getCommand("mp").setExecutor(GeneralCommands);
this.getCommand("nether").setExecutor(GeneralCommands);
this.getCommand("radar").setExecutor(GeneralCommands);
this.getCommand("rd").setExecutor(GeneralCommands);
this.getCommand("skylands").setExecutor(GeneralCommands);
this.getCommand("status").setExecutor(GeneralCommands);
this.getCommand("survival").setExecutor(GeneralCommands);
this.getCommand("fr").setExecutor(AdminCommands);
this.getCommand("gtfo").setExecutor(AdminCommands);
this.getCommand("gadmin").setExecutor(AdminCommands);
this.getCommand("wildcard").setExecutor(AdminCommands);
this.getCommand("nonuke").setExecutor(AdminCommands);
this.getCommand("prelog").setExecutor(AdminCommands);
this.getCommand("cake").setExecutor(AdminCommands);
this.getCommand("gcmd").setExecutor(AdminCommands);
this.getCommand("qjail").setExecutor(AdminCommands);
this.getCommand("umd").setExecutor(AdminCommands);
this.getCommand("csay").setExecutor(AdminCommands);
this.getCommand("cage").setExecutor(AdminCommands);
this.getCommand("cake").setExecutor(AdminCommands);
this.getCommand("csay").setExecutor(AdminCommands);
this.getCommand("fr").setExecutor(AdminCommands);
this.getCommand("gadmin").setExecutor(AdminCommands);
this.getCommand("gcmd").setExecutor(AdminCommands);
this.getCommand("gtfo").setExecutor(AdminCommands);
this.getCommand("nonuke").setExecutor(AdminCommands);
this.getCommand("orbit").setExecutor(AdminCommands);
this.getCommand("prelog").setExecutor(AdminCommands);
this.getCommand("qjail").setExecutor(AdminCommands);
this.getCommand("tfsmite").setExecutor(AdminCommands);
this.getCommand("umd").setExecutor(AdminCommands);
this.getCommand("wildcard").setExecutor(AdminCommands);
this.getCommand("explosives").setExecutor(AntiblockCommands);
this.getCommand("fireplace").setExecutor(AntiblockCommands);
this.getCommand("firespread").setExecutor(AntiblockCommands);
this.getCommand("lavadmg").setExecutor(AntiblockCommands);
this.getCommand("lavaplace").setExecutor(AntiblockCommands);
this.getCommand("firespread").setExecutor(AntiblockCommands);
this.getCommand("fireplace").setExecutor(AntiblockCommands);
this.getCommand("waterplace").setExecutor(AntiblockCommands);
this.getCommand("say").setExecutor(OverrideCommands);
this.getCommand("stop").setExecutor(OverrideCommands);
this.getCommand("list").setExecutor(OverrideCommands);
this.getCommand("listreal").setExecutor(OverrideCommands);
this.getCommand("say").setExecutor(OverrideCommands);
this.getCommand("stop").setExecutor(OverrideCommands);
}
}

View File

@ -112,6 +112,9 @@ commands:
survival:
description: Quickly change your own gamemode to survival, or define someone's username to change theirs.
usage: /<command> [partialname]
tfsmite:
description: De-op, inventory clear, de-godmode, lightning, and kill your target. For naughty people only (or the entire server).
usage: /<command> [playername|all]
umd:
description: Superadmin command - Undisguse all players.
usage: /<command>