Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

eMail Report

Iniciado por Swarlog, Sep 01, 2022, 12:12 AM

Tema anterior - Siguiente tema

Swarlog

### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/model/actor/instance/L2MailReportInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2MailReportInstance.java (revision 0)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2MailReportInstance.java (revision 0)
@@ -0,0 +1,138 @@
+package com.l2jserver.gameserver.model.actor.instance;
+
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.mail.Address;
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import com.l2jserver.gameserver.instancemanager.InstanceManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+import javolution.text.TextBuilder;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
+
+/**
+ * version v1.1
+ * @author  Mhoska
+ */
+
+public class L2MailReportInstance extends L2NpcInstance {
+
+ public L2MailReportInstance(int objectId, L2NpcTemplate template) {
+ super(objectId, template);
+ }
+
+ @Override
+ public void showChatWindow(L2PcInstance player , int val){
+ if (player == null)
+ return;
+
+ TextBuilder tb = new TextBuilder();
+ NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
+
+ tb.append("<html><head><title>Reporter For MxC </title></head><body>");
+ tb.append("<center>Welcome " + player.getName() + "</center><br>");
+ tb.append("<center>This is not a toy If you use this and you arent</center><br>");
+ tb.append("<center>really sure of what you re doing</center><br>");
+ tb.append("<center>you could get punished</center><br>");
+ tb.append("<center></center><br>");
+ tb.append("<center></center><br>");
+ tb.append("<center>Now Please do your report.</center><br>");
+ tb.append("Report:<edit var=\"mes\" width=150 height=45><br><br>");
+ tb.append("<button value=\"Send Report\" action=\"bypass -h MailReport $mes\" width=204 height=20>");
+ tb.append("</body></html>");
+
+ html.setHtml(tb.toString());
+ player.sendPacket(html);
+ }
+
+ @Override
+ @SuppressWarnings("null")
+ public void onBypassFeedback(L2PcInstance player, String command)
+ {
+ if (!canInteract(player))
+ return;
+ if (command.startsWith("MailReport")) {
+ Long resendtime = InstanceManager.getInstance().getInstanceTime(player.getObjectId(), 99999);
+    if (System.currentTimeMillis() < resendtime)
+    {
+    player.sendMessage("You did a report not too long ago, you gotta wait 24 hours");
+    }
+ else{
+ String value = command.substring(6);
+ StringTokenizer s = new StringTokenizer(value, " ");
+ String message = "";
+
+ try {
+ while (s.hasMoreTokens())
+ message = message + s.nextToken() + " ";
+
+ if (message == "" || message == null) {
+ player.sendMessage("Dont try to send a blank message.");
+ return;
+ }
+ if (message.length() < 30) {
+ player.sendMessage("You Must write at leas 30 characters.");
+ return;
+ }
+ if (message.length() > 1000) {
+ player.sendMessage("Maximun 1000 Characters, if you report isn't completed.");
+ player.sendMessage("please send us a new one.");
+ return;
+ }
+
+ try {
+ //Please use a Gmail email because this smtp is coded based on Gmail
+ //just add your real email data or this isn't going to work.
+ //you can set the string to. to any email adress you want to receive the reports.
+ String MyEmail = "trololo@gmail.com";
+ String MyPw = "trololo";
+ String to = "dum-beep-email@gmail.com";
+
+ Properties props = new Properties();
+ props.put("mail.smtps.host", "smtp.gmail.com");
+ props.put("mail.smtps.auth", "true");
+ props.put("mail.transport.protocol", "smtp");
+ props.put("mail.debug", "false");
+
+ Session mailSession = Session.getDefaultInstance(props);
+ Transport transport = mailSession.getTransport("smtps");
+
+ InternetAddress fromAddress = new InternetAddress(MyEmail);
+ InternetAddress toAddress = new InternetAddress(to);
+
+ Message simpleMessage = new MimeMessage(mailSession);
+
+ simpleMessage.setFrom(fromAddress);
+ simpleMessage.setRecipient(Message.RecipientType.TO,
+ toAddress);
+ simpleMessage.setSubject("Ingame Report from:"
+ + player.getName());
+ simpleMessage.setText("The player Report is:" + message);
+
+ transport.connect("smtp.gmail.com", MyEmail, MyPw);
+ transport.sendMessage(simpleMessage,
+ new Address[] { toAddress });
+ transport.close();
+
+ InstanceManager.getInstance().setInstanceTime(player.getObjectId(), 99999, ((System.currentTimeMillis() + 86400000)));
+
+ } catch (Exception e) {
+ System.exit(1);
+ }
+
+ } catch (Exception e) {
+ player.sendMessage("Something gone wrong you gotta do your report again");
+ e.printStackTrace();
+ }
+ }
+ super.onBypassFeedback(player, command);
+ }
+  }
+}
\ No newline at end of file