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

This commit is contained in:
CoderTim 2014-09-08 16:28:50 -04:00
commit b341089cfe
24 changed files with 214 additions and 151 deletions

View File

@ -31,7 +31,7 @@ public class MorphBlaze extends MorphGadget
C.cPurple + "Unlocked with Hero Rank",
},
-1,
Material.FIRE, (byte)0);
Material.BLAZE_POWDER, (byte)0);
}
@Override

View File

@ -13,9 +13,9 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.reward.ITreasureReward;
/**
@ -214,14 +214,15 @@ public class Treasure
ChestData data = getChestData(block);
if (data != null && !data.isOpened())
{
data.setOpened(true);
data.getReward().giveReward(_player);
String text = data.getReward().giveReward(_player);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data);
data.setOpened(true);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, text);
_animations.add(chestOpenTask);
if (isFinished())
{
// TODO figure out finish event
System.out.println("finished");
}
}

View File

@ -1,27 +1,16 @@
package mineplex.core.treasure;
import java.util.Iterator;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.block.CraftBlock;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
@ -29,10 +18,10 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.reward.rewards.GemReward;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -54,12 +43,18 @@ public class TreasureManager extends MiniPlugin
_playerTreasureMap = new NautHashMap<Player, Treasure>();
_rewardManager = new RewardManager();
// Very Rare
_rewardManager.addReward(new GemReward(donationManager, 1000, 2000, 1000, RewardRarity.VERY_RARE));
// Rare
_rewardManager.addReward(new GemReward(donationManager, 500, 1000, 1000, RewardRarity.RARE));
// Uncommon
_rewardManager.addReward(new GemReward(donationManager, 100, 500, 1000, RewardRarity.UNCOMMON));
// Common
_rewardManager.addReward(new GemReward(donationManager, 0, 100, 1000, RewardRarity.COMMON));
_rewardManager.addReward(new GemReward(_donationManager, 5));
_rewardManager.addReward(new GemReward(_donationManager, 50));
_rewardManager.addReward(new GemReward(_donationManager, 200));
_rewardManager.addReward(new GemReward(_donationManager, 500));
_rewardManager.addReward(new GemReward(_donationManager, 5000));
}
@Override

View File

@ -8,7 +8,6 @@ import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.common.util.UtilServer;
@ -22,14 +21,16 @@ import mineplex.core.treasure.Treasure;
public class ChestOpenAnimation extends Animation
{
private ChestData _chestData;
private String _text;
private Item _itemEntity;
private SimpleHologram _hologram;
public ChestOpenAnimation(Treasure treasure, ChestData chestData)
public ChestOpenAnimation(Treasure treasure, ChestData chestData, String text)
{
super(treasure);
_chestData = chestData;
_text = text;
// Send chest open packet
Block block = chestData.getBlock();
@ -53,7 +54,7 @@ public class ChestOpenAnimation extends Animation
}
else if (getTicks() == 15)
{
_hologram = new SimpleHologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _chestData.getReward().getText());
_hologram = new SimpleHologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _text);
_hologram.spawnWithPackets();
_chestData.setFinishedOpen(true);

View File

@ -8,13 +8,22 @@ import org.bukkit.inventory.ItemStack;
*/
public interface ITreasureReward
{
public String getText();
public ItemStack getItem();
public RewardRarity getRarity();
public void giveReward(Player player);
/**
* Give the reward to the player.
*
* @return String detailing the reward. This will be shown to the player
*/
public String giveReward(Player player);
public boolean canGiveReward(Player player);
/**
* This is used to weight rewards across different rarities. Rewards with a larger weight
* will have a higher chance of being selected
*/
public int getWeight();
}

View File

