当前位置: 首页>>代码示例>>Java>>正文


Java S02PacketChat类代码示例

本文整理汇总了Java中net.minecraft.network.play.server.S02PacketChat的典型用法代码示例。如果您正苦于以下问题:Java S02PacketChat类的具体用法?Java S02PacketChat怎么用?Java S02PacketChat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


S02PacketChat类属于net.minecraft.network.play.server包,在下文中一共展示了S02PacketChat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AutoAccept

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
public AutoAccept() {
    super("Auto Accept", 0xB3FFAC, ModuleCategory.MISCELLANEOUS);

    listeners.add(new Listener<ReceivePacket>() {
        @Override
        public void call(ReceivePacket event) {
            if (event.getPacket() instanceof S02PacketChat) {
                S02PacketChat packet = (S02PacketChat) event.getPacket();

                Serenity.getInstance().getFriendManager().getFriends().keySet().stream()
                        .filter(friend -> StringUtils.stripControlCodes(packet.getChatComponent().getUnformattedText()).contains(friend + " has requested to teleport to you.") || StringUtils.stripControlCodes(packet.getChatComponent().getUnformattedText()).equalsIgnoreCase(friend + " has requested that you teleport to them."))
                        .filter(friend -> isValidTeleportMessage(StringUtils.stripControlCodes(packet.getChatComponent().getFormattedText()), false))
                        .forEach(friend -> {
                            if (!EventManager.post(new TeleportAcceptEvent(friend).isCancelled()))
                                mc.thePlayer.sendChatMessage(command.getValue().replace("$name", friend));
                        });
            }
        }
    });
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:21,代码来源:AutoAccept.java

示例2: onPacketReceive

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public void onPacketReceive(EventPacketReceive event){
	if(event.getPacket() instanceof S02PacketChat){
		S02PacketChat p = (S02PacketChat) event.getPacket();
		
		try{
			String line = p.func_148915_c().getUnformattedText();
			String[] spaceArray = line.split(" ");
			for(Friend friend : Friend.friendList){
				if(spaceArray[0].toLowerCase().contains(friend.getName().toLowerCase())){
					String lineAfterSpace = line.replace(spaceArray[0], "");
					if(lineAfterSpace.trim().equals("has requested to teleport to you.")){
						invoker.sendChatMessage("/tpaccept");
					}
				}
			}
			if(FriendManager.isFriend(spaceArray[0])){
				
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:25,代码来源:ModuleAutoTPAccept.java

示例3: openContainer

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
* Opens a mod added container.
* 
* @param player      The player to open the container for
* @param inventory	  The tile entity providing the inventory
*/
  public static void openContainer(EntityPlayerMP player, IModInventory inventory) {
      if (player.openContainer != player.inventoryContainer) player.closeScreen();

      if (inventory instanceof IModLockableInventory) {
          IModLockableInventory lockable = (IModLockableInventory)inventory;
          if (lockable.isLocked() && !player.canOpen(lockable.getLockCode()) && !player.isSpectator()) {
              player.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation(lockable.getLockMessageString(), inventory.getDisplayName()), (byte) 2));
              player.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(lockable.getLockSoundString(), player.posX, player.posY, player.posZ, 1.0F, 1.0F));
              return;
          }
      }
      
      player.getNextWindowId();
      Container container = inventory.createContainer(player.inventory, player);
      player.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(player.currentWindowId, inventory.getGuiID(), inventory.getDisplayName(), inventory.getSizeInventory()));
      player.openContainer = container;
      player.openContainer.windowId = player.currentWindowId;
      player.openContainer.onCraftGuiOpened(player);
  }
 
开发者ID:warriordog,项目名称:BlazeLoader,代码行数:26,代码来源:ApiGui.java

示例4: displayGUIChest

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
 * Displays the GUI for interacting with a chest inventory. Args: chestInventory
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (this.openContainer != this.inventoryContainer)
    {
        this.closeScreen();
    }

    if (chestInventory instanceof ILockableContainer)
    {
        ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

        if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
        {
            this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
            this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
            return;
        }
    }

    this.getNextWindowId();

    if (chestInventory instanceof IInteractionObject)
    {
        this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
        this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
    }
    else
    {
        this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
        this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
    }

    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:39,代码来源:EntityPlayerMP.java

示例5: sendPacket

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
public void sendPacket(final Packet packetIn)
{
    if (packetIn instanceof S02PacketChat)
    {
        S02PacketChat s02packetchat = (S02PacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !s02packetchat.isChat())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.addCrashSectionCallable("Packet class", new Callable<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:37,代码来源:NetHandlerPlayServer.java

示例6: handleChat

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(S02PacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:NetHandlerPlayClient.java

示例7: handleChat

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(S02PacketChat packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

	if (packetIn.getType() == 2) {
		this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
	} else {
		this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:NetHandlerPlayClient.java

示例8: sendRawMessage

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public void sendRawMessage(String message) {
    if (getHandle().playerNetServerHandler == null) return;

    for (net.minecraft.util.IChatComponent component : CraftChatMessage.fromString(message)) {
        getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S02PacketChat(component));
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos,代码行数:9,代码来源:CraftPlayer.java

示例9: sendMessage

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public /* varargs */ void sendMessage(BaseComponent ... components) {
    if (CraftPlayer.this.getHandle().playerNetServerHandler == null) {
        return;
    }
    S02PacketChat packet = new S02PacketChat();
    packet.components = components;
    CraftPlayer.this.getHandle().playerNetServerHandler.sendPacket(packet);
}
 
开发者ID:CyberdyneCC,项目名称:Thermos,代码行数:10,代码来源:CraftPlayer.java

示例10: handleChat

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public void handleChat(Packet chatPacket) {
    if (!(((NeptunePacket) chatPacket).getHandle() instanceof S02PacketChat)) {
        return;
    }

    sendPacket(chatPacket);
}
 
开发者ID:NeptunePowered,项目名称:NeptuneCommon,代码行数:9,代码来源:MixinNetHandlerPlayServer.java

示例11: onPacketReceive

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public void onPacketReceive(EventPacketReceive event){
	if(event.getPacket() instanceof S02PacketChat){
		S02PacketChat p = (S02PacketChat) event.getPacket();
		
		String line = p.func_148915_c().getUnformattedText();
		if(line.toLowerCase().contains(".help") || line.toLowerCase().contains(".legit") && !line.contains(invoker.getSessionUsername())){
			Resilience.getInstance().getLogger().infoChat("\247f[\247bTIP\247f] \247c"+"Did someone just tell you to type \".help\"? Don't worry! You can type \".say .help\" and it will say it in the chat!");
		}
	}
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:12,代码来源:ModuleClientTips.java

示例12: sendPacket

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
public void sendPacket(final Packet p_147359_1_)
{
    if (p_147359_1_ instanceof S02PacketChat)
    {
        S02PacketChat var2 = (S02PacketChat)p_147359_1_;
        EntityPlayer.EnumChatVisibility var3 = this.playerEntity.func_147096_v();

        if (var3 == EntityPlayer.EnumChatVisibility.HIDDEN)
        {
            return;
        }

        if (var3 == EntityPlayer.EnumChatVisibility.SYSTEM && !var2.func_148916_d())
        {
            return;
        }
    }

    try
    {
        this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]);
    }
    catch (Throwable var5)
    {
        CrashReport var6 = CrashReport.makeCrashReport(var5, "Sending packet");
        CrashReportCategory var4 = var6.makeCategory("Packet being sent");
        var4.addCrashSectionCallable("Packet class", new Callable()
        {
            private static final String __OBFID = "CL_00001454";
            public String call()
            {
                return p_147359_1_.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(var6);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:38,代码来源:NetHandlerPlayServer.java

示例13: handleChat

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(S02PacketChat p_147251_1_)
{
	final EventPacketReceive eventPacket = new EventPacketReceive(p_147251_1_);
	
	eventPacket.onEvent();
	
	if(eventPacket.isCancelled()){ 
		eventPacket.setCancelled(false); 
		return;
	}
    this.gameController.ingameGUI.getChatGUI().func_146227_a(p_147251_1_.func_148915_c());
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:16,代码来源:NetHandlerPlayClient.java

示例14: processChatMessage

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
/**
 * @author jamierocks - 1st September 2016
 * @reason Overwrite to pass chat to Canary.
 */
@Overwrite
public void processChatMessage(C01PacketChatMessage packetIn) {
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayServer) (Object) this, this.playerEntity.getServerForPlayer());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN) {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend");
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
        this.sendPacket(new S02PacketChat(chatcomponenttranslation));
        return;
    }

    this.chatSpamThresholdCount += 20;

    final boolean op = Canary.ops().isOpped((PlayerReference) this.playerEntity);
    final boolean ignore = ((Player) this.playerEntity).canIgnoreRestrictions();
    final String spamProtectionLevel = Configuration.getServerConfig().getSpamProtectionLevel();

    if (spamProtectionLevel.equalsIgnoreCase("all") || (spamProtectionLevel.equalsIgnoreCase("default") && !(op || ignore))) {
        if (this.chatSpamThresholdCount > 200) {
            this.kickPlayerFromServer("disconnect.spam");
            return;
        }
    }
    this.playerEntity.markPlayerActive();
    ((Player) this.playerEntity).chat(packetIn.getMessage());
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:31,代码来源:MixinNetHandlerPlayServer.java

示例15: handleChat

import net.minecraft.network.play.server.S02PacketChat; //导入依赖的package包/类
@Override
public void handleChat(Packet chatPacket) {
    if (!(chatPacket instanceof S02PacketChat)) {
        return;
    }

    this.sendPacket(chatPacket);
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:9,代码来源:MixinNetHandlerPlayServer.java


注:本文中的net.minecraft.network.play.server.S02PacketChat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。