Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
CoderTim 2014-09-18 01:57:04 -04:00
commit 8b14c85572
43 changed files with 1281 additions and 642 deletions

View File

@ -113,4 +113,21 @@ public class UtilTitle
}
}
public static String progress(float exp)
{
String out = "";
for (int i=0 ; i<40 ; i++)
{
float cur = i * (1f /40f);
if (cur < exp)
out += C.cGreen + C.Bold + "|";
else
out += C.cGray + C.Bold + "|";
}
return out;
}
}

View File

@ -93,15 +93,7 @@ public class AntiStack extends MiniPlugin
Item item = event.getItem();
//Get Name
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
//Remove UID
if (name.contains(":"))
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
//Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name);
removeUID(item);
}
@EventHandler
@ -130,4 +122,17 @@ public class AntiStack extends MiniPlugin
{
_enabled = var;
}
public static void removeUID(Item item)
{
//Get Name
String name = ((CraftItemStack)item.getItemStack()).getHandle().getName();
//Remove UID
if (name.contains(":"))
name = name.substring(0, name.indexOf(":" + item.getUniqueId()));
//Set Name
((CraftItemStack)item.getItemStack()).getHandle().c(name);
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.SingleButton;
/**
* Created by shaun on 14-09-15.
*/
public class OpenCostumes extends SingleButton
{
private Menu _menu;
public OpenCostumes(Menu menu)
{
_menu = menu;
}
@Override
public void Clicked(Player player)
{
_menu.openCostumes(player);
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.SingleButton;
/**
* Created by shaun on 14-09-15.
*/
public class OpenMusic extends SingleButton
{
private Menu _menu;
public OpenMusic(Menu menu)
{
_menu = menu;
}
@Override
public void Clicked(Player player)
{
_menu.openMusic(player);
}
}

View File

@ -3,12 +3,10 @@ package mineplex.core.cosmetic.ui.button;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.SingleButton;
public class TreasureButton extends SingleButton
{
private Menu _menu;
public TreasureButton(Menu menu)
@ -16,11 +14,10 @@ public class TreasureButton extends SingleButton
_menu = menu;
}
@Override
public void Clicked(Player player)
{
_menu.openTreasure(player);
}
}

View File

@ -0,0 +1,114 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
/**
* Created by shaun on 14-09-15.
*/
public class CostumePage extends GadgetPage
{
public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
BuildPage();
}
protected void BuildPage()
{
int slot;
List<Class> costumeClasses = new ArrayList<Class>();
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.Costume))
{
OutfitGadget outfitGadget = ((OutfitGadget) gadget);
Class clazz = gadget.getClass();
if (!costumeClasses.contains(clazz))
{
costumeClasses.add(clazz);
}
slot = (costumeClasses.indexOf(clazz) * 2) + 3 + 18;
if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Chest)
slot += 9;
else if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Legs)
slot += 18;
else if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Boots)
slot += 27;
addGadget(gadget, slot);
if (gadget.IsActive(Player))
addGlow(slot);
}
AddButton(8, new ShopItem(Material.TNT, C.cRed + C.Bold + "Remove all Clothing", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
boolean gadgetDisabled = false;
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.Costume))
{
if (gadget.IsActive(player))
{
gadgetDisabled = true;
gadget.Disable(player);
}
}
if (gadgetDisabled)
{
BuildPage();
player.playSound(player.getEyeLocation(), Sound.SPLASH, 1, 1);
}
}
});
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
public void activateGadget(Player player, Gadget gadget)
{
if (gadget instanceof ItemGadget)
{
if (Plugin.getInventoryManager().Get(player).getItemCount(gadget.GetName()) <= 0)
{
purchaseGadget(player, gadget);
return;
}
}
PlayAcceptSound(player);
gadget.Enable(player);
BuildPage();
}
}

View File

