Skip to content

Commit b38108a

Browse files
Jitse BoonstraJitse Boonstra
authored andcommitted
Fix for #147
1 parent 34e79f5 commit b38108a

File tree

8 files changed

+16
-22
lines changed

8 files changed

+16
-22
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<artifactId>npclib</artifactId>
1010
<groupId>net.jitse</groupId>
11-
<version>2.12-SNAPSHOT</version>
11+
<version>2.12.1-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>npclib-api</artifactId>

api/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public abstract class TinyProtocol {
5151

5252
// Speedup channel lookup
5353
// Made channelLookup UUID-based (JMB - 23rd Jan. 2021)
54-
private Map<UUID, Channel> channelLookup = new MapMaker().weakValues().makeMap();
54+
private Map<String, Channel> channelLookup = new MapMaker().weakValues().makeMap();
5555
private Listener listener;
5656

5757
// Channels that have already been removed
@@ -162,29 +162,23 @@ private void registerBukkitEvents() {
162162

163163
@EventHandler(priority = EventPriority.MONITOR)
164164
public final void onPlayerLogin(PlayerLoginEvent event) {
165-
if (closed)
166-
return;
165+
if (closed) return;
167166

168167
Channel channel = getChannel(event.getPlayer());
169168

170169
// Don't inject players that have been explicitly uninjected
171-
if (!uninjectedChannels.contains(channel)) {
172-
injectPlayer(event.getPlayer());
173-
}
170+
if (!uninjectedChannels.contains(channel)) injectPlayer(event.getPlayer());
174171
}
175172

176173
@EventHandler(priority = EventPriority.MONITOR)
177174
public final void onPlayerAsyncPreLogin(AsyncPlayerPreLoginEvent event) {
178-
if (!injected) {
175+
if (!injected)
179176
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "TinyProtocol not injected yet");
180-
}
181177
}
182178

183179
@EventHandler
184180
public final void onPluginDisable(PluginDisableEvent e) {
185-
if (e.getPlugin().equals(plugin)) {
186-
close();
187-
}
181+
if (e.getPlugin().equals(plugin)) close();
188182
}
189183

190184
};
@@ -273,14 +267,14 @@ private PacketInterceptor injectChannelInternal(Channel channel) {
273267
}
274268

275269
private Channel getChannel(Player player) {
276-
Channel channel = channelLookup.get(player.getUniqueId());
270+
Channel channel = channelLookup.get(player.getName());
277271

278272
// Lookup channel again
279273
if (channel == null) {
280274
Object connection = getConnection.get(getPlayerHandle.invoke(player));
281275
Object manager = getManager.get(connection);
282276

283-
channelLookup.put(player.getUniqueId(), channel = getChannel.get(manager));
277+
channelLookup.put(player.getName(), channel = getChannel.get(manager));
284278
}
285279

286280
return channel;
@@ -347,7 +341,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
347341
private void handleLoginStart(Channel channel, Object packet) {
348342
if (PACKET_LOGIN_IN_START.isInstance(packet)) {
349343
GameProfile profile = getGameProfile.get(packet);
350-
channelLookup.put(profile.getId(), channel);
344+
channelLookup.put(profile.getName(), channel);
351345
}
352346
}
353347
}

api/src/main/java/net/jitse/npclib/hologram/Hologram.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void createPackets() {
124124
// Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
125125
// Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass));
126126
// Replacement for issue #59
127-
Reflection.ConstructorInvoker entityArmorStandConstructor = null;
127+
Reflection.ConstructorInvoker entityArmorStandConstructor;
128128
try {
129129
entityArmorStandConstructor = (version.isAboveOrEqual(MinecraftVersion.V1_14_R1) ?
130130
Reflection.getConstructor(ENTITY_ARMOR_STAND_CLASS, worldClass, double.class, double.class, double.class) :
@@ -158,7 +158,7 @@ private void createPackets() {
158158

159159
if (SET_MARKER_METHOD != null) { // setMarker isn't a method in 1.8_R2, so still check if it exists in the first place.
160160
Object bukkitEntity = GET_BUKKIT_ENTITY.invoke(entityArmorStand); // if it does, grab the Bukkit Entity
161-
ArmorStand as = (ArmorStand)bukkitEntity; // reflection wasn't working here for some reason- just using a regular ArmorStand object since it's not version-dependent.
161+
ArmorStand as = (ArmorStand) bukkitEntity; // reflection wasn't working here for some reason- just using a regular ArmorStand object since it's not version-dependent.
162162
as.setMarker(true); // set the marker state
163163
}
164164

nms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>net.jitse</groupId>
1010
<artifactId>npclib</artifactId>
11-
<version>2.12-SNAPSHOT</version>
11+
<version>2.12.1-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>npclib-nms</artifactId>

nms/v1_16_R2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>net.jitse</groupId>
1010
<artifactId>npclib-nms</artifactId>
11-
<version>2.12-SNAPSHOT</version>
11+
<version>2.12.1-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>npclib-nms-v1_16_R2</artifactId>

nms/v1_16_R3/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>net.jitse</groupId>
1010
<artifactId>npclib-nms</artifactId>
11-
<version>2.12-SNAPSHOT</version>
11+
<version>2.12.1-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>npclib-nms-v1_16_R3</artifactId>

plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>net.jitse</groupId>
1010
<artifactId>npclib</artifactId>
11-
<version>2.12-SNAPSHOT</version>
11+
<version>2.12.1-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>npclib-plugin</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>net.jitse</groupId>
99
<artifactId>npclib</artifactId>
10-
<version>2.12-SNAPSHOT</version>
10+
<version>2.12.1-SNAPSHOT</version>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

0 commit comments

Comments
 (0)