Skip to content

Commit

Permalink
Merge pull request #10 from HarvelsX/master
Browse files Browse the repository at this point in the history
Add support 1.18.2;
  • Loading branch information
cavallium authored Apr 17, 2022
2 parents b421c08 + 94aeac3 commit 7525307
Show file tree
Hide file tree
Showing 12 changed files with 1,497 additions and 164 deletions.
1,366 changes: 1,366 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ CoordinatesObfuscator

**Hide the real coordinates to the players.**


This plugin helps the owner to make sure that players with modded clients do not take unfair advantage of vanilla players when `/gamerule reducedDebugInfo` is set to `true`.
This plugin helps the owner to make sure that players with modded clients do not take unfair advantage of vanilla
players when `/gamerule reducedDebugInfo` is set to `true`.

How it works
------------
Every time a player changes position, dies, joins a server or changes a world, the **X** and **Z** coordinates will be shifted by a random number, making useless every tool that uses absolute coordinates systems.
Every time a player changes position, dies, joins a server or changes a world, the **X** and **Z** coordinates will be
shifted by a random number, making useless every tool that uses absolute coordinates systems.
126 changes: 63 additions & 63 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.warp</groupId>
<artifactId>CoordinatesObfuscator</artifactId>
<version>1.4.3</version>
<name>CoordinatesObfuscator</name>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>16</release>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/content/groups/public/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.warp</groupId>
<artifactId>CoordinatesObfuscator</artifactId>
<version>1.4.4</version>
<name>CoordinatesObfuscator</name>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>16</release>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/content/groups/public/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
21 changes: 0 additions & 21 deletions src/fake_respawn_code.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void validate() {
if ((int) (Math.round(z / 16f) * 16) != z) {
throw new IllegalArgumentException("z is not aligned with the chunks!");
}
double reconvertedX = (double) ((int) x);
double reconvertedX = (int) x;
if (reconvertedX != x) {
throw new IllegalArgumentException("x is not safe to convert between double and int");
}
double reconvertedZ = (double) ((int) z);
double reconvertedZ = (int) z;
if (reconvertedZ != z) {
throw new IllegalArgumentException("z is not safe to convert between double and int");
}
Expand Down Expand Up @@ -151,10 +151,7 @@ public boolean equals(final Object o) {
if (Double.compare(this.getX(), other.getX()) != 0) {
return false;
}
if (Double.compare(this.getZ(), other.getZ()) != 0) {
return false;
}
return true;
return Double.compare(this.getZ(), other.getZ()) == 0;
}

public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
package org.warp.coordinatesobfuscator;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Play;
import com.comphenix.protocol.PacketType.Play.Client;
import com.comphenix.protocol.PacketType.Play.Server;
import com.comphenix.protocol.ProtocolLib;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ConnectionSide;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.events.*;
import com.comphenix.protocol.injector.GamePhase;
import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
import com.comphenix.protocol.wrappers.nbt.NbtBase;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -30,8 +16,12 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class CoordinatesObfuscator extends JavaPlugin implements Listener {
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger;

public class CoordinatesObfuscator extends JavaPlugin implements Listener {

public static final boolean DEBUG_ENABLED = "debug".equals(System.getProperty("coordinates_obfuscator.env"));
public static final boolean DISALLOW_REMOVING_NONEXISTENT_COORDINATES = false;
Expand Down Expand Up @@ -99,7 +89,7 @@ public void onEnable() {
packets.add(PacketType.Play.Server.SET_SLOT);

packets.add(Server.TILE_ENTITY_DATA);

//todo: these packets shouldn't have position. Check if some of them must be translated
// packets.add(Server.ENTITY_DESTROY);
// packets.add(Server.ENTITY_EQUIPMENT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.warp.coordinatesobfuscator;

import org.bukkit.World;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Supplier;
import java.util.logging.Logger;
import org.bukkit.World;
import org.bukkit.entity.Player;

public class CoordsOffsetsManager {
private final Map<UUID, HashMap<UUID, CoordinateOffset>> playerCoordsPerWorld = new HashMap<>();
Expand Down Expand Up @@ -145,9 +146,6 @@ private CoordinateOffset getValueOrNull(UUID playerUUID, UUID worldUUID) {
return null;
}
CoordinateOffset offset = worldsMap.get(worldUUID);
if (offset == null) {
return null;
}
return offset;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.warp.coordinatesobfuscator;

import org.bukkit.Location;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.Location;

public class LastPlayerCoordinateManager {
Map<UUID, Location> locations = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.warp.coordinatesobfuscator;

import com.comphenix.protocol.injector.server.TemporaryPlayer;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;

import java.util.Optional;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;

public class PlayerManager {

Expand Down
Loading

0 comments on commit 7525307

Please sign in to comment.