mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
More fun code cleanup.
This commit is contained in:
parent
85f32fcc76
commit
d5d0bd1a26
@ -46,11 +46,11 @@ public class TFM_BlockListener extends BlockListener
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata == null)
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
|
||||
Location player_pos = p.getLocation();
|
||||
@ -101,11 +101,11 @@ public class TFM_BlockListener extends BlockListener
|
||||
|
||||
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||
{
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata == null)
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
|
||||
playerdata.incrementFreecamPlaceCount();
|
||||
|
@ -81,7 +81,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
p = matches.get(0);
|
||||
}
|
||||
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata != null)
|
||||
{
|
||||
playerdata.setFrozen(!playerdata.isFrozen());
|
||||
@ -90,7 +90,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
playerdata.setFrozen(true);
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
@ -239,7 +239,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
}
|
||||
else if (mode.equals("fr"))
|
||||
{
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata != null)
|
||||
{
|
||||
playerdata.setFrozen(!playerdata.isFrozen());
|
||||
@ -248,7 +248,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
playerdata.setFrozen(true);
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
@ -586,11 +586,11 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||
p = matches.get(0);
|
||||
}
|
||||
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata == null)
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
|
||||
Material cage_material_outer = Material.GLASS;
|
||||
|
45
src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java
Normal file
45
src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java
Normal file
@ -0,0 +1,45 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_Heartbeat implements Runnable
|
||||
{
|
||||
private TotalFreedomMod plugin;
|
||||
|
||||
TFM_Heartbeat(TotalFreedomMod instance)
|
||||
{
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata != null)
|
||||
{
|
||||
playerdata.resetMsgCount();
|
||||
playerdata.resetBlockDestroyCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.autoEntityWipe)
|
||||
{
|
||||
TFM_Util.wipeDropEntities(plugin);
|
||||
}
|
||||
|
||||
if (plugin.disableNight)
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (world.getTime() > 12000L)
|
||||
{
|
||||
TFM_Util.setWorldTime(world, 1000L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ class TFM_PlayerListener extends PlayerListener
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
|
||||
boolean do_freeze = false;
|
||||
if (plugin.allPlayersFrozen)
|
||||
@ -114,7 +114,7 @@ class TFM_PlayerListener extends PlayerListener
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
||||
if (playerdata != null)
|
||||
{
|
||||
playerdata.incrementMsgCount();
|
||||
@ -133,7 +133,7 @@ class TFM_PlayerListener extends PlayerListener
|
||||
{
|
||||
playerdata = new TFM_UserInfo();
|
||||
playerdata.incrementMsgCount();
|
||||
TotalFreedomMod.userinfo.put(p, playerdata);
|
||||
plugin.userinfo.put(p, playerdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,23 +18,18 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
public TotalFreedomMod tfm = this;
|
||||
|
||||
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 static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
public boolean allPlayersFrozen = false;
|
||||
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||
|
||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||
public static final String CONFIG_FILE = "config.yml";
|
||||
|
||||
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 Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||
public boolean allPlayersFrozen = false;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
@ -56,46 +50,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
log.log(Level.INFO, "[" + getDescription().getName() + "] - Disabled.");
|
||||
}
|
||||
|
||||
class TFM_Heartbeat implements Runnable
|
||||
{
|
||||
private TotalFreedomMod plugin;
|
||||
|
||||
TFM_Heartbeat(TotalFreedomMod instance)
|
||||
{
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
|
||||
if (playerdata != null)
|
||||
{
|
||||
playerdata.resetMsgCount();
|
||||
playerdata.resetBlockDestroyCount();
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.autoEntityWipe)
|
||||
{
|
||||
TFM_Util.wipeDropEntities(plugin);
|
||||
}
|
||||
|
||||
if (plugin.disableNight)
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (world.getTime() > 12000L)
|
||||
{
|
||||
TFM_Util.setWorldTime(world, 1000L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean allowFirePlace = false;
|
||||
public Boolean allowFireSpread = false;
|
||||
public Boolean allowLavaDamage = false;
|
||||
@ -150,6 +104,10 @@ 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 void registerEventHandlers()
|
||||
{
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
|
Loading…
Reference in New Issue
Block a user