Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

BlackXnt

Members
  • Joined

  • Last visited

  1. This is pretty wise, especially if you plan on your server almost never restarting. Unless you are saving this list to file, it will clear out every time you restart the server. Edit: Although if you remove a player from the list every time you find a null, it will be self-cleaning anyway, and the "new name" (when that feature comes available) will be used the next time that individual player logs in. So if all you are using this list for is notifying players of login, you will only run into issues for one specific player, during the specific session in which they changed their name. If you want a list for more sophisticated and long-term uses, then you should most definitely take larsgerrits' advice. If it were me I would start simple and work up, since it's pretty much all stilla challenge for you. I am not making this mod for the server- this is a bukkit server and I am not the owner Is it going to work if the mod isnt install on the server?
  2. I am new with Forge. I am just trying to make a simple mod for a server I am playing on. I know only basic java so I am having hard time doing it. If u know any other mod that does what I want it can really help me
  3. Thx its working now! btw I have another question: I want to make a mod for multiplayer that msg the player every time a player join or leave the server. How do I identify when a new player join or leave the server?
  4. else{ String[] stringList = msg.split(" "); for(int i = 0; i < stringList.length; i++){ finalstring += stringList[i]; finalstring += " "; finalstring += EnumChatFormatting.AQUA; } e.setCanceled(true); mc.thePlayer.addChatMessage(new ChatComponentText(finalstring)); } All the class: package com.TealNerd.SnitchCensor; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class ChatFilter { Minecraft mc = Minecraft.getMinecraft(); public String msg; public String finalstring =""; private Pattern snitch = Pattern.compile("\\[[-0-9]* [0-9]* [-0-9]*\\]"); private Pattern user = Pattern.compile("([a-zA-Z0-9_]+?) entered snitch at"); public String username; protected boolean isEnemy = false; public Matcher snitchMatcher; public Matcher usernameMatcher; private String modDir = mc.mcDataDir + "/mods/SnitchCensor/"; public File bounties = new File(modDir, "perps.txt"); private Pattern name = Pattern.compile("\\\"name\\\":\\\"([A-Za-z0-9_]+?)\\\""); boolean hasBounty = false; { } @SubscribeEvent public void onChat(ClientChatReceivedEvent e) throws IOException{ msg = e.message.getUnformattedText(); Matcher snitchMatcher = snitch.matcher(msg); Matcher usernameMatcher = user.matcher(msg); if(SnitchCensor.custom){ if(snitchMatcher.find()){ if(usernameMatcher.find()){ username = usernameMatcher.group(1); } String dir = mc.mcDataDir + "/mods/RadarBro/"; File enemies = new File(dir, "EnemyList.txt"); Scanner input = new Scanner(enemies); while(input.hasNext()){ String nextLine = input.nextLine(); if(nextLine.equals(username)){ isEnemy = true; }else{ isEnemy = false; } } input.close(); String contents; Scanner in = new Scanner(bounties); contents = readFile(bounties); Matcher nameMatcher = name.matcher(contents); while(nameMatcher.find()) { if(nameMatcher.group(1).equals(username)) { hasBounty = true; break; } else { hasBounty = false; } } in.close(); if(isEnemy){ if(SnitchCensor.isEnabled){ e.setCanceled(true); finalstring = snitchMatcher.replaceAll("[**** ** ****]"); mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + finalstring)); }else{ e.setCanceled(true); finalstring = msg; mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + finalstring)); } }else if(hasBounty){ if(SnitchCensor.isEnabled){ e.setCanceled(true); finalstring = snitchMatcher.replaceAll("[**** ** ****]"); mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + finalstring)); }else{ e.setCanceled(true); finalstring = msg; mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + finalstring)); } }else{ if(SnitchCensor.isEnabled){ String[] stringList = msg.split(" "); for(int i = 0; i < stringList.length; i++){ finalstring += stringList[i]; finalstring += " "; finalstring += EnumChatFormatting.AQUA; } e.setCanceled(true); finalstring = snitchMatcher.replaceAll("[**** ** ****]"); mc.thePlayer.addChatMessage(new ChatComponentText(finalstring)); mc.thePlayer.addChatMessage(new ChatComponentText(stringList[stringList.length-1])); }else{ String[] stringList = msg.split(" "); e.setCanceled(true); mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + finalstring)); } } } }else if(SnitchCensor.isEnabled){ e.setCanceled(true); finalstring = snitchMatcher.replaceAll("[**** ** ****]"); mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + finalstring)); }else{ e.setCanceled(true); finalstring = msg; mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + finalstring)); } } String readFile(File file) throws IOException { BufferedReader br = new BufferedReader(new FileReader(file)); try { StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } return sb.toString(); } finally { br.close(); } } }
  5. 1410831192] It doesnt work It does split the word but the color doesn't work I did this: String[] stringList = msg.split(" "); for(int i = 0; i < stringList.length; i++){ finalstring += stringList[i]; finalstring += " "; finalstring += EnumChatFormatting.AQUA.toString() + EnumChatFormatting.ITALIC.toString();
  6. Hey I am using this code: mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + finalstring)); And it paint only the first line: How do I fix this?

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.