mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-06-28 23:34:43 +02:00
[NOTEWORTHY] Fix player instances being stored, though shouldn't.
The static stuff might need a cleanup (removal).
This commit is contained in:
parent
46b4641ba5
commit
26766095fe
|
@ -1,13 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus.compat.versions;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import fr.neatmonster.nocheatplus.NCPAPIProvider;
|
||||
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
|
||||
|
||||
/**
|
||||
* Feature selection, based on the version.
|
||||
* @author asofold
|
||||
|
@ -22,14 +16,9 @@ public class Bugs {
|
|||
protected static void init() {
|
||||
final String mcVersion = ServerVersion.getMinecraftVersion();
|
||||
final String serverVersion = Bukkit.getServer().getVersion().toLowerCase();
|
||||
final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
|
||||
final List<String> noteWorthy = new LinkedList<String>();
|
||||
|
||||
// Need to add velocity (only internally) because the server does not.
|
||||
pvpKnockBackVelocity = ServerVersion.isMinecraftVersionBetween("1.8", true, "1.9", false);
|
||||
if (pvpKnockBackVelocity) {
|
||||
noteWorthy.add("pvpKnockBackVelocity");
|
||||
}
|
||||
|
||||
// First move exploit (classic CraftBukkit or Spigot before 1.7.5).
|
||||
if (mcVersion == GenericVersion.UNKNOWN_VERSION) {
|
||||
|
@ -49,13 +38,6 @@ public class Bugs {
|
|||
// Assume something where it's not an issue.
|
||||
enforceLocation = false;
|
||||
}
|
||||
if (enforceLocation) {
|
||||
noteWorthy.add("enforceLocation");
|
||||
}
|
||||
if (!noteWorthy.isEmpty()) {
|
||||
api.addFeatureTags("defaults", noteWorthy); // Not sure how to name these.
|
||||
// Consider Bukkit.getLogger, or put to status after post-enable.
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldEnforceLocation() {
|
||||
|
|
|
@ -30,6 +30,7 @@ import fr.neatmonster.nocheatplus.checks.access.ICheckConfig;
|
|||
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
|
||||
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
|
||||
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.BukkitVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.GenericVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
|
||||
import fr.neatmonster.nocheatplus.components.ComponentRegistry;
|
||||
|
@ -120,6 +121,10 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
|
|||
*/
|
||||
public DataManager() {
|
||||
instance = this;
|
||||
if (ServerVersion.isMinecraftVersionUnknown()) {
|
||||
// True hacks.
|
||||
BukkitVersion.init();
|
||||
}
|
||||
final String version = ServerVersion.getMinecraftVersion();
|
||||
if (GenericVersion.compareVersions(version, "1.8") >= 0 || version.equals("1.7.10") && Bukkit.getServer().getVersion().toLowerCase().indexOf("spigot") != -1) {
|
||||
// Safe to assume Spigot, don't store Player instances.
|
||||
|
@ -648,4 +653,13 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if player instances are stored for efficiency (legacy).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean storesPlayerInstances() {
|
||||
return playerMap.storesPlayerInstances();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import fr.neatmonster.nocheatplus.compat.versions.GenericVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
|
||||
|
||||
public class TestMinecraftVersion {
|
||||
|
@ -27,6 +28,27 @@ public class TestMinecraftVersion {
|
|||
fail("Expect " + pair[0] + " for input: " + pair[1] + ", got instead: " + parsed);
|
||||
}
|
||||
}
|
||||
|
||||
// Expect -1
|
||||
for (String[] pair : new String[][] {
|
||||
{"1.8", "1.8.8"}
|
||||
}) {
|
||||
testCompare(pair[0], pair[1], -1);
|
||||
};
|
||||
|
||||
// Expect 1
|
||||
for (String[] pair : new String[][] {
|
||||
{"1.8.8", "1.8"}
|
||||
}) {
|
||||
testCompare(pair[0], pair[1], 1);
|
||||
};
|
||||
}
|
||||
|
||||
private void testCompare(String v1, String v2, int expectedResult) {
|
||||
int res = GenericVersion.compareVersions(v1, v2);
|
||||
if (res != expectedResult) {
|
||||
fail("Comparing " + v1 + " with " + v2 + " should result in " + expectedResult + ", got instead: " + res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package fr.neatmonster.nocheatplus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -56,6 +57,7 @@ import fr.neatmonster.nocheatplus.compat.MCAccessConfig;
|
|||
import fr.neatmonster.nocheatplus.compat.MCAccessFactory;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.BlockChangeListener;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.Bugs;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.BukkitVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.GenericVersion;
|
||||
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
|
||||
|
@ -820,6 +822,15 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
|||
|
||||
// Re-check basic setup (if onLoad gets skipped by some custom thing).
|
||||
setupBasics();
|
||||
if (Bugs.shouldEnforceLocation()) {
|
||||
addFeatureTags("defaults", Arrays.asList("enforceLocation"));
|
||||
}
|
||||
if (Bugs.shouldPvpKnockBackVelocity()) {
|
||||
addFeatureTags("defaults", Arrays.asList("pvpKnockBackVelocity"));
|
||||
}
|
||||
if (dataMan.storesPlayerInstances()) {
|
||||
addFeatureTags("defaults", Arrays.asList("storePlayers"));
|
||||
}
|
||||
|
||||
// Start logger task(s).
|
||||
logManager.startTasks();
|
||||
|
|
Loading…
Reference in New Issue
Block a user