@ -37,12 +37,6 @@ public class RewardManager
public ITreasureReward nextReward(Player player)
{
/*
This is potentially blocking, need to make sure each RewardRarity has at least one reward that
players can recieve no matter what. May need to touch on this later.
*/
//todo
double rand = _random.nextDouble();
RewardRarity rarity;
@ -69,15 +63,34 @@ public class RewardManager
List<ITreasureReward> treasureList = _treasureMap.get(rarity);
ITreasureReward reward;
do
int totalWeight = 0;
ArrayList<ITreasureReward> possibleRewards = new ArrayList<ITreasureReward>();
for (ITreasureReward treasure : treasureList)
{
reward = treasureList.get(_random.nextInt(treasureList.size()));
if (treasure.canGiveReward(player))
{
possibleRewards.add(treasure);
totalWeight += treasure.getWeight();
}
}
while (!reward.canGiveReward(player));
return reward;
if (totalWeight > 0)
{
int weight = _random.nextInt(totalWeight);
int currentWeight = 0;
for (ITreasureReward reward : possibleRewards)
{
if (weight <= currentWeight)
return reward;
weight += reward.getWeight();
}
}
return null;
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.inventory.ItemStack;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-08.
*/
public abstract class AbstractReward implements ITreasureReward
{
protected static final Random RANDOM = new Random();
private ItemStack _itemStack;
private RewardRarity _rarity;
private int _weight;
public AbstractReward(ItemStack itemStack, RewardRarity rarity, int weight)
{
_itemStack = itemStack;
_rarity = rarity;
_weight = weight;
}
@Override
public ItemStack getItem()
{
return _itemStack;
}
@Override
public int getWeight()
{
return _weight;
}
@Override
public RewardRarity getRarity()
{
return _rarity;
}
}

View File

@ -0,0 +1,66 @@
package mineplex.core.treasure.reward.rewards;
/**
* Created by shaun on 2014-09-08.
*/
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;
/**
* Created by shaun on 2014-09-08.
*/
public class CoinReward extends AbstractReward
{
private DonationManager _donationManager;
private Random _random;
private int _minCoinCount;
private int _maxCoinCount;
public CoinReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
{
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
}
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
{
super(new ItemStack(Material.EMERALD), rarity, weight);
_donationManager = donationManager;
_minCoinCount = minCoinCount;
_maxCoinCount = maxCoinCount;
_random = random;
}
@Override
public String giveReward(Player player)
{
int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount;
_donationManager.RewardGems(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
}
}, "Treasure Chest", player.getName(), gemsToReward);
return C.cYellow + gemsToReward + " Coins";
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -1,45 +0,0 @@
package mineplex.core.treasure.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by Shaun on 9/2/2014.
*/
public class ExampleReward implements ITreasureReward
{
@Override
public String getText()
{
return C.cGreen + "100 Gems";
}
@Override
public ItemStack getItem()
{
return new ItemStack(Material.EMERALD);
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.COMMON;
}
@Override
public void giveReward(Player player)
{
player.sendMessage("give example reward...");
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -3,49 +3,31 @@ package mineplex.core.treasure.reward.rewards;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.treasure.reward.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GadgetReward implements ITreasureReward
public class GadgetReward extends AbstractReward
{
private Gadget _gadget;
private DonationManager _donationManager;
private Gadget _gadget;
public GadgetReward(Gadget gadget, DonationManager donationManager)
public GadgetReward(Gadget gadget, DonationManager donationManager, RewardRarity rarity, int weight)
{
super(new ItemStack(gadget.GetDisplayMaterial()), rarity, weight);
_gadget = gadget;
_donationManager = donationManager;
}
@Override
public String getText()
{
return _gadget.GetDisplayName();
}
@Override
public ItemStack getItem()
{
return new ItemStack(_gadget.GetDisplayMaterial());
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.VERY_RARE;
}
@Override
public void giveReward(Player player)
public String giveReward(Player player)
{
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_gadget.GetName());
return _gadget.GetDisplayName();
}
@Override
@ -53,4 +35,5 @@ public class GadgetReward implements ITreasureReward
{
return !(_donationManager.Get(player.getName()).OwnsUnknownPackage(_gadget.GetName()));
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.treasure.reward.rewards;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -7,47 +9,38 @@ 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.ITreasureReward;
import mineplex.core.treasure.reward.RewardRarity;
/**
* Created by shaun on 2014-09-04.
*/
public class GemReward implements ITreasureReward
public class GemReward extends AbstractReward
{
private DonationManager _donationManager;
private ItemStack _itemStack;
private int _gemAmount;
private Random _random;
private int _minGemCount;
private int _maxGemCount;
public GemReward(DonationManager donationManager, int gemAmount)
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
{
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
}
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random)
{
super(new ItemStack(Material.EMERALD), rarity, weight);
_donationManager = donationManager;
_gemAmount = gemAmount;
_minGemCount = minGemCount;
_maxGemCount = maxGemCount;
_itemStack = new ItemStack(Material.EMERALD);
_random = random;
}
@Override
public String getText()
public String giveReward(Player player)
{
return C.cGreen + _gemAmount + " Gems";
}
int gemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
@Override
public ItemStack getItem()
{
return _itemStack;
}
@Override
public RewardRarity getRarity()
{
return RewardRarity.COMMON;
}
@Override
public void giveReward(Player player)
{
_donationManager.RewardGems(new Callback<Boolean>()
{
@Override
@ -55,7 +48,9 @@ public class GemReward implements ITreasureReward
{
}
}, "Treasure Chest", player.getName(), _gemAmount);
}, "Treasure Chest", player.getName(), gemsToReward);
return C.cGreen + gemsToReward + " Gems";
}
@Override
@ -63,4 +58,5 @@ public class GemReward implements ITreasureReward
{
return true;
}
}

View File

@ -203,7 +203,7 @@ public class Immolate extends Skill
int level = getLevel(cur);
//Fire
Item fire = cur.getWorld().dropItem(cur.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.FIRE));
Item fire = cur.getWorld().dropItem(cur.getLocation().add(0, 0.5, 0), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
fire.setVelocity(new Vector((Math.random() - 0.5)/3,Math.random()/3,(Math.random() - 0.5)/3));
Factory.Fire().Add(fire, cur, 2, 0, 0.25 + (level * 0.25), 0, GetName());

View File

@ -103,7 +103,7 @@ public class Inferno extends SkillActive
}
//Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.FIRE));
Item fire = cur.getWorld().dropItem(cur.getEyeLocation().add(cur.getLocation().getDirection()), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Factory.Fire().Add(fire, cur, 0.7, 0, 0.3 + (0.1 * level), 1, GetName());
fire.teleport(cur.getEyeLocation());

View File

@ -121,7 +121,7 @@ public class NapalmShot extends SkillActive
for (int i = 0 ; i < 8 + (8 * level) ; i++)
{
Item fire = proj.getWorld().dropItemNaturally(proj.getLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE, 1));
Item fire = proj.getWorld().dropItemNaturally(proj.getLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER, 1));
Factory.Fire().Add(fire, damager, 16, 0.25, 2, 0, GetName());
fire.setVelocity(fire.getVelocity().multiply(1 + (0.15 * level)));
}

