SHARE
TWEET

Untitled

a guest Dec 8th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package net.sf.l2j.gameserver.eola.cb.extra;
  2.  
  3. import java.io.BufferedWriter;
  4. import java.io.File;
  5. import java.io.FileWriter;
  6. import java.util.StringTokenizer;
  7.  
  8. import net.sf.l2j.gameserver.cache.HtmCache;
  9. import net.sf.l2j.gameserver.data.xml.AdminData;
  10. import net.sf.l2j.gameserver.eola.cb.BaseBBSManager;
  11. import net.sf.l2j.gameserver.model.actor.instance.Player;
  12.  
  13.  
  14. public class ReportBBSManager extends BaseBBSManager
  15. {
  16.    protected ReportBBSManager()
  17.    {
  18.    }
  19.  
  20.    @Override
  21.    public void parseCmd(String command, Player player)
  22.    {
  23.        if (command.equals("_bbsreport"))
  24.            showContent(player);
  25.        else if (command.startsWith("_bbsreport"))
  26.        {
  27.            StringTokenizer st = new StringTokenizer(command);
  28.            st.nextToken();
  29.          
  30.            String type = null;
  31.            String description = "";
  32.  
  33.            try
  34.            {
  35.                type = st.nextToken();
  36.              
  37.                while (st.hasMoreTokens())
  38.                {
  39.                    description += st.nextToken() + " ";
  40.                }
  41.                if (description.equals(""))
  42.                {
  43.                    player.sendMessage("Insert the description of your report first.");
  44.                    return;
  45.                }
  46.                else if (description.length() >= 150)
  47.                {
  48.                    player.sendMessage("The current description length is " + description.length() + ". Maximum length is 150!");
  49.                }
  50.              
  51.                String name = "data/html/CommunityBoard/report/reports" + player.getName() + ".txt";
  52.                File file = new File(name);
  53.              
  54.                final boolean exist = file.createNewFile();
  55.                if (!exist)
  56.                {
  57.                    player.sendMessage("You have already submit a report, staff member must confirm it first.");
  58.                    return;
  59.                }
  60.              
  61.                try (BufferedWriter bw = new BufferedWriter(new FileWriter(name)))
  62.                {
  63.                    bw.write("Report:");
  64.                    bw.newLine();
  65.                    bw.write("- - - - - - - - - - - - - - - - - - - -");
  66.                    bw.newLine();
  67.                    bw.write("Account Name: " + player.getAccountName());
  68.                    bw.newLine();
  69.                    bw.write("Account IP: " + player.getClient().getConnection().getInetAddress().getHostAddress());
  70.                    bw.newLine();
  71.                    bw.write("- - - - - - - - - - - - - - - - - - - -");
  72.                    bw.newLine();
  73.                    bw.write("Name: " + player.getName());
  74.                    bw.newLine();
  75.                    bw.write("Level: " + player.getLevel());
  76.                    bw.newLine();
  77.                    bw.write("Class: " + player.getTemplate().getClassName());
  78.                    bw.newLine();
  79.                    bw.write("- - - - - - - - - - - - - - - - - - - -");
  80.                    bw.newLine();
  81.                    bw.write("Type: " + type);
  82.                    bw.newLine();
  83.                    bw.write("Description: " + description);
  84.                    bw.close();
  85.                }
  86.              
  87.                    separateAndSend(HtmCache.getInstance().getHtm(CB_PATH + "report/successfully.htm", player), player);
  88.              
  89.                    for (Player gm : AdminData.getInstance().getAllGms(true))
  90.                        gm.sendMessage("ATTENTION: " + player.getName() + " just submitted a report!");
  91.            }
  92.            catch (Exception e)
  93.            {
  94.                e.printStackTrace();
  95.            }
  96.        }
  97.        else
  98.            super.parseCmd(command, player);
  99.    }
  100.  
  101.    @Override
  102.    protected String getFolder()
  103.    {
  104.        return "report/";
  105.    }  
  106.  
  107.    private static void showContent(Player player)
  108.    {
  109.        String content = HtmCache.getInstance().getHtm(CB_PATH + "report/report.htm", player);
  110.        separateAndSend(content, player);
  111.    }  
  112.  
  113.    public static ReportBBSManager getInstance()
  114.    {
  115.        return SingletonHolder.INSTANCE;
  116.    }
  117.  
  118.    private static class SingletonHolder
  119.    {
  120.        protected static final ReportBBSManager INSTANCE = new ReportBBSManager();
  121.    }
  122. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top