@ -3,19 +3,19 @@ package mineplex.core.cosmetic.ui.page;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.button.OpenCostumes;
import mineplex.core.cosmetic.ui.button.OpenGadgets;
import mineplex.core.cosmetic.ui.button.OpenMorphs;
import mineplex.core.cosmetic.ui.button.OpenMounts;
import mineplex.core.cosmetic.ui.button.OpenMusic;
import mineplex.core.cosmetic.ui.button.OpenParticles;
import mineplex.core.cosmetic.ui.button.OpenPets;
import mineplex.core.cosmetic.ui.button.TreasureButton;
@ -42,29 +42,29 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
@Override
protected void BuildPage()
{
AddItem(11, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
AddItem(2, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
if (treasureChestCount <= 0 && Player.getName().equals("Chiss"))
if (treasureChestCount <= 0 && Player.getName().equals("Phinary"))
{
Plugin.getInventoryManager().addItemToInventory(Player, "Utility", "Treasure Chest", 1);
treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
}
// if (treasureChestCount > 0)
// {
// AddButton(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests", new String[] { ChatColor.RESET + "Click to Open Treasure Chest" }, 1, false), new TreasureButton(this));
// }
// else
// {
AddItem(13, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGold + treasureChestCount + " Treasure Chests" + ChatColor.RESET, new String[] { ChatColor.RESET + "Coming soon..." }, 1, false));
//}
if (treasureChestCount > 0)
{
AddButton(4, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests", new String[] { ChatColor.RESET + "Click to Open Treasure Chest" }, 1, false), new TreasureButton(this));
}
else
{
AddItem(4, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGold + treasureChestCount + " Treasure Chests" + ChatColor.RESET, new String[] { ChatColor.RESET + "Coming soon..." }, 1, false));
}
final GemBooster gemBoosterItem = new GemBooster(Shop.getBoosterEnabled(), Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
AddButton(15, new ShopItem(
AddButton(6, new ShopItem(
gemBoosterItem.GetDisplayMaterial(),
gemBoosterItem.GetDisplayName(),
gemBoosterItem.GetDescription(),
@ -111,17 +111,20 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
false));
}
AddButton(27, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
AddButton(29, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
AddButton(31, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
AddButton(33, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
AddButton(35, new ShopItem(Material.BONE, "Pets", 1, false), new OpenPets(this));
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
AddButton(24, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
AddButton(26, new ShopItem(Material.BONE, "Pets", 1, false), new OpenPets(this));
//
AddButton(48, new ShopItem(Material.GOLD_CHESTPLATE, "Costumes", 1, false), new OpenCostumes(this));
AddButton(50, new ShopItem(Material.GREEN_RECORD, "Music", 1, false), new OpenMusic(this));
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Particle) != null)
{
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
AddButton(36,
AddButton(18 + 9,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
new SingleButton()
{
@ -139,7 +142,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
AddButton(38,
AddButton(20 + 9,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
new SingleButton()
{
@ -157,7 +160,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
AddButton(40,
AddButton(22 + 9,
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
new SingleButton()
{
@ -175,7 +178,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
final Mount<?> mount = Plugin.getMountManager().getActive(Player);
AddButton(42,
AddButton(24 + 9,
new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), ChatColor.RESET + C.mItem + mount.GetName(), new String[] {}, 1, false, false),
new SingleButton()
{
@ -191,7 +194,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
if (Plugin.getPetManager().hasActivePet(Player.getName()))
{
AddButton(44, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
AddButton(26 + 9, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
new SingleButton()
{
@Override
@ -222,11 +225,6 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Shop.OpenPageForPlayer(player, new ParticlePage(Plugin, Shop, ClientManager, DonationManager, "Particles", player));
}
public void openTreasure(Player player)
{
Shop.OpenPageForPlayer(player, new TreasurePage(Plugin, Shop, ClientManager, DonationManager, "Open Treasure Chest", player));
}
public void openGadgets(Player player)
{
Shop.OpenPageForPlayer(player, new GadgetPage(Plugin, Shop, ClientManager, DonationManager, "Gadgets", player));
@ -246,4 +244,14 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
{
Shop.OpenPageForPlayer(player, new PetPage(Plugin, Shop, ClientManager, DonationManager, "Pets", player));
}
public void openCostumes(Player player)
{
Shop.OpenPageForPlayer(player, new CostumePage(Plugin, Shop, ClientManager, DonationManager, "Costumes", player));
}
public void openMusic(Player player)
{
Shop.OpenPageForPlayer(player, new MusicPage(Plugin, Shop, ClientManager, DonationManager, "Music", player));
}
}

View File

@ -0,0 +1,56 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
/**
* Created by shaun on 14-09-15.
*/
public class MusicPage extends GadgetPage
{
public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
protected void BuildPage()
{
int slot = 19;
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.MusicDisc))
{
addGadget(gadget, slot);
slot++;
if (slot == 26)
slot = 28;
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
@Override
public void activateGadget(Player player, Gadget gadget)
{
super.activateGadget(player, gadget);
player.closeInventory();
}
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -26,13 +25,13 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.*;
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.gadget.types.MusicGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
@ -111,7 +110,7 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphBlock(this));
addGadget(new MorphEnderman(this));
addGadget(new MorphBat(this));
addGadget(new MorphNotch(this));
//addGadget(new MorphNotch(this));
addGadget(new MorphPumpkinKing(this));
addGadget(new MorphPig(this));
addGadget(new MorphCreeper(this));
@ -178,7 +177,7 @@ public class GadgetManager extends MiniPlugin
{
for (Gadget gadget : _gadgets.get(gadgetType))
{
if (gadget instanceof MorphGadget)
if (gadget instanceof OutfitGadget)
{
OutfitGadget armor = (OutfitGadget) gadget;

View File

@ -1,22 +0,0 @@
package mineplex.core.join;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.F;
public class JoinQuit
{
@EventHandler
public void Join(PlayerJoinEvent event)
{
event.setJoinMessage(F.sys("Join", event.getPlayer().getName()));
}
@EventHandler
public void Quit(PlayerQuitEvent event)
{
event.setQuitMessage(F.sys("Quit", event.getPlayer().getName()));
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.treasure.reward;
package mineplex.core.reward;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Created by Shaun on 9/2/2014.
*/
public interface ITreasureReward
public interface IReward
{
public ItemStack getItem();

View File

@ -0,0 +1,331 @@
package mineplex.core.reward;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.rewards.CoinReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
/**
* Created by shaun on 2014-09-04.
*/
public class RewardManager
{
private HashMap<RewardRarity, List<IReward>> _treasureMap;
private Random _random;
private boolean _doubleGadgetValue;
public RewardManager(DonationManager donationManager, InventoryManager inventoryManager,
int commonValueMin, int commonValueMax,
int uncommonValueMin, int uncommonValueMax,
int rareValueMin, int rareValueMax,
int legendValueMin, int legendValueMax,
boolean doubleGadgetValue)
{
_treasureMap = new HashMap<RewardRarity, List<IReward>>();
_random = new Random();
for (RewardRarity rarity : RewardRarity.values())
{
_treasureMap.put(rarity, new ArrayList<IReward>());
}
_doubleGadgetValue = doubleGadgetValue;
addCommon(donationManager, inventoryManager, commonValueMin, commonValueMax);
addUncommon(donationManager, inventoryManager, uncommonValueMin, uncommonValueMax);
addRare(donationManager, inventoryManager, rareValueMin, rareValueMax);
addLegendary(donationManager, inventoryManager, legendValueMin, legendValueMax);
}
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
{
// Coins
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, RewardRarity.COMMON));
//Increase Value
if (_doubleGadgetValue)
{
minValue *= 2;
maxValue *= 2;
}
// Gadgets
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
new ItemStack(Material.GOLD_BARDING), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.FIREWORK), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.MELON_BLOCK), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
new ItemStack(Material.getMaterial(131)), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
new ItemStack(Material.ENDER_PEARL), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.IRON_BARDING), RewardRarity.COMMON, 1));
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.TNT), RewardRarity.COMMON, 1));
}
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
{
// Coins
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
//Increase Value
if (_doubleGadgetValue)
{
minValue *= 2;
maxValue *= 2;
}
// Gadgets
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
new ItemStack(Material.GOLD_BARDING), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.FIREWORK), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
new ItemStack(Material.MELON_BLOCK), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook",
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
new ItemStack(Material.getMaterial(131)), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
new ItemStack(Material.ENDER_PEARL), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.IRON_BARDING), RewardRarity.UNCOMMON, 250));
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.TNT), RewardRarity.UNCOMMON, 250));
// Pets
addReward(new UnknownPackageReward(donationManager, "Cow Pet", "Cow",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.COW.getTypeId()), RewardRarity.UNCOMMON, 500));
addReward(new UnknownPackageReward(donationManager, "Sheep Pet", "Sheep",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.SHEEP.getTypeId()), RewardRarity.UNCOMMON, 333));
addReward(new UnknownPackageReward(donationManager, "Mooshroom Pet", "Mooshroom",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.MUSHROOM_COW.getTypeId()), RewardRarity.UNCOMMON, 200));
addReward(new UnknownPackageReward(donationManager, "Pig Pet", "Pig",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.PIG.getTypeId()), RewardRarity.UNCOMMON, 200));
addReward(new UnknownPackageReward(donationManager, "Ocelot Pet", "Ocelot",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.OCELOT.getTypeId()), RewardRarity.UNCOMMON, 167));
addReward(new UnknownPackageReward(donationManager, "Chicken Pet", "Chicken",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.CHICKEN.getTypeId()), RewardRarity.RARE, 143));
addReward(new UnknownPackageReward(donationManager, "Wolf Pet", "Wolf",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.WOLF.getTypeId()), RewardRarity.RARE, 125));
}
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
{
// Coins
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
// Mounts
addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule",
new ItemStack(Material.HAY_BLOCK), RewardRarity.RARE, 200));
addReward(new UnknownPackageReward(donationManager, "Minecart Mount", "Minecart",
new ItemStack(Material.MINECART), RewardRarity.RARE, 100));
addReward(new UnknownPackageReward(donationManager, "Slime Mount", "Slime Mount",
new ItemStack(Material.SLIME_BALL), RewardRarity.RARE, 67));
addReward(new UnknownPackageReward(donationManager, "Glacial Steed", "Glacial Steed",
new ItemStack(Material.SNOW_BALL), RewardRarity.RARE, 50));
// Morphs
addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
new ItemStack(Material.LEATHER), RewardRarity.RARE, 167));
addReward(new UnknownPackageReward(donationManager, "Villager Morph", "Villager Morph",
new ItemStack(Material.EMERALD), RewardRarity.RARE, 83));
addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
new ItemStack(Material.FEATHER), RewardRarity.RARE, 50));
addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 33));
addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), RewardRarity.RARE, 25));
// Gadgets
addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
new ItemStack(Material.getMaterial(175)), RewardRarity.RARE, 100));
}
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
{
// Coins
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
// Mounts
addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
new ItemStack(Material.BONE), RewardRarity.LEGENDARY, 33));
// Morphs
addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.LEGENDARY, 20));
// Particles
addReward(new UnknownPackageReward(donationManager, "Shadow Walk Particles", "Shadow Walk",
new ItemStack(Material.LEATHER_BOOTS), RewardRarity.LEGENDARY, 33));
addReward(new UnknownPackageReward(donationManager, "Enchanted Particles", "Enchanted",
new ItemStack(Material.BOOK), RewardRarity.LEGENDARY, 25));
addReward(new UnknownPackageReward(donationManager, "Flame Rings Particles", "Flame Rings",
new ItemStack(Material.BLAZE_POWDER), RewardRarity.LEGENDARY, 17));
addReward(new UnknownPackageReward(donationManager, "Rain Cloud Particles", "Rain Cloud",
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), RewardRarity.LEGENDARY, 13));
addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix",
new ItemStack(Material.REDSTONE), RewardRarity.LEGENDARY, 10));
addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring",
new ItemStack(Material.EMERALD), RewardRarity.LEGENDARY, 8));
}
public void addReward(IReward reward)
{
RewardRarity rarity = reward.getRarity();
List<IReward> treasureList = _treasureMap.get(rarity);
treasureList.add(reward);
}
public IReward[] getRewards(Player player, boolean isChestOpening)
{
int currentReward = 0;
IReward[] rewards = new IReward[4];
boolean hasUncommon = false;
while (currentReward < 4)
{
IReward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon, isChestOpening);
if (reward == null)
{
continue;
}
if (reward.getRarity().ordinal() >= RewardRarity.UNCOMMON.ordinal())
{
hasUncommon = true;
}
rewards[currentReward] = reward;
currentReward++;
}
// Swap the last reward with another one, this makes the uncommon added at the end of some chests seem more random
int slotToSwitch = _random.nextInt(4);
if (slotToSwitch != 3)
{
IReward thirdReward = rewards[3];
IReward otherReward = rewards[slotToSwitch];
rewards[3] = otherReward;
rewards[slotToSwitch] = thirdReward;
}
return rewards;
}
// private IReward nextReward(Player player, IReward[] excludedRewards)
// {
// return nextReward(player, excludedRewards, false, isChestOpening);
// }
public IReward nextReward(Player player, IReward[] excludedRewards, boolean requiresUncommon, boolean isChestOpening)
{
double rand = _random.nextDouble();
RewardRarity rarity;
if (isChestOpening ? rand <= 0.01 : rand <= 0.0001)
{
// 1% or 0.01%
rarity = RewardRarity.LEGENDARY;
}
else if (isChestOpening ? rand <= 0.05 : rand <= 0.001)
{
// 4% or 0.09%
rarity = RewardRarity.RARE;
}
else if ((isChestOpening ? rand <= 0.3 : rand <= 0.03) || requiresUncommon)
{
// 25% or 2.9%
rarity = RewardRarity.UNCOMMON;
}
else
{
// 70% or 97%
rarity = RewardRarity.COMMON;
}
List<IReward> treasureList = _treasureMap.get(rarity);
int totalWeight = 0;
ArrayList<IReward> possibleRewards = new ArrayList<IReward>();
for (IReward treasure : treasureList)
{
boolean isExcluded = false;
if (excludedRewards != null)
{
for (int i = 0; i < excludedRewards.length && !isExcluded; i++)
{
if (excludedRewards[i] != null && excludedRewards[i].equals(treasure))
{
isExcluded = true;
}
}
}
if ((player == null || treasure.canGiveReward(player)) && !isExcluded)
{
possibleRewards.add(treasure);
totalWeight += treasure.getWeight();
}
}
if (totalWeight > 0)
{
int weight = _random.nextInt(totalWeight);
int currentWeight = 0;
for (IReward reward : possibleRewards)
{
currentWeight += reward.getWeight();
if (weight <= currentWeight)
return reward;
}
}
return null;
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.treasure.reward;
package mineplex.core.reward;
import mineplex.core.common.util.C;
import static mineplex.core.common.util.C.*;
@ -14,12 +14,14 @@ public enum RewardRarity
* (Fireworks, sounds, etc)
*/
COMMON(cAqua), UNCOMMON(cGreen), RARE(cGold), VERY_RARE(cRed);
COMMON("Common", cAqua), UNCOMMON("Uncommon", cGreen), RARE("Rare", cGold), LEGENDARY("Legendary", cRed);
private String _name;
private String _color;
RewardRarity(String color)
RewardRarity(String name, String color)
{
_name = name;
_color = color;
}
@ -28,4 +30,9 @@ public enum RewardRarity
return _color;
}
public String getName()
{
return _name;
}
}

