From 173c2c19c84cbb9b82bbf9bbb34cd248558fb3ed Mon Sep 17 00:00:00 2001 From: TheYeti Date: Fri, 3 Feb 2012 14:23:32 -0800 Subject: [PATCH] Super Secret Anniversary Easter Egg! Also, update build files for RB --- Changelog.txt | 3 +- pom.xml | 2 +- .../nossr50/commands/mc/McmmoCommand.java | 37 +++++++++++++++- src/main/java/com/gmail/nossr50/mcMMO.java | 44 ++++++++++++++++++- 4 files changed, 82 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 258a3a636..c2f8a83dd 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,7 +1,7 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code -Version 1.2.09-dev +Version 1.2.09 - Fixed issue with Repair Mastery (Issue #47) - Made Arcane Forging fully configurable (Pull Request #52) - Made Fishing configurable (Pull Request #60) @@ -19,6 +19,7 @@ Version 1.2.09-dev - Initial command alias framework added - Fixed abilities not handling Unbreaking items - Fix for treefeller glitch + - Super secret anniversary easter egg! Version 1.2.08 - Changed Bukkit events to new event system diff --git a/pom.xml b/pom.xml index 6fc8e5376..590bd0ebc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.2.09-dev + 1.2.09 mcMMO https://github.com/TheYeti/mcMMO diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java index d085aeb49..9bc4e176e 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java @@ -6,12 +6,20 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.mcMMO; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; public class McmmoCommand implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!LoadProperties.mcmmoEnable) { @@ -37,12 +45,39 @@ public class McmmoCommand implements CommandExecutor { if (LoadProperties.spoutEnabled && player instanceof SpoutPlayer) { SpoutPlayer sPlayer = (SpoutPlayer) player; if (LoadProperties.donateMessage) - sPlayer.sendNotification("[mcMMO] Donate!", "Paypal theno1yeti@gmail.com", Material.CAKE); + player.sendMessage(ChatColor.GREEN + "[mcMMO] Donate! Paypal theno1yeti@gmail.com"); } else { if (LoadProperties.donateMessage) player.sendMessage(ChatColor.GREEN + "If you like my work you can donate via Paypal: theno1yeti@gmail.com"); } + GregorianCalendar cakedayStart = new GregorianCalendar(2012, Calendar.FEBRUARY, 3); + GregorianCalendar cakedayEnd = new GregorianCalendar(2012, Calendar.FEBRUARY, 6); + GregorianCalendar day = new GregorianCalendar(); + int cakeCheck = 0; + + for (String cake : mcMMO.gotCake) + { + if (player.getName().equalsIgnoreCase(cake)) { + cakeCheck = 1; + } + } + + if (cakeCheck == 0) { + if (getDateRange(day.getTime(), cakedayStart.getTime(), cakedayEnd.getTime())) + { + player.sendMessage(ChatColor.BLUE + "Happy 1 Year Anniversary! In honor of all of"); + player.sendMessage(ChatColor.BLUE + "nossr50's work and all the devs, have some cake!"); + } + mcMMO.gotCake.add(player.getName()); + player.getInventory().addItem(new ItemStack(Material.CAKE_BLOCK, 1)); + } + return true; } + + private boolean getDateRange(Date date, Date start, Date end) + { + return !(date.before(start) || date.after(end)); + } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f96499ce5..f1f77aeb4 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -96,6 +96,8 @@ public class mcMMO extends JavaPlugin public static Database database = null; public Misc misc = new Misc(this); + public static ArrayList gotCake; + //Config file stuff LoadProperties config; //Jar stuff @@ -124,7 +126,35 @@ public class mcMMO extends JavaPlugin //Catch all for versions not matching and no specific code being needed else if(!vnum.equalsIgnoreCase(this.getDescription().getVersion())) updateFrom(-1); } - + File cakeFile = new File(getDataFolder().getAbsolutePath() + File.separator + "cake"); + + if (!cakeFile.exists()) { + try { + cakeFile.createNewFile(); + } + catch (IOException ex) { + System.out.println(ex); + } + } + + gotCake = new ArrayList(); + + try { + gotCake.clear(); + BufferedReader reader = new BufferedReader(new FileReader(getDataFolder().getAbsolutePath() + File.separator + "players")); + String line = reader.readLine(); + + while(line != null) { + gotCake.add(line); + line = reader.readLine(); + } + + reader.close(); + } + catch (Exception ex) { + System.out.println(ex); + } + mcPermissions.initialize(getServer()); this.config = new LoadProperties(this); @@ -255,6 +285,18 @@ public class mcMMO extends JavaPlugin return permissions; } public void onDisable() { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(getDataFolder().getAbsolutePath() + File.separator + "cake")); + for (String player : gotCake) { + writer.write(player); + writer.newLine(); + } + writer.close(); + } + catch (Exception ex) { + System.out.println(ex); + } + Bukkit.getServer().getScheduler().cancelTasks(this); System.out.println("mcMMO was disabled."); }