Skip to content

Commit

Permalink
Merge pull request #61 from DevotedMC/master
Browse files Browse the repository at this point in the history
Addresses deobfuscation on login ...
  • Loading branch information
ProgrammerDan committed Apr 21, 2016
2 parents 20dfccb + 53246e4 commit 6aae2d3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 49 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.lishid</groupId>
<artifactId>orebfuscator</artifactId>
<version>4.0.4-SNAPSHOT</version>
<version>4.0.5-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Orebfuscator4</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.Packet;
import net.minecraft.server.v1_9_R1.TileEntity;
import net.minecraft.server.v1_9_R1.World;

import org.bukkit.craftbukkit.v1_9_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;

import com.lishid.orebfuscator.Orebfuscator;
import com.lishid.orebfuscator.utils.ReflectionHelper;

//Volatile

public class MinecraftInternals {
Expand All @@ -53,14 +49,4 @@ public static void notifyBlockChange(org.bukkit.World world, CraftBlock block) {

((CraftWorld) world).getHandle().notify(blockPosition, blockData, blockData, 0);
}

public static void tryDisableSpigotAntiXray(org.bukkit.World world) {
try {
World mcworld = ((CraftWorld) world).getHandle();
Object spigotWorldConfig = World.class.getField("spigotConfig").get(mcworld);
ReflectionHelper.setPrivateField(spigotWorldConfig, "antiXray", false);
} catch (Exception e) {
Orebfuscator.log(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,43 @@

package com.lishid.orebfuscator.listeners;

import com.lishid.orebfuscator.Orebfuscator;
import com.lishid.orebfuscator.OrebfuscatorConfig;
import com.lishid.orebfuscator.hithack.BlockHitManager;
import com.lishid.orebfuscator.obfuscation.BlockUpdate;
import com.lishid.orebfuscator.obfuscation.ProximityHider;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;

import com.lishid.orebfuscator.Orebfuscator;
import com.lishid.orebfuscator.OrebfuscatorConfig;
import com.lishid.orebfuscator.hithack.BlockHitManager;
import com.lishid.orebfuscator.obfuscation.BlockUpdate;
import com.lishid.orebfuscator.obfuscation.ProximityHider;

public class OrebfuscatorPlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();

if (OrebfuscatorConfig.LoginNotification) {
if (OrebfuscatorConfig.playerBypassOp(player)) {
Orebfuscator.message(player, "Orebfuscator bypassed because you are OP.");
} else if (OrebfuscatorConfig.playerBypassPerms(player)) {
Orebfuscator.message(player, "Orebfuscator bypassed because you have permission.");
}
}

if (OrebfuscatorConfig.UseProximityHider) {
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
}
}

@EventHandler(priority = EventPriority.NORMAL)
Expand All @@ -63,7 +75,8 @@ public void onPlayerInteract(PlayerInteractEvent event) {
((event.getItem().getType() == Material.WOOD_HOE) ||
(event.getItem().getType() == Material.IRON_HOE) ||
(event.getItem().getType() == Material.GOLD_HOE) ||
(event.getItem().getType() == Material.DIAMOND_HOE))) {
(event.getItem().getType() == Material.DIAMOND_HOE)))
{
BlockUpdate.Update(event.getClickedBlock());
}
}
Expand All @@ -74,17 +87,26 @@ public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {

if (OrebfuscatorConfig.UseProximityHider) {
ProximityHider.clearBlocksForOldWorld(event.getPlayer());
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
}
}

@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (OrebfuscatorConfig.UseProximityHider) {
if(event.getCause() != TeleportCause.END_PORTAL
&& event.getCause() != TeleportCause.NETHER_PORTAL
)
{
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
}
}
}

@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled()) {
return;
}

if (OrebfuscatorConfig.UseProximityHider) {
ProximityHider.playerMoved(event.getPlayer(), event.getFrom());
ProximityHider.addPlayerToCheck(event.getPlayer(), event.getFrom());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private static byte[] Obfuscate(ChunkData chunkData, Player player, ArrayList<Bl
byte[] output = manager.createOutput();

putSignsList(player, chunkData.chunkX, chunkData.chunkZ, proximityBlocks);
ProximityHider.AddProximityBlocks(player, proximityBlocks);
ProximityHider.addProximityBlocks(player, proximityBlocks);

return output;
}
Expand Down Expand Up @@ -321,7 +321,7 @@ private static ObfuscatedCachedChunk tryUseCache(ChunkData chunkData, Player pla

// ProximityHider add blocks
putSignsList(player, chunkData.chunkX, chunkData.chunkZ, proximityBlocks);
ProximityHider.AddProximityBlocks(player, proximityBlocks);
ProximityHider.addProximityBlocks(player, proximityBlocks);

// Hash match, use the cached data instead and skip calculations
return cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void run() {
checkPlayers.putAll(playersToCheck);
playersToCheck.clear();
}

int distance = OrebfuscatorConfig.ProximityHiderDistance;
int distanceSquared = distance * distance;

Expand All @@ -97,21 +97,15 @@ public void run() {
}
}

Location loc1 = p.getLocation();
Location loc2 = checkPlayers.get(p);

// If player changed world
if (!loc1.getWorld().equals(loc2.getWorld())) {
synchronized (proximityHiderTracker) {
proximityHiderTracker.remove(p);
proximityHiderTrackerLocal.remove(p);
}
continue;
}

// Player didn't actually move
if (loc1.getBlockX() == loc2.getBlockX() && loc1.getBlockY() == loc2.getBlockY() && loc1.getBlockZ() == loc2.getBlockZ()) {
continue;
Location oldLocation = checkPlayers.get(p);

if(oldLocation != null) {
Location curLocation = p.getLocation();

// Player didn't actually move
if (curLocation.getBlockX() == oldLocation.getBlockX() && curLocation.getBlockY() == oldLocation.getBlockY() && curLocation.getBlockZ() == oldLocation.getBlockZ()) {
continue;
}
}

Set<Block> blocks = proximityHiderTrackerLocal.get(p);
Expand All @@ -127,6 +121,7 @@ public void run() {

synchronized (proximityHiderTracker) {
Set<Block> synchronizedBlocks = proximityHiderTracker.get(p).blocks;

if (synchronizedBlocks != null) {
blocks.addAll(synchronizedBlocks);
synchronizedBlocks.clear();
Expand Down Expand Up @@ -187,7 +182,7 @@ public static void restart() {
}
}

public static void AddProximityBlocks(Player player, ArrayList<Block> blocks) {
public static void addProximityBlocks(Player player, ArrayList<Block> blocks) {
if (!OrebfuscatorConfig.UseProximityHider) return;

restart();
Expand Down Expand Up @@ -233,7 +228,7 @@ public static void clearBlocksForOldWorld(Player player) {
}
}

public static void playerMoved(Player player, Location location) {
public static void addPlayerToCheck(Player player, Location location) {
synchronized (ProximityHider.playersToCheck) {
if (!ProximityHider.playersToCheck.containsKey(player)) {
ProximityHider.playersToCheck.put(player, location);
Expand Down

0 comments on commit 6aae2d3

Please sign in to comment.