Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VL scaling support for Simulation #1961

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class OffsetHandler extends Check implements PostPredictionCheck {
double immediateSetbackThreshold;
double maxAdvantage;
double maxCeiling;
double vlScale;
double maxVlsPerFlag;

// Current advantage gained
double advantageGained = 0;
Expand Down Expand Up @@ -50,7 +52,7 @@ public void onPredictionComplete(final PredictionComplete predictionComplete) {
player.getSetbackTeleportUtil().executeViolationSetback();
}

violations++;
violations += Math.min(maxVlsPerFlag, Math.ceil(offset * vlScale) - 1.0);

synchronized (flags) {
int flagId = (flags.get() & 255) + 1; // 1-256 as possible values
Expand Down Expand Up @@ -106,8 +108,11 @@ public void onReload(ConfigManager config) {
immediateSetbackThreshold = config.getDoubleElse("Simulation.immediate-setback-threshold", 0.1);
maxAdvantage = config.getDoubleElse("Simulation.max-advantage", 1);
maxCeiling = config.getDoubleElse("Simulation.max-ceiling", 4);
vlScale = Math.max(1.0, config.getDoubleElse("Simulation.vl-scale", 10));
maxVlsPerFlag = config.getDoubleElse("Simulation.max-vls-per-flag", 5);
if (maxAdvantage == -1) maxAdvantage = Double.MAX_VALUE;
if (immediateSetbackThreshold == -1) immediateSetbackThreshold = Double.MAX_VALUE;
if (maxVlsPerFlag == -1) maxVlsPerFlag = Double.MAX_VALUE;
}

public boolean doesOffsetFlag(double offset) {
Expand Down
55 changes: 27 additions & 28 deletions src/main/java/ac/grim/grimac/manager/PunishmentManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,33 @@ public boolean handleAlert(GrimPlayer player, String verbose, Check check) {
}
}

if (violationCount >= command.threshold) {
// 0 means execute once
// Any other number means execute every X interval
boolean inInterval = command.interval == 0 ? (command.executeCount == 0) : (violationCount % command.interval == 0);
if (inInterval) {
CommandExecuteEvent executeEvent = new CommandExecuteEvent(player, check, verbose, cmd);
Bukkit.getPluginManager().callEvent(executeEvent);
if (executeEvent.isCancelled()) continue;

if (command.command.equals("[webhook]")) {
GrimAPI.INSTANCE.getDiscordManager().sendAlert(player, verbose, check.getDisplayName(), vl);
} else if (command.command.equals("[proxy]")) {
ProxyAlertMessenger.sendPluginMessage(replaceAlertPlaceholders(command.command, vl, group, check, proxyAlertString, verbose));
} else {
if (command.command.equals("[alert]")) {
sentDebug = true;
if (testMode) { // secret test mode
player.user.sendMessage(MessageUtil.miniMessage(cmd));
continue;
}
cmd = "grim sendalert " + cmd; // Not test mode, we can add the command prefix
// 0 means execute once
// Any other number means execute every X interval
for (; vl >= (command.threshold + (command.interval * command.executeCount)); command.executeCount++) {
if (command.interval == 0 && command.executeCount > 0) break;

CommandExecuteEvent executeEvent = new CommandExecuteEvent(player, check, verbose, cmd);
Bukkit.getPluginManager().callEvent(executeEvent);
if (executeEvent.isCancelled()) continue;

if (command.command.equals("[webhook]")) {
GrimAPI.INSTANCE.getDiscordManager().sendAlert(player, verbose, check.getDisplayName(), vl);
} else if (command.command.equals("[proxy]")) {
ProxyAlertMessenger.sendPluginMessage(replaceAlertPlaceholders(command.command, vl, group, check, proxyAlertString, verbose));
} else {
if (command.command.equals("[alert]")) {
sentDebug = true;
if (testMode) { // secret test mode
player.user.sendMessage(MessageUtil.miniMessage(cmd));
continue;
}

String finalCmd = cmd;
FoliaScheduler.getGlobalRegionScheduler().run(GrimAPI.INSTANCE.getPlugin(), (dummy) ->
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalCmd));
cmd = "grim sendalert " + cmd; // Not test mode, we can add the command prefix
}
}

command.executeCount++;
String finalCmd = cmd;
FoliaScheduler.getGlobalRegionScheduler().run(GrimAPI.INSTANCE.getPlugin(), (dummy) ->
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalCmd));
}
}
}
}
Expand All @@ -186,7 +183,9 @@ public void handleViolation(Check check) {
private int getViolations(PunishGroup group, Check check) {
int vl = 0;
for (Check value : group.violations.values()) {
if (value == check) vl++;
if (value == check) {
vl = Math.max(vl, (int)Math.ceil(value.getViolations()));
}
}
return vl;
}
Comment on lines 183 to 191
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Violation entries added to PunishGroup.violations via handleViolation() are still getting deleted correctly, but the VL count returned by getViolations() no longer correspond directly to the amount of key-value pairs with the same value (check) as the supplied parameter, but is instead taken from Check.getViolations(), which would only decrease upon a Check.reward() call.
To fix this issue, there needs to be some sort of way to keep track of the VL gain from individual violations.

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulation:
# Standard-Vorteilsgrenze (x-Achse = Sekunden, y-Achse = 1/1000 Block): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Überprüft, ob ein Spieler während einer Bewegung einen Block betreten hat.
Phase:
setbackvl: 1 # Glitching in Blöcken kann das Klettern an der Wand ermöglichen, außerdem ist dieser Check relativ stabil.
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/config/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ Simulation:
# This is to stop the player from gathering too many violations and never being able to clear them all
# Default advantage ceiling (x axis = seconds, y axis = 1/1000 block): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4
# How much should we scale VL gain from a flag by the player's advantage?
# ≤1 for no scaling (old behavior)
vl-scale: 10
# Limits the amount of VLs the player could gain from each flag
# This is to prevent high latency players from getting large amount of VLs because of lag spikes
# -1 to disable
max-vls-per-flag: 5

# Checks to see if a player entered a block during a movement
Phase:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Simulation:
# Tope de ventaja por defecto (eje x = segundos, eje y = bloque 1/1000): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Comprobaciones para ver si un jugador entro a un bloque durante un movimiento
Phase:
setbackvl: 1 # Entrar a un bloque mediante bugs puede permitir subir paredes, además esta comprobación es relativamente estable.
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulation:
# Plafond d'avantage par défaut (l"axe x = secondes, l'axe y = 1/1000 de bloc)) : https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Vérifications pour voir si un joueur est entré dans un bloc pendant un mouvement.
Phase:
setbackvl: 1 # Rentrer dans des blocs peut permettre de grimper sur les murs, et cette vérification est relativement stable.
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Simulation:
# Limite massimo di vantaggio accumulabile prima di arretrare il giocatore
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

Phase:
# Livello di violazione per il glitch nel blocco
setbackvl: 1
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Simulation:
# デフォルトのアドバンテージの上限 (x軸 = 秒, y軸 = 1/1000ブロック): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# プレイヤーが移動中にブロックに入ったかどうかをチェックします。
Phase:
setbackvl: 1 # 1ブロック以上のズレがある場合に違反と判断します。
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulation:
# Standaard voordelenplatform (x-as = seconden, y-as = 1/1000 blok): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Controleert of een speler een blok is binnengegaan tijdens een beweging
Phase:
setbackvl: 1 # Glitching in blokken kan muurklimmen mogelijk maken, plus deze controle is relatief stabiel
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Simulation:
# Cela de vantagens padrão (eixo X = segundos, eixo Y = 1/1000 blocos): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Verifica se um jogador entrou em um bloco ao se mover.
Phase:
setbackvl: 1 # Entrar em blocos possibilita escalar paredes, além disso, essa verificação é relativamente estável.
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulation:
# Потолок преимущества по умолчанию (ось x = секунды, ось y = 1/1000 блока): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Проверяет, вошел ли игрок в блок во время движения.
Phase:
setbackvl: 1 # Глитч с блоками может позволить забраться на стену, к тому же эта проверка относительно стабильна
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Simulation:
# Varsayılan avantaj tavanı (x ekseni = saniye, y ekseni = 1/1000 blok): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# Bir oyuncunun bir hareket sırasında bir bloğa girip girmediğini kontrol eder
Phase:
setbackvl: 1 # Blokların içinde glitch yapmak duvara tırmanmaya izin verebilir, ayrıca bu kontrol nispeten stabildir
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Simulation:
# 这是默认配置的样子(x 轴 = seconds ,y 轴 = 1/1000 方块): https://www.desmos.com/calculator/4lovswdarj
max-ceiling: 4

vl-scale: 10
max-vls-per-flag: 5

# 检查玩家是否穿墙
Phase:
setbackvl: 1 # 错误的方块可以允许爬墙,加上这个检查是相对稳定的
Expand Down