Bug Title 1.7.10
-
Bonjour j ai codé le title de la 1.8 en 1.7 quand je fait la command sa me sais sa
class de la command
http://pastebin.com/mdkSVza8
class de des packethttp://pastebin.com/L15MLV0Z
http://pastebin.com/46ynHU2Z
http://pastebin.com/ydg4pdTU
client Proxy
public void registerRender()
{
MinecraftForge.EVENT_BUS.register(new MessageOverlay());
}
class principal
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandSendMessage());
} -
Ça serai bien d’avoir l’erreur aussi, si tu as ce message rouge (An unknown ….) c’est que dans tes logs tu dois avoir un crash même si ton jeu ne s’est pas fermé
-
[14:36:07] [Server thread/ERROR]: Couldn't process command: 'title test test 5 Player33' java.lang.NullPointerException at fr.impuuu.havenrp.packets.PacketHelper.sendTo(PacketHelper.java:140) ~[PacketHelper.class:?] at fr.impuuu.havenrp.commands.CommandSendMessage.processCommand(CommandSendMessage.java:68) ~[CommandSendMessage.class:?] at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:96) [CommandHandler.class:?] at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:788) [NetHandlerPlayServer.class:?] at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:764) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:47) [C01PacketChatMessage.class:?] at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:68) [C01PacketChatMessage.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] [14:36:07] [Client thread/INFO]: [CHAT] An unknown error occurred while attempting to perform this command
-
Il semblerai que le joueur auquel tu essai d’envoyer ton packet soit null, fait voir la classe PlayerHelper et dis-nous quelle commande tu a effectué pour obtenir ce crash
-
Moi je sais pourquoieuhhh……
C’est du copié collé de mon codeuh…
Et comme ça tu ne sais pas où est l’erreur
Surtout que mon code est pas open source
Et que tu n’as pas mon autorisation
Je ne t’aiderais pas ! -
package fr.impuuu.havenrp.utils; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.ServerConfigurationManager; public class PlayerHelper { public static EntityPlayer getPlayerByName(String name) { List <entityplayer>pl = MinecraftServer.getServer().getConfigurationManager().playerEntityList; for (EntityPlayer p : pl) { if (p.getDisplayName().equalsIgnoreCase(name)) { return p; } } return null; } } ```</entityplayer>
-
C’est un peu normal : BON fait des erreurs lui aussi
-
Couldn’t process command: ‘title test test 5 Player33’
Regardes le chat, ton pseudo c’est Player481. Donc normal que Player33 est null.
Si tu avais fait un peu mieux la commande tu aura renvoyé un message “le joueur n’existe pas” si player est null.Tu pourrai aussi compléter la fonction addTabCompletionOptions et la fonction isUsernameIndex.
Et en passant, tu utilises une vieille implémentation de paquet qui est mauvaise car elle cause des fuites de mémoire.
Le tutoriel de blackout sur le forum explique comme bien faire. -
robin l eurreur ses pas le pseudo puisque je les refait la command car j avais fermé le jeu est eclipse
-
Faut trouver alors pourquoi ton joueur renvoie null.
Et bon, à l’intérieur de la classe commande base il y a une fonction pour avoir l’instance du joueur à l’aide du pseudo, je ne sais pas pourquoi tu t’embête avec une nouvelle fonction. -
tu veut dire sa
public static EntityPlayerMP getPlayer(ICommandSender p_82359_0_, String p_82359_1_)
{
EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(p_82359_0_, p_82359_1_);if (entityplayermp != null)
{
return entityplayermp;
}
else
{
entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(p_82359_1_);if (entityplayermp == null)
{
throw new PlayerNotFoundException();
}
else
{
return entityplayermp;
}
}
} -
Oui, c’est cette fonction.
-
en gros
quand je change le entityplayer par
EntityPlayerMP p = getPlayer(sender, command[0]);sa me souligne le get player
sa me mais The method getPlayer(ICommandSender, String) is undefined for the type CommandSendMessage -
Normale. La méthode getPlayer provient de la classe CommandBase et non de l’interface ICommand.
-
dans le la class icommand appart le isUsernameIndex et addTabCompletionOptions
-
@‘impuuu’:
dans le la class icommand appart le isUsernameIndex et addTabCompletionOptions
Ta commande doit être extends CommandBase
-
oui mais quand je fait la command sa fait sa alor que le pseudo est bon
sa me met cette erreur
Couldn’t process command: ‘title player player 5 Player894’
java.lang.NullPointerException
at fr.impuuu.havenrp.packets.PacketHelper.sendTo(PacketHelper.java:140) ~[PacketHelper.class:?]
at fr.impuuu.havenrp.commands.CommandSendMessage.processCommand(CommandSendMessage.java:70) ~[CommandSendMessage.class:?]
at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:96) [CommandHandler.class:?]
at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:788) [NetHandlerPlayServer.class:?]
at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:764) [NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:47) [C01PacketChatMessage.class:?]
at net.minecraft.network.play.client.C01PacketChatMessage.processPacket(C01PacketChatMessage.java:68) [C01PacketChatMessage.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
[14:28:24] [Client thread/INFO]: [CHAT] An unknown error occurred while attempting to perform this command -
Envoi la classe du PacketHelper
-
package fr.impuuu.havenrp.packets; import cpw.mods.fml.common.network.FMLEmbeddedChannel; import cpw.mods.fml.common.network.FMLOutboundHandler; import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageCodec; import io.netty.util.Attribute; import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.LinkedList; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.INetHandler; import net.minecraft.network.NetHandlerPlayServer; @ChannelHandler.Sharable public class PacketHelper extends MessageToMessageCodec <fmlproxypacket, abstractpackethelper="">{ private EnumMap <side, fmlembeddedchannel="">channels; private LinkedList<class<? extends="" abstractpackethelper="">> packets = new LinkedList(); private boolean isPostInitialised = false; public boolean registerPacket(Class clazz) { if (this.packets.size() > 256) { return false; } if (this.packets.contains(clazz)) { return false; } if (this.isPostInitialised) { return false; } this.packets.add(clazz); return true; } protected void encode(ChannelHandlerContext ctx, AbstractPacketHelper msg, List <object>out) throws Exception { ByteBuf buffer = Unpooled.buffer(); Class clazz = msg.getClass(); if (!this.packets.contains(msg.getClass())) { throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName()); } byte discriminator = (byte)this.packets.indexOf(clazz); buffer.writeByte(discriminator); msg.encodeInto(ctx, buffer); FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), (String)ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get()); out.add(proxyPacket); } protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List <object>out) throws Exception { ByteBuf payload = msg.payload(); byte discriminator = payload.readByte(); Class clazz = (Class)this.packets.get(discriminator); if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: " + discriminator); } AbstractPacketHelper pkt = (AbstractPacketHelper)clazz.newInstance(); pkt.decodeInto(ctx, payload.slice()); switch (cpw.mods.fml.common.FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: EntityPlayer player = getClientPlayer(); pkt.handleClientSide(player); break; case SERVER: INetHandler netHandler = (INetHandler)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); EntityPlayer player1 = ((NetHandlerPlayServer)netHandler).playerEntity; pkt.handleServerSide(player1); } } public void initalise() { this.channels = NetworkRegistry.INSTANCE.newChannel("HavenRP", new ChannelHandler[] { this }); registerPackets(); } public void registerPackets() { registerPacket(PacketMessage.class); } public void postInitialise() { if (this.isPostInitialised) { return; } this.isPostInitialised = true; Collections.sort(this.packets, new Comparator() { public int compare(Class clazz1, Class clazz2) { int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName()); if (com == 0) { com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName()); } return com; } public int compare(Object o1, Object o2) { return 0; } }); } @SideOnly(Side.CLIENT) private EntityPlayer getClientPlayer() { return Minecraft.getMinecraft().thePlayer; } public void sendToAll(AbstractPacketHelper message) { ((FMLEmbeddedChannel)this.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); ((FMLEmbeddedChannel)this.channels.get(Side.SERVER)).writeAndFlush(message); } public void sendTo(AbstractPacketHelper message, EntityPlayerMP player) { ((FMLEmbeddedChannel)this.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); ((FMLEmbeddedChannel)this.channels.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); ((FMLEmbeddedChannel)this.channels.get(Side.SERVER)).writeAndFlush(message); } public void sendToServer(AbstractPacketHelper message) { ((FMLEmbeddedChannel)this.channels.get(Side.CLIENT)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); ((FMLEmbeddedChannel)this.channels.get(Side.CLIENT)).writeAndFlush(message); } } ```</object></object></class<?></side,></fmlproxypacket,>
-
J’ai déjà dit que cette façon de faire des paquets ne doit plus être utilisé …