mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 09:15:38 +00:00
Punishment logging!
This commit is contained in:
parent
2185794444
commit
40a78f8608
@ -15,6 +15,7 @@ import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
|||||||
import me.totalfreedom.totalfreedommod.fun.*;
|
import me.totalfreedom.totalfreedommod.fun.*;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -68,6 +69,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
public Discord dc;
|
public Discord dc;
|
||||||
|
public PunishmentList pul;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public PermbanList pm;
|
||||||
public ProtectArea pa;
|
public ProtectArea pa;
|
||||||
@ -169,6 +171,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
an = services.registerService(Announcer.class);
|
an = services.registerService(Announcer.class);
|
||||||
cm = services.registerService(ChatManager.class);
|
cm = services.registerService(ChatManager.class);
|
||||||
dc = services.registerService(Discord.class);
|
dc = services.registerService(Discord.class);
|
||||||
|
pul = services.registerService(PunishmentList.class);
|
||||||
bm = services.registerService(BanManager.class);
|
bm = services.registerService(BanManager.class);
|
||||||
pm = services.registerService(PermbanList.class);
|
pm = services.registerService(PermbanList.class);
|
||||||
pa = services.registerService(ProtectArea.class);
|
pa = services.registerService(ProtectArea.class);
|
||||||
|
@ -8,7 +8,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
public class AMP extends FreedomService
|
public class AMP extends FreedomService
|
||||||
{
|
{
|
||||||
public AMPManager ampManager;
|
public AMPManager ampManager;
|
||||||
public Boolean enabled;
|
public Boolean enabled = false;
|
||||||
|
|
||||||
public AMP(TotalFreedomMod plugin)
|
public AMP(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,7 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -112,27 +109,8 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//deprecated (buggy)
|
|
||||||
|
|
||||||
/* @EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onProjectileHit(ProjectileHitEvent event)
|
|
||||||
{
|
|
||||||
if (ConfigEntry.MAKE_ARROW_EXPLOSIVE.getBoolean())
|
|
||||||
{
|
|
||||||
Projectile entity = event.getEntity();
|
|
||||||
if (entity instanceof Projectile)
|
|
||||||
{
|
|
||||||
if (event.getEntityType() == EntityType.ARROW)
|
|
||||||
{
|
|
||||||
entity.getWorld().createExplosion(entity.getLocation(), 2F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDamage(EntityDamageEvent event
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
switch (event.getCause())
|
switch (event.getCause())
|
||||||
{
|
{
|
||||||
@ -160,15 +138,14 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
if (event.getPlayer().getWorld().getEntities().size() > 750 && !plugin.al.isAdmin(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -182,8 +159,7 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onFireworkExplode(final FireworkExplodeEvent event
|
public void onFireworkExplode(FireworkExplodeEvent event)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
|
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,11 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -79,6 +82,9 @@ public class Command_doom extends FreedomCommand
|
|||||||
// Shoot the player in the sky
|
// Shoot the player in the sky
|
||||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
|
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
|
||||||
|
|
||||||
|
// Log doom
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.DOOM, null));
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,8 +4,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -40,158 +43,162 @@ public class Command_glist extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
String username = null;
|
|
||||||
final List<String> ips = new ArrayList<>();
|
|
||||||
boolean usingIp = false;
|
|
||||||
String banIp = null;
|
|
||||||
if (args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$") || args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([*])\\.([*])$"))
|
|
||||||
{
|
|
||||||
usingIp = true;
|
|
||||||
banIp = args[1];
|
|
||||||
}
|
|
||||||
final Player player = getPlayer(args[1]);
|
|
||||||
if (!usingIp)
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
final PlayerData entry = plugin.pl.getData(args[1]);
|
|
||||||
|
|
||||||
if (entry == null)
|
|
||||||
{
|
|
||||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
username = entry.getUsername();
|
|
||||||
ips.addAll(entry.getIps());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
final PlayerData entry = plugin.pl.getData(player);
|
|
||||||
username = entry.getUsername();
|
|
||||||
ips.addAll(entry.getIps());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (args[0])
|
|
||||||
{
|
|
||||||
case "ban":
|
|
||||||
case "gtfo":
|
|
||||||
if (usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify a player, not an ip.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final String playerBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
|
||||||
Ban playerBan = Ban.forPlayerName(username, sender, null, playerBanReason);
|
|
||||||
for (String ip : ips)
|
|
||||||
{
|
|
||||||
playerBan.addIp(ip);
|
|
||||||
playerBan.addIp(FUtil.getFuzzyIp(ip));
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
|
||||||
|
|
||||||
plugin.bm.addBan(playerBan);
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
player.kickPlayer(playerBan.bakeKickMessage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "unban":
|
|
||||||
case "pardon":
|
|
||||||
if (usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify a player, not an ip.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
|
||||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
|
||||||
|
|
||||||
for (String ip : ips)
|
|
||||||
{
|
|
||||||
Ban playerUnban = plugin.bm.getByIp(ip);
|
|
||||||
if (playerUnban != null)
|
|
||||||
{
|
|
||||||
plugin.bm.removeBan(playerUnban);
|
|
||||||
}
|
|
||||||
playerUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
|
||||||
if (playerUnban != null)
|
|
||||||
{
|
|
||||||
plugin.bm.removeBan(playerUnban);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
case "nameban":
|
|
||||||
case "banname":
|
|
||||||
if (usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify a name, not an ip.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final String nameBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
|
||||||
Ban nameBan = Ban.forPlayerName(username, sender, null, nameBanReason);
|
|
||||||
FUtil.adminAction(sender.getName(), "Banning IGN: " + username, true);
|
|
||||||
plugin.bm.addBan(nameBan);
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
player.kickPlayer(nameBan.bakeKickMessage());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "unbanname":
|
|
||||||
case "nameunban":
|
|
||||||
if (usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify a name, not an ip.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
FUtil.adminAction(sender.getName(), "Unbanning IGN: " + username, true);
|
|
||||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
|
||||||
return true;
|
|
||||||
case "banip":
|
|
||||||
case "ipban":
|
|
||||||
if (!usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify an IP.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String ipBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
|
||||||
Ban ipBan = Ban.forPlayerIp(banIp, sender, null, ipBanReason);
|
|
||||||
plugin.bm.addBan(ipBan);
|
|
||||||
FUtil.adminAction(sender.getName(), "Banning IP: " + banIp, true);
|
|
||||||
return true;
|
|
||||||
case "unbanip":
|
|
||||||
case "pardonip":
|
|
||||||
if (!usingIp)
|
|
||||||
{
|
|
||||||
msg("Please specify an IP.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Unbanning IP: " + banIp, true);
|
|
||||||
Ban ipUnban = plugin.bm.getByIp(banIp);
|
|
||||||
if (ipUnban != null)
|
|
||||||
{
|
|
||||||
plugin.bm.removeBan(ipUnban);
|
|
||||||
plugin.bm.unbanIp(banIp);
|
|
||||||
}
|
|
||||||
ipUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(banIp));
|
|
||||||
if (ipUnban != null)
|
|
||||||
{
|
|
||||||
plugin.bm.removeBan(ipUnban);
|
|
||||||
plugin.bm.unbanIp(banIp);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String username = null;
|
||||||
|
final List<String> ips = new ArrayList<>();
|
||||||
|
boolean usingIp = false;
|
||||||
|
String banIp = null;
|
||||||
|
if (args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$") || args[1].matches("^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\\.([*])\\.([*])$"))
|
||||||
|
{
|
||||||
|
usingIp = true;
|
||||||
|
banIp = args[1];
|
||||||
|
}
|
||||||
|
final Player player = getPlayer(args[1]);
|
||||||
|
if (!usingIp)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(args[1]);
|
||||||
|
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
username = entry.getUsername();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
|
username = entry.getUsername();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (args[0])
|
||||||
|
{
|
||||||
|
case "ban":
|
||||||
|
case "gtfo":
|
||||||
|
if (usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify a player, not an ip.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final String playerBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
||||||
|
Ban playerBan = Ban.forPlayerName(username, sender, null, playerBanReason);
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
playerBan.addIp(ip);
|
||||||
|
playerBan.addIp(FUtil.getFuzzyIp(ip));
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
|
|
||||||
|
plugin.bm.addBan(playerBan);
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(playerBan.bakeKickMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, null));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
case "unban":
|
||||||
|
case "pardon":
|
||||||
|
if (usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify a player, not an ip.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||||
|
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
Ban playerUnban = plugin.bm.getByIp(ip);
|
||||||
|
if (playerUnban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(playerUnban);
|
||||||
|
}
|
||||||
|
playerUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
||||||
|
if (playerUnban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(playerUnban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
case "nameban":
|
||||||
|
case "banname":
|
||||||
|
if (usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify a name, not an ip.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final String nameBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
||||||
|
Ban nameBan = Ban.forPlayerName(username, sender, null, nameBanReason);
|
||||||
|
FUtil.adminAction(sender.getName(), "Banning IGN: " + username, true);
|
||||||
|
plugin.bm.addBan(nameBan);
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(nameBan.bakeKickMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
case "unbanname":
|
||||||
|
case "nameunban":
|
||||||
|
if (usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify a name, not an ip.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), "Unbanning IGN: " + username, true);
|
||||||
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||||
|
return true;
|
||||||
|
case "banip":
|
||||||
|
case "ipban":
|
||||||
|
if (!usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify an IP.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String ipBanReason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
||||||
|
Ban ipBan = Ban.forPlayerIp(banIp, sender, null, ipBanReason);
|
||||||
|
plugin.bm.addBan(ipBan);
|
||||||
|
FUtil.adminAction(sender.getName(), "Banning IP: " + banIp, true);
|
||||||
|
return true;
|
||||||
|
case "unbanip":
|
||||||
|
case "pardonip":
|
||||||
|
if (!usingIp)
|
||||||
|
{
|
||||||
|
msg("Please specify an IP.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Unbanning IP: " + banIp, true);
|
||||||
|
Ban ipUnban = plugin.bm.getByIp(banIp);
|
||||||
|
if (ipUnban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(ipUnban);
|
||||||
|
plugin.bm.unbanIp(banIp);
|
||||||
|
}
|
||||||
|
ipUnban = plugin.bm.getByIp(FUtil.getFuzzyIp(banIp));
|
||||||
|
if (ipUnban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(ipUnban);
|
||||||
|
plugin.bm.unbanIp(banIp);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -14,7 +19,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Makes someone GTFO (deop and ip ban by username).", usage = "/<command> <partialname> [reason] [-nrb]")
|
@CommandParameters(description = "Bans a player", usage = "/<command> <username> [reason] [-nrb]")
|
||||||
public class Command_gtfo extends FreedomCommand
|
public class Command_gtfo extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,12 +31,51 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
final String username;
|
||||||
|
final List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||||
return true;
|
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
username = entry.getUsername();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
|
username = player.getName();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
|
||||||
|
// Deop
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
// Gamemode suvival
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
// Clear inventory
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
// Strike with lightning
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
for (int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
for (int z = -1; z <= 1; z++)
|
||||||
|
{
|
||||||
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
|
targetPos.getWorld().strikeLightning(strike_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill player
|
||||||
|
player.setHealth(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String reason = null;
|
String reason = null;
|
||||||
@ -52,77 +96,67 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
|
||||||
|
|
||||||
//checks if there is CoreProtect loaded and installed , if not it skips the rollback and uses coreprotect directly
|
//checks if there is CoreProtect loaded and installed , if not it skips the rollback and uses coreprotect directly
|
||||||
if (!cancelRollback)
|
if (!cancelRollback)
|
||||||
{
|
{
|
||||||
if (!server.getPluginManager().isPluginEnabled("CoreProtect"))
|
if (!plugin.cpb.isEnabled())
|
||||||
{
|
{
|
||||||
// Undo WorldEdits
|
// Undo WorldEdits
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
plugin.web.undo(player, 15);
|
plugin.web.undo(player, 15);
|
||||||
}
|
}
|
||||||
catch (NoClassDefFoundError ex)
|
catch (NoClassDefFoundError | NullPointerException ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rollback
|
// Rollback
|
||||||
plugin.rb.rollback(player.getName());
|
plugin.rb.rollback(username);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plugin.cpb.rollback(player.getName());
|
plugin.cpb.rollback(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deop
|
if (player != null)
|
||||||
player.setOp(false);
|
|
||||||
|
|
||||||
// Gamemode suvival
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
|
||||||
|
|
||||||
// Clear inventory
|
|
||||||
player.getInventory().clear();
|
|
||||||
|
|
||||||
// Strike with lightning
|
|
||||||
final Location targetPos = player.getLocation();
|
|
||||||
for (int x = -1; x <= 1; x++)
|
|
||||||
{
|
{
|
||||||
for (int z = -1; z <= 1; z++)
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
{
|
|
||||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
|
||||||
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ip = FUtil.getFuzzyIp(Ips.getIp(player));
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
ban.addIp(ip);
|
||||||
|
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||||
|
}
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
// Broadcast
|
// Broadcast
|
||||||
final StringBuilder bcast = new StringBuilder()
|
final StringBuilder bcast = new StringBuilder()
|
||||||
.append(ChatColor.RED)
|
.append(ChatColor.RED)
|
||||||
.append(sender.getName())
|
.append(sender.getName())
|
||||||
.append(" - Banning ")
|
.append(" - ")
|
||||||
.append(player.getName())
|
.append("Banning: ")
|
||||||
.append(", IP: ")
|
.append(username)
|
||||||
.append(ip);
|
.append(", IPs: ")
|
||||||
|
.append(StringUtils.join(ips, ", "));
|
||||||
if (reason != null)
|
if (reason != null)
|
||||||
{
|
{
|
||||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(FUtil.colorize(reason));
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
}
|
}
|
||||||
FUtil.bcastMsg(bcast.toString());
|
FUtil.bcastMsg(bcast.toString());
|
||||||
|
|
||||||
// Ban player
|
|
||||||
Ban ban = Ban.forPlayerFuzzy(player, sender, null, reason);
|
|
||||||
plugin.bm.addBan(ban);
|
|
||||||
|
|
||||||
// Kill player
|
|
||||||
player.setHealth(0.0);
|
|
||||||
|
|
||||||
// Kick player
|
// Kick player
|
||||||
player.kickPlayer(ban.bakeKickMessage());
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log ban
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -49,6 +52,9 @@ public class Command_kick extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.kickPlayer(builder.toString());
|
player.kickPlayer(builder.toString());
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,12 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
admin.setRank(rank);
|
admin.setRank(rank);
|
||||||
plugin.al.save();
|
plugin.al.save();
|
||||||
|
|
||||||
|
Player player = getPlayer(admin.getName());
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
|
|
||||||
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -174,7 +180,10 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true);
|
||||||
plugin.al.addAdmin(new Admin(player));
|
plugin.al.addAdmin(new Admin(player));
|
||||||
plugin.rm.updateDisplay(player);
|
if (player != null)
|
||||||
|
{
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // Existing admin
|
else // Existing admin
|
||||||
{
|
{
|
||||||
@ -191,7 +200,10 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
|
|
||||||
plugin.al.save();
|
plugin.al.save();
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
plugin.rm.updateDisplay(player);
|
if (player != null)
|
||||||
|
{
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
@ -202,6 +214,12 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
fPlayer.getFreezeData().setFrozen(false);
|
fPlayer.getFreezeData().setFrozen(false);
|
||||||
msg(player.getPlayer(), "You have been unfrozen.");
|
msg(player.getPlayer(), "You have been unfrozen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!player.isOp())
|
||||||
|
{
|
||||||
|
player.setOp(true);
|
||||||
|
player.sendMessage(YOU_ARE_OP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -230,7 +248,10 @@ public class Command_saconfig extends FreedomCommand
|
|||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.al.save();
|
plugin.al.save();
|
||||||
plugin.al.updateTables();
|
plugin.al.updateTables();
|
||||||
plugin.rm.updateDisplay(player);
|
if (player != null)
|
||||||
|
{
|
||||||
|
plugin.rm.updateDisplay(player);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -65,7 +68,7 @@ public class Command_stfu extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Muting all non-Superadmins", true);
|
FUtil.adminAction(sender.getName(), "Muting all non-admins", true);
|
||||||
|
|
||||||
FPlayer playerdata;
|
FPlayer playerdata;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
@ -121,7 +124,7 @@ public class Command_stfu extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is a superadmin, and can't be muted.");
|
msg(player.getName() + " is an admin, and can't be muted.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,9 +136,15 @@ public class Command_stfu extends FreedomCommand
|
|||||||
Command_smite.smite(sender, player, reason);
|
Command_smite.smite(sender, player, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(player, "You have been muted.", ChatColor.RED);
|
msg(player, "You have been muted by " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
msg(player, "Reason: " + ChatColor.YELLOW + reason);
|
||||||
|
}
|
||||||
msg("Muted " + player.getName());
|
msg("Muted " + player.getName());
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -57,6 +60,8 @@ public class Command_tban extends FreedomCommand
|
|||||||
|
|
||||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,11 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -72,6 +75,8 @@ public class Command_tempban extends FreedomCommand
|
|||||||
|
|
||||||
player.kickPlayer(sender.getName() + " - " + message.toString());
|
player.kickPlayer(sender.getName() + " - " + message.toString());
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.TEMPBAN, reason));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Wipes all logged punishments or punishments for a specific user.", usage = "/<command> <username | -a>")
|
||||||
|
public class Command_wipepunishments extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("-a"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Wiping the punishment history", true);
|
||||||
|
|
||||||
|
msg("Wiped " + plugin.pul.clear() + " punishments.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String username = args[0];
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Wiping the punishment history for " + username, true);
|
||||||
|
|
||||||
|
msg("Wiped " + plugin.pul.clear(username) + " punishments for " + username + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ import java.util.regex.Pattern;
|
|||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
|
|
||||||
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
import me.totalfreedom.totalfreedommod.httpd.module.HTTPDModule;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_admins;
|
||||||
@ -23,6 +22,7 @@ import me.totalfreedom.totalfreedommod.httpd.module.Module_logfile;
|
|||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_logs;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_permbans;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_players;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_punishments;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
import me.totalfreedom.totalfreedommod.httpd.module.Module_schematic;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -67,6 +67,7 @@ public class HTTPDaemon extends FreedomService
|
|||||||
module("logs", Module_logs.class, true);
|
module("logs", Module_logs.class, true);
|
||||||
module("permbans", Module_permbans.class, true);
|
module("permbans", Module_permbans.class, true);
|
||||||
module("players", Module_players.class, false);
|
module("players", Module_players.class, false);
|
||||||
|
module("punishments", Module_punishments.class, true);
|
||||||
module("schematic", Module_schematic.class, true);
|
module("schematic", Module_schematic.class, true);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -72,7 +72,7 @@ public class Module_logfile extends HTTPDModule
|
|||||||
if (!isAuthorized(remoteAddress))
|
if (!isAuthorized(remoteAddress))
|
||||||
{
|
{
|
||||||
|
|
||||||
out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to a superadmin on this server."));
|
out.append(HTMLGenerationTools.paragraph("Log files access denied: Your IP, " + remoteAddress + ", is not registered to an admin on this server."));
|
||||||
FLog.info("An unregistered IP (" + remoteAddress + ") has tried to access the log files");
|
FLog.info("An unregistered IP (" + remoteAddress + ") has tried to access the log files");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.httpd.module;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
|
||||||
|
|
||||||
|
public class Module_punishments extends HTTPDModule
|
||||||
|
{
|
||||||
|
|
||||||
|
public Module_punishments(TotalFreedomMod plugin, NanoHTTPD.HTTPSession session)
|
||||||
|
{
|
||||||
|
super(plugin, session);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NanoHTTPD.Response getResponse()
|
||||||
|
{
|
||||||
|
File adminFile = new File(plugin.getDataFolder(), PunishmentList.CONFIG_FILENAME);
|
||||||
|
if (adminFile.exists())
|
||||||
|
{
|
||||||
|
final String remoteAddress = socket.getInetAddress().getHostAddress();
|
||||||
|
if (!isAuthorized(remoteAddress))
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"You may not view the punishment list, Your IP, " + remoteAddress + ", is not registered to an admin on the server.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return HTTPDaemon.serveFileBasic(new File(plugin.getDataFolder(), PunishmentList.CONFIG_FILENAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT,
|
||||||
|
"Error 404: Not Found - The requested resource was not found on this server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isAuthorized(String remoteAddress)
|
||||||
|
{
|
||||||
|
Admin entry = plugin.al.getEntryByIp(remoteAddress);
|
||||||
|
return entry != null && entry.isActive();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.punishments;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import net.pravian.aero.base.ConfigLoadable;
|
||||||
|
import net.pravian.aero.base.ConfigSavable;
|
||||||
|
import net.pravian.aero.base.Validatable;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class Punishment implements ConfigLoadable, ConfigSavable, Validatable
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
private String ip = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String by = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private PunishmentType type = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String reason = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Date issued_on = null;
|
||||||
|
|
||||||
|
public Punishment()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Punishment(String username, String ip, String by, PunishmentType type, String reason)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
this.ip = ip;
|
||||||
|
this.by = by;
|
||||||
|
this.type = type;
|
||||||
|
this.reason = reason;
|
||||||
|
this.issued_on = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
this.username = cs.getString("username", null);
|
||||||
|
this.ip = cs.getString("ip", null);
|
||||||
|
this.by = cs.getString("by", null);
|
||||||
|
this.type = PunishmentType.valueOf(cs.getString("type", null).toUpperCase());
|
||||||
|
this.reason = cs.getString("reason", null);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.issued_on = DATE_FORMAT.parse(cs.getString("issued_on", null));
|
||||||
|
}
|
||||||
|
catch (ParseException e)
|
||||||
|
{
|
||||||
|
this.issued_on = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
cs.set("username", username);
|
||||||
|
cs.set("ip", ip);
|
||||||
|
cs.set("by", by);
|
||||||
|
cs.set("type", type.name().toLowerCase());
|
||||||
|
cs.set("reason", reason);
|
||||||
|
cs.set("issued_on", DATE_FORMAT.format(issued_on));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return username != null || ip != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,128 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.punishments;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
public class PunishmentList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Set<Punishment> punishments = Sets.newHashSet();
|
||||||
|
public static final String CONFIG_FILENAME = "punishments.yml";
|
||||||
|
|
||||||
|
//
|
||||||
|
private final YamlConfig config;
|
||||||
|
|
||||||
|
public PunishmentList(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
this.config = new YamlConfig(plugin, CONFIG_FILENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
punishments.clear();
|
||||||
|
for (String id : config.getKeys(false))
|
||||||
|
{
|
||||||
|
if (!config.isConfigurationSection(id))
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to load punishment number " + id + "!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Punishment punishment = new Punishment();
|
||||||
|
punishment.loadFrom(config.getConfigurationSection(id));
|
||||||
|
|
||||||
|
if (!punishment.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Not adding punishment number " + id + ". Missing information.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
punishments.add(punishment);
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + punishments.size() + " punishments.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
saveAll();
|
||||||
|
logger.info("Saved " + punishments.size() + " player bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAll()
|
||||||
|
{
|
||||||
|
config.clear();
|
||||||
|
|
||||||
|
for (Punishment punishment : punishments)
|
||||||
|
{
|
||||||
|
punishment.saveTo(config.createSection(String.valueOf(punishment.hashCode())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save config
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int clear()
|
||||||
|
{
|
||||||
|
int removed = punishments.size();
|
||||||
|
punishments.clear();
|
||||||
|
saveAll();
|
||||||
|
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int clear(String username)
|
||||||
|
{
|
||||||
|
List<Punishment> removed = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Punishment punishment : punishments)
|
||||||
|
{
|
||||||
|
if (punishment.getUsername().equalsIgnoreCase(username))
|
||||||
|
{
|
||||||
|
removed.add(punishment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removed.size() != 0)
|
||||||
|
{
|
||||||
|
punishments.removeAll(removed);
|
||||||
|
saveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return removed.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastPunishmentID()
|
||||||
|
{
|
||||||
|
int size = punishments.size();
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean logPunishment(Punishment punishment)
|
||||||
|
{
|
||||||
|
if (punishments.add(punishment))
|
||||||
|
{
|
||||||
|
saveAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.punishments;
|
||||||
|
|
||||||
|
public enum PunishmentType
|
||||||
|
{
|
||||||
|
MUTE,
|
||||||
|
SMITE,
|
||||||
|
KICK,
|
||||||
|
TEMPBAN,
|
||||||
|
BAN,
|
||||||
|
DOOM
|
||||||
|
}
|
@ -122,10 +122,7 @@ public class RankManager extends FreedomService
|
|||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
Displayable display = getDisplay(player);
|
Displayable display = getDisplay(player);
|
||||||
if (fPlayer.getTag() == null)
|
fPlayer.setTag(display.getColoredTag());
|
||||||
{
|
|
||||||
fPlayer.setTag(display.getColoredTag());
|
|
||||||
}
|
|
||||||
String displayName = display.getColor() + player.getName();
|
String displayName = display.getColor() + player.getName();
|
||||||
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||||
}
|
}
|
||||||
|
3
src/main/resources/punishments.yml
Normal file
3
src/main/resources/punishments.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#
|
||||||
|
# TotalFreedomMod 5.0 Player Punishments
|
||||||
|
#
|
Loading…
Reference in New Issue
Block a user