mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-28 02:54:17 +00:00
Fix it this time
This commit is contained in:
parent
ef957467ce
commit
ec7e370a01
4 changed files with 15 additions and 37 deletions
|
@ -82,10 +82,6 @@ public class EntityWipeCMD extends PlexCommand
|
|||
list = list.replaceAll("(, )(?!.*\1)", (list.indexOf(", ") == list.lastIndexOf(", ") ? "" : ",") + " and ");
|
||||
PlexUtils.broadcast(messageComponent("removedEntitiesOfTypes", sender.getName(), entityCount, list));
|
||||
}
|
||||
|
||||
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||
});*/
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import dev.plex.listener.PlexListener;
|
|||
import dev.plex.services.impl.TimingService;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
@ -12,24 +11,26 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||
|
||||
public class AntiNukerListener extends PlexListener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
TimingService.nukerCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||
{
|
||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
TimingService.nukerCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||
{
|
||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class BanListener extends PlexListener
|
|||
if (plugin.getPunishmentManager().isBanned(event.getUniqueId()))
|
||||
{
|
||||
PlexPlayer player = DataUtils.getPlayer(event.getUniqueId());
|
||||
player.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.BAN && punishment.isActive()).findFirst().ifPresent(punishment ->
|
||||
player.getPunishments().stream().filter(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive()).findFirst().ifPresent(punishment ->
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
||||
Punishment.generateBanMessage(punishment)));
|
||||
}
|
||||
|
|
|
@ -5,12 +5,11 @@ import dev.plex.player.PlexPlayer;
|
|||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.services.AbstractService;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -18,10 +17,6 @@ public class TimingService extends AbstractService
|
|||
{
|
||||
public static final Map<UUID, Long> spamCooldown = new HashMap<>();
|
||||
public static final Map<UUID, Long> nukerCooldown = new HashMap<>();
|
||||
// 1 - Default
|
||||
// 2 - Kick
|
||||
// 3 - Tempban 5 minutes
|
||||
// 4 - Ban
|
||||
public static final Map<UUID, Long> strikes = new HashMap<>();
|
||||
|
||||
public TimingService()
|
||||
|
@ -36,46 +31,32 @@ public class TimingService extends AbstractService
|
|||
nukerCooldown.clear();
|
||||
for (Map.Entry<UUID, Long> map : strikes.entrySet())
|
||||
{
|
||||
if (map.getValue() == 2)
|
||||
PlexLog.debug(map.getKey() + ": " + map.getValue());
|
||||
// Tempban for 5 minutes and reset strikes. This will probably stop people from actually trying to use a Nuker to grief.
|
||||
if (map.getValue() >= 2L)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(map.getKey());
|
||||
if (player != null)
|
||||
{
|
||||
player.kick(Component.text("Please disable your nuker!").color(NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
if (map.getValue() == 3)
|
||||
{
|
||||
issueBan(map, "5m");
|
||||
}
|
||||
else if (map.getValue() == 4)
|
||||
{
|
||||
issueBan(map, "24h");
|
||||
map.setValue(0L);
|
||||
issueBan(map);
|
||||
strikes.remove(map.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void issueBan(Map.Entry<UUID, Long> map, String time)
|
||||
private void issueBan(Map.Entry<UUID, Long> map)
|
||||
{
|
||||
Punishment punishment = new Punishment(map.getKey(), null);
|
||||
Player player = Bukkit.getPlayer(map.getKey());
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(map.getKey());
|
||||
punishment.setType(PunishmentType.TEMPBAN);
|
||||
punishment.setReason("You are temporarily banned for five minutes for either using a Nuker or spamming chat/commands.");
|
||||
punishment.setReason("You are temporarily banned for five minutes for using a Nuker.");
|
||||
if (player != null)
|
||||
{
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
punishment.setEndDate(TimeUtils.createDate(time));
|
||||
punishment.setEndDate(TimeUtils.createDate("5m"));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(!plugin.getRankManager().isAdmin(plexPlayer));
|
||||
punishment.setActive(!plexPlayer.isAdminActive());
|
||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||
if (player != null)
|
||||
{
|
||||
player.kick(Punishment.generateBanMessage(punishment));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue