diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index daeb8bae3..324da4b52 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -56,7 +56,8 @@ public class MotdManager implements Listener, Runnable //String motdLine = "§f§l◄ §c§lMaintenance§f§l ►"; //String motdLine = "§f§l◄ §a§lCarl the Creeper§f§l ►"; // String motdLine = " §2§l§n M O N S T E R M A Z E B E T A §f"; - String motdLine = " §f❄ §2§lNew Game §f❄ §2§lType Wars §f❄"; + String motdLine = " §f❄ §2§lMerry Christmas §f❄ §2§lElf Presents §f❄"; +// String motdLine = " §f❄ §2§lServer Maintenance §f❄ §2§lBe Back Soon §f❄"; //String motdLine = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►"); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/Weight.java similarity index 84% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java rename to Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/Weight.java index 108347832..72c2a5fb3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/Weight.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/Weight.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.items.generation; +package mineplex.core.common.weight; public class Weight { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java similarity index 97% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java rename to Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java index 7af1d76a7..08327f982 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/generation/WeightSet.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/weight/WeightSet.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.items.generation; +package mineplex.core.common.weight; import java.util.Collection; import java.util.HashSet; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java index 272b5fe38..79afa7b23 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/ExclusivePreferencesPage.java @@ -124,7 +124,7 @@ public class ExclusivePreferencesPage extends ShopPageBase new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager); // _halloweenManager = new HalloweenSpookinessManager(this); + + new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HolidayGiftManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HolidayGiftManager.java new file mode 100644 index 000000000..6fa903565 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/HolidayGiftManager.java @@ -0,0 +1,118 @@ +package mineplex.hub.modules; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Villager; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.weight.WeightSet; +import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.recharge.Recharge; +import mineplex.core.reward.Reward; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.RewardType; +import mineplex.core.reward.rewards.GemReward; +import mineplex.core.reward.rewards.InventoryReward; +import mineplex.core.task.TaskManager; +import mineplex.core.treasure.TreasureType; + +public class HolidayGiftManager extends MiniPlugin +{ + private final String IDENTIFIER = "the elf"; + + private boolean _enabled = true; + private WeightSet _rewards; + private TaskManager _taskManager; + + public HolidayGiftManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, TaskManager taskManager) + { + super("Holiday Gift", plugin); + + _taskManager = taskManager; + + _rewards = new WeightSet<>(); + _rewards.add(100, new GemReward(donationManager, 50, 300, 1, 1, RewardRarity.UNCOMMON)); + _rewards.add(100, new InventoryReward(inventoryManager, "Coal", "Coal", 10, 50, new ItemStack(Material.COAL), RewardRarity.UNCOMMON, 10, 0)); + _rewards.add(50, new InventoryReward(inventoryManager, "Old Chest", TreasureType.OLD.getItemName(), 1, 1, new ItemStack(Material.CHEST), RewardRarity.RARE, 1, 1)); + _rewards.add(50, new InventoryReward(inventoryManager, "Ancient Chest", TreasureType.ANCIENT.getItemName(), 1, 1, new ItemStack(Material.CHEST), RewardRarity.RARE, 1, 1)); + _rewards.add(20, new InventoryReward(inventoryManager, "Winter Holiday Chest", TreasureType.CHRISTMAS.getItemName(), 1, 1, new ItemStack(Material.CHEST), RewardRarity.RARE, 1, 1)); + _rewards.add(20, new InventoryReward(inventoryManager, "Mythical Chest", TreasureType.MYTHICAL.getItemName(), 1, 1, new ItemStack(Material.CHEST), RewardRarity.RARE, 1, 1)); + } + + @EventHandler + public void onInteract(PlayerInteractEntityEvent event) + { + if (!_enabled) + return; + + if (!(event.getRightClicked() instanceof Villager)) + return; + + Villager villager = ((Villager) event.getRightClicked()); + String colorLess = ChatColor.stripColor(villager.getCustomName()); + String parsedName = colorLess.toLowerCase(); + String elfName = parsedName.split(" ")[0]; + + if (!parsedName.endsWith(IDENTIFIER)) + return; + + if (!Recharge.Instance.use(event.getPlayer(), parsedName, 2000, false, false)) + return; + + String taskName = getTaskName(elfName); + + if (taskName == null) + return; + + if (!_taskManager.hasCompletedTask(event.getPlayer(), taskName)) + { + _taskManager.completedTask(completed -> { + if (completed) + { + Reward reward = _rewards.generateRandom(); + + reward.giveReward(RewardType.GameLoot, event.getPlayer(), rewardData -> { + UtilPlayer.message(event.getPlayer(), F.main("Gift", F.elem(colorLess) + " searches for your gift...")); + UtilPlayer.message(event.getPlayer(), F.main("Gift", "You received " + rewardData.getFriendlyName() + C.mBody + "!")); + }); + } + else + { + UtilPlayer.message(event.getPlayer(), F.main("Gift", F.elem(colorLess) + " had trouble finding a gift for you")); + UtilPlayer.message(event.getPlayer(), F.main("Gift", "Please try again later!")); + } + }, event.getPlayer(), taskName); + } + else + { + UtilPlayer.message(event.getPlayer(), F.main("Gift", F.elem(colorLess) + " has no more gifts for you!")); + } + } + + private String getTaskName(String elfName) + { + if (elfName == null || elfName.length() == 0) + return null; + + return "ChristmasGift.2015." + elfName; + } + + public boolean isEnabled() + { + return _enabled; + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java index 235b7c99b..f3ebc2e5d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerInfo.java @@ -1,5 +1,7 @@ package mineplex.hub.server; +import mineplex.core.common.Rank; + public class ServerInfo { public String Name; @@ -9,7 +11,7 @@ public class ServerInfo public String Map; public String ServerType; public String Game; - public boolean HostedByStaff; + public Rank HostRank = Rank.ALL; public int getAvailableSlots() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index a80aa4503..0b54138c0 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -435,7 +435,25 @@ public class ServerManager extends MiniPlugin serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.getMotd(); serverInfo.CurrentPlayers = serverStatus.getPlayerCount(); serverInfo.MaxPlayers = serverStatus.getMaxPlayerCount(); - serverInfo.HostedByStaff = serverStatus.getMotd().contains("StaffHosted"); + + for (String arg : args) + { + if (arg != null && arg.startsWith("HostRank.") && arg.length() > "HostRank.".length()) + { + String rankEnum = arg.split("\\.")[1]; + + try + { + serverInfo.HostRank = Rank.valueOf(rankEnum); + } + catch (Exception e) + { + // Ignore + } + + break; + } + } if (args.length > 1) serverInfo.ServerType = args[1]; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index 5bc9aa8fa..34ce492a1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -237,7 +237,7 @@ public class ServerNpcPage extends ShopPageInventory