[plugin]Chat Time Stamp

    • [plugin]Chat Time Stamp

      Hello everybody,

      I present a plugin that adds time stamp to player chat.

      .jar plugin file
      ChatTimeStamp.zip

      Screenshot

      Source code:

      Java-Quellcode: ChatTimeStamp.java

      1. /*
      2. * To change this license header, choose License Headers in Project Properties.
      3. * To change this template file, choose Tools | Templates
      4. * and open the template in the editor.
      5. */
      6. package world.yokohama.chattimestamp;
      7. /**
      8. *
      9. * @author Usiemon
      10. */
      11. import java.text.SimpleDateFormat;
      12. import java.util.Date;
      13. import net.risingworld.api.Plugin;
      14. import net.risingworld.api.events.EventMethod;
      15. import net.risingworld.api.events.Listener;
      16. import net.risingworld.api.events.player.PlayerChatEvent;
      17. import net.risingworld.api.objects.Player;
      18. public class ChatTimeStamp extends Plugin implements Listener{
      19. @Override
      20. public void onEnable(){
      21. //Register event listener
      22. registerEventListener(this);
      23. }
      24. @Override
      25. public void onDisable(){
      26. //...
      27. }
      28. @EventMethod
      29. public void onChat(PlayerChatEvent event){
      30. Player player = event.getPlayer();
      31. String message = event.getChatMessage();
      32. //cancel the event, so the chat message does not show up
      33. event.setCancelled(true);
      34. //Generate a class to store a date/time w/ formatting
      35. SimpleDateFormat ukSdf = new SimpleDateFormat("HH:mm");
      36. //Fetch the time
      37. String dateTime = ukSdf.format(new Date());
      38. //send your own custom chat message
      39. getServer().broadcastTextMessage(dateTime + " " + player.getName() + " said: [#FFFFFF]" + message);
      40. }
      41. }
      Alles anzeigen

      Edit by yahgiggle, because some users could not see the screenshot
      Rising World Server: Yokohama
      Server discord: discord.gg/BQ7J7EM

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von yahgiggle ()

    • nice, hope you get used to java and create more complex plugins in the future :)

      one small point about using the chat and intercepting player messages, in MP server owners usually use different chat colours for different player ranks (using permission files), thus a plugin that intercepts all messages and resends them altered causes those colours not to appear.
      Admin on Artisan's Realm
      Rising World Projects:
      Blueprint Texture Editor
      MailingSystem
      ServerTools
      Portals