Did some stuff

This commit is contained in:
Norbi Peti 2016-04-11 22:55:26 +02:00
parent c54a8e2a6d
commit c6a19599e0
7 changed files with 19 additions and 2 deletions

Binary file not shown.

View file

@ -163,6 +163,16 @@ public class PlayerListener implements Listener {
}
}, 120);
}
else if(!mp.FlairState.equals(FlairStates.Accepted) && !mp.FlairState
.equals(FlairStates.Commented))
{
String json = String
.format("[\"\",{\"text\":\"Welcome! You appear to log in from a non-premium account. Please verify your /r/thebutton flair to play, \",\"color\":\"aqua\"},{\"text\":\"[here].\",\"color\":\"aqua\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Click here to go to the Reddit thread\",\"color\":\"aqua\"}]}}}]",
PluginMain.FlairThreadURL);
PluginMain.Instance.getServer().dispatchCommand(
PluginMain.Console,
"tellraw " + mp.PlayerName + " " + json);
}
}
@EventHandler

View file

@ -171,6 +171,8 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
MaybeOfflinePlayer mp = MaybeOfflinePlayer.GetFromName(ign);
if (mp == null)
continue;
if (!JoinedBefore(mp, 2015, 6, 5))
continue;
if (!mp.UserNames.contains(author))
mp.UserNames.add(author);
if (mp.FlairState.equals(FlairStates.NoComment)) {
@ -301,6 +303,11 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
public static boolean CheckForJoinDate(MaybeOfflinePlayer mp)
throws Exception {
return JoinedBefore(mp, 2015, 4, 1);
}
public static boolean JoinedBefore(MaybeOfflinePlayer mp, int year,
int month, int day) throws Exception {
URL url = new URL("https://www.reddit.com/u/" + mp.UserName);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
@ -315,8 +322,8 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
joindate = joindate.split("T")[0];
Date date = parserSDF.parse(joindate);
return date.before(new Calendar.Builder()
.setTimeZone(TimeZone.getTimeZone("UTC")).setDate(2015, 4, 1)
.build().getTime());
.setTimeZone(TimeZone.getTimeZone("UTC"))
.setDate(year, month, day).build().getTime());
}
public static void ConfirmUserMessage(MaybeOfflinePlayer mp) {