Fixed npcs can have names that exceed the maximum name length (#31)

This commit is contained in:
OmerBenGera 2021-11-12 19:33:35 +02:00
parent 0a1273f6a6
commit 5a343283a3
7 changed files with 32 additions and 11 deletions

View File

@ -91,4 +91,9 @@ public final class NPCHandler implements NPCManager {
return uuid;
}
public static String getName(String worldName) {
String name = "Loader-" + worldName;
return name.length() > 16 ? name.substring(0, 16) : name;
}
}

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_12_R1.DamageSource;
@ -32,8 +33,10 @@ import java.util.UUID;
public final class ChunkLoaderNPC_v1_12_R1 extends EntityPlayer implements ChunkLoaderNPC {
public ChunkLoaderNPC_v1_12_R1(Location location, UUID uuid){
super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()), new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
playerConnection = new DummyPlayerConnection(server, this);

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_15_R1.EntityPlayer;
@ -33,8 +34,10 @@ public final class ChunkLoaderNPC_v1_15_R1 extends EntityPlayer implements Chunk
private boolean dieCall = false;
public ChunkLoaderNPC_v1_15_R1(Location location, UUID uuid){
super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()), new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
playerConnection = new DummyPlayerConnection(server, this);

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_16_R3.Chunk;
@ -34,8 +35,10 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
private boolean dieCall = false;
public ChunkLoaderNPC_v1_16_R3(Location location, UUID uuid){
super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()), new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
playerConnection = new DummyPlayerConnection(server, this);

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.NetworkManager;
@ -30,7 +31,7 @@ public final class ChunkLoaderNPC_v1_17_R1 extends EntityPlayer implements Chunk
public ChunkLoaderNPC_v1_17_R1(MinecraftServer minecraftServer, Location location, UUID uuid){
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()));
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
this.b = new DummyPlayerConnection(minecraftServer, this);

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.EntityPlayer;
@ -31,8 +32,10 @@ import java.util.UUID;
public final class ChunkLoaderNPC_v1_7_R4 extends EntityPlayer implements ChunkLoaderNPC {
public ChunkLoaderNPC_v1_7_R4(Location location, UUID uuid){
super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()), new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
playerConnection = new DummyPlayerConnection(server, this);

View File

@ -1,6 +1,7 @@
package com.bgsoftware.wildloaders.nms;
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_8_R3.DamageSource;
@ -32,8 +33,10 @@ import java.util.UUID;
public final class ChunkLoaderNPC_v1_8_R3 extends EntityPlayer implements ChunkLoaderNPC {
public ChunkLoaderNPC_v1_8_R3(Location location, UUID uuid){
super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, "Loader-" + location.getWorld().getName()), new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
playerConnection = new DummyPlayerConnection(server, this);