本文整理汇总了Java中net.minecraftforge.client.event.ClientChatReceivedEvent类的典型用法代码示例。如果您正苦于以下问题:Java ClientChatReceivedEvent类的具体用法?Java ClientChatReceivedEvent怎么用?Java ClientChatReceivedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientChatReceivedEvent类属于net.minecraftforge.client.event包,在下文中一共展示了ClientChatReceivedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClientChat
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientChat(ClientChatReceivedEvent event) {
String message = ( event.getMessage().getUnformattedText() );
if (message.contains(search.get()) && !message.startsWith(MC.getSession().getUsername() )) {
String append;
switch (mode.get().toUpperCase()) {
case "REPLY":
append = "/w ";
break;
case "CHAT":
default:
append = Strings.EMPTY;
break;
}
getLocalPlayer().sendChatMessage(append + reply.get());
}
}
示例2: messageReceived
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void messageReceived(ClientChatReceivedEvent e) {
// we got a chat message, let checks whether it's from HiddenOre
String msg = e.getMessage().getUnformattedText();
Matcher matcher = hiddenOreRegex.matcher(msg);
if (matcher.matches()) {
// confirmed a HiddenOre message
String item = matcher.group(2);
// because I suck with regex
if (item.endsWith(" nearby")) {
item = item.substring(0, item.length() - " nearby".length());
}
String amount = matcher.group(1);
Biome biome = OreLogger.instance.mc.theWorld.getBiome(OreLogger.instance.mc.thePlayer.getPosition());
// send to aggregator
hoManager.logBreak(cachedBlockPos.getY(), item, amount, biome, cachedItem);
}
}
示例3: trueJoin
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
/**
* Fired when the IP message is picked up and
* {@link Server#getServer()} returns {@link Server#NONE},
* meaning a server has been joined and the server is identified.
*
* @param server The server joined.
*/
public static void trueJoin(Server server) {
if (AllChat.track) {
// Set to false to avoid comodification
AllChat.track = false;
// Cycle through each tracked event and feed it
// back to the server that was joined
for (ClientChatReceivedEvent event : AllChat.tracked)
server.onChat(event);
// Clear the tracked messages.
AllChat.tracked.clear();
}
AllRender.removeSkins();
server.onJoin();
}
示例4: onChat
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
public static void onChat(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText();
ChatTracker.checkAll(message);
ChatTrigger.checkAll(message);
if (message.matches(CoreHG.MSG_WELCOME))
StateHG.state = StateHG.WAIT;
if (message.matches(CoreHG.MSG_VULNERABLE))
StateHG.state = StateHG.PLAY;
if (message.startsWith("\00A7r\u00A7b" + Main.mc.thePlayer.getDisplayName())) {
if (Vars.getInt("hg:kills") == -1)
Vars.put("hg:kills", "" + 1);
else
Vars.put("hg:kills", "" + (Vars.getInt("hg:kills") + 1));
}
}
示例5: relatedChatEventHandler
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
public static void relatedChatEventHandler(ClientChatReceivedEvent event) {
System.out.println("Passing chat event to server location parser");
// We know that the message isn't null
String message = event.message.getUnformattedText();
/*
* Let's check if the message is a whereami response via checking if it
* starts with the correct string
*/
if (message.startsWith("You are currently on server")) {
// Debug message output used here
System.out.println("Processed user location");
// Cancel the event so the user doesn't see the response
event.setCanceled(true);
// Save the server detected
setServer(message.split(" ")[5]);
// Now, we will remove this status, because it's served the purpose
// it was meant to
ChatListener.currentStatus.remove(ChatStatus.WHEREAMI);
}
}
示例6: getUnformattedText
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
public static String getUnformattedText(ClientChatReceivedEvent event) {
String msg = "";
try {
Object component = null;
switch (Autotip.MC_VERSION) {
case V1_8:
case V1_8_8:
case V1_8_9:
component = getField(ClientChatReceivedEvent.class, "message").get(event);
break;
case V1_9:
case V1_9_4:
case V1_10:
case V1_10_2:
case V1_11:
case V1_11_2:
component = getMethod(ClientChatReceivedEvent.class, "getMessage")
.invoke(event);
break;
}
// Original method name: getUnformattedText
msg = (String) getMethod(component.getClass(), "func_150260_c").invoke(component);
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
return msg;
}
示例7: onChatReceive
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChatReceive(ClientChatReceivedEvent event) {
//IndexOutOfBoundException when it's a broadcast message.. this will fix it
String username = !event.message.getUnformattedText().isEmpty() ? event.message.getSiblings().get(0).getUnformattedText().trim() : "";
if (RewiMod.mutedPlayers.getMuted().contains(username)) {
event.setCanceled(true);
}
if(Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getCurrentServerData() != null) {
if (Minecraft.getMinecraft().getCurrentServerData().serverIP.endsWith("rewinside.tv")) {
for (String badWord : RewiMod.badWords) {
if (event.message.getUnformattedText().contains(badWord)) {
if (!username.equals(Minecraft.getMinecraft().thePlayer.getName())) {
Minecraft.getMinecraft().thePlayer.sendChatMessage("/chatreport " + username);
break;
}
}
}
if (event.message.getUnformattedText().contains(RewiMod.CHATLOG_URL)) {
try {
Desktop.getDesktop().browse(new URI("https://rewinside.tv/wpbt/IssueAdd/1/?issueType=bug"));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(RewiMod.CHATLOG_URL + event.message.getUnformattedText().split("/")[3]), null);
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
}
}
}
示例8: onEvent
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onEvent(ClientChatReceivedEvent evt) {
ITextComponent message = evt.getMessage();
String txt = message.getUnformattedText();
WolTestEnvironment.instance.getPacketDispatcher().sendToServer(
new ClientChatReceivedMessage(txt));
}
示例9: clientReceivedChat
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void clientReceivedChat(ClientChatReceivedEvent e) {
ChatComponentTranslation a = (ChatComponentTranslation)e.message;
for(String disable : Util.CHAT_DISABLE_KEYS) {
if(a.getKey().contains(disable)) {
e.setCanceled(true);
return;
}
}
}
示例10: onChatEvent
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onChatEvent(ClientChatReceivedEvent event) {
if (Config.translateChat)
if (!event.isCanceled())
try {
String message = getFallback().containsTranslateKey(event.message.getUnformattedText()) ? StatCollector.translateToFallback(event.message.getUnformattedText()) :event.message.getUnformattedText();
event.message = new ChatComponentText(translateToLocal(message, "en"));
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: clientChatReceived
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
@SubscribeEvent
public void clientChatReceived(ClientChatReceivedEvent e) {
Iterator<Blocker> blocksIterator = blocks.iterator();
while (blocksIterator.hasNext()) {
Blocker block = blocksIterator.next();
if (!block.accept(e.getMessage()))
e.setCanceled(true);
if (block.isDone())
blocksIterator.remove();
}
}
示例12: checkSplit
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
public static void checkSplit(ClientChatReceivedEvent event) {
if (Main.secondChat.shouldSplit(event)
&& !Server.getServer().equals(Server.CTF)
&& !Server.getServer().equals(Server.HS)) {
Main.secondChat.printChatMessage(event.message);
event.setCanceled(true);
}
}
示例13: addLinks
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
/**
* Re-adds link click events to any links in chat. Links
* must start with <code>http://</code> to be added properly.
* @param event The event to add links to.
*/
public static void addLinks(ClientChatReceivedEvent event) {
if (!event.message.getUnformattedText().matches(".*" + RE_URL + ".*")) return;
Matcher urlMatcher = URL_PATTERN.matcher(event.message.getUnformattedText());
while (urlMatcher.find()) {
event.message.getChatStyle().setChatClickEvent(
new ClickEvent(ClickEvent.Action.OPEN_URL, urlMatcher.group()));
}
}
示例14: onChat
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
public static void onChat(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText();
handleAll(event);
if (event.isCanceled()) return;
switch (MessageType.getType(message)) {
case ALERT: filterAlerts(event);
case STATS: filterAlerts(event); event.setCanceled(ConfigCTFChat.chatHistory);
case NONE:
// The chat section has a number of lines depending on the state.
// If we have more than that number, remove the first.
if (chatBlock.size() == StateCTF.getState().chatLines()) {
chatBlock.remove(0);
}
// Does our new chat equal the old?
if (!oldChat.equals(chatBlock)) {
// Does it contain our message?
if (!oldChat.contains(message)) {
// It's a new message!
handleMessages(event);
oldChat.add(message);
} else {
// Set it canceled based on config settings.
event.setCanceled(ConfigCTFChat.chatHistory);
}
}
// Index the chat message.
chatBlock.add(message);
}
}
示例15: handleMessages
import net.minecraftforge.client.event.ClientChatReceivedEvent; //导入依赖的package包/类
/**
* Handles repeated messages, e.g. players talking,
* class selected, kills, and more. Does NOT include
* stats or team info.
* @param event The chat event to handle.
*/
public static void handleMessages(ClientChatReceivedEvent event) {
String message = event.message.getUnformattedText();
ChatTracker.checkAll(message);
ChatTrigger.checkAll(message);
// TODO: Move to Var system.
if (message.matches(msgFreeDay)) {
InfoCTF.freeDay = true;
}
if (message.matches(reHeadshot)) {
StatsCTF.headshots++;
Medal.add("headshot");
}
if (Main.secondChat.shouldSplit(event)) {
Main.secondChat.printChatMessage(event.message);
event.setCanceled(true);
}
// Medic calling.
if (message.matches(reMedic)) {
if (StateCTF.getState() == StateCTF.PLAY) {
for (String string : ConfigCTFChat.medicClasses) {
if (KitCTF.getKit(Main.mc.thePlayer).toString().toLowerCase().equals(string.toLowerCase()) || InfoCTF.chosenClass.toLowerCase().equals(string.toLowerCase())) {
String formatted = event.message.getUnformattedText().replaceAll("\u00A7(.)", "\u00A7$1\u00A7l");
event.message = new ChatComponentText(formatted);
}
}
}
}
}