Fix anticheat banning in clans

This commit is contained in:
AlexTheCoder 2017-07-21 22:31:23 -04:00
parent a29cff2db1
commit d8d1ee7832
7 changed files with 44 additions and 39 deletions

View File

@ -1,6 +1,5 @@
package mineplex.core.antihack;
import javax.xml.bind.DatatypeConverter;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
@ -10,11 +9,7 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import javax.xml.bind.DatatypeConverter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -77,6 +72,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Category;
@ -85,6 +81,11 @@ import mineplex.core.punish.PunishClient;
import mineplex.core.punish.Punishment;
import mineplex.core.punish.PunishmentResponse;
import mineplex.serverdata.commands.ServerCommandManager;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin
@ -238,7 +239,7 @@ public class AntiHack extends MiniPlugin
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, finalMessage, null, ban -> {});
_punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), finalMessage, null, ban -> {});
});
}
};
@ -254,17 +255,18 @@ public class AntiHack extends MiniPlugin
else
{
runBanAnimation(player, () ->
doPunish.accept(result ->
{
doPunish.accept(result ->
{
if (result == PunishmentResponse.Punished)
{
if (result == PunishmentResponse.Punished)
{
announceBan(player);
_banned.add(player.getUniqueId());
_banWaveManager.flagDone(coreClient);
}
_pendingBan.remove(player);
})
);
announceBan(player);
_banned.add(player.getUniqueId());
_banWaveManager.flagDone(coreClient);
}
_pendingBan.remove(player);
});
});
}
}, custom);
}
@ -286,7 +288,7 @@ public class AntiHack extends MiniPlugin
{
_punish.getClansPunish().loadClient(coreClient.getUniqueId(), client ->
{
_punish.getClansPunish().ban(client, null, AntiHack.NAME, 90 * 24 * 60 * 60 * 1000, info.getMessage(), null, ban -> {});
_punish.getClansPunish().ban(client, null, AntiHack.NAME, UtilTime.convert(90L, mineplex.core.common.util.UtilTime.TimeUnit.DAYS, mineplex.core.common.util.UtilTime.TimeUnit.MILLISECONDS), info.getMessage(), null, ban -> {});
});
}
};

View File

@ -5,7 +5,6 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import mineplex.core.common.util.UtilTasks;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
@ -45,4 +44,4 @@ public class AnticheatDatabase extends RepositoryBase
}
}
}
}
}

View File

@ -20,4 +20,4 @@ public abstract class AnticheatMetadata implements Listener
public abstract JsonElement build(UUID player);
public abstract void remove(UUID player);
}
}

View File

@ -28,7 +28,12 @@ public class PartyInfoMetadata extends AnticheatMetadata
@Override
public JsonElement build(UUID player)
{
Party party = require(PartyManager.class).getPartyByPlayer(player);
PartyManager pm = require(PartyManager.class);
if (pm == null)
{
return JsonNull.INSTANCE;
}
Party party = pm.getPartyByPlayer(player);
if (party != null)
{
JsonObject partyData = new JsonObject();
@ -52,4 +57,4 @@ public class PartyInfoMetadata extends AnticheatMetadata
{
}
}
}

View File

@ -48,4 +48,4 @@ public class PlayerInfoMetadata extends AnticheatMetadata
{
}
}
}

View File

@ -156,4 +156,4 @@ public class ViolationInfoMetadata extends AnticheatMetadata
violations.add(data);
}
}
}

View File

@ -108,20 +108,19 @@ public class ClansBanRepository extends RepositoryBase
{
// Yes, this is garbage.
// Yes, it would be better implemented in a functional language.
return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name))
.thenCompose(uuid ->
{
if (uuid == null)
{
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
future.complete(Optional.empty());
return future;
}
else
{
return loadClient(uuid).thenApply(Optional::of);
}
});
return CompletableFuture.supplyAsync(() -> Managers.get(CoreClientManager.class).loadUUIDFromDB(name)).thenCompose(uuid ->
{
if (uuid == null)
{
CompletableFuture<Optional<ClansBanClient>> future = new CompletableFuture<>();
future.complete(Optional.empty());
return future;
}
else
{
return loadClient(uuid).thenApply(Optional::of);
}
});
}
public void removeBan(ClansBan ban)