View File

@ -1,16 +1,16 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
import java.util.Random;
import org.bukkit.inventory.ItemStack;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.IReward;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 2014-09-08.
*/
public abstract class AbstractReward implements ITreasureReward
public abstract class AbstractReward implements IReward
{
protected static final Random RANDOM = new Random();

View File

@ -1,4 +1,4 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
/**
* Created by shaun on 2014-09-08.
@ -6,14 +6,12 @@ package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 2014-09-08.
@ -32,7 +30,7 @@ public class CoinReward extends AbstractReward
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
{
super(new ItemStack(Material.GOLD_INGOT), rarity, weight);
super(new ItemStack(175), rarity, weight);
_donationManager = donationManager;
_minCoinCount = minCoinCount;
_maxCoinCount = maxCoinCount;
@ -71,5 +69,4 @@ public class CoinReward extends AbstractReward
return false;
}
}

View File

@ -1,11 +1,11 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.

View File

@ -1,4 +1,4 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
import java.util.Random;
@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.

View File

@ -1,4 +1,4 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
import java.util.Random;
@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 14-09-12.

View File

@ -1,11 +1,10 @@
package mineplex.core.treasure.reward.rewards;
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 14-09-12.
@ -35,7 +34,7 @@ public class UnknownPackageReward extends AbstractReward
@Override
public boolean canGiveReward(Player player)
{
return _donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
}
protected String getPackageName()

View File

@ -1,17 +1,27 @@
package mineplex.core.treasure;
import org.bukkit.block.Block;
/**
* Created by Shaun on 8/28/2014.
*/
public class BlockInfo
{
private Block _block;
private int _id;
private byte _data;
public BlockInfo(int id, byte data)
public BlockInfo(Block block)
{
_id = id;
_data = data;
_block = block;
_id = block.getTypeId();
_data = block.getData();
}
public Block getBlock()
{
return _block;
}
public int getId()
@ -23,4 +33,10 @@ public class BlockInfo
{
return _data;
}
@Override
public int hashCode()
{
return _block.hashCode();
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.common.util.UtilServer;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.reward.IReward;
/**
* Created by Shaun on 8/29/2014.
@ -16,10 +16,10 @@ import mineplex.core.treasure.reward.ITreasureReward;
public class ChestData
{
private Block _block;
private ITreasureReward _reward;
private IReward _reward;
private boolean _opened;
public ChestData(Block block, ITreasureReward reward)
public ChestData(Block block, IReward reward)
{
_block = block;
_opened = false;
@ -41,7 +41,7 @@ public class ChestData
return _block;
}
public ITreasureReward getReward()
public IReward getReward()
{
return _reward;
}

View File

@ -1,9 +1,10 @@
package mineplex.core.treasure;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
@ -15,25 +16,31 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.reward.IReward;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.animation.ChestExplodeAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.CircleAnimation;
import mineplex.core.treasure.animation.FireworksAnimation;
import mineplex.core.treasure.animation.LegendaryAnimation;
import mineplex.core.treasure.animation.RareAnimation;
import mineplex.core.treasure.animation.TreasureRemoveAnimation;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.animation.UncommonAnimation;
/**
* Created by Shaun on 8/27/2014.
*/
public class Treasure
{
private NautHashMap<Block, BlockInfo> _blockRestoreMap = new NautHashMap<Block, BlockInfo>();
// Decay Sets
private HashSet<BlockInfo> _wallsBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _outerRingBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _centerBlockInfo = new HashSet<>();
private HashSet<BlockInfo> _chestBlockInfo = new HashSet<>();
private Player _player;
private Random _random;
private Block _centerBlock;
@ -47,12 +54,12 @@ public class Treasure
private TreasureStyle _style;
public Treasure(Player player, ITreasureReward[] rewards)
public Treasure(Player player, IReward[] rewards)
{
this(player, new Random(), rewards);
}
public Treasure(Player player, Random seed, ITreasureReward[] rewards)
public Treasure(Player player, Random seed, IReward[] rewards)
{
_player = player;
_random = seed;
@ -80,6 +87,7 @@ public class Treasure
if (Math.abs(x) == 1 || Math.abs(z) == 1)
{
Block block = _centerBlock.getRelative(x, 0, z);
_centerBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
}
}
@ -92,11 +100,13 @@ public class Treasure
{
{
Block block = _centerBlock.getRelative(x, 0, -2);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(x, 0, 2);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
}
@ -105,17 +115,19 @@ public class Treasure
{
{
Block block = _centerBlock.getRelative(-2, 0, z);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(2, 0, z);
_outerRingBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
}
}
private void createGlass()
private void createWalls()
{
for (int z = -2; z <= 2; z++)
{
@ -125,6 +137,7 @@ public class Treasure
{
Block playerBlock = getPlayerBlock();
Block block = playerBlock.getRelative(x, 0, z);
_wallsBlockInfo.add(new BlockInfo(block));
setBlock(block, _style.getWallMaterial(), _style.getWallData());
}
}
@ -146,7 +159,10 @@ public class Treasure
if (_tickCount == 5)
{
Block block = _centerBlock;
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
_centerBlockInfo.add(new BlockInfo(block));
_centerBlockInfo.add(new BlockInfo(block.getRelative(BlockFace.DOWN)));
setBlock(block, Material.REDSTONE_LAMP_ON, (byte) 0);
setBlock(block.getRelative(BlockFace.DOWN), Material.REDSTONE_TORCH_ON, (byte) 0);
}
else if (_tickCount == 10)
{
@ -158,30 +174,30 @@ public class Treasure
}
else if (_tickCount == 30)
{
createGlass();
createWalls();
}
else if (_tickCount == 50)
{
Block block = getPlayerBlock().getRelative(2, 0, 0);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 80)
{
Block block = getPlayerBlock().getRelative(-2, 0, 0);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 110)
{
Block block = getPlayerBlock().getRelative(0, 0, 2);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2, _chestBlockInfo);
_animations.add(task);
}
else if (_tickCount == 140)
{
Block block = getPlayerBlock().getRelative(0, 0, -2);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3);
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3, _chestBlockInfo);
_animations.add(task);
}
@ -223,21 +239,13 @@ public class Treasure
return _centerBlock.getRelative(BlockFace.UP);
}
public void setBlock(Block block, Material material, byte data, boolean addToBlockRestoreMap)
public void setBlock(Block block, Material material, byte data)
{
if (addToBlockRestoreMap)
_blockRestoreMap.put(block, new BlockInfo(block.getTypeId(), block.getData()));
block.setType(material);
block.setData(data);
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
}
public void setBlock(Block block, Material material, byte data)
{
setBlock(block, material, data, true);
}
public void openChest(Block block)
{
ChestData data = getChestData(block);
@ -252,22 +260,22 @@ public class Treasure
// Extra effects based off the rarity of the treasure
if (data.getReward().getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new FireworksAnimation(this, data.getBlock()));
_animations.add(new UncommonAnimation(this, data.getBlock()));
}
else if (data.getReward().getRarity() == RewardRarity.RARE)
{
_animations.add(new CircleAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened a Rare treasure!"));
_animations.add(new RareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + text));
}
else if (data.getReward().getRarity() == RewardRarity.VERY_RARE)
else if (data.getReward().getRarity() == RewardRarity.LEGENDARY)
{
_animations.add(new ChestExplodeAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened a Legendary treasure!"));
_animations.add(new LegendaryAnimation(this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + text));
}
if (isFinished())
{
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _blockRestoreMap);
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _centerBlockInfo, _outerRingBlockInfo, _wallsBlockInfo);
_animations.add(animation);
_finished = true;
}
@ -286,7 +294,6 @@ public class Treasure
for (Player player : players)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
System.out.println("sending chest open packet");
}
}
@ -337,20 +344,11 @@ public class Treasure
}
}
for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet())
{
Block block = entry.getKey();
BlockInfo data = entry.getValue();
if (block.getType().equals(Material.CHEST))
{
block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(data.getId());
block.setData(data.getData());
}
// Remove any extra blocks
resetBlockInfo(_wallsBlockInfo);
resetBlockInfo(_centerBlockInfo);
resetBlockInfo(_outerRingBlockInfo);
resetBlockInfo(_chestBlockInfo);
for (Animation animation : _animations)
{
@ -359,6 +357,26 @@ public class Treasure
_animations.clear();
}
public void resetBlockInfo(Set<BlockInfo> blockInfoSet)
{
for (BlockInfo blockInfo : blockInfoSet)
{
Block block = blockInfo.getBlock();
if (block.getType().equals(Material.CHEST))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10);
// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(blockInfo.getId());
block.setData(blockInfo.getData());
}
blockInfoSet.clear();
}
public TreasureStyle getStyle()
{
return _style;

View File

@ -11,12 +11,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
@ -31,15 +33,16 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.event.StackerEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.IReward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.CoinReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.reward.rewards.CoinReward;
import mineplex.core.treasure.reward.rewards.InventoryReward;
import mineplex.core.treasure.reward.rewards.UnknownPackageReward;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -50,171 +53,18 @@ public class TreasureManager extends MiniPlugin
{
private NautHashMap<Player, Treasure> _playerTreasureMap;
private RewardManager _rewardManager;
private DonationManager _donationManager;
private InventoryManager _inventoryManager;
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager)
{
super("Treasure", plugin);
_donationManager = donationManager;
_playerTreasureMap = new NautHashMap<Player, Treasure>();
_rewardManager = new RewardManager();
_inventoryManager = inventoryManager;
// Very Rare
{
// Coins
{
_rewardManager.addReward(new CoinReward(donationManager, 2000, 5000, 25, RewardRarity.VERY_RARE));
}
// Mounts
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
new ItemStack(Material.BONE), RewardRarity.VERY_RARE, 33));
}
// Morphs
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.VERY_RARE, 20));
}
// Particles
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Shadow Walk Particles", "Shadow Walk",
new ItemStack(Material.LEATHER_BOOTS), RewardRarity.VERY_RARE, 33));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enchanted Particles", "Enchanted",
new ItemStack(Material.BOOK), RewardRarity.VERY_RARE, 25));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Flame Rings Particles", "Flame Rings",
new ItemStack(Material.BLAZE_POWDER), RewardRarity.VERY_RARE, 17));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Rain Cloud Particles", "Rain Cloud",
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), RewardRarity.VERY_RARE, 13));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix",
new ItemStack(Material.REDSTONE), RewardRarity.VERY_RARE, 10));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring",
new ItemStack(Material.EMERALD), RewardRarity.VERY_RARE, 8));
}
}
// Rare
{
// Coins
{
_rewardManager.addReward(new CoinReward(donationManager, 1000, 2000, 100, RewardRarity.RARE));
}
// Gadgets
{
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun", 200, 400,
// new ItemStack(Material.GOLD_BARDING), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",100, 200,
// new ItemStack(Material.FIREWORK), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher", 100, 200,
// new ItemStack(Material.MELON_BLOCK), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook", 80, 160,
// new ItemStack(Material.getMaterial(131)), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl", 60, 120,
// new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster", 40, 80,
// new ItemStack(Material.IRON_BARDING), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 40, 80,
// new ItemStack(Material.TNT), RewardRarity.RARE, 100));
// _rewardManager.addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
// new ItemStack(Material.getMaterial(175)), RewardRarity.RARE, 100));
}
// Pets
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Chicken Pet", "Chicken",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.CHICKEN.getTypeId()), RewardRarity.RARE, 143));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Wolf Pet", "Wolf",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.WOLF.getTypeId()), RewardRarity.RARE, 125));
}
// Mounts
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule",
new ItemStack(Material.HAY_BLOCK), RewardRarity.RARE, 200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Minecart Mount", "Minecart",
new ItemStack(Material.MINECART), RewardRarity.RARE, 100));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Slime Mount", "Slime Mount",
new ItemStack(Material.SLIME_BALL), RewardRarity.RARE, 67));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Glacial Steed", "Glacial Steed",
new ItemStack(Material.SNOW_BALL), RewardRarity.RARE, 50));
}
// Morphs
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
new ItemStack(Material.LEATHER), RewardRarity.RARE, 167));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Villager Morph", "Villager Morph",
new ItemStack(Material.EMERALD), RewardRarity.RARE, 83));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
new ItemStack(Material.FEATHER), RewardRarity.RARE, 50));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 33));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), RewardRarity.RARE, 25));
}
}
// Uncommon
{
// Coins
{
_rewardManager.addReward(new CoinReward(donationManager, 500, 1000, 250, RewardRarity.UNCOMMON));
}
// Gadgets
{
_rewardManager.addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun", 100, 200,
new ItemStack(Material.GOLD_BARDING), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", 50, 100,
new ItemStack(Material.FIREWORK), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher", 50, 100,
new ItemStack(Material.MELON_BLOCK), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook", 40, 80,
new ItemStack(Material.getMaterial(131)), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl", 30, 60,
new ItemStack(Material.ENDER_PEARL), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster", 20, 40,
new ItemStack(Material.IRON_BARDING), RewardRarity.UNCOMMON, 250));
_rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 20, 40,
new ItemStack(Material.TNT), RewardRarity.UNCOMMON, 250));
}
// Pets
{
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Cow Pet", "Cow",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.COW.getTypeId()), RewardRarity.UNCOMMON, 500));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Sheep Pet", "Sheep",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.SHEEP.getTypeId()), RewardRarity.UNCOMMON, 333));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Mooshroom Pet", "Mooshroom",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.MUSHROOM_COW.getTypeId()), RewardRarity.UNCOMMON, 200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Pig Pet", "Pig",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.PIG.getTypeId()), RewardRarity.UNCOMMON, 200));
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Ocelot Pet", "Ocelot",
new ItemStack(Material.MONSTER_EGG, 1, EntityType.OCELOT.getTypeId()), RewardRarity.UNCOMMON, 167));
}
}
// Common
{
// Coins
{
_rewardManager.addReward(new CoinReward(donationManager, 250, 500, 1, RewardRarity.COMMON));
}
// Gadgets
{
_rewardManager.addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun", 50, 100,
new ItemStack(Material.GOLD_BARDING), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", 25, 50,
new ItemStack(Material.FIREWORK), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher", 25, 50,
new ItemStack(Material.MELON_BLOCK), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook", 20, 40,
new ItemStack(Material.getMaterial(131)), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl", 15, 30,
new ItemStack(Material.ENDER_PEARL), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster", 10, 20,
new ItemStack(Material.IRON_BARDING), RewardRarity.COMMON, 1));
_rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 10, 20,
new ItemStack(Material.TNT), RewardRarity.COMMON, 1));
}
}
_rewardManager = new RewardManager(donationManager, inventoryManager,
250, 500,
750, 1500,
2000, 3000,
10000, 20000,
true);
}
@Override
@ -241,7 +91,7 @@ public class TreasureManager extends MiniPlugin
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
ITreasureReward[] rewards = _rewardManager.getRewards(player);
IReward[] rewards = _rewardManager.getRewards(player, true);
Treasure treasure = new Treasure(player, rewards);
_playerTreasureMap.put(player, treasure);
@ -330,7 +180,7 @@ public class TreasureManager extends MiniPlugin
treasure.update();
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 100)
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80)
{
treasure.cleanup();
iterator.remove();
@ -391,17 +241,52 @@ public class TreasureManager extends MiniPlugin
{
for (Treasure treasure : _playerTreasureMap.values())
{
Location fromLocation = event.getFrom();
Location toLocation = event.getTo();
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
if (centerLocation.distanceSquared(event.getTo()) <= 9)
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
if (toDistanceFromCenter <= 9)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
event.setTo(event.getFrom());
// Only cancel movement if they are moving towards the center
double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation);
if (toDistanceFromCenter < fromDistanceFromCenter)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
event.setTo(event.getFrom());
}
}
}
}
}
@EventHandler
public void cancelVelocity(PlayerVelocityEvent event)
{
// Need to prevent players
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
event.setCancelled(true);
}
}
@EventHandler
public void cancelStacker(StackerEvent event)
{
if (event.getEntity() instanceof Player)
{
Player player = ((Player) event.getEntity());
if (_playerTreasureMap.containsKey(player))
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
@ -409,11 +294,12 @@ public class TreasureManager extends MiniPlugin
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
event.setCancelled(true);
Treasure treasure = _playerTreasureMap.get(player);
treasure.openChest(event.getClickedBlock());
}
// Always cancel interact for treasure players, prevents players from being able to open up cosmetic menu and other menus
event.setCancelled(true);
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
@ -443,10 +329,39 @@ public class TreasureManager extends MiniPlugin
//TODO Remove
if (event.getMessage().startsWith("/treasuredebug"))
{
event.getPlayer().sendMessage("Attempting to open treasure...");
event.getPlayer().sendMessage(C.cGreen + C.Bold + "Treasure Debug...");
attemptOpenTreasure(event.getPlayer());
event.setCancelled(true);
}
if (event.getMessage().startsWith("/rewardchest") || event.getMessage().startsWith("/rewardgame"))
{
int common = 0;
int uncommon = 0;
int rare = 0;
int legend = 0;
int toTest = 10000000;
for (int i=0 ; i<toTest ; i++)
{
IReward reward = _rewardManager.nextReward(null, null, false, event.getMessage().startsWith("/rewardchest"));
if (reward.getRarity() == RewardRarity.COMMON) common++;
if (reward.getRarity() == RewardRarity.UNCOMMON) uncommon++;
if (reward.getRarity() == RewardRarity.RARE) rare++;
if (reward.getRarity() == RewardRarity.LEGENDARY) legend++;
}
event.getPlayer().sendMessage(C.cGreen + C.Bold + (event.getMessage().startsWith("/rewardchest") ? "Chest Rewards" : "Post-Game Rewards"));
event.getPlayer().sendMessage("Common: " + common + " " + UtilMath.trim(3, (double)common/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Uncommon: " + uncommon + " " + UtilMath.trim(3, (double)uncommon/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Rare: " + rare + " " + UtilMath.trim(3, (double)rare/(double)toTest*100d) + "%");
event.getPlayer().sendMessage("Legendary: " + legend + " " + UtilMath.trim(3, (double)legend/(double)toTest*100d) + "%");
event.setCancelled(true);
}
}
}

