mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Restore inventories looted by fast inventory and flush magic values when reloaded
This commit is contained in:
1 parent
873a1b9d60
commit
96f3906eff
6 files changed
+61
-8
No files matched your search
@@ -100,11 +100,15 @@ public class Backend {
|
||||
private static final CheckResult PASS = new CheckResult(Result.PASSED);
|
||||
|
||||
public Backend(AnticheatManager instance) {
|
||||
magic = new Magic(instance.getConfiguration().getMagic(), instance.getConfiguration(), CommentedConfiguration.loadConfiguration(instance.getPlugin().getResource("magic.yml")));
|
||||
magic = instance.getConfiguration().getMagicInstance();
|
||||
micromanage = instance;
|
||||
lang = micromanage.getConfiguration().getLang();
|
||||
transparent.add((byte) -1);
|
||||
}
|
||||
|
||||
public void updateMagic(Magic magic) {
|
||||
this.magic = magic;
|
||||
}
|
||||
|
||||
public void garbageClean(Player player) {
|
||||
String pN = player.getName();
|
||||
@@ -795,7 +799,7 @@ public class Backend {
|
||||
|
||||
public CheckResult checkAutoTool(Player player) {
|
||||
if (itemInHand.containsKey(player.getName()) && itemInHand.get(player.getName()) != player.getItemInHand().getType()) {
|
||||
return new CheckResult(Result.FAILED, player.getName()+" switched tools too fast (had "+itemInHand.get(player.getName())+", has "+player.getItemInHand().getType());
|
||||
return new CheckResult(Result.FAILED, player.getName()+" switched tools too fast (had "+itemInHand.get(player.getName())+", has "+player.getItemInHand().getType()+")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,11 @@ import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class User {
|
||||
private final String name;
|
||||
@@ -32,6 +37,7 @@ public class User {
|
||||
private int med;
|
||||
private Location goodLocation;
|
||||
private boolean silentMode;
|
||||
private List<ItemStack> inventorySnapshot = null;
|
||||
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
@@ -114,5 +120,26 @@ public class User {
|
||||
|
||||
goodLocation = e;
|
||||
}
|
||||
|
||||
|
||||
public void setSnapshot(ItemStack[] is) {
|
||||
inventorySnapshot = new ArrayList<ItemStack>();
|
||||
for(int i=0;i<is.length;i++) {
|
||||
if(is[i] != null) {
|
||||
inventorySnapshot.add(is[i].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSnapshot() {
|
||||
inventorySnapshot = null;
|
||||
}
|
||||
|
||||
public void restore(Inventory inventory) {
|
||||
inventory.clear();
|
||||
for(ItemStack is : inventorySnapshot) {
|
||||
if(is != null) {
|
||||
inventory.addItem(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user