當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerChatEvent.setCanceled方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.ServerChatEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerChatEvent.setCanceled方法的具體用法?Java ServerChatEvent.setCanceled怎麽用?Java ServerChatEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.ServerChatEvent的用法示例。


在下文中一共展示了ServerChatEvent.setCanceled方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onServerChat

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onServerChat(ServerChatEvent e)
{
    EntityPlayerMP sender = e.player;
    List<EntityPlayerMP> players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;


    String finalMessage = ChatFormatter.ChatParser(sender);


    for (EntityPlayerMP receiver : players)
    {receiver.addChatMessage(new ChatComponentText(finalMessage + "<" + e.username + ">: " + e.message));
    }

    BetterChat.bLog.info(sender.getDisplayName() + " said: " + e.message);
    e.setCanceled(true);
}
 
開發者ID:mads256c,項目名稱:BetterChat,代碼行數:18,代碼來源:EventHandler.java

示例2: onChatEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onChatEvent(ServerChatEvent event)
{
    if(event.getMessage().toLowerCase().toLowerCase().startsWith("!ll") || event.getMessage().toLowerCase().toLowerCase().startsWith("!limitedlives"))
    {
        NBTTagCompound tag = EntityHelper.getPlayerPersistentData(event.getPlayer(), "LimitedLivesSave");
        int deaths = tag.getInteger("deathCount");
        if(deaths >= LimitedLives.maxLives && LimitedLives.banTime > 0)
        {
            int time = (int)Math.ceil((tag.getLong("banTime") + 1000L + (LimitedLives.banTime * 1000L) - System.currentTimeMillis()) / (float)(FIVE_MINS_IN_MS / 5F));
            event.getPlayer().sendStatusMessage(new TextComponentTranslation(time == 1 ? "limitedlives.respawnTimeLeftSingle" : "limitedlives.respawnTimeLeft", time), false);
        }
        else
        {
            event.getPlayer().sendStatusMessage(new TextComponentTranslation(LimitedLives.maxLives - deaths == 1 ? "limitedlives.livesLeftSingle" : "limitedlives.livesLeft", LimitedLives.maxLives - deaths), false);
        }
        event.setCanceled(true);
    }
}
 
開發者ID:iChun,項目名稱:Limited-Lives,代碼行數:20,代碼來源:EventHandler.java

示例3: PlayerCommand

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@ForgeSubscribe
public void PlayerCommand(ServerChatEvent event)
{
	if(!event.username.equals("szszss") || !event.message.startsWith("debug"))
		return;
	event.setCanceled(true);
	if(event.message.indexOf("pitch") != -1)
	{
		event.player.addChatMessage(turnPitch(event.message));
	}
	else if(event.message.indexOf("roll") != -1)
	{
		event.player.addChatMessage(turnRoll(event.message));
	}
	
	else if(event.message.indexOf("cgs") != -1)
	{
		event.player.addChatMessage(changeGravitySource(event.message,event.player));
	}
}
 
開發者ID:szszss,項目名稱:MigoCraft,代碼行數:21,代碼來源:MigocraftDebuger.java

示例4: ChatEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void ChatEvent(ServerChatEvent evt) {
	
	if(Main.debug==1)System.out.println(evt.getPlayer().getName() + " called ChatEvent");

	
	if(evt.getPlayer() instanceof EntityPlayer && !Main.logged.contains(evt.getPlayer().getName()) && Integer.parseInt((String) Main.config.get("nochat")) == 1){
		evt.setCanceled(true);
		if(Main.passwords.containsKey(evt.getPlayer().getName())){
		evt.getPlayer().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
	} else {
	evt.getPlayer().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
	}
	}
}
 
開發者ID:Fungie2134,項目名稱:AuthMod,代碼行數:16,代碼來源:ChatEvent.java

示例5: serverRecievedChat

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void serverRecievedChat(ServerChatEvent e) {
    e.setCanceled(true);
    EntityPlayer player = e.player;
    for(Object obj : MinecraftServer.getServer().getEntityWorld().playerEntities) {
        if(((EntityPlayer) obj).getDistanceToEntity(player) <= Util.CHAT_MIN_RANGE && !e.message.contains("achievement")) {
            AgeOfKingdom.channel.sendTo(new GuiChatMessage(e.message, player.getDisplayName(), GuiChatMessage.Type.TO_CLIENT), (EntityPlayerMP) obj);
        }
    }
}
 
開發者ID:jackey8616,項目名稱:Age-of-Kingdom,代碼行數:11,代碼來源:EventManager.java

示例6: onEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
public void onEvent(ServerChatEvent event) {
	ServerPlayerSettings settings = getPlayerSettings(event.getPlayer());
	
	for (ChatChannel channel : settings.chatChannels) 
		channel.sendChatMessage(event.getComponent(), ChatType.CHAT);
	
	event.setCanceled(true);
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:9,代碼來源:CommandChatchannel.java

示例7: serverChatEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void serverChatEvent(ServerChatEvent e){
    ChatEvent event = new ChatEvent(e);

    eventManager.fireEvent(event);

    e.setCanceled(true);

    if(!event.getCancelled()){
        for (Player player : ServerForge.instance.getOnlinePlayers()){
            player.sendMessage(event.getChatFormat());
        }
    }
}
 
開發者ID:john01dav,項目名稱:ServerForge,代碼行數:15,代碼來源:DefaultEventListener.java

示例8: onServerChat

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onServerChat(final ServerChatEvent event) {
    if (silencedUsers.contains(event.player.getPersistentID())) {
        ChatComponentText text = new ChatComponentText("You are silenced from chat");
        text.getChatStyle().setColor(EnumChatFormatting.RED);
        event.player.addChatMessage(text);
        event.setCanceled(true);
    }
}
 
開發者ID:MCServerTools,項目名稱:ServerTools-CORE,代碼行數:10,代碼來源:SilenceHandler.java

示例9: onServerChat

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onServerChat(ServerChatEvent event){
	long curTime = MinecraftServer.getCurrentTimeMillis();
	if (chatSpamCooldown.containsKey(event.player.getCommandSenderEntity())){
		if (curTime - chatSpamCooldown.get(event.player.getCommandSenderEntity()) < GriefGuardian.config.getInt(ConfigKeys.spamguard_time)){
			if (!GriefGuardian.config.getBoolean(ConfigKeys.spamguard_silent))
				event.player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Your message was too soon after the previous one and was not sent."));
			event.setCanceled(true);
		}			
	}
	chatSpamCooldown.put(event.player.getCommandSenderEntity().getName(), curTime);		
}
 
開發者ID:Mithion,項目名稱:GriefGuardian,代碼行數:13,代碼來源:SpamGuardEventHandler.java

示例10: onServerChatEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGH)
public void onServerChatEvent(ServerChatEvent event) {
	final EntityPlayerMP player = event.player;
	final Optional<Long> guid = TerminalIdAccess.instance.getIdFrom(player);
	if (guid.isPresent()) {
		if (event.message.startsWith("$$")) {
			sendChatEvent(EVENT_CHAT_COMMAND, player, guid.get(), event.message.substring(2).trim());
			event.setCanceled(true);
		} else if (Config.listenToAllChat) {
			sendChatEvent(EVENT_CHAT_MESSAGE, player, guid.get(), event.message);
		}

	}
}
 
開發者ID:OpenMods,項目名稱:OpenPeripheral-Addons,代碼行數:15,代碼來源:TerminalManagerServer.java

示例11: chatMessage

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void chatMessage(ServerChatEvent event){
    if (ChatBoxEventSystem.eventMessage(event.player, event.message))
        event.setCanceled(true);
}
 
開發者ID:Avaja,項目名稱:OpenTechnology,代碼行數:6,代碼來源:CommonEvents.java

