本文整理匯總了Java中net.minecraftforge.event.ServerChatEvent類的典型用法代碼示例。如果您正苦於以下問題:Java ServerChatEvent類的具體用法?Java ServerChatEvent怎麽用?Java ServerChatEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServerChatEvent類屬於net.minecraftforge.event包,在下文中一共展示了ServerChatEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test_player_can_post_several_chat_messages
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@Test
public void test_player_can_post_several_chat_messages() {
// Given:
String message1 = "hello";
String message2 = "dude";
// When:
mc().player().chat(message1);
mc().player().chat(message2);
// Then:
ServerChatEvent act1 = mc().waitFor(ServerChatEvent.class);
assertThat(act1.getMessage()).isEqualTo(message1);
ServerChatEvent act2 = mc().waitFor(ServerChatEvent.class);
assertThat(act2.getMessage()).isEqualTo(message2);
}
示例2: 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);
}
示例3: 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);
}
}
示例4: onEvent
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@Override
public void onEvent(ServerChatEvent event) {
TextComponentTranslation component = (TextComponentTranslation) event.getComponent();
if (!component.getKey().equals("chat.type.text") || component.getFormatArgs().length != 2 ||
!(component.getFormatArgs()[0] instanceof ITextComponent) ||
!(component.getFormatArgs()[1] instanceof ITextComponent)) return;
ServerPlayerSettings settings = getPlayerSettings(event.getPlayer());
if (settings.nameStyle != null)
((ITextComponent) component.getFormatArgs()[0]).getStyle().setParentStyle(settings.nameStyle);
if (settings.textStyle != null)
((ITextComponent) component.getFormatArgs()[1]).getStyle().setParentStyle(settings.textStyle);
}
示例5: magicWords
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void magicWords(ServerChatEvent event) {
int x = (int) Math.floor(event.player.posX);
int y = (int) Math.floor(event.player.posY);
int z = (int) Math.floor(event.player.posZ);
if (event.player.getCurrentEquippedItem() != null) {
if (event.player.getCurrentEquippedItem().getItem() instanceof ItemModularWand) {
if (Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getCastSpell()) {
if (event.message.startsWith(Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getMagicWords())) {
Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).beginSpell(event.player.worldObj,x,y,z,event.player,event.message.substring(Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getMagicWords().length() + 1));
}
}
}
}
}
示例6: magicWords
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void magicWords(ServerChatEvent event) {
int x = (int) Math.floor(event.player.posX);
int y = (int) Math.floor(event.player.posY);
int z = (int) Math.floor(event.player.posZ);
if (event.player.getCurrentEquippedItem() != null) {
if (event.player.getCurrentEquippedItem().getItem() instanceof ItemWand) {
if (Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getCastSpell()) {
if (event.message.startsWith(Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getMagicWords())) {
Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).beginSpell(event.player.worldObj,x,y,z,event.player,event.message.substring(Spells.spells.get(event.player.getCurrentEquippedItem().stackTagCompound.getInteger("currentSpell")).getMagicWords().length() + 1));
}
}
}
}
}
示例7: OnChat
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void OnChat(ServerChatEvent e) {
if(!e.player.worldObj.isRemote) {
if(ConfigurationHandler.enableOzTransport) {
if(e.player.inventory.armorItemInSlot(0) != null && e.player.inventory.armorItemInSlot(0).getItem() != null && e.player.inventory.armorItemInSlot(0).getItem() == ModArmour.bootsRuby) {
if(e.message.toLowerCase().contains("no place like home") && !e.player.isPlayerSleeping()) {
if(e.player.getBedLocation(e.player.dimension) != null) {
e.player.setPositionAndUpdate(e.player.getBedLocation(e.player.dimension).posX, e.player.getBedLocation(e.player.dimension).posY+1, e.player.getBedLocation(e.player.dimension).posZ);
e.player.worldObj.playSoundAtEntity(e.player, "minecraft:portal.travel", 1.0F, 1.0F);
e.player.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 120, 2, true));
} else {
e.player.setPositionAndUpdate(e.player.worldObj.getSpawnPoint().posX, e.player.worldObj.getHeightValue(e.player.worldObj.getSpawnPoint().posX, e.player.worldObj.getSpawnPoint().posZ), e.player.worldObj.getSpawnPoint().posZ);
e.player.worldObj.playSoundAtEntity(e.player, "minecraft:portal.travel", 1.0F, 1.0F);
e.player.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 120, 2, true));
}
}
}
}
}
}
示例8: onSM
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void onSM(ServerChatEvent message) {
if (message.isCanceled()) {return;}
String sPrefix = Config.pIRCMSG.replaceAll("%n",dePing(IRCBot.colorNick(message.username)))+ " ";
TkIrc.toIrc.sendMessage(Config.cName, sPrefix + message.message);
String[] aMessage = message.message.split(" ", 2);
if (aMessage[0].matches("^<" + message.username + ">$")) {
TkIrc.toIrc.sendMessage(Config.cName, aMessage[1]);
} else if ((aMessage[0].matches("^\\*$")) && (aMessage[1].split(" ", 2)[0].matches(message.username))) {
TkIrc.toIrc.sendAction(Config.cName, aMessage[1].split(" ", 2)[1]);
}
return;
}
示例9: 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));
}
}
示例10: quetziMoo
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void quetziMoo(ServerChatEvent event) {
if (event.getUsername().equals("Quetzz") && event.getMessage().equals("m00")) {
for (int i = 0; i < 4; i++)
NetworkHandler.sendTo(new PacketPlaySound(SoundEvents.ENTITY_COW_AMBIENT, SoundCategory.NEUTRAL, event.getPlayer().posX, event.getPlayer().posY, event.getPlayer().posZ, 1, 1, true), event.getPlayer());
}
}
示例11: onServerChatEvent
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void onServerChatEvent(ServerChatEvent event) {
Matcher m = ModConfig.REGEX_PATTERN.matcher(event.getMessage().toLowerCase());
if (m.find()) {
String triggerWord;
if (m.group(1) != null)
triggerWord = m.group(1);
else
triggerWord = m.group(0);
LogUtility.info("Triggered! %s", triggerWord);
explodeInRadius(event, new BlockPos(event.getPlayer().getPosition()), 8, 4, triggerWord);
}
}
示例12: explodeInRadius
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
private static void explodeInRadius(ServerChatEvent event, BlockPos pos, int radius, int height, String triggerWord) {
for (BlockPos tempPos : BlockPos.getAllInBox(pos.add(-radius, -height / 2, -radius), pos.add(radius, height / 2, radius))) {
IBlockState state = event.getPlayer().getEntityWorld().getBlockState(tempPos);
if (state.getBlock() instanceof BlockChatBomb) {
((BlockChatBomb) state.getBlock()).trigger(event.getPlayer().getEntityWorld(), tempPos, event.getPlayer(), triggerWord);
}
}
}
示例13: 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")));
}
}
}
示例14: onServerChatEvent
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
{
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
if (MinecraftForge.EVENT_BUS.post(event))
{
return null;
}
return event.getComponent();
}
示例15: onChat
import net.minecraftforge.event.ServerChatEvent; //導入依賴的package包/類
@SubscribeEvent
public void onChat(ServerChatEvent event) {
if (event.message.isEmpty()) {
return;
}
System.out.println(event.message);
}