View File

@ -105,13 +105,13 @@ public class CustomBuildPage extends ShopPageBase<ClassShopManager, ClassCombatS
if (i != 0)
{
AddButton(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true), new EditAndSaveCustomBuildButton(this, customBuild));
AddButton(slot + 36, new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true), new DeleteCustomBuildButton(this, customBuild));
AddButton(slot + 36, new ShopItem(Material.TNT, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true), new DeleteCustomBuildButton(this, customBuild));
}
}
else
{
getInventory().setItem(slot + 18, new ShopItem(Material.ANVIL, "Edit Build", new String[] { }, 1, locked, true).getHandle());
getInventory().setItem(slot + 36, new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true).getHandle());
getInventory().setItem(slot + 36, new ShopItem(Material.TNT, "Delete Build", new String[] { "§rIt will never come back..."}, 1, locked, true).getHandle());
}
slot += 2;

View File

@ -413,7 +413,7 @@ public class Halloween extends SoloGame
{
Material type = event.getEntity().getItemStack().getType();
if (type == Material.DIAMOND_AXE || type == Material.FIRE || type == Material.SNOW_BALL)
if (type == Material.DIAMOND_AXE || type == Material.BLAZE_POWDER || type == Material.SNOW_BALL)
return;
event.setCancelled(true);

View File

@ -146,7 +146,7 @@ public class PumpkinKing extends CreatureBase<Skeleton>
return;
//Effect
Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.FIRE, (byte)0, 10, false);
Host.Manager.GetBlood().Effects(event.GetDamageeEntity().getLocation(), 10, 0.2, null, 0f, 0f, Material.BLAZE_POWDER, (byte)0, 10, false);
event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 51);
//Remove

View File

@ -58,7 +58,6 @@ public class Armor extends StrikeItem
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}

View File

@ -20,7 +20,7 @@ public class AWP extends Gun
10, 3, //Clip Size, Spare Ammo
1500, 3600, //ROF, Reload Time
115, 0, 0.97, //Damage, Dropoff, Armor Penetration
0.1, 0.1, //COF Min, COF Max
0.14, 0.14, //COF Min, COF Max
0, 0, //COF Inc per Bullet, COF Dec per Second
Material.GOLD_SPADE, Sound.DRINK);

View File

@ -71,7 +71,7 @@ public class KitSkeletalHorse extends SmashKit
}));
if (Manager.GetGame().GetState() == GameState.Recruit)
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.FIRE, (byte)0, 1,
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER, (byte)0, 1,
C.cYellow + C.Bold + "Passive" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Infernal Horror",
new String[]
{

View File

@ -149,7 +149,7 @@ public class PerkBoneRush extends Perk implements IThrown
}
else
{
Item fire = player.getWorld().dropItem(player.getLocation().add(Math.random()*5 - 2.5, Math.random()*3, Math.random()*5 - 2.5), new ItemStack(Material.FIRE));
Item fire = player.getWorld().dropItem(player.getLocation().add(Math.random()*5 - 2.5, Math.random()*3, Math.random()*5 - 2.5), new ItemStack(Material.BLAZE_POWDER));
UtilAction.velocity(fire, dir, 0.6 + 0.3 * Math.random(), false, 0, 0.1 + Math.random() * 0.05, 0.3, false);
Manager.GetProjectile().AddThrow(fire, player, this, -1, true, true, true, false, 1d);
}
@ -169,7 +169,7 @@ public class PerkBoneRush extends Perk implements IThrown
@Override
public void Collide(LivingEntity target, Block block, ProjectileUser data)
{
boolean burning = ((Item)data.GetThrown()).getItemStack().getType() == Material.FIRE;
boolean burning = ((Item)data.GetThrown()).getItemStack().getType() == Material.BLAZE_POWDER;
data.GetThrown().remove();

View File

@ -110,7 +110,7 @@ public class PerkFlamingSword extends Perk
}
//Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE));
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno");
fire.teleport(cur.getEyeLocation());

View File

@ -100,7 +100,7 @@ public class PerkInferno extends Perk
}
//Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE));
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno");
fire.teleport(cur.getEyeLocation());

View File

@ -85,7 +85,7 @@ public class PerkInfernoFinn extends Perk
}
//Fire
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE));
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER));
Manager.GetFire().Add(fire, cur, 0.7, 0, 2, 2, "Inferno");
fire.teleport(cur.getEyeLocation());