示例12: ServerChat

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void ServerChat(ServerChatEvent event)
{
    if (event.getPlayer() != null)
    {
        if (this.usernamePropsRegistry.containsKey(event.getUsername()))
        {
            EntityPlayer player = event.getPlayer();
            event.setCanceled(true);
            
            String nameFormat = "\u00A7f";
            String chatFormat = "\u00A7f";
            String prefixFormat = "\u00A7f";
            String prefix = "";
            String prefixWithFormat = "";

            if (this.usernamePropsRegistry.get(event.getUsername()).containsKey("nameformat"))
                nameFormat = this.usernamePropsRegistry.get(event.getUsername()).get("nameformat");

            if (this.usernamePropsRegistry.get(event.getUsername()).containsKey("chatformat"))
                chatFormat = this.usernamePropsRegistry.get(event.getUsername()).get("chatformat");

            if (this.usernamePropsRegistry.get(event.getUsername()).containsKey("prefixformat"))
                prefixFormat = this.usernamePropsRegistry.get(event.getUsername()).get("prefixformat");

            if (this.usernamePropsRegistry.get(event.getUsername()).containsKey("prefix"))
                prefix = this.usernamePropsRegistry.get(event.getUsername()).get("prefix");
            
            if (!prefix.isEmpty()) 
            	prefixWithFormat =  "[" + prefixFormat + prefix + TextFormatting.WHITE + "] ";
            
            String nameWithFormat = TextFormatting.WHITE + "<" + nameFormat + player.getDisplayNameString() + TextFormatting.WHITE + "> ";
            	
            TextComponentTranslation message = new TextComponentTranslation(prefixWithFormat + nameWithFormat + chatFormat + event.getMessage().replaceAll("%", "%%"));
            
            
            List<EntityPlayer> players = null;

            for(WorldServer world : DimensionManager.getWorlds()){
            	for(EntityPlayer target : world.playerEntities){
                    target.sendMessage(message);
                }
            }
           LogManager.getLogger().info(message.getUnformattedText());
        }
    }
}
 
開發者ID:Wehavecookies56,項目名稱:Kingdom-Keys-Re-Coded,代碼行數:48,代碼來源:UsernameHandler.java

示例13: chatEvent

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void chatEvent(ServerChatEvent event) {
  World world = event.getPlayer().getEntityWorld();
  //for each loop hits a // oops : java.util.ConcurrentModificationException, so we need iterator
  Iterator<TileEntityPassword> iterator = TileEntityPassword.listeningBlocks.iterator();
  List<TileEntityPassword> toRemove = new ArrayList<TileEntityPassword>();
  //TileEntityPassword current;
  int wasFound = 0;
  while (iterator.hasNext()) {
    TileEntityPassword current = iterator.next();
    if (current.isInvalid() == false) {
      if (current.getMyPassword() != null && current.getMyPassword().length() > 0 && event.getMessage().equals(current.getMyPassword())) {
        boolean isAllowed;
        if (current.getUserPerm() == UsersAllowed.ALL) {//user said everyones allowed
          isAllowed = true;
        }
        else {//it has no claimed user.. OR it is claimed
          isAllowed = !current.isClaimedBySomeone() || current.isClaimedBy(event.getPlayer());//nobody || me
        }
        if (isAllowed) {
          current.onCorrectPassword(world);
          wasFound++;
        }
        //          else {
        //            UtilChat.addChatMessage(event.getPlayer(), UtilChat.lang(this.getUnlocalizedName() + ".notallowed"));
        //          }
      } //else password was wrong
    }
    else {
      toRemove.add(current);///is invalid
    }
  }
  //even with iterator we were getting ConcurrentModificationException on the iterator.next() line
  for (TileEntityPassword rm : toRemove) {
    TileEntityPassword.listeningBlocks.remove(rm);
  }
  if (wasFound > 0) {
    event.setCanceled(true);//If this event is canceled, the chat message is never distributed to all clients.
    if (wasFound == 1)
      UtilChat.addChatMessage(event.getPlayer(), UtilChat.lang(this.getUnlocalizedName() + ".triggered") + event.getMessage());
    else
      UtilChat.addChatMessage(event.getPlayer(), wasFound + " " + UtilChat.lang(this.getUnlocalizedName() + ".triggeredmany") + event.getMessage());
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:45,代碼來源:BlockPassword.java

示例14: onCommandSend

import net.minecraftforge.event.ServerChatEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onCommandSend(ServerChatEvent event) {
    if (ProgressionAPI.registry.fireTrigger((EntityPlayer) event.getPlayer().getCommandSenderEntity(), getProvider().getUnlocalisedName(), event.getMessage()) == Result.DENY) {
        event.setCanceled(true);
    }
}
 
開發者ID:joshiejack,項目名稱:Progression,代碼行數:7,代碼來源:TriggerChat.java


注:本文中的net.minecraftforge.event.ServerChatEvent.setCanceled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。