fix issue with parsing player
All checks were successful
/ Auto-Build-App (push) Successful in 1m43s
All checks were successful
/ Auto-Build-App (push) Successful in 1m43s
This commit is contained in:
parent
695cf46146
commit
f13d855955
2 changed files with 7 additions and 5 deletions
|
@ -26,7 +26,8 @@ public class MessagePacketMixin {
|
||||||
public String playerUniqueId;
|
public String playerUniqueId;
|
||||||
@Shadow public String message;
|
@Shadow public String message;
|
||||||
|
|
||||||
private static Map<String, MessageInfo> ply_msgs = new HashMap<>();
|
@Unique
|
||||||
|
private static final Map<String, MessageInfo> ply_msgs = new HashMap<>();
|
||||||
|
|
||||||
@Inject(method = "handle", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "handle", at = @At("HEAD"), cancellable = true)
|
||||||
private void event_on_message(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
|
private void event_on_message(CallbackInfo ci, @Local NetworkIdentity identity, @Local ChannelHandlerContext ctx){
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.pietru.cookie_utils.utils;
|
package net.pietru.cookie_utils.utils;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import finalforeach.cosmicreach.GameSingletons;
|
||||||
import finalforeach.cosmicreach.accounts.Account;
|
import finalforeach.cosmicreach.accounts.Account;
|
||||||
import finalforeach.cosmicreach.chat.commands.Command;
|
import finalforeach.cosmicreach.chat.commands.Command;
|
||||||
import finalforeach.cosmicreach.entities.player.Player;
|
import finalforeach.cosmicreach.entities.player.Player;
|
||||||
|
@ -46,15 +47,15 @@ public class player_utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player parseAsPlayer(String arg) {
|
public static Player parseAsPlayer(String arg) {
|
||||||
Array<Player> players = InGame.getWorld().players;
|
Array<Player> players = GameSingletons.world.players;
|
||||||
Player player = (Player) ArrayUtils.find(players, (p) -> {
|
Player player = ArrayUtils.find(players, (p) -> {
|
||||||
Account account = p.getAccount();
|
Account account = p.getAccount();
|
||||||
return account != null && arg.equals(account.getUniqueId());
|
return account != null && arg.equals(account.getUniqueId());
|
||||||
});
|
});
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
return player;
|
return player;
|
||||||
} else {
|
} else {
|
||||||
player = (Player)ArrayUtils.find(players, (p) -> {
|
player = ArrayUtils.find(players, (p) -> {
|
||||||
Account account = p.getAccount();
|
Account account = p.getAccount();
|
||||||
return account != null && arg.equals(account.getUsername());
|
return account != null && arg.equals(account.getUsername());
|
||||||
});
|
});
|
||||||
|
@ -75,7 +76,7 @@ public class player_utils {
|
||||||
String combined = var10000 + ":" + arg;
|
String combined = var10000 + ":" + arg;
|
||||||
return combined.equals(account.getUsername());
|
return combined.equals(account.getUsername());
|
||||||
}, allMatches);
|
}, allMatches);
|
||||||
return allMatches.size == 1 ? (Player)allMatches.first() : null;
|
return allMatches.size == 1 ? allMatches.first() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue