Merge remote-tracking branch 'origin/clans-beta' into clans-beta
# Conflicts: # Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java
This commit is contained in:
commit
63e580404c
@ -35,6 +35,7 @@ import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -115,7 +116,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private static final TimeZone TIME_ZONE = TimeZone.getDefault();
|
||||
private static ClansManager _instance;
|
||||
public static ClansManager getInstance() { return _instance; }
|
||||
|
||||
public DonationManager donationManager;
|
||||
private String _serverName;
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
@ -287,6 +288,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.donationManager=donationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -480,6 +483,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
{
|
||||
clanInfo.playerOnline(player);
|
||||
}
|
||||
|
||||
donationManager.rewardGold(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
}
|
||||
}, event.getPlayer().getName(), event.getPlayer().getName(), _clientManager.getAccountId(event.getPlayer()), 133137);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,83 @@
|
||||
package mineplex.game.clans.clans.loot;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
public class CustomItemLoot implements ILoot
|
||||
{
|
||||
private Material _material;
|
||||
private byte _data;
|
||||
private int _min;
|
||||
private int _max;
|
||||
private String _displayName;
|
||||
private String[] _lore;
|
||||
|
||||
public CustomItemLoot(Material material)
|
||||
{
|
||||
this(material, 1, 1);
|
||||
}
|
||||
|
||||
public CustomItemLoot(Material material, int min, int max)
|
||||
{
|
||||
this(material, (byte) 0, min, max, null, new String[] {});
|
||||
}
|
||||
|
||||
public CustomItemLoot(Material material, int min, int max, String displayName, String... lore)
|
||||
{
|
||||
this(material, (byte) 0, min, max, displayName, lore);
|
||||
}
|
||||
|
||||
public CustomItemLoot(Material material, byte data, int min, int max, String displayName, String... lore)
|
||||
{
|
||||
_material = material;
|
||||
_data = data;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_displayName = displayName;
|
||||
_lore = lore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropLoot(Location location)
|
||||
{
|
||||
location.getWorld().dropItemNaturally(location, getItemStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
ItemStack stack = new ItemStack(_material, UtilMath.rRange(_min, _max), _data);
|
||||
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
|
||||
if (meta == null)
|
||||
{
|
||||
meta = Bukkit.getItemFactory().getItemMeta(_material);
|
||||
}
|
||||
|
||||
if (meta != null && _displayName != null)
|
||||
{
|
||||
meta.setDisplayName(_displayName);
|
||||
}
|
||||
|
||||
if (meta != null && _lore != null && _lore.length > 0)
|
||||
{
|
||||
meta.setLore(Arrays.asList(_lore));
|
||||
}
|
||||
|
||||
if (meta != null)
|
||||
{
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
@ -12,64 +12,98 @@ public class LootManager
|
||||
{
|
||||
private GearManager _gearManager;
|
||||
private GoldManager _goldManager;
|
||||
|
||||
|
||||
private WeightSet<ILoot> _commonSet;
|
||||
private WeightSet<ILoot> _rareSet;
|
||||
|
||||
|
||||
public LootManager(GearManager gearManager, GoldManager goldManager)
|
||||
{
|
||||
_gearManager = gearManager;
|
||||
_goldManager = goldManager;
|
||||
|
||||
|
||||
_commonSet = new WeightSet<ILoot>();
|
||||
_rareSet = new WeightSet<ILoot>();
|
||||
|
||||
|
||||
populateCommon();
|
||||
populateRare();
|
||||
}
|
||||
|
||||
|
||||
private void populateCommon()
|
||||
{
|
||||
// Food
|
||||
_commonSet.add(5, new ItemLoot(Material.CARROT, 1, 5));
|
||||
_commonSet.add(5, new ItemLoot(Material.APPLE, 1, 3));
|
||||
_commonSet.add(5, new ItemLoot(Material.COOKED_BEEF, 1, 3));
|
||||
_commonSet.add(5, new ItemLoot(Material.RAW_BEEF, 1, 4));
|
||||
_commonSet.add(5, new ItemLoot(Material.POTATO_ITEM, 1, 5));
|
||||
_commonSet.add(5, new ItemLoot(Material.CARROT, 1, 5));
|
||||
_commonSet.add(5, new ItemLoot(Material.APPLE, 1, 3));
|
||||
_commonSet.add(5, new ItemLoot(Material.COOKED_BEEF, 1, 3));
|
||||
_commonSet.add(5, new ItemLoot(Material.RAW_BEEF, 1, 4));
|
||||
_commonSet.add(5, new ItemLoot(Material.POTATO_ITEM, 1, 5));
|
||||
|
||||
// Armor
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.GOLD_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.GOLD_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.GOLD_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.GOLD_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.LEATHER_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.LEATHER_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.LEATHER_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.LEATHER_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.DIAMOND_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.DIAMOND_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.DIAMOND_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.DIAMOND_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.CHAINMAIL_HELMET, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.CHAINMAIL_CHESTPLATE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.CHAINMAIL_LEGGINGS, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.CHAINMAIL_BOOTS, 1, 1));
|
||||
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_AXE, 1, 1));
|
||||
_commonSet.add(2, new ItemLoot(Material.IRON_SWORD, 1, 1));
|
||||
|
||||
_commonSet.add(2, new CustomItemLoot(Material.STONE_SWORD, 1, 1, "Standard Sword"));
|
||||
_commonSet.add(2, new CustomItemLoot(Material.STONE_AXE, 1, 1, "Standard Axe"));
|
||||
_commonSet.add(2, new CustomItemLoot(Material.GOLD_SWORD, 1, 1, "Booster Sword"));
|
||||
_commonSet.add(2, new CustomItemLoot(Material.GOLD_AXE, 1, 1, "Booster Axe"));
|
||||
_commonSet.add(2, new CustomItemLoot(Material.DIAMOND_SWORD, 1, 1, "Power Sword"));
|
||||
_commonSet.add(2, new CustomItemLoot(Material.DIAMOND_AXE, 1, 1, "Power Axe"));
|
||||
|
||||
_commonSet.add(1, new ItemLoot(Material.WOOD_SWORD, 1, 1));
|
||||
_commonSet.add(1, new ItemLoot(Material.WOOD_AXE, 1, 1));
|
||||
|
||||
// Gear
|
||||
_commonSet.add(1, new GearLoot(_gearManager));
|
||||
|
||||
|
||||
// Gold
|
||||
// _commonSet.add(5, new GoldLoot(_goldManager, 100, 1000));
|
||||
// _commonSet.add(5, new GoldLoot(_goldManager, 100, 1000));
|
||||
_commonSet.add(1, new GoldTokenLoot(5000, 10000));
|
||||
}
|
||||
|
||||
|
||||
private void populateRare()
|
||||
{
|
||||
// Gear
|
||||
_rareSet.add(100, new GearLoot(_gearManager));
|
||||
_rareSet.add(10, new GoldTokenLoot(50000, 100000));
|
||||
}
|
||||
|
||||
|
||||
public void dropCommon(Location location)
|
||||
{
|
||||
_commonSet.generateRandom().dropLoot(location);
|
||||
}
|
||||
|
||||
|
||||
public void dropRare(Location location)
|
||||
{
|
||||
_rareSet.generateRandom().dropLoot(location);
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getRareItemStack()
|
||||
{
|
||||
return _rareSet.generateRandom().getItemStack();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class KingHill extends WorldEvent
|
||||
_scoreMap = new HashMap<ClanInfo, CaptureData>();
|
||||
_hill = LOADED_HILLS.get(0);
|
||||
_nextLootDrop = System.currentTimeMillis() + getRandomRange(300000, 600000);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,11 +87,8 @@ public class KingHill extends WorldEvent
|
||||
@Override
|
||||
protected void customTick()
|
||||
{
|
||||
// uh who wrote this code? below code == [divide ticksRunning by 1, if
|
||||
// remainder is 0 do tickHill()]
|
||||
// if (getTicksRunning() % 1 == 0)
|
||||
|
||||
tickHill();
|
||||
|
||||
if (System.currentTimeMillis() > _nextLootDrop)
|
||||
{
|
||||
// Drop Loot!
|
||||
|
@ -19,6 +19,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -228,19 +229,19 @@ public class GoldManager extends MiniPlugin
|
||||
|
||||
public void dropGold(Location location, int amount)
|
||||
{
|
||||
dropGold(location, amount, 0.1);
|
||||
dropGold(location, amount, 0.15);
|
||||
}
|
||||
|
||||
public void dropGold(Location location, int amount, double velMult)
|
||||
{
|
||||
int count = amount / 1000;
|
||||
int extraGold = amount % 1000;
|
||||
int count = amount / 700;
|
||||
int extraGold = amount % 700;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
double x = Math.random() * 2 * Math.PI;
|
||||
Vector velocity = new Vector(Math.sin(x), 0, Math.cos(x));
|
||||
dropGold(location, 1000, velocity, velMult, 100);
|
||||
dropGold(location, 1000, velocity, velMult);
|
||||
}
|
||||
|
||||
// Drop Extra
|
||||
@ -248,51 +249,20 @@ public class GoldManager extends MiniPlugin
|
||||
{
|
||||
double x = Math.random() * 2 * Math.PI;
|
||||
Vector velocity = new Vector(Math.sin(x), 0, Math.cos(x));
|
||||
dropGold(location, extraGold, velocity, velMult, 100);
|
||||
dropGold(location, extraGold, velocity, velMult);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropGold(Location location, int amount, Vector velocity, double velMult, int goldPerEntity)
|
||||
private void dropGold(Location location, int amount, Vector velocity, double velMult)
|
||||
{
|
||||
int count = amount / goldPerEntity;
|
||||
int extraGold = amount % goldPerEntity;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Item item = location.getWorld().dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
||||
item.setPickupDelay(40);
|
||||
item.setMetadata(META_STRING, new FixedMetadataValue(getPlugin(), goldPerEntity));
|
||||
_itemSet.add(item);
|
||||
|
||||
if (item.getItemStack().getItemMeta() == null)
|
||||
{
|
||||
item.getItemStack().setItemMeta(Bukkit.getItemFactory().getItemMeta(item.getItemStack().getType()));
|
||||
}
|
||||
|
||||
item.getItemStack().getItemMeta().setDisplayName(UUID.randomUUID().toString());
|
||||
|
||||
// Velocity
|
||||
UtilAction.velocity(item, velocity, velMult, false, 0, 0.2, 0.2, false);
|
||||
}
|
||||
|
||||
if (extraGold > 0)
|
||||
{
|
||||
Item item = location.getWorld().dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
||||
item.setPickupDelay(40);
|
||||
item.setMetadata(META_STRING, new FixedMetadataValue(getPlugin(), extraGold));
|
||||
|
||||
if (item.getItemStack().getItemMeta() == null)
|
||||
{
|
||||
item.getItemStack().setItemMeta(Bukkit.getItemFactory().getItemMeta(item.getItemStack().getType()));
|
||||
}
|
||||
|
||||
item.getItemStack().getItemMeta().setDisplayName(UUID.randomUUID().toString());
|
||||
item.setMetadata(META_STRING, new FixedMetadataValue(getPlugin(), amount));
|
||||
|
||||
_itemSet.add(item);
|
||||
|
||||
// Velocity
|
||||
UtilAction.velocity(item, velocity, velMult, false, 0, 0.2, 0.2, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void purchaseToken(final Player player, final int tokenValue)
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.game.clans.items.attributes.AttributeContainer;
|
||||
import mineplex.game.clans.items.attributes.ItemAttribute;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -52,6 +53,8 @@ public class CustomItem
|
||||
|
||||
private String _uuid;
|
||||
|
||||
private boolean _dullEnchantment;
|
||||
|
||||
public String getUuid()
|
||||
{
|
||||
return _uuid;
|
||||
@ -112,7 +115,11 @@ public class CustomItem
|
||||
ItemStack item = new ItemStack(_material, amount);
|
||||
update(item);
|
||||
|
||||
// TODO: Add non-descript enchantment for glowing efect?
|
||||
if (_dullEnchantment)
|
||||
{
|
||||
UtilInv.addDullEnchantment(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -121,6 +128,16 @@ public class CustomItem
|
||||
return toItemStack(1);
|
||||
}
|
||||
|
||||
public void addDullEnchantment()
|
||||
{
|
||||
_dullEnchantment = true;
|
||||
}
|
||||
|
||||
public void removeDullEnchantment()
|
||||
{
|
||||
_dullEnchantment = false;
|
||||
}
|
||||
|
||||
public void onInteract(PlayerInteractEvent event)
|
||||
{
|
||||
for (ItemAttribute attribute : _attributes.getAttributes())
|
||||
|
@ -247,34 +247,42 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
public CustomItem generateItem()
|
||||
{
|
||||
int attributeCount = _attributeWeights.generateRandom();
|
||||
ItemType itemType = _typeWeights.generateRandom();
|
||||
CustomItem item = generateItem(itemType);
|
||||
|
||||
ItemType itemType = _typeWeights.generateRandom();
|
||||
|
||||
RareItemFactory factory = RareItemFactory.begin(itemType);
|
||||
|
||||
if (itemType == ItemType.LEGENDARY)
|
||||
{
|
||||
factory.setLegendary(_legendaryWeights.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.ARMOR)
|
||||
{
|
||||
factory.setType(_armorTypes.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.WEAPON)
|
||||
{
|
||||
factory.setType(_weaponTypes.generateRandom());
|
||||
}
|
||||
else if (itemType == ItemType.BOW)
|
||||
{
|
||||
factory.setType(Material.BOW);
|
||||
}
|
||||
|
||||
if (itemType != ItemType.LEGENDARY) // Only non-legendaries have attributes
|
||||
{
|
||||
generateAttributes(item.getAttributes(), itemType, attributeCount);
|
||||
}
|
||||
AttributeContainer attributes = new AttributeContainer();
|
||||
generateAttributes(attributes, itemType, attributeCount);
|
||||
|
||||
if (attributes.getSuperPrefix()!= null){
|
||||
factory.setSuperPrefix(attributes.getSuperPrefix().getClass());
|
||||
}
|
||||
if (attributes.getPrefix() != null){
|
||||
factory.setPrefix(attributes.getPrefix().getClass());
|
||||
}if (attributes.getSuffix() != null){
|
||||
factory.setSuffix(attributes.getSuffix().getClass());
|
||||
} }
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private CustomItem generateItem(ItemType itemType)
|
||||
{
|
||||
switch(itemType)
|
||||
{
|
||||
case LEGENDARY: // Legendary weapon
|
||||
Class<? extends LegendaryItem> legendaryClass = _legendaryWeights.generateRandom();
|
||||
System.out.println("Legendary: " + legendaryClass.getName());
|
||||
return instantiate(legendaryClass);
|
||||
case WEAPON: // Sword or axe
|
||||
return new CustomItem(_weaponTypes.generateRandom());
|
||||
case ARMOR: // Helmet, chestplate, leggings, or boots
|
||||
return new CustomItem(_armorTypes.generateRandom());
|
||||
case BOW: // A bow
|
||||
return new CustomItem(Material.BOW);
|
||||
default:
|
||||
return null;// Never reached, yet required for compilation purposes.
|
||||
}
|
||||
return factory.getWrapper();
|
||||
}
|
||||
|
||||
private void generateAttributes(AttributeContainer container, ItemType type, int count)
|
||||
|
@ -48,6 +48,7 @@ public class RareItemFactory
|
||||
public RareItemFactory setType(Material type)
|
||||
{
|
||||
_item = new CustomItem(type);
|
||||
_item.addDullEnchantment();
|
||||
_material = type;
|
||||
return this;
|
||||
}
|
||||
@ -59,6 +60,7 @@ public class RareItemFactory
|
||||
try
|
||||
{
|
||||
_item = legendary.newInstance();
|
||||
_item.addDullEnchantment();
|
||||
_material = _item.getMaterial();
|
||||
}
|
||||
catch (InstantiationException | IllegalAccessException e)
|
||||
@ -118,8 +120,6 @@ public class RareItemFactory
|
||||
|
||||
ItemStack item = _item.toItemStack();
|
||||
|
||||
UtilInv.addDullEnchantment(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user