Jump to content

[Share] Ingame MailReporter.


Mhoska

Recommended Posts

So I was bored and I decide to do something to share it.

 

I'll explain a little:

 

So Basically the player talks to a NPC and he writes a msg with whatever he/she wants to report and this its gonna be sended to the administrator mail, so you can see whatever the report on your smartphone or on your pc or w/e.

 

also you need to put a valid gmail account in order to make this work, it doesnt work with yahoo or any of those, just with gmail you can read that in the code, so read it carefuly while you adding it.

 

You can extend it,its the very basic idea.

 

Created: Today.

Credits: Me

 

Thanks to vampir who help me to test the code.

 

### 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

 

v1.1 update

 

I added a delay on the use of the report, 24 hours.

Link to comment
Share on other sites

[Hidden post: You need 2 karma to see it. You currently have 0.]

It will be very good if make only with topic...

Sorry for spam, but i think its very usefull code.

u have got 1 karma so u cant see it, dont spam the topic.

Link to comment
Share on other sites

Nice spam! :)

I don't think that it is spam by the time he can normally see the post.

 

Anyway, your share is simple but really usefull. Great.

Link to comment
Share on other sites

wut? I just encourage you to keep sharing things with us here in mxc. Is that so bad?

 

2 words :( i hate 2 words post, but np i got the point of your post. and thank you :)

 

Amazing good idea ,some ppl working and they cant stay always in pc to see all the message from players. Good Dude .

 

tyvm :)

I don't think that it is spam by the time he can normally see the post.

 

Anyway, your share is simple but really usefull. Great.

 

thanks for your kind words sir :)

Link to comment
Share on other sites

Guest Elfocrash

Mhoska also mention that this will cuz terrible lag for the server if people do not rework the code working on a separate mailserver

Link to comment
Share on other sites

Mhoska also mention that this will cuz terrible lag for the server if people do not rework the code working on a separate mailserver

 

oh yeah, it may cause lag.

 

but as i say its a pretty basic idea pussaaaay! haha

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • I can use this folder system for High Five offline server?   The folder does not have a l2.exe file.   Thank you very much if anyone can help me.   https://drive.google.com/file/d/13kU-g_4JJ-sP-kg2F7pqkUOVKmQdubFm/view
    • I know, but...every time I have problem with IP address setup 😞
    • ENGLISH As you know, we have always profiled in the development of Java emulators, we continue to do our favorite thing, and now we have the opportunity to provide you with services in the field of private development of L2 assemblies Essence, Classic and High Five, which we have been doing in recent years, we have not been working on basic builds for a long time and work only on contracts for the world's best projects. These are the best builds we can offer, we have test servers and we can show them to you on the test, and if you are very good at gameplay, you will see a big difference in the quality and detail of the official content compared to the basic builds. These are the best top solutions in the world, which are currently used to implement the largest projects in the world. We guarantee 100% implementation of all official content. If you have any questions about testing, discussions, etc., please contact our studio and we will discuss everything. At the moment, you can get acquainted with the preliminary information and prices for Private L2 contracts here: Private Server packs L2 Essence 464, 447, 388, 362, 286 protocols Private server packs L2Classic Private server pack High Five РУССКИЙ --------------------------------------------- Как вы знаете мы всегда профилировались на разработке в сфере Java эмуляторов, мы продолжаем заниматься своим любимым делом, и сейчас у нас появилась возможность предоставлять вам услуги в сфере приватных разработок L2 сборок Essence, Classic и High Five, которыми мы занимаемся последние годы, мы уже давно не работаем над базовыми сборками и работаем только на контрактах для лучших мировых проектов. Это лучшие сборки, которые мы можем предложить, у нас есть тестовые сервера, и мы можем показать их вам на тесте, и если вы очень хорошо разбираетесь в игровом процессе, вы увидите большую разницу в качестве и детализации официального контента по сравнению с базовыми сборками. Это лучшие топовые решения в мире, которые на данный момент используются для реализации крупнейших проектов в мире. Мы даем гарантии - 100% реализации всего официального контента. По вопросам тестирования, обсуждений и тд - пишите по контактам нашей студии и мы все обсудим. На данный момент вы можете ознакомиться с предварительной информацией и ценами на Приватные контракты L2 тут: Приватные Сборки L2 Essence 464, 447, 388, 362, 286 protocols Приватные Сборки L2Classic Приватная Сборка High Five -------------------------------------------------------------- Contacts: Telegram: https://t.me/L2scripts Whatsapp, Viber: +1 (916) 226 1910 С уважением, Администрация !
    • I can sell it. If you are interested just pm.
  • Topics

×
×
  • Create New...