From a900dc18d42497f0fd9379d0607e6cfb7fcda7de Mon Sep 17 00:00:00 2001 From: Minenash Date: Fri, 3 Mar 2017 20:34:25 -0500 Subject: [PATCH] Added FirstSeen Module --- src/com/redstoner/misc/Main.java | 4 +- .../modules/firstseen/FirstSeen.java | 62 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/com/redstoner/modules/firstseen/FirstSeen.java diff --git a/src/com/redstoner/misc/Main.java b/src/com/redstoner/misc/Main.java index a4e067a..715a28e 100644 --- a/src/com/redstoner/misc/Main.java +++ b/src/com/redstoner/misc/Main.java @@ -17,6 +17,7 @@ import com.redstoner.modules.clear.Clear; import com.redstoner.modules.clearonjoin.ClearOnJoin; import com.redstoner.modules.cycle.Cycle; import com.redstoner.modules.damnspam.DamnSpam; +import com.redstoner.modules.firstseen.FirstSeen; import com.redstoner.modules.illumination.Illumination; import com.redstoner.modules.imout.Imout; import com.redstoner.modules.lagchunks.LagChunks; @@ -39,7 +40,7 @@ import com.redstoner.modules.webtoken.WebToken; /** Main class. Duh. * * @author Pepich */ -@Version(major = 1, minor = 4, revision = 2, compatible = -1) +@Version(major = 1, minor = 5, revision = 0, compatible = -1) public class Main extends JavaPlugin { public static JavaPlugin plugin; @@ -64,6 +65,7 @@ public class Main extends JavaPlugin ModuleLoader.addModule(Chatgroups.class); ModuleLoader.addModule(Check.class); ModuleLoader.addModule(DamnSpam.class); + ModuleLoader.addModule(FirstSeen.class); // TODO: ModuleLoader.addModule(Friends.class); ModuleLoader.addModule(Illumination.class); // TODO: ModuleLoader.addModule(Imbusy.class); diff --git a/src/com/redstoner/modules/firstseen/FirstSeen.java b/src/com/redstoner/modules/firstseen/FirstSeen.java new file mode 100644 index 0000000..81ea56a --- /dev/null +++ b/src/com/redstoner/modules/firstseen/FirstSeen.java @@ -0,0 +1,62 @@ +package com.redstoner.modules.firstseen; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.nemez.cmdmgr.Command; +import com.redstoner.annotations.Version; +import com.redstoner.misc.Utils; +import com.redstoner.modules.Module; + +@Version(major = 2, minor = 0, revision = 0, compatible = 2) +public class FirstSeen implements Module{ + + @SuppressWarnings("deprecation") + @Command(hook = "firstseenP") + public void firstseen(CommandSender sender, String person) + { + Player player = (Player) sender; + Utils.sendMessage(sender, "", "&7Please note that the data may not be fully accurate!", '&'); + OfflinePlayer oPlayer = Bukkit.getPlayer(person); + if (oPlayer == null) + oPlayer = Bukkit.getServer().getOfflinePlayer(person); + Long firstJoin = oPlayer.getFirstPlayed(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + String disDate = format.format( new Date(firstJoin) ); + if( disDate.equals("1969-12-31 19:00") ) { + Utils.sendMessage(player, null, "&3" + oPlayer.getName() + "&c has never joined.", '&'); + } + else { + Utils.sendMessage(player, null, "&3" + oPlayer.getName() + " &efirst joined&a " + disDate + "&e.", '&'); + } + } + @Command(hook = "firstseen") + public void firstseen(CommandSender sender) + { + firstseen(sender, sender.getName()); + } + + + @Override + public String getCommandString() { + return "command firstseen {\n" + + " [empty] {\n" + + " run firstseen;\n" + + " type player;\n" + + " help Gives the date and time they first joined;\n" + + " perm utils.firstseen;\n" + + " }\n" + + " [string:person] {\n" + + " run firstseenP person;\n" + + " type player;\n" + + " help Gives the date and time when a player first joined;\n" + + " perm utils.firstseen.other;\n" + + " }\n" + + "}"; + } +}