View File

@ -1,15 +1,16 @@
package mineplex.core.treasure.animation;
import java.util.HashSet;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldEvent;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
/**
@ -23,13 +24,16 @@ public class ChestSpawnAnimation extends Animation
private byte _direction;
private Location _centerLocation;
public ChestSpawnAnimation(Treasure tresure, Block block, byte direction)
private HashSet<BlockInfo> _chestBlockInfo;
public ChestSpawnAnimation(Treasure tresure, Block block, byte direction, HashSet<BlockInfo> chestBlockInfo)
{
super(tresure);
_block = block;
_direction = direction;
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
_centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1);
_chestBlockInfo = chestBlockInfo;
}
@Override
@ -50,6 +54,7 @@ public class ChestSpawnAnimation extends Animation
if (getTicks() >= ANIMATION_DURATION)
{
_chestBlockInfo.add(new BlockInfo(_block));
getTreasure().setBlock(_block, Material.CHEST, _direction);
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);

View File

@ -1,60 +0,0 @@
package mineplex.core.treasure.animation;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class CircleAnimation extends Animation
{
/**
* Played when a "Rare" chest is opened
*/
private Location _centerLocation;
public CircleAnimation(Treasure treasure, Location centerLocation)
{
super(treasure);
_centerLocation = centerLocation;
}
@Override
protected void tick()
{
if (getTicks() == 2)
{
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build());
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
{
finish();
}
double currentRotation = getTicks() / 20D;
double radius = currentRotation;
double yDiff = currentRotation;
double xDiff = Math.sin(currentRotation * 2 * Math.PI) * radius;
double zDiff = Math.cos(currentRotation * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
}
@Override
protected void onFinish()
{
}
}

