mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added weather
This commit is contained in:
parent
d5d0bd1a26
commit
5aaab9ff1e
@ -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:
|
||||
|
@ -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,7 +21,6 @@ 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)
|
||||
@ -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)
|
||||
@ -473,7 +541,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
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
|
||||
@ -578,7 +646,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
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
|
||||
@ -658,7 +726,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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;
|
||||
@ -93,6 +95,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()
|
||||
{
|
||||
return this.user_frozen;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
src/me/StevenLawson/TotalFreedomMod/TFM_WeatherListener.java
Normal file
33
src/me/StevenLawson/TotalFreedomMod/TFM_WeatherListener.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user