mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Re-hide spying players when they join the server
This commit is contained in:
1 parent
ebe01991c6
commit
6b2835b018
3 files changed
+46
-35
No files matched your search
@@ -51,7 +51,8 @@ public class Anticheat extends JavaPlugin
|
||||
private static boolean verbose;
|
||||
private static Metrics metrics;
|
||||
private static final long XRAY_TIME = 1200;
|
||||
|
||||
public static final String SPY_METADATA = "ac-spydata";
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
@@ -62,7 +63,7 @@ public class Anticheat extends JavaPlugin
|
||||
eventList.add(new VehicleListener());
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
||||
setupConfig();
|
||||
setupConfig();
|
||||
// Xray must come before events
|
||||
setupXray();
|
||||
setupEvents();
|
||||
@@ -74,7 +75,7 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
getLogger().log(Level.INFO, "Finished loading.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
@@ -88,13 +89,13 @@ public class Anticheat extends JavaPlugin
|
||||
getServer().getScheduler().cancelAllTasks();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void save(InputStream in, File file)
|
||||
|
||||
private void save(InputStream in, File file)
|
||||
{
|
||||
if (!file.exists())
|
||||
{
|
||||
{
|
||||
file.getParentFile().mkdirs();
|
||||
try
|
||||
try
|
||||
{
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
byte[] buf = new byte[1024];
|
||||
@@ -105,18 +106,18 @@ public class Anticheat extends JavaPlugin
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
getLogger().log(Level.INFO, file.getName()+" created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupXray()
|
||||
{
|
||||
final XRayTracker xtracker = manager.getXRayTracker();
|
||||
@@ -149,9 +150,9 @@ public class Anticheat extends JavaPlugin
|
||||
getLogger().log(Level.INFO, "Scheduled the XRay checker.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupEvents()
|
||||
{
|
||||
for (Listener listener : eventList)
|
||||
@@ -161,18 +162,18 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
getLogger().log(Level.INFO, "Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupCommands()
|
||||
{
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
if (verbose)
|
||||
{
|
||||
getLogger().log(Level.INFO, "Registered commands.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupUpdater()
|
||||
{
|
||||
if (config.autoUpdate())
|
||||
@@ -180,16 +181,16 @@ public class Anticheat extends JavaPlugin
|
||||
if (verbose)
|
||||
{
|
||||
getLogger().log(Level.INFO, "Checking for a new update...");
|
||||
}
|
||||
}
|
||||
Updater updater = new Updater(this, "anticheat", this.getFile(), Updater.UpdateType.DEFAULT, false);
|
||||
update = updater.getResult() != Updater.UpdateResult.NO_UPDATE;
|
||||
if (verbose)
|
||||
{
|
||||
getLogger().log(Level.INFO, "Update avaliable: "+update);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupMetrics()
|
||||
{
|
||||
try
|
||||
@@ -234,9 +235,9 @@ public class Anticheat extends JavaPlugin
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setupConfig()
|
||||
{
|
||||
config = manager.getConfiguration();
|
||||
@@ -245,9 +246,9 @@ public class Anticheat extends JavaPlugin
|
||||
if (verbose)
|
||||
{
|
||||
getLogger().log(Level.INFO, "Setup the config.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void restoreLevels()
|
||||
{
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
@@ -258,14 +259,14 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkConfigs()
|
||||
{
|
||||
save(getResource("config.yml"), new File(getDataFolder() + "/config.yml"));
|
||||
save(getResource("lang.yml"), new File(getDataFolder() + "/lang.yml"));
|
||||
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
||||
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin()
|
||||
@@ -287,7 +288,7 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
|
||||
private void cleanup()
|
||||
{
|
||||
eventList = null;
|
||||
|
||||
@@ -45,7 +45,6 @@ public class CommandHandler implements CommandExecutor
|
||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||
private static final String SPY_METADATA = "ac-spydata";
|
||||
private List<String> high = new ArrayList<String>();
|
||||
private List<String> med = new ArrayList<String>();
|
||||
private List<String> low = new ArrayList<String>();
|
||||
@@ -207,10 +206,10 @@ public class CommandHandler implements CommandExecutor
|
||||
p.hidePlayer(sender);
|
||||
}
|
||||
}
|
||||
if(!sender.hasMetadata(SPY_METADATA)) // Maintain ORIGINAL location and other data
|
||||
if(!sender.hasMetadata(Anticheat.SPY_METADATA)) // Maintain ORIGINAL location and other data
|
||||
{
|
||||
SpyState state = new SpyState(sender.getAllowFlight(), sender.isFlying(), sender.getLocation());
|
||||
sender.setMetadata(SPY_METADATA, new FixedMetadataValue(Anticheat.getPlugin(), state));
|
||||
sender.setMetadata(Anticheat.SPY_METADATA, new FixedMetadataValue(Anticheat.getPlugin(), state));
|
||||
}
|
||||
sender.setAllowFlight(true);
|
||||
sender.setFlying(true);
|
||||
@@ -229,13 +228,13 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sender.hasMetadata(SPY_METADATA))
|
||||
if (sender.hasMetadata(Anticheat.SPY_METADATA))
|
||||
{
|
||||
SpyState state = ((SpyState) sender.getMetadata(SPY_METADATA).get(0).value());
|
||||
SpyState state = ((SpyState) sender.getMetadata(Anticheat.SPY_METADATA).get(0).value());
|
||||
sender.setAllowFlight(state.getAllowFlight());
|
||||
sender.setFlying(state.getFlying());
|
||||
sender.teleport(state.getLocation());
|
||||
sender.removeMetadata(SPY_METADATA, Anticheat.getPlugin());
|
||||
sender.removeMetadata(Anticheat.SPY_METADATA, Anticheat.getPlugin());
|
||||
for (Player p : cs.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.showPlayer(sender);
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.User;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.Distance;
|
||||
import net.h31ix.anticheat.util.Permission;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -268,7 +269,7 @@ public class PlayerListener extends EventListener
|
||||
{
|
||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||
}
|
||||
backend.logJoin(event.getPlayer());
|
||||
backend.logJoin(player);
|
||||
if (getUserManager().getUser(player.getName()) == null)
|
||||
{
|
||||
getUserManager().addUser(new User(player.getName()));
|
||||
@@ -277,6 +278,16 @@ public class PlayerListener extends EventListener
|
||||
{
|
||||
getUserManager().addUserFromFile(player.getName());
|
||||
}
|
||||
if(player.hasMetadata(Anticheat.SPY_METADATA))
|
||||
{
|
||||
for(Player p : player.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (!Permission.SYSTEM_SPY.get(p))
|
||||
{
|
||||
p.hidePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
|
||||
Reference in new issue
Block a user