mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-23 07:24:57 +00:00
Lots of new commands.
Code cleanup.
This commit is contained in:
parent
e2d772bc4f
commit
8119ca553a
11 changed files with 525 additions and 158 deletions
|
@ -45,13 +45,7 @@ public class TFM_BlockListener extends BlockListener
|
||||||
if (plugin.nukeMonitor)
|
if (plugin.nukeMonitor)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
|
||||||
if (playerdata == null)
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
Location player_pos = p.getLocation();
|
Location player_pos = p.getLocation();
|
||||||
Location block_pos = event.getBlock().getLocation();
|
Location block_pos = event.getBlock().getLocation();
|
||||||
|
@ -59,7 +53,7 @@ public class TFM_BlockListener extends BlockListener
|
||||||
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||||
{
|
{
|
||||||
playerdata.incrementFreecamDestroyCount();
|
playerdata.incrementFreecamDestroyCount();
|
||||||
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
|
if (playerdata.getFreecamDestroyCount() > plugin.freecamTriggerCount)
|
||||||
{
|
{
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
@ -82,6 +76,7 @@ public class TFM_BlockListener extends BlockListener
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
|
p.kickPlayer("You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -101,12 +96,7 @@ public class TFM_BlockListener extends BlockListener
|
||||||
|
|
||||||
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata == null)
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
playerdata.incrementFreecamPlaceCount();
|
playerdata.incrementFreecamPlaceCount();
|
||||||
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
|
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
@ -81,17 +82,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
p = matches.get(0);
|
p = matches.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
playerdata.setFrozen(!playerdata.isFrozen());
|
||||||
{
|
|
||||||
playerdata.setFrozen(!playerdata.isFrozen());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
playerdata.setFrozen(true);
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
@ -128,7 +120,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
//Undo WorldEdits:
|
//Undo WorldEdits:
|
||||||
Bukkit.getServer().dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName()));
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("/undo %d %s", 15, p.getName()));
|
||||||
|
|
||||||
//Deop
|
//Deop
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
|
@ -211,11 +203,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
p.getInventory().clear();
|
p.getInventory().clear();
|
||||||
|
|
||||||
//Flag for insta-kill:
|
//Flag for insta-kill:
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
playerdata.setForcedDeath(true);
|
||||||
{
|
|
||||||
playerdata.setForcedDeath(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Strike with lightning effect:
|
//Strike with lightning effect:
|
||||||
final Location target_pos = p.getLocation();
|
final Location target_pos = p.getLocation();
|
||||||
|
@ -307,17 +296,9 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
}
|
}
|
||||||
else if (mode.equals("fr"))
|
else if (mode.equals("fr"))
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
playerdata.setFrozen(!playerdata.isFrozen());
|
||||||
{
|
|
||||||
playerdata.setFrozen(!playerdata.isFrozen());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
playerdata.setFrozen(true);
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
}
|
}
|
||||||
|
@ -354,7 +335,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
{
|
{
|
||||||
String out_command = base_command.replaceAll("\\x3f", p.getName());
|
String out_command = base_command.replaceAll("\\x3f", p.getName());
|
||||||
sender.sendMessage("Running Command: " + out_command);
|
sender.sendMessage("Running Command: " + out_command);
|
||||||
Bukkit.getServer().dispatchCommand(sender, out_command);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), out_command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -375,12 +356,24 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
|
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
plugin.nukeMonitorRange = Double.parseDouble(args[1]);
|
try
|
||||||
|
{
|
||||||
|
plugin.nukeMonitorRange = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
{
|
{
|
||||||
plugin.nukeMonitorCountBreak = Integer.parseInt(args[2]);
|
try
|
||||||
|
{
|
||||||
|
plugin.nukeMonitorCountBreak = Integer.parseInt(args[2]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
|
@ -570,7 +563,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send to jail "mgjail":
|
//Send to jail "mgjail":
|
||||||
Bukkit.getServer().dispatchCommand(sender, String.format("tjail %s mgjail", p.getName()));
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
|
||||||
|
|
||||||
TFM_Util.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED);
|
TFM_Util.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
|
@ -654,12 +647,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
p = matches.get(0);
|
p = matches.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata == null)
|
|
||||||
{
|
|
||||||
playerdata = new TFM_UserInfo();
|
|
||||||
plugin.userinfo.put(p, playerdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
Material cage_material_outer = Material.GLASS;
|
Material cage_material_outer = Material.GLASS;
|
||||||
Material cage_material_inner = Material.AIR;
|
Material cage_material_inner = Material.AIR;
|
||||||
|
@ -699,8 +687,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
playerdata.regenerateHistory();
|
playerdata.regenerateHistory();
|
||||||
playerdata.clearHistory();
|
playerdata.clearHistory();
|
||||||
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
||||||
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
|
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
||||||
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
|
||||||
|
|
||||||
p.setGameMode(GameMode.SURVIVAL);
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
@ -734,13 +722,127 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
p = matches.get(0);
|
p = matches.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double strength = 100.0;
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
|
|
||||||
|
double strength = 10.0;
|
||||||
|
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
strength = Double.parseDouble(args[1]);
|
if (args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("end"))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
|
||||||
|
playerdata.stopOrbiting();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
strength = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
strength = 10.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.setGameMode(GameMode.SURVIVAL);
|
||||||
|
playerdata.startOrbiting(strength);
|
||||||
|
|
||||||
p.setVelocity(new Vector(0, strength, 0));
|
p.setVelocity(new Vector(0, strength, 0));
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Orbiting " + p.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (cmd.getName().equalsIgnoreCase("expel"))
|
||||||
|
{
|
||||||
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
double radius = 50.0;
|
||||||
|
double strength = 100.0;
|
||||||
|
|
||||||
|
if (args.length >= 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
radius = Double.parseDouble(args[0]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
strength = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location sender_pos = sender_p.getLocation();
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!p.equals(sender_p))
|
||||||
|
{
|
||||||
|
Location target_pos = p.getLocation();
|
||||||
|
if (target_pos.distance(sender_pos) < radius)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Pushing " + p.getName());
|
||||||
|
Vector expel_direction = target_pos.subtract(sender_pos).toVector().normalize();
|
||||||
|
p.setVelocity(expel_direction.multiply(strength));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (cmd.getName().equalsIgnoreCase("mp44"))
|
||||||
|
{
|
||||||
|
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p, plugin);
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("draw"))
|
||||||
|
{
|
||||||
|
playerdata.stopArrowShooter();
|
||||||
|
int schedule_id = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new ArrowShooter(sender_p), 1L, 1L);
|
||||||
|
playerdata.startArrowShooter(schedule_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerdata.stopArrowShooter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -757,4 +859,21 @@ public class TFM_Cmds_Admin implements CommandExecutor
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ArrowShooter implements Runnable
|
||||||
|
{
|
||||||
|
private Player _player;
|
||||||
|
|
||||||
|
public ArrowShooter(Player player)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Arrow shot_arrow = _player.shootArrow();
|
||||||
|
shot_arrow.setVelocity(shot_arrow.getVelocity().multiply(2.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,13 @@ public class TFM_Cmds_AntiBlock implements CommandExecutor
|
||||||
|
|
||||||
if (args.length == 2)
|
if (args.length == 2)
|
||||||
{
|
{
|
||||||
plugin.explosiveRadius = Double.parseDouble(args[1]);
|
try
|
||||||
|
{
|
||||||
|
plugin.explosiveRadius = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("on"))
|
if (args[0].equalsIgnoreCase("on"))
|
||||||
|
|
|
@ -3,7 +3,9 @@ package me.StevenLawson.TotalFreedomMod;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import me.desmin88.mobdisguise.api.MobDisguiseAPI;
|
import me.desmin88.mobdisguise.api.MobDisguiseAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -20,9 +22,8 @@ import org.bukkit.entity.*;
|
||||||
public class TFM_Cmds_General implements CommandExecutor
|
public class TFM_Cmds_General implements CommandExecutor
|
||||||
{
|
{
|
||||||
private TotalFreedomMod plugin;
|
private TotalFreedomMod plugin;
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger("Minecraft");
|
private static final Logger log = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
public TFM_Cmds_General(TotalFreedomMod plugin)
|
public TFM_Cmds_General(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -45,7 +46,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
senderIsConsole = true;
|
senderIsConsole = true;
|
||||||
log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TFM_Util.implodeStringList(" ", Arrays.asList(args))));
|
log.info(String.format("[CONSOLE_COMMAND] %s: /%s %s", sender.getName(), commandLabel, TFM_Util.implodeStringList(" ", Arrays.asList(args))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd.getName().equalsIgnoreCase("creative"))
|
if (cmd.getName().equalsIgnoreCase("creative"))
|
||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
|
@ -144,7 +145,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
sender.sendMessage("This command can only be used in-game.");
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,13 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
int countmax = 5;
|
int countmax = 5;
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
countmax = Integer.parseInt(args[0]);
|
try
|
||||||
|
{
|
||||||
|
countmax = Integer.parseInt(args[0]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -183,8 +190,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s",
|
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s",
|
||||||
i.player.getName(),
|
i.player.getName(),
|
||||||
Math.round(i.distance),
|
Math.round(i.distance),
|
||||||
MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No"
|
MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No"));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -194,7 +200,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
if (senderIsConsole || sender.isOp())
|
if (senderIsConsole || sender.isOp())
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GRAY + "Removing all dropped items, arrows, exp. orbs and TNT...");
|
sender.sendMessage(ChatColor.GRAY + "Removing all dropped items, arrows, exp. orbs and TNT...");
|
||||||
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeDropEntities(plugin)) + " dropped enties removed.");
|
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeDropEntities(true)) + " dropped enties removed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -231,21 +237,21 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cmd.getName().equalsIgnoreCase("flatlands"))
|
else if (cmd.getName().equalsIgnoreCase("flatlands"))
|
||||||
{
|
{
|
||||||
TFM_Util.gotoWorld(sender, "flatlands");
|
TFM_Util.gotoWorld(sender, "flatlands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cmd.getName().equalsIgnoreCase("skylands"))
|
else if (cmd.getName().equalsIgnoreCase("skylands"))
|
||||||
{
|
{
|
||||||
TFM_Util.gotoWorld(sender, "skylands");
|
TFM_Util.gotoWorld(sender, "skylands");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cmd.getName().equalsIgnoreCase("nether"))
|
else if (cmd.getName().equalsIgnoreCase("nether"))
|
||||||
{
|
{
|
||||||
TFM_Util.gotoWorld(sender, "nether");
|
TFM_Util.gotoWorld(sender, "nether");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cmd.getName().equalsIgnoreCase("tfbanlist"))
|
else if (cmd.getName().equalsIgnoreCase("tfbanlist"))
|
||||||
{
|
{
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
|
@ -269,7 +275,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder banned_players = new StringBuilder();
|
StringBuilder banned_players = new StringBuilder();
|
||||||
banned_players.append("Banned Players: ");
|
banned_players.append("Banned Players: ");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
@ -282,9 +288,9 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
first = false;
|
first = false;
|
||||||
banned_players.append(p.getName().trim());
|
banned_players.append(p.getName().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + banned_players.toString());
|
sender.sendMessage(ChatColor.GRAY + banned_players.toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (cmd.getName().equalsIgnoreCase("tfipbanlist"))
|
else if (cmd.getName().equalsIgnoreCase("tfipbanlist"))
|
||||||
|
@ -310,10 +316,10 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> ip_bans = Arrays.asList(Bukkit.getIPBans().toArray(new String[0]));
|
List<String> ip_bans = Arrays.asList(Bukkit.getIPBans().toArray(new String[0]));
|
||||||
Collections.sort(ip_bans);
|
Collections.sort(ip_bans);
|
||||||
|
|
||||||
StringBuilder banned_ips = new StringBuilder();
|
StringBuilder banned_ips = new StringBuilder();
|
||||||
banned_ips.append("Banned IPs: ");
|
banned_ips.append("Banned IPs: ");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
@ -329,9 +335,86 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
banned_ips.append(ip.trim());
|
banned_ips.append(ip.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + banned_ips.toString());
|
sender.sendMessage(ChatColor.GRAY + banned_ips.toString());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (cmd.getName().equalsIgnoreCase("tossmob"))
|
||||||
|
{
|
||||||
|
if (senderIsConsole || sender.isOp())
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p, plugin);
|
||||||
|
|
||||||
|
CreatureType creature = CreatureType.PIG;
|
||||||
|
if (args.length >= 1)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("end"))
|
||||||
|
{
|
||||||
|
playerData.disableMobThrower();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
|
||||||
|
mobtypes.put("chicken", CreatureType.CHICKEN);
|
||||||
|
mobtypes.put("cow", CreatureType.COW);
|
||||||
|
mobtypes.put("creeper", CreatureType.CREEPER);
|
||||||
|
mobtypes.put("pig", CreatureType.PIG);
|
||||||
|
mobtypes.put("sheep", CreatureType.SHEEP);
|
||||||
|
mobtypes.put("skeleton", CreatureType.SKELETON);
|
||||||
|
mobtypes.put("spider", CreatureType.SPIDER);
|
||||||
|
mobtypes.put("zombie", CreatureType.ZOMBIE);
|
||||||
|
mobtypes.put("wolf", CreatureType.WOLF);
|
||||||
|
|
||||||
|
CreatureType creature_query = mobtypes.get(args[0].toLowerCase().trim());
|
||||||
|
if (creature_query != null)
|
||||||
|
{
|
||||||
|
creature = creature_query;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(args[1] + " is not a supported mob type. Using a pig instead.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double speed = 1.0;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
speed = Double.parseDouble(args[1]);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (speed < 1.0)
|
||||||
|
{
|
||||||
|
speed = 1.0;
|
||||||
|
}
|
||||||
|
else if (speed > 5.0)
|
||||||
|
{
|
||||||
|
speed = 5.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerData.enableMobThrower(creature, speed);
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".");
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Left click while holding a stick to throw mobs!");
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Type '/tossmob off' to disable. -By Madgeek1450");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,7 +422,7 @@ public class TFM_Cmds_General implements CommandExecutor
|
||||||
{
|
{
|
||||||
log.severe("Exception in TFM_Cmds_General.onCommand(): " + ex.getMessage());
|
log.severe("Exception in TFM_Cmds_General.onCommand(): " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,18 +53,15 @@ public class TFM_EntityListener extends EntityListener
|
||||||
Player p = (Player) event.getEntity();
|
Player p = (Player) event.getEntity();
|
||||||
if (p != null)
|
if (p != null)
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
if (playerdata.getForcedDeath())
|
||||||
{
|
{
|
||||||
if (playerdata.getForcedDeath())
|
event.setCancelled(false);
|
||||||
{
|
p.setFoodLevel(0);
|
||||||
event.setCancelled(false);
|
p.setHealth(0);
|
||||||
p.setFoodLevel(0);
|
event.setDamage(100);
|
||||||
p.setHealth(0);
|
playerdata.setForcedDeath(false);
|
||||||
event.setDamage(100);
|
return;
|
||||||
playerdata.setForcedDeath(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package me.StevenLawson.TotalFreedomMod;
|
package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -19,17 +18,14 @@ public class TFM_Heartbeat implements Runnable
|
||||||
{
|
{
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
playerdata.resetMsgCount();
|
||||||
{
|
playerdata.resetBlockDestroyCount();
|
||||||
playerdata.resetMsgCount();
|
|
||||||
playerdata.resetBlockDestroyCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.autoEntityWipe)
|
if (plugin.autoEntityWipe)
|
||||||
{
|
{
|
||||||
TFM_Util.wipeDropEntities(plugin);
|
TFM_Util.wipeDropEntities(!plugin.allowExplosions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableNight)
|
if (plugin.disableNight)
|
||||||
|
|
|
@ -5,10 +5,13 @@ import java.util.regex.Pattern;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
class TFM_PlayerListener extends PlayerListener
|
class TFM_PlayerListener extends PlayerListener
|
||||||
{
|
{
|
||||||
|
@ -23,12 +26,12 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
{
|
{
|
||||||
if (event.getMaterial() == Material.WATER_BUCKET)
|
if (event.getMaterial() == Material.WATER_BUCKET)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
int slot = player.getInventory().getHeldItemSlot();
|
int slot = player.getInventory().getHeldItemSlot();
|
||||||
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
||||||
player.getInventory().setItem(slot, heldItem);
|
player.getInventory().setItem(slot, heldItem);
|
||||||
|
@ -40,8 +43,6 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
}
|
}
|
||||||
else if (event.getMaterial() == Material.LAVA_BUCKET)
|
else if (event.getMaterial() == Material.LAVA_BUCKET)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
int slot = player.getInventory().getHeldItemSlot();
|
int slot = player.getInventory().getHeldItemSlot();
|
||||||
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
||||||
player.getInventory().setItem(slot, heldItem);
|
player.getInventory().setItem(slot, heldItem);
|
||||||
|
@ -52,13 +53,32 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
if (event.getMaterial() == Material.STICK)
|
||||||
|
{
|
||||||
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
|
||||||
|
if (playerdata.mobThrowerEnabled())
|
||||||
|
{
|
||||||
|
Location player_pos = player.getLocation();
|
||||||
|
Vector direction = player_pos.getDirection().normalize();
|
||||||
|
Location rez_pos = player_pos.add(direction.multiply(2.0));
|
||||||
|
|
||||||
|
LivingEntity rezzed_mob = player.getWorld().spawnCreature(rez_pos, playerdata.mobThrowerCreature());
|
||||||
|
rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
|
||||||
|
playerdata.enqueueMob(rezzed_mob);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
|
|
||||||
boolean do_freeze = false;
|
boolean do_freeze = false;
|
||||||
if (plugin.allPlayersFrozen)
|
if (plugin.allPlayersFrozen)
|
||||||
|
@ -70,12 +90,9 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (playerdata != null)
|
if (playerdata.isFrozen())
|
||||||
{
|
{
|
||||||
if (playerdata.isFrozen())
|
do_freeze = true;
|
||||||
{
|
|
||||||
do_freeze = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,21 +108,26 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
event.setTo(to);
|
event.setTo(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerdata != null)
|
if (playerdata.isCaged())
|
||||||
{
|
{
|
||||||
if (playerdata.isCaged())
|
Location target_pos = p.getLocation().add(0, 1, 0);
|
||||||
{
|
|
||||||
Location target_pos = p.getLocation().add(0, 1, 0);
|
|
||||||
|
|
||||||
if (target_pos.distance(playerdata.getCagePos()) > 2.5)
|
if (target_pos.distance(playerdata.getCagePos()) > 2.5)
|
||||||
{
|
{
|
||||||
playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
||||||
playerdata.regenerateHistory();
|
playerdata.regenerateHistory();
|
||||||
playerdata.clearHistory();
|
playerdata.clearHistory();
|
||||||
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
TFM_Util.buildHistory(target_pos, 2, playerdata);
|
||||||
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
|
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
||||||
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
|
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerdata.isOrbiting())
|
||||||
|
{
|
||||||
|
if (p.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0))
|
||||||
|
{
|
||||||
|
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,26 +137,18 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
TFM_UserInfo playerdata = plugin.userinfo.get(p);
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
|
||||||
if (playerdata != null)
|
playerdata.incrementMsgCount();
|
||||||
{
|
|
||||||
playerdata.incrementMsgCount();
|
|
||||||
|
|
||||||
if (playerdata.getMsgCount() > 10)
|
if (playerdata.getMsgCount() > 10)
|
||||||
{
|
|
||||||
p.setOp(false);
|
|
||||||
p.kickPlayer("No Spamming");
|
|
||||||
TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
playerdata = new TFM_UserInfo();
|
p.setOp(false);
|
||||||
playerdata.incrementMsgCount();
|
p.kickPlayer("No Spamming");
|
||||||
plugin.userinfo.put(p, playerdata);
|
TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String message = event.getMessage().toLowerCase();
|
String message = event.getMessage().toLowerCase();
|
||||||
|
@ -177,6 +191,11 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
block_command = true;
|
block_command = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Pattern.compile("^/time").matcher(command).find())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
|
||||||
|
block_command = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (block_command)
|
if (block_command)
|
||||||
{
|
{
|
||||||
|
@ -185,4 +204,34 @@ class TFM_PlayerListener extends PlayerListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
if (plugin.autoEntityWipe)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event.getItemDrop().remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
|
||||||
|
playerdata.stopArrowShooter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
|
||||||
|
playerdata.stopArrowShooter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,12 @@ package me.StevenLawson.TotalFreedomMod;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class TFM_UserInfo
|
public class TFM_UserInfo
|
||||||
{
|
{
|
||||||
|
@ -16,12 +20,51 @@ public class TFM_UserInfo
|
||||||
private boolean user_caged = false;
|
private boolean user_caged = false;
|
||||||
private Location user_cage_pos;
|
private Location user_cage_pos;
|
||||||
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
|
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
|
||||||
private Material cage_material_outer;
|
private Material cage_material_outer = Material.GLASS;
|
||||||
private Material cage_material_inner;
|
private Material cage_material_inner = Material.AIR;
|
||||||
|
private boolean is_orbiting = false;
|
||||||
|
private double orbit_strength = 10.0;
|
||||||
|
private boolean mob_thrower_enabled = false;
|
||||||
|
private CreatureType mob_thrower_creature = CreatureType.PIG;
|
||||||
|
private double mob_thrower_speed = 4.0;
|
||||||
|
private List<LivingEntity> mobqueue = new ArrayList<LivingEntity>();
|
||||||
|
private int schedule_id = -1;
|
||||||
|
|
||||||
public TFM_UserInfo()
|
public TFM_UserInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TFM_UserInfo getPlayerData(Player p, TotalFreedomMod tfm)
|
||||||
|
{
|
||||||
|
TFM_UserInfo playerdata = tfm.userinfo.get(p);
|
||||||
|
if (playerdata == null)
|
||||||
|
{
|
||||||
|
playerdata = new TFM_UserInfo();
|
||||||
|
tfm.userinfo.put(p, playerdata);
|
||||||
|
}
|
||||||
|
return playerdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOrbiting()
|
||||||
|
{
|
||||||
|
return this.is_orbiting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startOrbiting(double orbit_strength)
|
||||||
|
{
|
||||||
|
this.is_orbiting = true;
|
||||||
|
this.orbit_strength = orbit_strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopOrbiting()
|
||||||
|
{
|
||||||
|
this.is_orbiting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double orbitStrength()
|
||||||
|
{
|
||||||
|
return this.orbit_strength;
|
||||||
|
}
|
||||||
|
|
||||||
public void setCaged(boolean state)
|
public void setCaged(boolean state)
|
||||||
{
|
{
|
||||||
|
@ -173,4 +216,58 @@ public class TFM_UserInfo
|
||||||
{
|
{
|
||||||
this.freecam_place_count = 0;
|
this.freecam_place_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableMobThrower(CreatureType mob_thrower_creature, double mob_thrower_speed)
|
||||||
|
{
|
||||||
|
this.mob_thrower_enabled = true;
|
||||||
|
this.mob_thrower_creature = mob_thrower_creature;
|
||||||
|
this.mob_thrower_speed = mob_thrower_speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableMobThrower()
|
||||||
|
{
|
||||||
|
this.mob_thrower_enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreatureType mobThrowerCreature()
|
||||||
|
{
|
||||||
|
return this.mob_thrower_creature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double mobThrowerSpeed()
|
||||||
|
{
|
||||||
|
return this.mob_thrower_speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean mobThrowerEnabled()
|
||||||
|
{
|
||||||
|
return this.mob_thrower_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enqueueMob(LivingEntity mob)
|
||||||
|
{
|
||||||
|
mobqueue.add(mob);
|
||||||
|
if (mobqueue.size() > 4)
|
||||||
|
{
|
||||||
|
LivingEntity oldmob = mobqueue.remove(0);
|
||||||
|
if (oldmob != null)
|
||||||
|
{
|
||||||
|
oldmob.damage(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startArrowShooter(int schedule_id)
|
||||||
|
{
|
||||||
|
this.schedule_id = schedule_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopArrowShooter()
|
||||||
|
{
|
||||||
|
if (this.schedule_id != -1)
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().cancelTask(this.schedule_id);
|
||||||
|
this.schedule_id = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class TFM_Util
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("This command may not be used from the console.");
|
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ public class TFM_Util
|
||||||
|
|
||||||
if (Bukkit.getOnlineMode())
|
if (Bukkit.getOnlineMode())
|
||||||
{
|
{
|
||||||
if (tfm.superadmins.contains(user.getName()))
|
if (tfm.superadmins.contains(user.getName().toLowerCase()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -250,14 +250,14 @@ public class TFM_Util
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int wipeDropEntities(TotalFreedomMod tfm)
|
public static int wipeDropEntities(boolean wipe_tnt)
|
||||||
{
|
{
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
for (World world : Bukkit.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
for (Entity ent : world.getEntities())
|
for (Entity ent : world.getEntities())
|
||||||
{
|
{
|
||||||
if (ent instanceof Arrow || (ent instanceof TNTPrimed && !tfm.allowExplosions) || ent instanceof Item || ent instanceof ExperienceOrb)
|
if (ent instanceof Arrow || (ent instanceof TNTPrimed && wipe_tnt) || ent instanceof Item || ent instanceof ExperienceOrb)
|
||||||
{
|
{
|
||||||
ent.remove();
|
ent.remove();
|
||||||
removed++;
|
removed++;
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
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 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 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 static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||||
|
|
||||||
public Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
public Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||||
public boolean allPlayersFrozen = false;
|
public boolean allPlayersFrozen = false;
|
||||||
|
@ -92,20 +93,34 @@ public class TotalFreedomMod extends JavaPlugin
|
||||||
disableNight = config.getBoolean("disable_night", disableNight);
|
disableNight = config.getBoolean("disable_night", disableNight);
|
||||||
disableWeather = config.getBoolean("disable_weather", disableWeather);
|
disableWeather = config.getBoolean("disable_weather", disableWeather);
|
||||||
|
|
||||||
superadmins = (List<String>) config.getList("superadmins", null);
|
superadmins = new ArrayList<String>();
|
||||||
if (superadmins == null)
|
List<String> superadmins_temp = (List<String>) config.getList("superadmins", null);
|
||||||
|
if (superadmins_temp == null || superadmins_temp.isEmpty())
|
||||||
{
|
{
|
||||||
superadmins = new ArrayList<String>();
|
|
||||||
superadmins.add("Madgeek1450");
|
superadmins.add("Madgeek1450");
|
||||||
superadmins.add("markbyron");
|
superadmins.add("markbyron");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
superadmin_ips = (List<String>) config.getList("superadmin_ips", null);
|
{
|
||||||
if (superadmin_ips == null)
|
for (String admin_name : superadmins_temp)
|
||||||
|
{
|
||||||
|
superadmins.add(admin_name.toLowerCase().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
superadmin_ips = new ArrayList<String>();
|
||||||
|
List<String> superadmin_ips_temp = (List<String>) config.getList("superadmin_ips", null);
|
||||||
|
if (superadmin_ips_temp == null || superadmin_ips_temp.isEmpty())
|
||||||
{
|
{
|
||||||
superadmin_ips = new ArrayList<String>();
|
|
||||||
superadmin_ips.add("127.0.0.1");
|
superadmin_ips.add("127.0.0.1");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (String admin_ip : superadmin_ips_temp)
|
||||||
|
{
|
||||||
|
superadmin_ips.add(admin_ip.toLowerCase().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final TFM_EntityListener entityListener = new TFM_EntityListener(this);
|
private final TFM_EntityListener entityListener = new TFM_EntityListener(this);
|
||||||
|
@ -131,6 +146,9 @@ public class TotalFreedomMod extends JavaPlugin
|
||||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
|
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_MOVE, playerListener, Event.Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Event.Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Event.Priority.Monitor, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this);
|
pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this);
|
||||||
pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this);
|
pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this);
|
||||||
|
@ -161,10 +179,12 @@ public class TotalFreedomMod extends JavaPlugin
|
||||||
this.getCommand("skylands").setExecutor(GeneralCommands);
|
this.getCommand("skylands").setExecutor(GeneralCommands);
|
||||||
this.getCommand("status").setExecutor(GeneralCommands);
|
this.getCommand("status").setExecutor(GeneralCommands);
|
||||||
this.getCommand("survival").setExecutor(GeneralCommands);
|
this.getCommand("survival").setExecutor(GeneralCommands);
|
||||||
|
this.getCommand("tossmob").setExecutor(GeneralCommands);
|
||||||
|
|
||||||
this.getCommand("cage").setExecutor(AdminCommands);
|
this.getCommand("cage").setExecutor(AdminCommands);
|
||||||
this.getCommand("cake").setExecutor(AdminCommands);
|
this.getCommand("cake").setExecutor(AdminCommands);
|
||||||
this.getCommand("csay").setExecutor(AdminCommands);
|
this.getCommand("csay").setExecutor(AdminCommands);
|
||||||
|
this.getCommand("expel").setExecutor(AdminCommands);
|
||||||
this.getCommand("fr").setExecutor(AdminCommands);
|
this.getCommand("fr").setExecutor(AdminCommands);
|
||||||
this.getCommand("gadmin").setExecutor(AdminCommands);
|
this.getCommand("gadmin").setExecutor(AdminCommands);
|
||||||
this.getCommand("gcmd").setExecutor(AdminCommands);
|
this.getCommand("gcmd").setExecutor(AdminCommands);
|
||||||
|
@ -176,6 +196,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||||
this.getCommand("tfsmite").setExecutor(AdminCommands);
|
this.getCommand("tfsmite").setExecutor(AdminCommands);
|
||||||
this.getCommand("umd").setExecutor(AdminCommands);
|
this.getCommand("umd").setExecutor(AdminCommands);
|
||||||
this.getCommand("wildcard").setExecutor(AdminCommands);
|
this.getCommand("wildcard").setExecutor(AdminCommands);
|
||||||
|
this.getCommand("mp44").setExecutor(AdminCommands);
|
||||||
|
|
||||||
this.getCommand("explosives").setExecutor(AntiblockCommands);
|
this.getCommand("explosives").setExecutor(AntiblockCommands);
|
||||||
this.getCommand("fireplace").setExecutor(AntiblockCommands);
|
this.getCommand("fireplace").setExecutor(AntiblockCommands);
|
||||||
|
|
|
@ -22,6 +22,9 @@ commands:
|
||||||
explosives:
|
explosives:
|
||||||
description: Superadmin command - Enable/disable explosives and set effect radius.
|
description: Superadmin command - Enable/disable explosives and set effect radius.
|
||||||
usage: /<command> <on|off> [radius]
|
usage: /<command> <on|off> [radius]
|
||||||
|
expel:
|
||||||
|
description: Superadmin command - Push people away from you.
|
||||||
|
usage: /<command> [radius] [strength]
|
||||||
fireplace:
|
fireplace:
|
||||||
description: Superadmin command - Enable/disable fire placement.
|
description: Superadmin command - Enable/disable fire placement.
|
||||||
usage: /<command> <on|off>
|
usage: /<command> <on|off>
|
||||||
|
@ -58,6 +61,9 @@ commands:
|
||||||
mp:
|
mp:
|
||||||
description: Use moblimiter to purge all mobs.
|
description: Use moblimiter to purge all mobs.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
mp44:
|
||||||
|
description: Superadmin Command - Modern weaponry, FTW. Use 'draw' to start firing, 'sling' to stop firing.
|
||||||
|
usage: /<command> [draw|sling]
|
||||||
nether:
|
nether:
|
||||||
description: Goto the nether.
|
description: Goto the nether.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
@ -106,6 +112,9 @@ commands:
|
||||||
survival:
|
survival:
|
||||||
description: Quickly change your own gamemode to survival, or define someone's username to change theirs.
|
description: Quickly change your own gamemode to survival, or define someone's username to change theirs.
|
||||||
usage: /<command> [partialname]
|
usage: /<command> [partialname]
|
||||||
|
tossmob:
|
||||||
|
description: Throw a mob in the direction you are facing when you left click with a stick.
|
||||||
|
usage: /<command> [mobtype | off] [speed]
|
||||||
tfbanlist:
|
tfbanlist:
|
||||||
description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.
|
description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.
|
||||||
usage: /<command> [purge]
|
usage: /<command> [purge]
|
||||||
|
|
Loading…
Reference in a new issue