View File

@ -9,12 +9,13 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class ChestExplodeAnimation extends Animation
public class LegendaryAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
@ -23,7 +24,7 @@ public class ChestExplodeAnimation extends Animation
private Random _random = new Random();
private Block _chestBlock;
public ChestExplodeAnimation(Treasure treasure, Block chestBlock)
public LegendaryAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
@ -38,13 +39,27 @@ public class ChestExplodeAnimation extends Animation
// _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 10F, 1.2F);
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
if (getTicks() == 10)
if (getTicks() == 20)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), effect);
// ((CraftWorld) _chestBlock.getWorld()).getHandle().triggerEffect(1005, _chestBlock.getX(), _chestBlock.getY(), _chestBlock.getZ(), 2257);
}
else if (getTicks() < 10)
else if (getTicks() < 15)
{
double radius = 2 - (getTicks() / 10D * 2);
int particleAmount = 20 - (getTicks() * 2);
Location _centerLocation = _chestBlock.getLocation().add(0.5, 0.1, 0.5);
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.CLOUD, location, 0, 0, 0, 0, 1);
}
}
else if (getTicks() < 20)
{
double xDif = _random.nextGaussian() * 0.5;
double zDif = _random.nextGaussian() * 0.5;

View File

@ -0,0 +1,72 @@
package mineplex.core.treasure.animation;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class RareAnimation extends Animation
{
/**
* Played when a "Rare" chest is opened
*/
private Location _centerLocation;
public RareAnimation(Treasure treasure, Location centerLocation)
{
super(treasure);
_centerLocation = centerLocation;
}
@Override
protected void tick()
{
if (getTicks() == 2)
{
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build());
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
{
finish();
}
{
double currentRotation = getTicks() / 20D;
double radius = currentRotation;
double yDiff = currentRotation;
double xDiff = Math.sin(currentRotation * 2 * Math.PI) * radius;
double zDiff = Math.cos(currentRotation * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
}
double radius = getTicks() / 20D;
int particleAmount = getTicks() / 2;
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location, 0, 0, 0, 0, 1);
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,11 +1,8 @@
package mineplex.core.treasure.animation;
import java.util.HashSet;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
@ -16,21 +13,43 @@ public class TreasureRemoveAnimation extends Animation
{
private Random _random = new Random();
private NautHashMap<Block, BlockInfo> _blockRestoreMap;
private HashSet<BlockInfo> _wallsBlockInfo;
private HashSet<BlockInfo> _outerRingBlockInfo;
private HashSet<BlockInfo> _centerBlockInfo;
public TreasureRemoveAnimation(Treasure treasure, NautHashMap<Block, BlockInfo> blockRestoreMap)
public TreasureRemoveAnimation(Treasure treasure, HashSet<BlockInfo> centerBlockInfo, HashSet<BlockInfo> outerRingBlockInfo, HashSet<BlockInfo> wallsBlockInfo)
{
super(treasure);
_blockRestoreMap = blockRestoreMap;
_wallsBlockInfo = wallsBlockInfo;
_centerBlockInfo = centerBlockInfo;
_outerRingBlockInfo = outerRingBlockInfo;
}
@Override
protected void tick()
{
// first wait for 1 second
if (getTicks() <= 20)
return;
// Chests go away at 100 ticks
HashSet<BlockInfo> blockInfoSet = null;
if (getTicks() == 40)
{
blockInfoSet = _wallsBlockInfo;
}
else if (getTicks() == 50)
{
blockInfoSet = _outerRingBlockInfo;
}
else if (getTicks() == 60)
{
blockInfoSet = _centerBlockInfo;
}
if (blockInfoSet != null)
{
getTreasure().resetBlockInfo(blockInfoSet);
}
/*
if (getTicks() % 2 == 0)
{
if (_blockRestoreMap.size() > 4)
@ -52,6 +71,7 @@ public class TreasureRemoveAnimation extends Animation
finish();
}
}
*/
}
@Override

View File

@ -2,27 +2,18 @@ package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityStatus;
import mineplex.core.common.util.FireworkUtil;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class FireworksAnimation extends Animation
public class UncommonAnimation extends Animation
{
/**
* Played when an "Uncommon" chest is opened
@ -31,7 +22,7 @@ public class FireworksAnimation extends Animation
private Random _random = new Random();
private Block _block;
public FireworksAnimation(Treasure treasure, Block block)
public UncommonAnimation(Treasure treasure, Block block)
{
super(treasure);
@ -41,22 +32,26 @@ public class FireworksAnimation extends Animation
@Override
protected void tick()
{
if (getTicks() >= 1)
if (getTicks() >= 10)
finish();
if (getTicks() % 10 == 0)
if (getTicks() == 10)
{
double xDif = 0;//_random.nextGaussian() * 1;
double zDif = 0;//_random.nextGaussian() * 1;
double yDif = 2;//(_random.nextInt(3) * _random.nextDouble()) + 2;
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
FireworkEffect effect = FireworkEffect.builder().withColor(Color.RED)
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5).add(xDif, yDif, zDif), effect);
}
else if (getTicks() % 2 == 0)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1);
}
}

View File

@ -1,149 +0,0 @@
package mineplex.core.treasure.reward;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import org.bukkit.entity.Player;
/**
* Created by shaun on 2014-09-04.
*/
public class RewardManager
{
private HashMap<RewardRarity, List<ITreasureReward>> _treasureMap;
private Random _random;
public RewardManager()
{
_treasureMap = new HashMap<RewardRarity, List<ITreasureReward>>();
_random = new Random();
for (RewardRarity rarity : RewardRarity.values())
{
_treasureMap.put(rarity, new ArrayList<ITreasureReward>());
}
}
public void addReward(ITreasureReward reward)
{
RewardRarity rarity = reward.getRarity();
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
treasureList.add(reward);
}
public ITreasureReward[] getRewards(Player player)
{
int currentReward = 0;
ITreasureReward[] rewards = new ITreasureReward[4];
boolean hasUncommon = false;
while (currentReward < 4)
{
ITreasureReward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon);
if (reward == null)
{
continue;
}
if (reward.getRarity().ordinal() >= RewardRarity.UNCOMMON.ordinal())
{
hasUncommon = true;
}
rewards[currentReward] = reward;
currentReward++;
}
// Swap the last reward with another one, this makes the uncommon added at the end of some chests seem more random
int slotToSwitch = _random.nextInt(4);
if (slotToSwitch != 3)
{
ITreasureReward thirdReward = rewards[3];
ITreasureReward otherReward = rewards[slotToSwitch];
rewards[3] = otherReward;
rewards[slotToSwitch] = thirdReward;
}
return rewards;
}
private ITreasureReward nextReward(Player player, ITreasureReward[] excludedRewards)
{
return nextReward(player, excludedRewards, false);
}
private ITreasureReward nextReward(Player player, ITreasureReward[] excludedRewards, boolean requiresUncommon)
{
double rand = _random.nextDouble();
RewardRarity rarity;
if (rand <= 0.01)
{
// 1%
rarity = RewardRarity.VERY_RARE;
}
else if (rand <= 0.05)
{
// 4%
rarity = RewardRarity.RARE;
}
else if (rand <= 0.30 || requiresUncommon)
{
// 25%
rarity = RewardRarity.UNCOMMON;
}
else
{
// 70%
rarity = RewardRarity.COMMON;
}
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
int totalWeight = 0;
ArrayList<ITreasureReward> possibleRewards = new ArrayList<ITreasureReward>();
for (ITreasureReward treasure : treasureList)
{
boolean isExcluded = false;
if (excludedRewards != null)
{
for (int i = 0; i < excludedRewards.length && !isExcluded; i++)
{
if (excludedRewards[i] != null && excludedRewards[i].equals(treasure))
{
isExcluded = true;
}
}
}
if (treasure.canGiveReward(player) && !isExcluded)
{
possibleRewards.add(treasure);
totalWeight += treasure.getWeight();
}
}
if (totalWeight > 0)
{
int weight = _random.nextInt(totalWeight);
int currentWeight = 0;
for (ITreasureReward reward : possibleRewards)
{
currentWeight += reward.getWeight();
if (weight <= currentWeight)
return reward;
}
}
return null;
}
}

View File

@ -42,6 +42,7 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
@ -92,6 +93,7 @@ import nautilus.game.arcade.managers.GameGemManager;
import nautilus.game.arcade.managers.GameLobbyManager;
import nautilus.game.arcade.managers.GameManager;
import nautilus.game.arcade.managers.GamePlayerManager;
import nautilus.game.arcade.managers.GameLootManager;
import nautilus.game.arcade.managers.GameWorldManager;
import nautilus.game.arcade.managers.IdleManager;
import nautilus.game.arcade.managers.MiscManager;
@ -243,6 +245,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameFlagManager(this);
_gamePlayerManager = new GamePlayerManager(this);
new GameAchievementManager(this);
new GameLootManager(this);
_gameWorldManager = new GameWorldManager(this);
new MiscManager(this);
new IdleManager(this);
@ -679,6 +682,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation
GetDisguise().undisguise(player);
}
public void RefreshPlayers()
{
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
{
player.hidePlayer(other);
player.showPlayer(other);
}
}
}
public ArrayList<String> LoadFiles(String gameName)
{
TimingManager.start("ArcadeManager LoadFiles");

View File

@ -539,7 +539,7 @@ public class CastleSiege extends TeamGame
if (this.WorldTimeSet > 24100)
{
SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the seige!");
SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!");
AnnounceEnd(GetTeam(ChatColor.AQUA));

View File

@ -188,7 +188,8 @@ public class HideSeek extends TeamGame
{
new KitHiderSwapper(manager),
new KitHiderQuick(manager),
new KitHiderShocker(manager),
//new KitHiderShocker(manager),
new NullKit(manager),
new NullKit(manager),
new KitSeekerLeaper(manager),
new KitSeekerTNT(manager),

View File

@ -49,6 +49,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.util.Vector;
import mineplex.core.antistack.AntiStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
@ -88,16 +89,13 @@ import nautilus.game.arcade.game.games.minestrike.data.Bomb;
import nautilus.game.arcade.game.games.minestrike.data.Bullet;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
import nautilus.game.arcade.game.games.minestrike.items.guns.GunType;
import nautilus.game.arcade.game.games.minestrike.items.guns.pistol.Glock18;
import nautilus.game.arcade.game.games.minestrike.items.guns.pistol.P2000;
import nautilus.game.arcade.game.games.minestrike.items.guns.rifle.AWP;
import nautilus.game.arcade.game.games.minestrike.kits.KitPlayer;
import nautilus.game.arcade.game.games.turfforts.TurfForts.ShredBlockEvent;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_7_R4.EntityArrow;
@ -193,7 +191,7 @@ public class MineStrike extends TeamGame
//"Tap Crouch when close to an ally to Boost",
"Open Inventory at spawn to buy guns",
"Hold Right-Click to Plant Bomb",
"Hold Right-Click with knife to Defuse Bomb",
"Look at the Bomb to Defuse Bomb",
"Moving decreases accuracy",
"Sprinting heavily decreases accuracy",
"Jumping massively decreases accuracy",
@ -379,21 +377,37 @@ public class MineStrike extends TeamGame
{
for (Player other : team.GetPlayers(false))
if (!other.equals(player))
{
UtilTitle.display(null, player.getName() + " has the Bomb", 10, 80, 10, other);
UtilPlayer.message(other, C.cGold + C.Bold + player.getName() + " has the Bomb!");
}
//Chat
UtilPlayer.message(player, C.cGold + C.Bold + "You have the Bomb!");
UtilPlayer.message(player, C.cGold + C.Bold + "Hold Right-Click to place at a Bomb Site!");
//Title
UtilTitle.display(C.cRed + "You have the Bomb", "Hold Right-Click to place at a Bomb Site!", 10, 80, 10, player);
}
else
{
for (Player other : team.GetPlayers(false))
if (!other.equals(player))
{
UtilPlayer.message(other, C.cGold + C.Bold + player.getName() + " picked up the Bomb!");
UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!");
}
//Title
UtilTitle.display(null, player.getName() + " picked up the Bomb", 10, 50, 10, other);
}
//Chat
UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!");
//Title
UtilTitle.display(null, "You picked up the Bomb", 10, 50, 10, player);
}
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
_bombHolder = player;
@ -762,6 +776,8 @@ public class MineStrike extends TeamGame
if (UtilInv.contains(event.getPlayer(), Material.SHEARS, (byte)0, 1))
return;
AntiStack.removeUID(event.getItem());
event.getPlayer().getInventory().setItem(8, event.getItem().getItemStack());
UtilPlayer.message(event.getPlayer(), F.main("Game", "You equipped Defusal Kit."));
@ -1168,7 +1184,6 @@ public class MineStrike extends TeamGame
while (!hitHead(damagee, loc) && !hitBody(damagee, loc) && UtilMath.offset(damagee.getLocation(), loc) < 6)
{
UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, loc, 0, 0, 0, 0, 1);
loc.add(trajectory.clone().multiply(0.1));
}
@ -1387,8 +1402,8 @@ public class MineStrike extends TeamGame
if (!_bombPlanter.isBlocking())
{
_bombPlanter.setExp(0f);
UtilTitle.clear(_bombPlanter);
_bombPlanter = null;
return;
}
@ -1397,6 +1412,8 @@ public class MineStrike extends TeamGame
if (Math.random() > 0.90)
_bombPlanter.getWorld().playSound(_bombPlanter.getLocation(), Sound.NOTE_PLING, 1f, 3f);
UtilTitle.display(C.cRed + C.Bold + "Planting Bomb", UtilTitle.progress(_bombPlanter.getExp()), 0, 10, 0, _bombPlanter);
if (_bombPlanter.getExp() >= 0.98f)
{
_bomb = new Bomb(_bombPlanter);
@ -1412,6 +1429,8 @@ public class MineStrike extends TeamGame
_bombPlanter = null;
_bombHolder = null;
//Title
UtilTitle.display(null, C.cRed + C.Bold + "Bomb has been planted!", 10, 50, 10);
}
}
@ -1422,9 +1441,9 @@ public class MineStrike extends TeamGame
if (UtilMath.offset(event.getFrom(), event.getTo()) > 0)
event.setTo(event.getFrom());
if (_bombDefuser != null && _bombDefuser.equals(event.getPlayer()))
if (UtilMath.offset(event.getFrom(), event.getTo()) > 0)
event.setTo(event.getFrom());
// if (_bombDefuser != null && _bombDefuser.equals(event.getPlayer()))
// if (UtilMath.offset(event.getFrom(), event.getTo()) > 0)
// event.setTo(event.getFrom());
}
@EventHandler
@ -1435,69 +1454,61 @@ public class MineStrike extends TeamGame
if (!UtilGear.isMat(player.getItemInHand(), Material.SHEARS))
return;
UtilPlayer.message(player, F.main("Game", F.elem(C.cGreen + "Right-Click") + " with your " + F.elem("Knife") + " to defuse bombs."));
UtilPlayer.message(player, F.main("Game", "Look at the Bomb to defuse it."));
}
@EventHandler
public void defuseBomb(PlayerInteractEvent event)
public void startDefuse()
{
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD))
return;
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true))
{
if (_bomb != null && event.getClickedBlock() == null && _bomb.isBlock(event.getClickedBlock()))
Block block = player.getTargetBlock(null, 5);
if (block == null || !_bomb.isBlock(block))
continue;
if (UtilMath.offset(player.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3)
continue;
if (_bombDefuser != null)
{
UtilPlayer.message(player, F.main("Game", "Hold Right-Click to defuse the Bomb!"));
return;
if (Recharge.Instance.use(player, "Defuse Message", 2000, false, false))
UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb."));
continue;
}
return;
_bombDefuser = player;
_bombDefuser.setExp(0f);
UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb."));
_bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f);
}
if (_bomb == null || event.getClickedBlock() == null || !_bomb.isBlock(event.getClickedBlock()))
{
UtilPlayer.message(player, F.main("Game", "You must be looking at the Bomb to defuse."));
return;
}
if (!UtilEnt.isGrounded(player))
{
UtilPlayer.message(player, F.main("Game", "You can only defuse Bomb while on the ground!"));
return;
}
if (_bombDefuser != null)
{
UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb."));
return;
}
_bombDefuser = player;
_bombDefuser.setExp(0f);
UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb."));
_bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 2f, 1f);
}
@EventHandler
public void defuseBombUpdate(UpdateEvent event)
{
if (_bomb == null)
return;
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
if (_bombDefuser == null)
{
startDefuse();
}
if (_bombDefuser == null)
return;
if (!_bombDefuser.isBlocking())
Block block = _bombDefuser.getTargetBlock(null, 5);
if (block == null || !_bomb.isBlock(block) || UtilMath.offset(_bombDefuser.getLocation(), block.getLocation().add(0.5, 0, 0.5)) > 3)
{
_bombDefuser.setExp(0f);
_bombDefuser = null;
@ -1511,6 +1522,8 @@ public class MineStrike extends TeamGame
_bombDefuser.setExp(Math.min(_bombDefuser.getExp() + defuseRate, 0.99999f));
UtilTitle.display(C.cAqua + C.Bold + "Defusing Bomb", UtilTitle.progress(_bombDefuser.getExp()), 0, 10, 0, _bombDefuser);
if (_bombDefuser.getExp() >= 0.98f)
{
_bomb.defuse();
@ -1722,7 +1735,7 @@ public class MineStrike extends TeamGame
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
UtilTitle.display(winnerLine, _winText, 20, 120, 20);
UtilTitle.display(null, winnerLine, 20, 120, 20);
//Check for total game win
EndCheck();
@ -1781,11 +1794,9 @@ public class MineStrike extends TeamGame
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f);
Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false);
UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ". Open your Inventory to spend it."));
}
//Give Bomb
Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true));
giveBombToPlayer(player);
UtilTitle.display(C.cGreen + "$" + _shopManager.getMoney(player), "Open your Inventory to buy new equipment", 10, 120, 10, player);
}
//Update Scoreboard Teams
for (GameTeam team : GetTeamList())
@ -1968,6 +1979,13 @@ public class MineStrike extends TeamGame
else
player.playSound(player.getLocation(), Sound.NOTE_SNARE_DRUM, 1f, 1f);
}
if (_freezeTime == 0)
{
//Give Bomb
Player bombPlayer = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true));
giveBombToPlayer(bombPlayer);
}
}
@EventHandler
@ -1976,6 +1994,9 @@ public class MineStrike extends TeamGame
if (_freezeTime <= 0)
return;
if (!IsAlive(event.getPlayer()))
return;
if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0)
return;
@ -2089,7 +2110,10 @@ public class MineStrike extends TeamGame
ItemStack stack = _scoped.remove(player);
player.getInventory().setHelmet(stack);
UtilInv.Update(player);
Manager.GetCondition().EndCondition(player, null, "Scope");
player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f);
@ -2446,6 +2470,12 @@ public class MineStrike extends TeamGame
return _bulletInstant;
}
@EventHandler
public void joinMessage(PlayerJoinEvent event)
{
UtilTitle.display(C.cGold + C.Bold + "MineStrike", "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
}
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{

View File

@ -160,7 +160,7 @@ public abstract class StrikeItem
public void fixStackName()
{
ItemMeta meta = _stack.getItemMeta();
meta.setDisplayName((_ownerName == null ? "" : _ownerName + "'s ") + C.Bold + getName() + ChatColor.RESET);
meta.setDisplayName(ChatColor.RESET + (_ownerName == null ? "" : _ownerName + "'s ") + C.Bold + getName() + ChatColor.RESET);
_stack.setItemMeta(meta);
}

View File

@ -163,11 +163,11 @@ public abstract class Gun extends StrikeItem
loc.add(UtilAlg.getDown(player.getLocation().getDirection()).multiply(0.3));
UtilParticle.PlayParticle(ParticleType.EXPLODE, loc, 0, 0, 0, 0, 1);
game.registerBullet(fireBullet(player, game));
//Unscope
if (_gunType == GunType.SNIPER)
game.removeScope(player);
game.registerBullet(fireBullet(player, game));
}
public Bullet fireBullet(Player player, MineStrike game)
@ -297,7 +297,7 @@ public abstract class Gun extends StrikeItem
public void updateWeaponName(Player player)
{
ItemMeta meta = getStack().getItemMeta();
meta.setDisplayName((getOwnerName() == null ? "" : getOwnerName() + "'s ") + C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo);
meta.setDisplayName(ChatColor.RESET + (getOwnerName() == null ? "" : getOwnerName() + "'s ") + C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo);
getStack().setItemMeta(meta);
if (player != null)

View File

@ -75,7 +75,7 @@ public class KitPig extends SmashKit
{
ChatColor.RESET + "When your health drops below 4, you morph",
ChatColor.RESET + "into a Nether Pig. This gives you Speed I,",
ChatColor.RESET + "10 Armor and half Energy costs for skills.",
ChatColor.RESET + "8 Armor and reduces Energy costs by 33%.",
ChatColor.RESET + "",
ChatColor.RESET + "When your health returns to 8, you return",
ChatColor.RESET + "back to Pig Form.",

View File

@ -71,7 +71,7 @@ public class PerkPigBaconBomb extends Perk
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
if (disguise != null && disguise instanceof DisguisePigZombie)
energy = 0.2f;
energy = energy * 0.7f;
//Energy
if (player.getExp() < energy)

View File

@ -73,7 +73,7 @@ public class PerkPigBaconBounce extends Perk implements IThrown
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
if (disguise != null && disguise instanceof DisguisePigZombie)
energy = 0.1f;
energy = energy * 0.7f;
//Energy
if (player.getExp() < energy)

View File

@ -60,10 +60,10 @@ public class PerkPigZombie extends Perk
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
player.getInventory().remove(Material.DIAMOND_HELMET);
player.getInventory().remove(Material.DIAMOND_CHESTPLATE);
player.getInventory().remove(Material.DIAMOND_LEGGINGS);
player.getInventory().remove(Material.DIAMOND_BOOTS);
player.getInventory().remove(Material.IRON_HELMET);
player.getInventory().remove(Material.IRON_CHESTPLATE);
player.getInventory().remove(Material.IRON_LEGGINGS);
player.getInventory().remove(Material.IRON_BOOTS);
//Disguise
DisguisePig disguise = new DisguisePig(player);
@ -93,10 +93,10 @@ public class PerkPigZombie extends Perk
_active.add(player);
//Armor
player.getInventory().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
player.getInventory().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
player.getInventory().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
player.getInventory().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
player.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
//Disguise
DisguisePigZombie disguise = new DisguisePigZombie(player);

View File

@ -0,0 +1,172 @@
package nautilus.game.arcade.managers;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Random;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTitle;
import mineplex.core.reward.IReward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
public class GameLootManager implements Listener
{
private ArcadeManager Manager;
private RewardManager _rewardManager;
private HashSet<Player> _players = new HashSet<Player>();
private long _startTime = 0;
public GameLootManager(ArcadeManager manager)
{
Manager = manager;
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
_rewardManager = new RewardManager(Manager.GetDonation(), Manager.getInventoryManager(),
100, 250,
750, 1500,
2000, 3000,
10000, 20000,
false);
//Chest
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.COMMON, 3));
//Key
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 500));
}
@EventHandler
public void registerPlayers(GameStateChangeEvent event)
{
if (!Manager.IsRewardAchievements())
return;
if (event.GetState() != GameState.Live)
return;
for (Player player : event.GetGame().GetPlayers(true))
_players.add(player);
_startTime = System.currentTimeMillis();
}
@EventHandler
public void unregisterPlayer(PlayerQuitEvent event)
{
_players.remove(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void giveLoot(final GameStateChangeEvent event)
{
if (!Manager.IsRewardAchievements())
return;
if (event.GetState() != GameState.Dead)
return;
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
for (Player player : _players)
{
giveReward(player);
}
}
}, 240);
//Delay after Achievements
_players.clear();
}
public void giveReward(Player player)
{
double chance = (System.currentTimeMillis() - _startTime)/3600000d;
if (Math.random() > chance)
return;
IReward reward = _rewardManager.nextReward(player, null, false, false);
String name = reward.giveReward(player);
String outputName = reward.getRarity().getColor() + name;
//Self Display
UtilTitle.display(C.cDGreen + C.Bold + "Loot", "You found " + outputName, 20, 120, 20, player);
Random _random = new Random();
//Announce
if (reward.getRarity() != RewardRarity.COMMON)
{
Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found the " + reward.getRarity().getName() + " treasure " + outputName));
}
//Effect
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
.with(FireworkEffect.Type.STAR)
.build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
}
else if (reward.getRarity() == RewardRarity.RARE)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
UtilFirework.playFirework(player.getEyeLocation(), effect);
}
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (!event.getPlayer().isOp())
return;
//TODO Remove
if (event.getMessage().startsWith("/lootdebug"))
{
event.getPlayer().sendMessage(C.cGreen + C.Bold + "Loot Debug...");
giveReward(event.getPlayer());
event.setCancelled(true);
}
}
}

View File

@ -253,6 +253,15 @@ public class GameManager implements Listener
event.setCancelled(true);
}
@EventHandler
public void VisibilityRefresh(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
return;
Manager.RefreshPlayers();
}
@EventHandler
public void KitRegister(GameStateChangeEvent event)
{

View File

@ -23,8 +23,15 @@ public class DamageTakenStatTracker extends StatTracker<Game>
return;
addStat(damagee, "Damage Taken", (int) Math.round(event.GetDamage()), false, false);
if (event.GetDamagerPlayer(true) != null)
addStat(damagee, "Damage Taken PvP ", (int) Math.round(event.GetDamage()), false, false);
if (getGame().GetKit(damagee) != null)
{
addStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken", (int) Math.round(event.GetDamage()), false, false);
if (event.GetDamagerPlayer(true) != null)
addStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken PvP ", (int) Math.round(event.GetDamage()), false, false);
}
}
}