Re-added potion spy (#14)

* Re-added potion spy

* grammar nazi
This commit is contained in:
Seth 2017-12-30 20:58:20 -07:00 committed by Lemon
parent 7e524da928
commit d9d1d4fa9b
4 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,92 @@
package me.totalfreedom.totalfreedommod;
import java.text.DecimalFormat;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.projectiles.ProjectileSource;
public class Monitors extends FreedomService
{
private final DecimalFormat decimalFormat = new DecimalFormat("#");
public Monitors(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public String getMaterial(final int id)
{
return String.valueOf(Material.getMaterial(id));
}
@EventHandler(priority = EventPriority.LOW)
public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int droppedItem = event.getEntity().getItem().getTypeId();
final Location location = player.getLocation();
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(p) && plugin.pl.getPlayer(p).isPotionMonitorEnabled())
{
FUtil.playerMsg(p, player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + getMaterial(droppedItem) + " at [" + decimalFormat.format(location.getX()) + ", " + decimalFormat.format(location.getY()) + ", " + decimalFormat.format(location.getZ()) + "] in the world '" + location.getWorld().getName() + "'.");
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPotionSplash(PotionSplashEvent event)
{
ProjectileSource source = event.getEntity().getShooter();
if (!(source instanceof Player))
{
return;
}
Player player = (Player) source;
if (plugin.al.isAdmin((Player) event.getEntity().getShooter()))
{
return;
}
final int droppedItem = event.getPotion().getItem().getTypeId();
final Location location = player.getLocation();
for (Player p : server.getOnlinePlayers())
{
if (plugin.al.isAdmin(p) && plugin.pl.getPlayer(p).isPotionMonitorEnabled())
{
FUtil.playerMsg(p, player.getName() + " splashed " + event.getPotion().getItem().getAmount() + " " + this.getMaterial(droppedItem) + " at [" + decimalFormat.format(location.getX()) + ", " + decimalFormat.format(location.getY()) + ", " + decimalFormat.format(location.getZ()) + "] in the world '" + location.getWorld().getName() + "'.");
}
}
}
}

View File

@ -96,6 +96,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public Fuckoff fo;
public AutoKick ak;
public AutoEject ae;
public Monitors mo;
public MovementValidator mv;
public EntityWiper ew;
public FrontDoor fd;
@ -198,6 +199,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
fo = services.registerService(Fuckoff.class);
ak = services.registerService(AutoKick.class);
ae = services.registerService(AutoEject.class);
mo = services.registerService(Monitors.class);
mv = services.registerService(MovementValidator.class);

View File

@ -0,0 +1,22 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Toggles potion spy.", usage = "/<command>")
public class Command_potionspy extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
playerdata.setPotionMonitorEnabled(!playerdata.isPotionMonitorEnabled());
msg("PotionSpy is now " + (playerdata.isPotionMonitorEnabled() ? "enabled." : "disabled."));
return true;
}
}

View File

@ -75,6 +75,9 @@ public class FPlayer
@Getter
@Setter
private boolean invSee = false;
@Getter
@Setter
private boolean potionMonitorEnabled = false;
public FPlayer(TotalFreedomMod plugin, Player player)
{