Holiday Gifts

This commit is contained in:
Shaun Bennett 2015-12-25 01:51:36 -06:00
parent 1d4a5e5804
commit d08cfa0c4c
12 changed files with 181 additions and 17 deletions

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.items.generation; package mineplex.core.common.weight;
public class Weight<T> public class Weight<T>
{ {

View File

@ -1,4 +1,4 @@
package mineplex.game.clans.items.generation; package mineplex.core.common.weight;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;

View File

@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.items.GearManager; import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.items.generation.WeightSet; import mineplex.core.common.weight.WeightSet;
public class LootManager public class LootManager
{ {

View File

@ -60,8 +60,8 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.generation.Weight; import mineplex.core.common.weight.Weight;
import mineplex.game.clans.items.generation.WeightSet; import mineplex.core.common.weight.WeightSet;
import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent; import mineplex.minecraft.game.classcombat.Skill.event.BlockTossEvent;

View File

@ -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.attributes.weapon.SharpAttribute;
import mineplex.game.clans.items.commands.GearCommand; import mineplex.game.clans.items.commands.GearCommand;
import mineplex.game.clans.items.economy.GoldToken; import mineplex.game.clans.items.economy.GoldToken;
import mineplex.game.clans.items.generation.Weight; import mineplex.core.common.weight.Weight;
import mineplex.game.clans.items.generation.WeightSet; import mineplex.core.common.weight.WeightSet;
import mineplex.game.clans.items.legendaries.AlligatorsTooth; import mineplex.game.clans.items.legendaries.AlligatorsTooth;
import mineplex.game.clans.items.legendaries.GiantsBroadsword; import mineplex.game.clans.items.legendaries.GiantsBroadsword;
import mineplex.game.clans.items.legendaries.HyperAxe; 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.NBTTagCompound;
import net.minecraft.server.v1_8_R3.Packet; 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.PacketPlayOutSetSlot;
import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems; import net.minecraft.server.v1_8_R3.PacketPlayOutWindowItems;

View File

@ -1,11 +1,5 @@
package mineplex.game.clans.items; 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 public enum ItemType
{ {
LEGENDARY, LEGENDARY,

View File

@ -16,7 +16,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
@ -33,7 +32,6 @@ import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer; 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.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; 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.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.Condition.ConditionType;

View File

@ -74,6 +74,7 @@ import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.commands.GameModeCommand; import mineplex.hub.commands.GameModeCommand;
import mineplex.hub.commands.NewsCommand; import mineplex.hub.commands.NewsCommand;
import mineplex.hub.modules.ForcefieldManager; import mineplex.hub.modules.ForcefieldManager;
import mineplex.hub.modules.HolidayGiftManager;
import mineplex.hub.modules.HubVisibilityManager; import mineplex.hub.modules.HubVisibilityManager;
import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.JumpManager;
import mineplex.hub.modules.KothManager; import mineplex.hub.modules.KothManager;
@ -246,6 +247,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager); new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
// _halloweenManager = new HalloweenSpookinessManager(this); // _halloweenManager = new HalloweenSpookinessManager(this);
new HolidayGiftManager(plugin, clientManager, donationManager, inventoryManager, taskManager);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
// new MailManager(_plugin, notificationManager); // new MailManager(_plugin, notificationManager);

View File

@ -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<Reward> _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;
}
}

View File

@ -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";
}
}

View File

@ -0,0 +1,5 @@
package mineplex.hub.modules.holidaygift;
public class GiftReward
{
}

View File

@ -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);
}