From d08cfa0c4cec2a742c2c62bbf0e66dd2612330b1 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 25 Dec 2015 01:51:36 -0600 Subject: [PATCH 1/3] Holiday Gifts --- .../mineplex/core/common/weight}/Weight.java | 2 +- .../core/common/weight}/WeightSet.java | 2 +- .../game/clans/clans/loot/LootManager.java | 2 +- .../game/clans/gameplay/Gameplay.java | 4 +- .../game/clans/items/GearManager.java | 5 +- .../mineplex/game/clans/items/ItemType.java | 6 - .../src/mineplex/game/clans/spawn/Spawn.java | 4 +- .../src/mineplex/hub/HubManager.java | 3 + .../hub/modules/HolidayGiftManager.java | 118 ++++++++++++++++++ .../hub/modules/holidaygift/GemGift.java | 37 ++++++ .../hub/modules/holidaygift/GiftReward.java | 5 + .../hub/modules/holidaygift/HolidayGift.java | 10 ++ 12 files changed, 181 insertions(+), 17 deletions(-) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/items/generation => Mineplex.Core.Common/src/mineplex/core/common/weight}/Weight.java (84%) rename Plugins/{Mineplex.Game.Clans/src/mineplex/game/clans/items/generation => Mineplex.Core.Common/src/mineplex/core/common/weight}/WeightSet.java (97%) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/HolidayGiftManager.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java 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.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java index 73832f6ec..0ce0bc9e1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/loot/LootManager.java @@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.items.GearManager; -import mineplex.game.clans.items.generation.WeightSet; +import mineplex.core.common.weight.WeightSet; public class LootManager { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index fb578a210..e5c4b62b9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -60,8 +60,8 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.items.generation.Weight; -import mineplex.game.clans.items.generation.WeightSet; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index c3a3acc07..1c30244f5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -53,8 +53,8 @@ import mineplex.game.clans.items.attributes.weapon.JaggedAttribute; import mineplex.game.clans.items.attributes.weapon.SharpAttribute; import mineplex.game.clans.items.commands.GearCommand; import mineplex.game.clans.items.economy.GoldToken; -import mineplex.game.clans.items.generation.Weight; -import mineplex.game.clans.items.generation.WeightSet; +import mineplex.core.common.weight.Weight; +import mineplex.core.common.weight.WeightSet; import mineplex.game.clans.items.legendaries.AlligatorsTooth; import mineplex.game.clans.items.legendaries.GiantsBroadsword; import mineplex.game.clans.items.legendaries.HyperAxe; @@ -67,7 +67,6 @@ import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; import net.minecraft.server.v1_8_R3.NBTTagCompound; import net.minecraft.server.v1_8_R3.Packet; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java index e4b52a9b2..4d854879a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/ItemType.java @@ -1,11 +1,5 @@ package mineplex.game.clans.items; -import com.google.common.collect.Sets; - -import mineplex.game.clans.items.generation.WeightSet; -import mineplex.game.clans.items.legendaries.AlligatorsTooth; -import mineplex.game.clans.items.legendaries.WindBlade; - public enum ItemType { LEGENDARY, diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 118c483ea..53ef5e8a1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -16,7 +16,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFromToEvent; @@ -33,7 +32,6 @@ import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; -import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; @@ -44,7 +42,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.items.generation.WeightSet; +import mineplex.core.common.weight.WeightSet; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 738c79422..55d00076d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -74,6 +74,7 @@ import mineplex.hub.commands.GadgetToggle; import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.NewsCommand; import mineplex.hub.modules.ForcefieldManager; +import mineplex.hub.modules.HolidayGiftManager; import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.KothManager; @@ -246,6 +247,8 @@ public class HubManager extends MiniClientPlugin 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/modules/holidaygift/GemGift.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java new file mode 100644 index 000000000..c0826fc15 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java @@ -0,0 +1,37 @@ +package mineplex.hub.modules.holidaygift; + +import java.util.Random; + +import org.bukkit.entity.Player; + +import mineplex.core.donation.DonationManager; + +public class GemGift implements HolidayGift +{ + private Random _random; + private DonationManager _donationManager; + private int _min; + private int _max; + + public GemGift(DonationManager donationManager, int min, int max) + { + _random = new Random(); + _donationManager = donationManager; + _min = min; + _max = max; + } + + @Override + public boolean canGive(Player player) + { + return false; + } + + @Override + public String give(Player player) + { + int gems = _random.nextInt(_max - _min) + _min; + _donationManager.RewardGemsLater("HolidayManager", player, gems); + return gems + " Gems"; + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java new file mode 100644 index 000000000..11e7edd96 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java @@ -0,0 +1,5 @@ +package mineplex.hub.modules.holidaygift; + +public class GiftReward +{ +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java new file mode 100644 index 000000000..188a6621a --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java @@ -0,0 +1,10 @@ +package mineplex.hub.modules.holidaygift; + +import org.bukkit.entity.Player; + +public interface HolidayGift +{ + public boolean canGive(Player player); + + public String give(Player player); +} From 25d36b546a307b8d8a6ec796f0862ae24f8b7044 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 25 Dec 2015 01:53:00 -0600 Subject: [PATCH 2/3] Remove unnecessary files --- .../hub/modules/holidaygift/GemGift.java | 37 ------------------- .../hub/modules/holidaygift/GiftReward.java | 5 --- .../hub/modules/holidaygift/HolidayGift.java | 10 ----- 3 files changed, 52 deletions(-) delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java deleted file mode 100644 index c0826fc15..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GemGift.java +++ /dev/null @@ -1,37 +0,0 @@ -package mineplex.hub.modules.holidaygift; - -import java.util.Random; - -import org.bukkit.entity.Player; - -import mineplex.core.donation.DonationManager; - -public class GemGift implements HolidayGift -{ - private Random _random; - private DonationManager _donationManager; - private int _min; - private int _max; - - public GemGift(DonationManager donationManager, int min, int max) - { - _random = new Random(); - _donationManager = donationManager; - _min = min; - _max = max; - } - - @Override - public boolean canGive(Player player) - { - return false; - } - - @Override - public String give(Player player) - { - int gems = _random.nextInt(_max - _min) + _min; - _donationManager.RewardGemsLater("HolidayManager", player, gems); - return gems + " Gems"; - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java deleted file mode 100644 index 11e7edd96..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/GiftReward.java +++ /dev/null @@ -1,5 +0,0 @@ -package mineplex.hub.modules.holidaygift; - -public class GiftReward -{ -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java deleted file mode 100644 index 188a6621a..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/holidaygift/HolidayGift.java +++ /dev/null @@ -1,10 +0,0 @@ -package mineplex.hub.modules.holidaygift; - -import org.bukkit.entity.Player; - -public interface HolidayGift -{ - public boolean canGive(Player player); - - public String give(Player player); -} From dd8e91e4635967544de2e418bd4f196eb8bd7225 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 25 Dec 2015 03:03:53 -0600 Subject: [PATCH 3/3] Update MOTD --- .../src/mineplex/bungee/motd/MotdManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..6cd314fd3 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,7 @@ 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 = " §d§lRank Sale §a§l40% Off"); //String motdLine = " §f§l◄§c§lMAINTENANCE§f§l►");