Skip to content

Commit

Permalink
fake_player skin_blob
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 20, 2022
1 parent 05bd616 commit c0729e4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface CustomEntityHelper {

ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack);

FakePlayer spawnFakePlayer(Location location, String name, String skin);
FakePlayer spawnFakePlayer(Location location, String name, String skin, String blob, boolean doAdd);
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ else if (!isCustom()) {
if (Settings.packetInterception()) {
String name = null;
String skin = null;
String blob = null;
for (Mechanism mechanism : new ArrayList<>(mechanisms)) {
if (mechanism.matches("name")) {
name = mechanism.getValue().asString();
Expand All @@ -110,12 +111,16 @@ else if (mechanism.matches("skin")) {
skin = mechanism.getValue().asString();
mechanisms.remove(mechanism);
}
if (name != null && skin != null) {
else if (mechanism.matches("skin_blob")) {
blob = mechanism.getValue().asString();
mechanisms.remove(mechanism);
}
if (name != null && (skin != null || blob != null)) {
break;
}
}
NetworkInterceptHelper.enable();
return customEntityHelper.spawnFakePlayer(location, name, skin);
return customEntityHelper.spawnFakePlayer(location, name, skin, blob, true);
}
break;
case ITEM_PROJECTILE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack
}

@Override
public FakePlayer spawnFakePlayer(Location location, String name, String skin) throws IllegalArgumentException {
return spawnFakePlayer(location, name, skin, true);
public FakePlayer spawnFakePlayer(Location location, String name, String skin, String blob, boolean doAdd) throws IllegalArgumentException {
return spawnFakePlayer(location, name, skin, doAdd);
}

public static FakePlayer spawnFakePlayer(Location location, String name, String skin, boolean doAdd) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack
}

@Override
public FakePlayer spawnFakePlayer(Location location, String name, String skin) throws IllegalArgumentException {
return spawnFakePlayer(location, name, skin, true);
public FakePlayer spawnFakePlayer(Location location, String name, String skin, String blob, boolean doAdd) throws IllegalArgumentException {
return spawnFakePlayer(location, name, skin, doAdd);
}

public static FakePlayer spawnFakePlayer(Location location, String name, String skin, boolean doAdd) throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ public ItemProjectile spawnItemProjectile(Location location, ItemStack itemStack
return entity.getBukkitEntity();
}

@Override
public FakePlayer spawnFakePlayer(Location location, String name, String skin) throws IllegalArgumentException {
return spawnFakePlayer(location, name, skin, true);
}

public static FakePlayer spawnFakePlayer(Location location, String name, String skin, boolean doAdd) throws IllegalArgumentException {
public FakePlayer spawnFakePlayer(Location location, String name, String skin, String blob, boolean doAdd) throws IllegalArgumentException {
String fullName = name;
String prefix = null;
String suffix = null;
Expand Down Expand Up @@ -99,7 +94,14 @@ else if (name.length() > 46) {
CraftWorld world = (CraftWorld) location.getWorld();
ServerLevel worldServer = world.getHandle();
PlayerProfile playerProfile = new PlayerProfile(name, null);
if (skin == null && !name.matches(".*[^A-Za-z0-9_].*")) {
if (blob != null) {
int sc = blob.indexOf(';');
if (sc != -1) {
playerProfile.setTexture(blob.substring(0, sc));
playerProfile.setTextureSignature(blob.substring(sc + 1));
}
}
else if (skin == null && !name.matches(".*[^A-Za-z0-9_].*")) {
playerProfile = NMSHandler.getInstance().fillPlayerProfile(playerProfile);
}
if (skin != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public FakeEntity sendEntitySpawn(List<PlayerTag> players, DenizenEntityType ent
else if (entityType.customEntityType == CustomEntityType.FAKE_PLAYER) {
String name = null;
String skin = null;
String blob = null;
for (Mechanism mechanism : new ArrayList<>(mechanisms)) {
if (mechanism.matches("name")) {
name = mechanism.getValue().asString();
Expand All @@ -133,11 +134,15 @@ else if (mechanism.matches("skin")) {
skin = mechanism.getValue().asString();
mechanisms.remove(mechanism);
}
if (name != null && skin != null) {
else if (mechanism.matches("skin_blob")) {
blob = mechanism.getValue().asString();
mechanisms.remove(mechanism);
}
if (name != null && (skin != null || blob != null)) {
break;
}
}
nmsEntity = ((CraftFakePlayerImpl) CustomEntityHelperImpl.spawnFakePlayer(location, name, skin, false)).getHandle();
nmsEntity = ((CraftFakePlayerImpl) NMSHandler.customEntityHelper.spawnFakePlayer(location, name, skin, blob, false)).getHandle();
}
else {
throw new IllegalArgumentException("entityType");
Expand Down

0 comments on commit c0729e4

Please sign in to comment.