Merge remote-tracking branch 'origin/clans-beta' into clans-beta
This commit is contained in:
commit
6f39c072a4
@ -10,6 +10,7 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -354,10 +355,25 @@ public class UtilAlg
|
|||||||
return bestLoc;
|
return bestLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, Entity entity)
|
||||||
|
{
|
||||||
|
if (entity instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
return calculateVelocity(from, to, heightGain, 1.15);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return calculateVelocity(from, to, heightGain, 0.115);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
|
public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
|
||||||
{
|
{
|
||||||
// Gravity of a potion
|
return calculateVelocity(from, to, heightGain, 0.115);
|
||||||
double gravity = 0.115;
|
}
|
||||||
|
|
||||||
|
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, double gravity)
|
||||||
|
{
|
||||||
// Block locations
|
// Block locations
|
||||||
int endGain = to.getBlockY() - from.getBlockY();
|
int endGain = to.getBlockY() - from.getBlockY();
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R4.EntityPlayer;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -118,7 +119,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ShopPageBase<PluginType, ? extends ShopBase<PluginType>> getOpeningPageForPlayer(Player player)
|
protected ShopPageBase<PluginType, ? extends ShopBase<PluginType>> getOpeningPageForPlayer(HumanEntity player)
|
||||||
{
|
{
|
||||||
return _playerPageMap.get(player.getName());
|
return _playerPageMap.get(player.getName());
|
||||||
}
|
}
|
||||||
@ -126,10 +127,19 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event)
|
public void onInventoryClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (_playerPageMap.containsKey(event.getWhoClicked().getName()) && _playerPageMap.get(event.getWhoClicked().getName()).getName().equalsIgnoreCase(event.getInventory().getName()))
|
if (isPlayerInShop(event.getWhoClicked()))
|
||||||
{
|
{
|
||||||
_playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event);
|
ShopPageBase<?,?> page = getOpeningPageForPlayer(event.getWhoClicked());
|
||||||
event.setCancelled(true);
|
|
||||||
|
if (page.matchesInventory(event.getInventory()))
|
||||||
|
{
|
||||||
|
_playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event);
|
||||||
|
|
||||||
|
if (event.getRawSlot() < page.getSize())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +248,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
|||||||
|
|
||||||
protected abstract ShopPageBase<PluginType, ? extends ShopBase<PluginType>> buildPagesFor(Player player);
|
protected abstract ShopPageBase<PluginType, ? extends ShopBase<PluginType>> buildPagesFor(Player player);
|
||||||
|
|
||||||
public boolean isPlayerInShop(Player player)
|
public boolean isPlayerInShop(HumanEntity player)
|
||||||
{
|
{
|
||||||
return _playerPageMap.containsKey(player.getName());
|
return _playerPageMap.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
@ -135,27 +135,25 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
|
|
||||||
public void playerClicked(InventoryClickEvent event)
|
public void playerClicked(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
if (_buttonMap.containsKey(event.getRawSlot()))
|
int rawSlot = event.getRawSlot();
|
||||||
|
|
||||||
|
if (_buttonMap.containsKey(rawSlot))
|
||||||
{
|
{
|
||||||
_buttonMap.get(event.getRawSlot()).onClick(_player, event.getClick());
|
_buttonMap.get(event.getRawSlot()).onClick(_player, event.getClick());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (event.getRawSlot() != -999)
|
else if (rawSlot != -999 && rawSlot < inventory.getSize())
|
||||||
{
|
{
|
||||||
if (event.getRawSlot() < inventory.getSize())
|
playDenySound(_player);
|
||||||
{
|
event.setCancelled(true);
|
||||||
playDenySound(_player);
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesInventory(Inventory newInventory)
|
public boolean matchesInventory(Inventory newInventory)
|
||||||
{
|
{
|
||||||
return newInventory.getTitle() == inventory.getInventoryName();
|
return getName().equalsIgnoreCase(newInventory.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void playerOpened()
|
public void playerOpened()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -116,7 +116,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
|||||||
private Teleport _teleport;
|
private Teleport _teleport;
|
||||||
private ConditionManager _condition;
|
private ConditionManager _condition;
|
||||||
private ClassCombatShop _classShop;
|
private ClassCombatShop _classShop;
|
||||||
|
|
||||||
private ClassManager _classManager;
|
private ClassManager _classManager;
|
||||||
|
public ClassManager getClassManager() { return _classManager; }
|
||||||
|
|
||||||
private WarManager _warManager;
|
private WarManager _warManager;
|
||||||
private ProjectileManager _projectileManager;
|
private ProjectileManager _projectileManager;
|
||||||
private WorldEventManager _worldEvent;
|
private WorldEventManager _worldEvent;
|
||||||
|
@ -4,6 +4,8 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.ClientClass;
|
||||||
|
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
@ -43,6 +45,7 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
|||||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
@ -71,6 +74,23 @@ public class Gameplay extends MiniPlugin
|
|||||||
_foodDecrease = new WeightSet<Boolean>(new Weight<Boolean>(10, true), new Weight<Boolean>(90, false));
|
_foodDecrease = new WeightSet<Boolean>(new Weight<Boolean>(10, true), new Weight<Boolean>(90, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBowShoot(EntityShootBowEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
ClientClass playerClass = _clansManager.getClassManager().Get(player);
|
||||||
|
|
||||||
|
if (!playerClass.IsGameClass(ClassType.Assassin, ClassType.Ranger))
|
||||||
|
{
|
||||||
|
notify(player, "You cannot use bows without the proper class!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void BucketEmpty(PlayerBucketEmptyEvent event)
|
public void BucketEmpty(PlayerBucketEmptyEvent event)
|
||||||
{
|
{
|
||||||
@ -591,4 +611,9 @@ public class Gameplay extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _damageManager;
|
return _damageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void notify(Player player, String message)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Clans", message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,18 +18,11 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.common.util.UtilMath;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.disguise.DisguiseManager;
|
import mineplex.core.disguise.DisguiseManager;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.shop.ShopBase;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
|
||||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
|
||||||
|
|
||||||
public class CombatLogNPC
|
public class CombatLogNPC
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.game.clans.items.smelting;
|
package mineplex.game.clans.items.smelting;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.game.clans.items.GearManager;
|
import mineplex.game.clans.items.GearManager;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -19,7 +21,7 @@ public class Smelter
|
|||||||
player.getInventory().setItemInHand(returns);
|
player.getInventory().setItemInHand(returns);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Notify player of smelt success/failure?
|
notify(player, "You have successfully smelted your item!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack smeltItem(ItemStack item)
|
public static ItemStack smeltItem(ItemStack item)
|
||||||
@ -109,4 +111,9 @@ public class Smelter
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void notify(Player player, String message)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Smelter", message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
package mineplex.game.clans.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.shop.ShopBase;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.game.clans.Clans;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
|
public abstract class ClansShopPage<T extends ShopBase<ClansManager>> extends ShopPageBase<ClansManager, T>
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param plugin
|
||||||
|
* @param shop
|
||||||
|
* @param clientManager
|
||||||
|
* @param donationManager
|
||||||
|
* @param name
|
||||||
|
* @param player
|
||||||
|
* @param slots
|
||||||
|
*/
|
||||||
|
public ClansShopPage(ClansManager plugin, T shop, CoreClientManager clientManager,
|
||||||
|
DonationManager donationManager, String name, Player player, int slots)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, name, player, slots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param plugin
|
||||||
|
* @param shop
|
||||||
|
* @param clientManager
|
||||||
|
* @param donationManager
|
||||||
|
* @param name
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public ClansShopPage(ClansManager plugin, T shop, CoreClientManager clientManager,
|
||||||
|
DonationManager donationManager, String name, Player player)
|
||||||
|
{
|
||||||
|
super(plugin, shop, clientManager, donationManager, name, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)
|
||||||
|
{
|
||||||
|
addShopItem(slot, material, buyPrice, sellPrice, Clans.prettifyName(material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data)
|
||||||
|
{
|
||||||
|
addShopItem(slot, material, buyPrice, sellPrice, Clans.prettifyName(material));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, String displayName)
|
||||||
|
{
|
||||||
|
addShopItem(slot, material, buyPrice, sellPrice, (byte)0, displayName, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data, String displayName, int amount)
|
||||||
|
{
|
||||||
|
PvpItem item = new PvpItem(material, data, 1, displayName, buyPrice, sellPrice, 64);
|
||||||
|
addButton(slot, item, new ShopItemButton<ClansShopPage<?>>(this, buyPrice, sellPrice, material, data, amount));
|
||||||
|
}
|
||||||
|
}
|
@ -1,115 +0,0 @@
|
|||||||
package mineplex.game.clans.shop;
|
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.Callback;
|
|
||||||
import mineplex.core.common.util.F;
|
|
||||||
import mineplex.core.common.util.InventoryUtil;
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.shop.item.IButton;
|
|
||||||
import mineplex.core.shop.item.ShopItem;
|
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
|
||||||
|
|
||||||
public class PvpShopButton<PageType extends ShopPageBase<ClansManager, ?>> implements IButton
|
|
||||||
{
|
|
||||||
protected PageType Page;
|
|
||||||
protected PvpItem Item;
|
|
||||||
|
|
||||||
public PvpShopButton(PageType page, PvpItem item)
|
|
||||||
{
|
|
||||||
Page = page;
|
|
||||||
Item = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(final Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
int balance = Page.getDonationManager().Get(player.getName()).getGold();
|
|
||||||
int cost = Item.getPrice();
|
|
||||||
int tempAmount = Item.getAmount();
|
|
||||||
|
|
||||||
if (clickType == ClickType.SHIFT_LEFT)
|
|
||||||
{
|
|
||||||
cost *= Item.getBulkCount() == -1 ? 1 : Item.getBulkCount();
|
|
||||||
tempAmount = Item.getBulkCount() == -1 ? Item.getAmount() : Item.getBulkCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
final int deliveryAmount = tempAmount;
|
|
||||||
|
|
||||||
if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT)
|
|
||||||
{
|
|
||||||
if (cost > balance)
|
|
||||||
{
|
|
||||||
Page.playDenySound(player);
|
|
||||||
UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "You do not have enough funds to purchase " + deliveryAmount + " " + Item.GetName() + "."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Page.getDonationManager().rewardGold(new Callback<Boolean>()
|
|
||||||
{
|
|
||||||
public void run(Boolean result)
|
|
||||||
{
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Page.playAcceptSound(player);
|
|
||||||
ShopItem item = Item.clone();
|
|
||||||
item.setAmount(deliveryAmount);
|
|
||||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Item.getType(), Item.getData().getData(), Item.getAmount(), Item.GetName(), new String[] {}, player.getName() + " Shop", false));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Page.playDenySound(player);
|
|
||||||
UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "An error occurred processing your purchase."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "Clans", player.getName(), Page.getClientManager().Get(player).getAccountId(), -cost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (clickType == ClickType.RIGHT || clickType == ClickType.SHIFT_RIGHT)
|
|
||||||
{
|
|
||||||
int removed = 1;
|
|
||||||
ItemStack dumbItem = new ItemStack(Item.getType(), Item.getAmount(), Item.getDurability());
|
|
||||||
|
|
||||||
if (InventoryUtil.first((CraftInventory)player.getInventory(), 36, dumbItem, true) == -1)
|
|
||||||
{
|
|
||||||
Page.playDenySound(player);
|
|
||||||
UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "You do not have " + deliveryAmount + " " + Item.GetName() + " in your inventory."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clickType == ClickType.RIGHT)
|
|
||||||
{
|
|
||||||
if (player.getInventory().contains(Item.getType(), Item.getAmount()))
|
|
||||||
InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, dumbItem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
removed = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, dumbItem);
|
|
||||||
|
|
||||||
final int creditAmount = removed * Item.getPrice() / 2;
|
|
||||||
System.out.println("Crediting " + player.getName() + " with " + creditAmount + " gold.");
|
|
||||||
Page.getDonationManager().rewardGold(new Callback<Boolean>()
|
|
||||||
{
|
|
||||||
public void run(Boolean result)
|
|
||||||
{
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
Page.playAcceptSound(player);
|
|
||||||
System.out.println("Credited " + player.getName() + " with " + creditAmount + " gold.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Page.playDenySound(player);
|
|
||||||
UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "An error occurred processing your return."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "Clans", player.getName(), Page.getClientManager().Get(player).getAccountId(), creditAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.game.clans.shop;
|
package mineplex.game.clans.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@ -18,15 +19,20 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
|
|||||||
{
|
{
|
||||||
private int _buyPrice;
|
private int _buyPrice;
|
||||||
private int _sellPrice;
|
private int _sellPrice;
|
||||||
|
private ItemStack _item;
|
||||||
private T _page;
|
private T _page;
|
||||||
private PvpItem _item;
|
|
||||||
|
|
||||||
public ShopItemButton(T page, PvpItem item, int buyPrice, int sellPrice)
|
public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount)
|
||||||
{
|
{
|
||||||
_page = page;
|
_page = page;
|
||||||
_item = item;
|
|
||||||
_sellPrice = sellPrice;
|
_sellPrice = sellPrice;
|
||||||
_buyPrice = buyPrice;
|
_buyPrice = buyPrice;
|
||||||
|
_item = new ItemStack(material, amount, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopItemButton(T page, int buyPrice, int sellPrice, Material material)
|
||||||
|
{
|
||||||
|
this(page, buyPrice, sellPrice, material, (byte)0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,9 +43,8 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
|
|||||||
if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT)
|
if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT)
|
||||||
{
|
{
|
||||||
int amount = 1; // # of items removed/sold from inventory
|
int amount = 1; // # of items removed/sold from inventory
|
||||||
ItemStack dumbItem = new ItemStack(_item.getType(), amount);
|
|
||||||
|
|
||||||
if (!hasItem(player, dumbItem))
|
if (!hasItem(player, _item))
|
||||||
{
|
{
|
||||||
_page.playDenySound(player);
|
_page.playDenySound(player);
|
||||||
notify(player, "You do not have any of the appropriate item in your inventory!");
|
notify(player, "You do not have any of the appropriate item in your inventory!");
|
||||||
@ -48,11 +53,11 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
|
|||||||
|
|
||||||
if (shiftClick)
|
if (shiftClick)
|
||||||
{
|
{
|
||||||
amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, dumbItem);
|
amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, _item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, dumbItem);
|
InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, _item);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reward = amount * _sellPrice;
|
int reward = amount * _sellPrice;
|
||||||
@ -108,7 +113,8 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
|
|||||||
|
|
||||||
private void giftItem(Player player, int amount)
|
private void giftItem(Player player, int amount)
|
||||||
{
|
{
|
||||||
ItemStack item = new ItemStack(_item.getType(), amount);
|
ItemStack item = _item.clone();
|
||||||
|
item.setAmount(amount);
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,6 @@ import mineplex.core.shop.page.ShopPageBase;
|
|||||||
import mineplex.game.clans.clans.ClanInfo;
|
import mineplex.game.clans.clans.ClanInfo;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.economy.GoldManager;
|
import mineplex.game.clans.economy.GoldManager;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
|
||||||
import mineplex.game.clans.shop.PvpShopButton;
|
|
||||||
import mineplex.game.clans.shop.building.BuildingPage;
|
|
||||||
|
|
||||||
public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
||||||
{
|
{
|
||||||
@ -121,11 +118,6 @@ public class BankPage extends ShopPageBase<ClansManager, BankShop>
|
|||||||
addButton(3, shopItem, button);
|
addButton(3, shopItem, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPvpItem(int slot, PvpItem item)
|
|
||||||
{
|
|
||||||
addButton(slot, item, new PvpShopButton<BankPage>(this, item));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasEnoughGold()
|
public boolean hasEnoughGold()
|
||||||
{
|
{
|
||||||
return getPlayerGold() >= TOKEN_VALUE;
|
return getPlayerGold() >= TOKEN_VALUE;
|
||||||
|
@ -37,6 +37,7 @@ public class CashInButton implements IButton
|
|||||||
GoldToken token = (GoldToken) cursorItem;
|
GoldToken token = (GoldToken) cursorItem;
|
||||||
GoldManager.getInstance().cashIn(player, token);
|
GoldManager.getInstance().cashIn(player, token);
|
||||||
player.setItemOnCursor(null); // Delete the gold token on cursor
|
player.setItemOnCursor(null); // Delete the gold token on cursor
|
||||||
|
_page.playAcceptSound(player);
|
||||||
_page.refresh();
|
_page.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@ import org.bukkit.Material;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.game.clans.Clans;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.shop.ClansShopPage;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
import mineplex.game.clans.shop.PvpItem;
|
||||||
import mineplex.game.clans.shop.PvpShopButton;
|
import mineplex.game.clans.shop.ShopItemButton;
|
||||||
|
|
||||||
public class BuildingPage extends ShopPageBase<ClansManager, BuildingShop>
|
public class BuildingPage extends ClansShopPage<BuildingShop>
|
||||||
{
|
{
|
||||||
public BuildingPage(ClansManager plugin, BuildingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
public BuildingPage(ClansManager plugin, BuildingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
@ -21,29 +23,24 @@ public class BuildingPage extends ShopPageBase<ClansManager, BuildingShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
addPvpItem(1, new PvpItem(Material.STONE, (byte)0, 1, "Stone", 100, 20, 64));
|
addShopItem(1, Material.STONE, 100, 20);
|
||||||
addPvpItem(2, new PvpItem(Material.SMOOTH_BRICK, (byte)0, 1, "Stone Bricks", 100, 20, 64));
|
addShopItem(2, Material.SMOOTH_BRICK, 100, 20);
|
||||||
addPvpItem(3, new PvpItem(Material.SMOOTH_BRICK, (byte)2, 1, "Cracked Stone Bricks", 25, 5, 64));
|
addShopItem(3, Material.SMOOTH_BRICK, 25, 5, (byte)2);
|
||||||
addPvpItem(4, new PvpItem(Material.COBBLESTONE, (byte)0, 1, "Cobblestone", 25, 5, 64));
|
addShopItem(4, Material.COBBLESTONE, 25, 5);
|
||||||
|
|
||||||
addPvpItem(10, new PvpItem(Material.LOG, (byte)0, 1, "Oak Wood", 50, 10, 64));
|
addShopItem(10, Material.LOG, 50, 10, (byte) 0);
|
||||||
addPvpItem(11, new PvpItem(Material.LOG, (byte)1, 1, "Spruce Wood", 50, 10, 64));
|
addShopItem(11, Material.LOG, 50, 10, (byte) 1);
|
||||||
addPvpItem(12, new PvpItem(Material.LOG, (byte)2, 1, "Birch Wood", 50, 10, 64));
|
addShopItem(12, Material.LOG, 50, 10, (byte) 2);
|
||||||
addPvpItem(13, new PvpItem(Material.LOG, (byte)3, 1, "Jungle Wood", 50, 10, 64));
|
addShopItem(13, Material.LOG, 50, 10, (byte) 3);
|
||||||
addPvpItem(14, new PvpItem(Material.LOG_2, (byte)0, 1, "Acacia Wood", 50, 10, 64));
|
addShopItem(14, Material.LOG_2, 50, 10, (byte) 0);
|
||||||
addPvpItem(15, new PvpItem(Material.LOG_2, (byte)1, 1, "Dark Oak Wood", 50, 10, 64));
|
addShopItem(15, Material.LOG_2, 50, 10, (byte) 1);
|
||||||
|
|
||||||
addPvpItem(19, new PvpItem(Material.SAND, (byte)0, 1, "Sand", 20, 4, 64));
|
addShopItem(19, Material.SAND, 20, 4);
|
||||||
addPvpItem(20, new PvpItem(Material.GLASS, (byte)0, 1, "Glass", 30, 6, 64));
|
addShopItem(20, Material.GLASS, 30, 6);
|
||||||
addPvpItem(21, new PvpItem(Material.SANDSTONE, (byte)0, 1, "Sandstone", 80, 16, 64));
|
addShopItem(21, Material.SANDSTONE, 80, 16);
|
||||||
addPvpItem(22, new PvpItem(Material.DIRT, (byte)0, 1, "Dirt", 10, 2, 64));
|
addShopItem(22, Material.DIRT, 10, 2);
|
||||||
addPvpItem(23, new PvpItem(Material.NETHER_BRICK, (byte)0, 1, "Netherbrick", 50, 10, 64));
|
addShopItem(23, Material.NETHER_BRICK, 50, 10);
|
||||||
addPvpItem(24, new PvpItem(Material.QUARTZ_BLOCK, (byte)0, 1, "Quartz Block", 75, 15, 64));
|
addShopItem(24, Material.QUARTZ_BLOCK, 75, 15);
|
||||||
addPvpItem(25, new PvpItem(Material.CLAY, (byte)0, 1, "Clay Block", 30, 6, 64));
|
addShopItem(25, Material.CLAY, 30, 6);
|
||||||
}
|
|
||||||
|
|
||||||
public void addPvpItem(int slot, PvpItem item)
|
|
||||||
{
|
|
||||||
addButton(slot, item, new PvpShopButton<BuildingPage>(this, item));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.game.clans.Clans;
|
import mineplex.game.clans.Clans;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.shop.ClansShopPage;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
import mineplex.game.clans.shop.PvpItem;
|
||||||
import mineplex.game.clans.shop.ShopItemButton;
|
import mineplex.game.clans.shop.ShopItemButton;
|
||||||
|
import mineplex.game.clans.shop.mining.MiningShop;
|
||||||
|
|
||||||
public class FarmingPage extends ShopPageBase<ClansManager, FarmingShop>
|
public class FarmingPage extends ClansShopPage<FarmingShop>
|
||||||
{
|
{
|
||||||
public FarmingPage(ClansManager plugin, FarmingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
public FarmingPage(ClansManager plugin, FarmingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
@ -38,10 +40,4 @@ public class FarmingPage extends ShopPageBase<ClansManager, FarmingShop>
|
|||||||
addShopItem(15, Material.ROTTEN_FLESH, 5, 5);
|
addShopItem(15, Material.ROTTEN_FLESH, 5, 5);
|
||||||
addShopItem(16, Material.SPIDER_EYE, 5, 5);
|
addShopItem(16, Material.SPIDER_EYE, 5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)
|
|
||||||
{
|
|
||||||
PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64);
|
|
||||||
addButton(slot, item, new ShopItemButton<FarmingPage>(this, item, buyPrice, sellPrice));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,11 @@ import mineplex.core.donation.DonationManager;
|
|||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.game.clans.Clans;
|
import mineplex.game.clans.Clans;
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
import mineplex.game.clans.shop.ClansShopPage;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
import mineplex.game.clans.shop.PvpItem;
|
||||||
import mineplex.game.clans.shop.ShopItemButton;
|
import mineplex.game.clans.shop.ShopItemButton;
|
||||||
|
|
||||||
public class MiningPage extends ShopPageBase<ClansManager, MiningShop>
|
public class MiningPage extends ClansShopPage<MiningShop>
|
||||||
{
|
{
|
||||||
public MiningPage(ClansManager plugin, MiningShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
public MiningPage(ClansManager plugin, MiningShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
@ -30,10 +31,4 @@ public class MiningPage extends ShopPageBase<ClansManager, MiningShop>
|
|||||||
addShopItem(6, Material.REDSTONE, 10, 2);
|
addShopItem(6, Material.REDSTONE, 10, 2);
|
||||||
addShopItem(7, Material.LAPIS_BLOCK, 500, 100);
|
addShopItem(7, Material.LAPIS_BLOCK, 500, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addShopItem(int slot, Material material, int buyPrice, int sellPrice)
|
|
||||||
{
|
|
||||||
PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64);
|
|
||||||
addButton(slot, item, new ShopItemButton<MiningPage>(this, item, buyPrice, sellPrice));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,10 @@ import org.bukkit.Material;
|
|||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
import mineplex.game.clans.shop.ClansShopPage;
|
||||||
import mineplex.game.clans.shop.PvpShopButton;
|
|
||||||
|
|
||||||
public class PvpPage extends ShopPageBase<ClansManager, PvpShop>
|
public class PvpPage extends ClansShopPage<PvpShop>
|
||||||
{
|
{
|
||||||
public PvpPage(ClansManager plugin, PvpShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
public PvpPage(ClansManager plugin, PvpShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
@ -21,49 +19,45 @@ public class PvpPage extends ShopPageBase<ClansManager, PvpShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void buildPage()
|
protected void buildPage()
|
||||||
{
|
{
|
||||||
addPvpItem(9, new PvpItem(Material.GOLD_HELMET, (byte)0, 1, "Mage Helmet", 875, 175, 4));
|
addShopItem(9, Material.GOLD_HELMET, 875, 175, "Mage Helmet");
|
||||||
addPvpItem(18, new PvpItem(Material.GOLD_CHESTPLATE, (byte)0, 1, "Mage Chestplate", 1400, 280, 4));
|
addShopItem(18, Material.GOLD_CHESTPLATE, 1400, 280, "Mage Chestplate");
|
||||||
addPvpItem(27, new PvpItem(Material.GOLD_LEGGINGS, (byte)0, 1, "Mage Leggings", 1225, 245, 4));
|
addShopItem(27, Material.GOLD_LEGGINGS, 1225, 245, "Mage Leggings");
|
||||||
addPvpItem(36, new PvpItem(Material.GOLD_BOOTS, (byte)0, 1, "Mage Boots", 700, 140, 4));
|
addShopItem(36, Material.GOLD_BOOTS, 700, 140, "Mage Boots");
|
||||||
|
|
||||||
addPvpItem(10, new PvpItem(Material.LEATHER_HELMET, (byte)0, 1, "Assassin Helmet", 625, 125, 4));
|
addShopItem(10, Material.LEATHER_HELMET, 625, 125, "Assassin Helmet");
|
||||||
addPvpItem(19, new PvpItem(Material.LEATHER_CHESTPLATE, (byte)0, 1, "Assassin Chestplate", 1000, 200, 4));
|
addShopItem(19, Material.LEATHER_CHESTPLATE, 1000, 200, "Assassin Chestplate");
|
||||||
addPvpItem(28, new PvpItem(Material.LEATHER_LEGGINGS, (byte)0, 1, "Assassin Leggings", 875, 125, 4));
|
addShopItem(28, Material.LEATHER_LEGGINGS, 875, 125, "Assassin Leggings");
|
||||||
addPvpItem(37, new PvpItem(Material.LEATHER_BOOTS, (byte)0, 1, "Assassin Boots", 500, 100, 4));
|
addShopItem(37, Material.LEATHER_BOOTS, 500, 100, "Assassin Boots");
|
||||||
|
|
||||||
addPvpItem(11, new PvpItem(Material.CHAINMAIL_HELMET, (byte)0, 1, "Ranger Helmet", 750, 150, 4));
|
addShopItem(11, Material.CHAINMAIL_HELMET, 750, 150, "Ranger Helmet");
|
||||||
addPvpItem(20, new PvpItem(Material.CHAINMAIL_CHESTPLATE, (byte)0, 1, "Ranger Chestplate", 1200, 240, 4));
|
addShopItem(20, Material.CHAINMAIL_CHESTPLATE, 1200, 240, "Ranger Chestplate");
|
||||||
addPvpItem(29, new PvpItem(Material.CHAINMAIL_LEGGINGS, (byte)0, 1, "Ranger Leggings", 1050, 210, 4));
|
addShopItem(29, Material.CHAINMAIL_LEGGINGS, 1050, 210, "Ranger Leggings");
|
||||||
addPvpItem(38, new PvpItem(Material.CHAINMAIL_BOOTS, (byte)0, 1, "Ranger Boots", 600, 120, 4));
|
addShopItem(38, Material.CHAINMAIL_BOOTS, 600, 120, "Ranger Boots");
|
||||||
|
|
||||||
addPvpItem(12, new PvpItem(Material.IRON_HELMET, (byte)0, 1, "Knight Helmet", 750, 150, 4));
|
addShopItem(12, Material.IRON_HELMET, 750, 150, "Knight Helmet");
|
||||||
addPvpItem(21, new PvpItem(Material.IRON_CHESTPLATE, (byte)0, 1, "Knight Chestplate", 1200, 240, 4));
|
addShopItem(21, Material.IRON_CHESTPLATE, 1200, 240, "Knight Chestplate");
|
||||||
addPvpItem(30, new PvpItem(Material.IRON_LEGGINGS, (byte)0, 1, "Knight Leggings", 1050, 210, 4));
|
addShopItem(30, Material.IRON_LEGGINGS, 1050, 210, "Knight Leggings");
|
||||||
addPvpItem(39, new PvpItem(Material.IRON_BOOTS, (byte)0, 1, "Knight Boots", 600, 120, 4));
|
addShopItem(39, Material.IRON_BOOTS, 600, 120, "Knight Boots");
|
||||||
|
|
||||||
addPvpItem(13, new PvpItem(Material.DIAMOND_HELMET, (byte)0, 1, "Brute Helmet", 1000, 200, 4));
|
addShopItem(13, Material.DIAMOND_HELMET, 1000, 200, "Brute Helmet");
|
||||||
addPvpItem(22, new PvpItem(Material.DIAMOND_CHESTPLATE, (byte)0, 1, "Brute Chestplate", 1600, 320, 4));
|
addShopItem(22, Material.DIAMOND_CHESTPLATE, 1600, 320, "Brute Chestplate");
|
||||||
addPvpItem(31, new PvpItem(Material.DIAMOND_LEGGINGS, (byte)0, 1, "Brute Leggings", 1400, 280, 4));
|
addShopItem(31, Material.DIAMOND_LEGGINGS, 1400, 280, "Brute Leggings");
|
||||||
addPvpItem(40, new PvpItem(Material.DIAMOND_BOOTS, (byte)0, 1, "Brute Boots", 800, 160, 4));
|
addShopItem(40, Material.DIAMOND_BOOTS, 800, 160, "Brute Boots");
|
||||||
|
|
||||||
addPvpItem(15, new PvpItem(Material.IRON_SWORD, (byte)0, 1, "Iron Sword", 320, 160, 4));
|
addShopItem(15, Material.IRON_SWORD, 320, 160, "Iron Sword");
|
||||||
addPvpItem(16, new PvpItem(Material.DIAMOND_SWORD, (byte)0, 1, "Power Sword", 800, 400, 4));
|
addShopItem(16, Material.DIAMOND_SWORD, 800, 400, "Power Sword");
|
||||||
addPvpItem(17, new PvpItem(Material.GOLD_SWORD, (byte)0, 1, "Booster Sword", 800, 400, 4));
|
addShopItem(17, Material.GOLD_SWORD, 800, 400, "Booster Sword");
|
||||||
|
|
||||||
addPvpItem(24, new PvpItem(Material.IRON_AXE, (byte)0, 1, "Iron Axe", 470, 95, 4));
|
addShopItem(24, Material.IRON_AXE, 470, 95, "Iron Axe");
|
||||||
addPvpItem(25, new PvpItem(Material.DIAMOND_AXE, (byte)0, 1, "Power Axe", 800, 400, 4));
|
addShopItem(25, Material.DIAMOND_AXE, 800, 400, "Power Axe");
|
||||||
addPvpItem(26, new PvpItem(Material.GOLD_AXE, (byte)0, 1, "Booster Axe", 800, 400, 4));
|
addShopItem(26, Material.GOLD_AXE, 800, 400, "Booster Axe");
|
||||||
|
|
||||||
addPvpItem(33, new PvpItem(Material.BOW, (byte)0, 1, "Standard Bow", 175, 35, 4));
|
addShopItem(33, Material.BOW, 175, 35, "Standard Bow");
|
||||||
addPvpItem(34, new PvpItem(Material.ARROW, (byte)0, 16, "Arrows", 10, 2));
|
addShopItem(34, Material.ARROW, 10, 2, (byte)0, "Arrows", 16);
|
||||||
|
|
||||||
addPvpItem(51, new PvpItem(Material.ENCHANTMENT_TABLE, (byte)0, 1, "Class Shop", 30000));
|
//addPvpItem(51, new PvpItem(Material.ENCHANTMENT_TABLE, (byte)0, 1, "Class Shop", 30000));
|
||||||
addPvpItem(52, new PvpItem(Material.TNT, (byte)0, 1, "TNT", 30000, 1));
|
//addPvpItem(52, new PvpItem(Material.TNT, (byte)0, 1, "TNT", 30000, 1));
|
||||||
addPvpItem(53, new PvpItem(Material.BREWING_STAND_ITEM, (byte)0, 1, "TNT Generator", 300000));
|
//addPvpItem(53, new PvpItem(Material.BREWING_STAND_ITEM, (byte)0, 1, "TNT Generator", 300000));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPvpItem(int slot, PvpItem item)
|
|
||||||
{
|
|
||||||
addButton(slot, item, new PvpShopButton<PvpPage>(this, item));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package mineplex.game.clans.spawn;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -30,6 +31,7 @@ import mineplex.core.MiniPlugin;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -45,6 +47,7 @@ public class Spawn extends MiniPlugin
|
|||||||
public static final int SPAWN_RADIUS = 32;
|
public static final int SPAWN_RADIUS = 32;
|
||||||
public static final int SHOP_RADIUS = 48;
|
public static final int SHOP_RADIUS = 48;
|
||||||
public static final String COMBAT_TAG_NAME = "Unsafe";
|
public static final String COMBAT_TAG_NAME = "Unsafe";
|
||||||
|
public static final long COMBAT_TAG_DURATION = 15000;
|
||||||
|
|
||||||
private static Spawn _instance;
|
private static Spawn _instance;
|
||||||
public static Spawn getInstance() { return _instance; }
|
public static Spawn getInstance() { return _instance; }
|
||||||
@ -103,14 +106,20 @@ public class Spawn extends MiniPlugin
|
|||||||
if (_clansManager.getClanUtility().isSafe(cur.getLocation()))
|
if (_clansManager.getClanUtility().isSafe(cur.getLocation()))
|
||||||
{
|
{
|
||||||
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat();
|
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat();
|
||||||
|
long duration = System.currentTimeMillis() - lastDamager;
|
||||||
|
|
||||||
if (!UtilTime.elapsed(lastDamager, 15000))
|
if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION))
|
||||||
{
|
{
|
||||||
UtilPlayer.message(cur, F.main("Safe Zone", "You are not safe for " +
|
String message = ChatColor.RED + "Unsafe for "
|
||||||
F.time(UtilTime.convertString(15000 - (System.currentTimeMillis() - lastDamager), 1, TimeUnit.FIT))));
|
+ ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT));
|
||||||
|
|
||||||
|
UtilTextMiddle.display(null, message, 0, 20, 0, cur);
|
||||||
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
|
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
|
||||||
}
|
}
|
||||||
|
else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600))
|
||||||
|
{
|
||||||
|
UtilTextMiddle.display(null, ChatColor.GREEN + "Safe!", 0, 60, 20, cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,8 +200,6 @@ public class Spawn extends MiniPlugin
|
|||||||
{
|
{
|
||||||
int size = event.getDrops().size();
|
int size = event.getDrops().size();
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
|
|
||||||
System.out.println("Cleared " + size + " to " + event.getDrops().size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,11 +216,9 @@ public class Spawn extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (isInSpawn(event.getBlock().getLocation()) && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return;
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
if (isInSpawn(event.getBlock().getLocation()) || isInSpawn(event.getPlayer()))
|
||||||
}
|
|
||||||
else if (isInSpawn(event.getPlayer()) && event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,7 @@ import org.bukkit.Material;
|
|||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.game.clans.Clans;
|
|
||||||
import mineplex.game.clans.clans.ClansManager;
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.shop.PvpItem;
|
|
||||||
import mineplex.game.clans.shop.PvpShopButton;
|
|
||||||
import mineplex.game.clans.spawn.Spawn;
|
import mineplex.game.clans.spawn.Spawn;
|
||||||
|
|
||||||
public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
public class TravelPage extends ShopPageBase<ClansManager, TravelShop>
|
||||||
|
@ -475,12 +475,20 @@ public class ClientClass
|
|||||||
return _gameClass;
|
return _gameClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean IsGameClass(ClassType type)
|
public boolean IsGameClass(ClassType... types)
|
||||||
{
|
{
|
||||||
if (GetGameClass() == null)
|
if (GetGameClass() == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return GetGameClass().GetType() == type;
|
for (ClassType type : types)
|
||||||
|
{
|
||||||
|
if (type == GetGameClass().GetType())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<ISkill> GetSkills()
|
public Collection<ISkill> GetSkills()
|
||||||
|
@ -100,7 +100,7 @@ public class HeavyArrows extends Skill
|
|||||||
if (level == 0) return;
|
if (level == 0) return;
|
||||||
|
|
||||||
//Knockback
|
//Knockback
|
||||||
event.AddKnockback(GetName(), 1.1 + (0.1 * level));
|
event.AddKnockback(GetName(), 0.55d + (0.1 * level));
|
||||||
event.AddMod(GetName(), GetName(), 1 + level, true);
|
event.AddMod(GetName(), GetName(), 1 + level, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public abstract class WorldEvent implements Listener
|
|||||||
private List<EventCreature> _creatures;
|
private List<EventCreature> _creatures;
|
||||||
// Block Restore
|
// Block Restore
|
||||||
private BlockRestoreMap _blocks;
|
private BlockRestoreMap _blocks;
|
||||||
private boolean _instantSchematic;
|
private boolean _isArcade;
|
||||||
private double _difficulty = 1;
|
private double _difficulty = 1;
|
||||||
|
|
||||||
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
|
public WorldEvent(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager, String name,
|
||||||
@ -99,9 +99,9 @@ public abstract class WorldEvent implements Listener
|
|||||||
_difficulty = difficulty;
|
_difficulty = difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstantSchematic(boolean instantSchematic)
|
public void setArcadeGame(boolean isArcade)
|
||||||
{
|
{
|
||||||
_instantSchematic = instantSchematic;
|
_isArcade = isArcade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadMap()
|
public void loadMap()
|
||||||
@ -289,16 +289,19 @@ public abstract class WorldEvent implements Listener
|
|||||||
@Override
|
@Override
|
||||||
public void run(List<BlockData> data)
|
public void run(List<BlockData> data)
|
||||||
{
|
{
|
||||||
for (BlockData blockData : data)
|
if (!_isArcade)
|
||||||
{
|
{
|
||||||
_blocks.addBlockData(blockData);
|
for (BlockData blockData : data)
|
||||||
|
{
|
||||||
|
_blocks.addBlockData(blockData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete.run();
|
onComplete.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
task.setBlocksPerTick(_instantSchematic ? 2000000 : 100);
|
task.setBlocksPerTick(_isArcade ? 2000000 : 100);
|
||||||
task.start();
|
task.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -25,6 +24,7 @@ import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake;
|
|||||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura;
|
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemExplodingAura;
|
||||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack;
|
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemMeleeAttack;
|
||||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture;
|
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemRupture;
|
||||||
|
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSlam;
|
||||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode;
|
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemWallExplode;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
@ -52,6 +52,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
|||||||
private ArrayList<GolemAbility> _currentAbilities = new ArrayList<GolemAbility>();
|
private ArrayList<GolemAbility> _currentAbilities = new ArrayList<GolemAbility>();
|
||||||
private double _canCaveIn = 450;
|
private double _canCaveIn = 450;
|
||||||
private Vector _afkWalk = new Vector();
|
private Vector _afkWalk = new Vector();
|
||||||
|
private long _lastSlam;
|
||||||
|
|
||||||
public GolemCreature(GolemBoss boss, Location location, double maxHealth)
|
public GolemCreature(GolemBoss boss, Location location, double maxHealth)
|
||||||
{
|
{
|
||||||
@ -197,7 +198,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Rumble
|
{ // Rupture
|
||||||
ArrayList<Player> players = getPlayers(dist, 30);
|
ArrayList<Player> players = getPlayers(dist, 30);
|
||||||
|
|
||||||
if (!players.isEmpty())
|
if (!players.isEmpty())
|
||||||
@ -206,6 +207,15 @@ public class GolemCreature extends EventCreature<IronGolem>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ // Slam
|
||||||
|
ArrayList<Player> players = getPlayers(dist, 30);
|
||||||
|
|
||||||
|
if (!players.isEmpty() && UtilTime.elapsed(_lastSlam, 20000))
|
||||||
|
{
|
||||||
|
weight.put(GolemSlam.class, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_canCaveIn <= 0) // Cave in
|
if (_canCaveIn <= 0) // Cave in
|
||||||
{
|
{
|
||||||
ArrayList<Player> players = getPlayers(dist, 30);
|
ArrayList<Player> players = getPlayers(dist, 30);
|
||||||
@ -318,10 +328,14 @@ public class GolemCreature extends EventCreature<IronGolem>
|
|||||||
{
|
{
|
||||||
_canCaveIn = 450;
|
_canCaveIn = 450;
|
||||||
}
|
}
|
||||||
|
else if (ability instanceof GolemSlam)
|
||||||
|
{
|
||||||
|
_lastSlam = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(ability, _boss.getPlugin());
|
Bukkit.getPluginManager().registerEvents(ability, _boss.getPlugin());
|
||||||
|
|
||||||
// Bukkit.broadcastMessage("Ability: " + _currentAbility.getClass().getSimpleName());
|
// Bukkit.broadcastMessage("Prepare fair maidens for " + ability.getClass().getSimpleName() + "!");
|
||||||
|
|
||||||
System.out.print("Golem boss is using " + ability.getClass().getSimpleName());
|
System.out.print("Golem boss is using " + ability.getClass().getSimpleName());
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import org.bukkit.entity.FallingBlock;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -216,6 +217,15 @@ public class GolemCaveIn extends GolemAbility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPhysics(BlockPhysicsEvent event)
|
||||||
|
{
|
||||||
|
if (_blocks.contains(event.getBlock()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
@ -243,23 +253,6 @@ public class GolemCaveIn extends GolemAbility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks = UtilShapes.getSphereBlocks(l, 3, 3, true);
|
|
||||||
|
|
||||||
for (Location loc : blocks)
|
|
||||||
{
|
|
||||||
if (loc.getBlockY() >= l.getBlockY())
|
|
||||||
{
|
|
||||||
Block b = loc.getBlock();
|
|
||||||
|
|
||||||
if (b.getType() == Material.AIR)
|
|
||||||
{
|
|
||||||
_blocks.add(b);
|
|
||||||
|
|
||||||
b.setType(Material.FENCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_tick % 5 == 0)
|
if (_tick % 5 == 0)
|
||||||
|
@ -105,7 +105,7 @@ public class GolemExplodingAura extends GolemAbility
|
|||||||
@Override
|
@Override
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
if (_tick < 25 * 25)
|
if (_tick < 25 * 25 && getGolem().getHealth() > 30)
|
||||||
{
|
{
|
||||||
double angle = (2 * Math.PI) / UtilMath.random.nextDouble();
|
double angle = (2 * Math.PI) / UtilMath.random.nextDouble();
|
||||||
double x = 1.7 * Math.cos(angle);
|
double x = 1.7 * Math.cos(angle);
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -36,6 +37,7 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||||
|
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||||
|
|
||||||
public class GolemRupture extends GolemAbility
|
public class GolemRupture extends GolemAbility
|
||||||
{
|
{
|
||||||
@ -191,6 +193,12 @@ public class GolemRupture extends GolemAbility
|
|||||||
target.setY(loc.getY());
|
target.setY(loc.getY());
|
||||||
|
|
||||||
_ruptures.add(new HashMap.SimpleEntry(loc, target));
|
_ruptures.add(new HashMap.SimpleEntry(loc, target));
|
||||||
|
|
||||||
|
UtilEnt.CreatureLook(getEntity(), player.getLocation());
|
||||||
|
|
||||||
|
EntityIronGolem golem = ((CraftIronGolem) getEntity()).getHandle();
|
||||||
|
|
||||||
|
golem.world.broadcastEntityEffect(golem, (byte) 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,259 @@
|
|||||||
|
package mineplex.minecraft.game.core.boss.ironwizard.abilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class GolemSlam extends GolemAbility
|
||||||
|
{
|
||||||
|
private ArrayList<Item> _items = new ArrayList<Item>();
|
||||||
|
private int _ticksFinished;
|
||||||
|
private int _stage;
|
||||||
|
private Vector _target;
|
||||||
|
private int _ticksJumped;
|
||||||
|
|
||||||
|
public GolemSlam(GolemCreature creature)
|
||||||
|
{
|
||||||
|
super(creature);
|
||||||
|
|
||||||
|
Player target = getTarget();
|
||||||
|
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
_target = UtilAlg.calculateVelocity(getLocation().toVector(),
|
||||||
|
target.getLocation().toVector().setY(getLocation().getY()), 2, getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMove()
|
||||||
|
{
|
||||||
|
return !UtilEnt.isGrounded(getEntity()) && _stage == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasFinished()
|
||||||
|
{
|
||||||
|
return _stage == 2 && --_ticksFinished <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFinished()
|
||||||
|
{
|
||||||
|
for (Item item : _items)
|
||||||
|
{
|
||||||
|
item.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick()
|
||||||
|
{
|
||||||
|
Entity entity = getEntity();
|
||||||
|
|
||||||
|
if (_stage == 0)
|
||||||
|
{
|
||||||
|
UtilEnt.CreatureLook(getEntity(), getLocation().add(_target));
|
||||||
|
|
||||||
|
entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_THROW, 4, 0);
|
||||||
|
|
||||||
|
entity.setVelocity(_target);
|
||||||
|
_stage++;
|
||||||
|
}
|
||||||
|
else if (_stage == 1)
|
||||||
|
{
|
||||||
|
_ticksJumped++;
|
||||||
|
|
||||||
|
if (_ticksJumped > 4 && getLocation().subtract(0, 0.2, 0).getBlock().getType() != Material.AIR)
|
||||||
|
{
|
||||||
|
explodeRupture(getLocation());
|
||||||
|
|
||||||
|
_stage = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void HopperPickup(InventoryPickupItemEvent event)
|
||||||
|
{
|
||||||
|
if (_items.contains(event.getItem()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ItemDestroy(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_items.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Iterator<Item> itemIterator = _items.iterator();
|
||||||
|
|
||||||
|
while (itemIterator.hasNext())
|
||||||
|
{
|
||||||
|
Item item = itemIterator.next();
|
||||||
|
|
||||||
|
if (item.isDead() || !item.isValid())
|
||||||
|
{
|
||||||
|
item.remove();
|
||||||
|
itemIterator.remove();
|
||||||
|
}
|
||||||
|
else if (UtilEnt.isGrounded(item) || item.getTicksLived() > 60)
|
||||||
|
{
|
||||||
|
item.getWorld().playEffect(item.getLocation(), Effect.STEP_SOUND, item.getItemStack().getTypeId());
|
||||||
|
item.remove();
|
||||||
|
itemIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inProgress()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getTarget()
|
||||||
|
{
|
||||||
|
Player target = null;
|
||||||
|
double dist = 0;
|
||||||
|
|
||||||
|
for (Player player : UtilPlayer.getNearby(getLocation(), 30, true))
|
||||||
|
{
|
||||||
|
if (!player.hasLineOfSight(getEntity()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
double d = player.getLocation().distance(getLocation());
|
||||||
|
|
||||||
|
if (d < 10)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null || dist > d)
|
||||||
|
{
|
||||||
|
target = player;
|
||||||
|
dist = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void explodeRupture(Location loc)
|
||||||
|
{
|
||||||
|
loc.add(0, 1.1, 0);
|
||||||
|
loc.setX(loc.getBlockX() + 0.5);
|
||||||
|
loc.setZ(loc.getBlockZ() + 0.5);
|
||||||
|
|
||||||
|
// Fling
|
||||||
|
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(loc, 3.5);
|
||||||
|
for (LivingEntity cur : targets.keySet())
|
||||||
|
{
|
||||||
|
if (cur.equals(getEntity()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Velocity
|
||||||
|
UtilAction.velocity(cur,
|
||||||
|
UtilAlg.getTrajectory2d(loc.toVector().add(new Vector(0.5, 0, 0.5)), cur.getLocation().toVector()),
|
||||||
|
0.8 + 0.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.4, true);
|
||||||
|
|
||||||
|
// Condition
|
||||||
|
getGolem().getEvent().getCondition().Factory().Falling("Rupture", cur, getEntity(), 10, false, true);
|
||||||
|
|
||||||
|
// Damage Event
|
||||||
|
getGolem().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM,
|
||||||
|
4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard", "Rupture");
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
|
||||||
|
for (int x = -3; x <= 3; x++)
|
||||||
|
{
|
||||||
|
for (int z = -3; z <= 3; z++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y <= 1; y++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
if (Math.sqrt(x * x + z * z + y * y) <= 3)
|
||||||
|
{
|
||||||
|
blocks.add(loc.clone().add(x, y, z).getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.shuffle(blocks);
|
||||||
|
|
||||||
|
// Blocks
|
||||||
|
int done = 0;
|
||||||
|
Iterator<Block> itel = blocks.iterator();
|
||||||
|
|
||||||
|
while (done < 30 && itel.hasNext())
|
||||||
|
{
|
||||||
|
Block block = itel.next();
|
||||||
|
|
||||||
|
Vector vec = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize();
|
||||||
|
|
||||||
|
if (!UtilBlock.airFoliage(block))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Add Directional
|
||||||
|
vec.add(UtilAlg.getTrajectory(loc.getBlock().getLocation(), block.getLocation().add(0.5, 0, 0.5)));
|
||||||
|
|
||||||
|
// Add Up
|
||||||
|
vec.add(new Vector(0, 1.6, 0));
|
||||||
|
|
||||||
|
vec.normalize();
|
||||||
|
|
||||||
|
// Scale
|
||||||
|
vec.multiply(0.1 + 0.3 * Math.random() + 0.6);
|
||||||
|
|
||||||
|
// Block!
|
||||||
|
Item item = loc.getWorld().dropItem(block.getLocation().add(0.5, 0, 0.5), new ItemStack(Material.DIRT.getId(), 0));
|
||||||
|
item.setVelocity(vec);
|
||||||
|
item.setPickupDelay(50000);
|
||||||
|
_items.add(item);
|
||||||
|
|
||||||
|
// Effect
|
||||||
|
loc.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId());
|
||||||
|
|
||||||
|
done++;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ticksFinished = 20;
|
||||||
|
}
|
||||||
|
}
|
@ -248,6 +248,8 @@ public class BossBattles extends TeamGame
|
|||||||
bossDisplay.start();
|
bossDisplay.start();
|
||||||
bossDisplay.spawnHologram();
|
bossDisplay.spawnHologram();
|
||||||
|
|
||||||
|
_displays.add(bossDisplay);
|
||||||
|
|
||||||
System.out.print(
|
System.out.print(
|
||||||
"Registered " + bossDisplay.getClass().getSimpleName());
|
"Registered " + bossDisplay.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
@ -327,7 +329,7 @@ public class BossBattles extends TeamGame
|
|||||||
_currentBoss = createInstance(boss.getBoss(),
|
_currentBoss = createInstance(boss.getBoss(),
|
||||||
new Location(WorldData.World, 0, 6, 0));
|
new Location(WorldData.World, 0, 6, 0));
|
||||||
|
|
||||||
_currentBoss.setInstantSchematic(true);
|
_currentBoss.setArcadeGame(true);
|
||||||
_currentBoss.setDifficulty(0.6);
|
_currentBoss.setDifficulty(0.6);
|
||||||
|
|
||||||
_currentBoss.loadMap();
|
_currentBoss.loadMap();
|
||||||
|
Loading…
Reference in New Issue
Block a user