mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
parent
7e524da928
commit
d9d1d4fa9b
92
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
92
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal 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() + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -96,6 +96,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public Fuckoff fo;
|
public Fuckoff fo;
|
||||||
public AutoKick ak;
|
public AutoKick ak;
|
||||||
public AutoEject ae;
|
public AutoEject ae;
|
||||||
|
public Monitors mo;
|
||||||
public MovementValidator mv;
|
public MovementValidator mv;
|
||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public FrontDoor fd;
|
public FrontDoor fd;
|
||||||
@ -198,6 +199,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
fo = services.registerService(Fuckoff.class);
|
fo = services.registerService(Fuckoff.class);
|
||||||
ak = services.registerService(AutoKick.class);
|
ak = services.registerService(AutoKick.class);
|
||||||
ae = services.registerService(AutoEject.class);
|
ae = services.registerService(AutoEject.class);
|
||||||
|
mo = services.registerService(Monitors.class);
|
||||||
|
|
||||||
|
|
||||||
mv = services.registerService(MovementValidator.class);
|
mv = services.registerService(MovementValidator.class);
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -75,6 +75,9 @@ public class FPlayer
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean invSee = false;
|
private boolean invSee = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean potionMonitorEnabled = false;
|
||||||
|
|
||||||
public FPlayer(TotalFreedomMod plugin, Player player)
|
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user