Supply drop, loot, small fixes
This commit is contained in:
parent
323921dcfa
commit
6a4c9061fa
@ -19,6 +19,7 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.give.Give;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.ignore.IgnoreManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -116,12 +117,13 @@ public class Clans extends JavaPlugin
|
||||
new Explosion(this, blockRestore);
|
||||
new FriendManager(this, _clientManager, preferenceManager, portal);
|
||||
new InventoryManager(this, _clientManager);
|
||||
HologramManager hologramManager = new HologramManager(this);
|
||||
|
||||
// Enable custom-gear related managers
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
GearManager customGear = new GearManager(this, packetHandler);
|
||||
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, chat, customGear, webServerAddress);
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, chat, customGear, hologramManager, webServerAddress);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
|
@ -6,8 +6,6 @@ import java.util.TimeZone;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -46,6 +44,7 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.gui.SimpleGuiItem;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -130,6 +129,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private Teleport _teleport;
|
||||
private ConditionManager _condition;
|
||||
private ClassCombatShop _classShop;
|
||||
private HologramManager _hologramManager;
|
||||
private GearManager _gearManager;
|
||||
private LootManager _lootManager;
|
||||
|
||||
private ClassManager _classManager;
|
||||
public ClassManager getClassManager() { return _classManager; }
|
||||
@ -161,7 +163,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
public String[] denyClan = new String[] {
|
||||
"neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"};
|
||||
|
||||
public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, String webServerAddress)
|
||||
public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
@ -169,6 +171,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_serverName = serverName;
|
||||
_clientManager = clientManager;
|
||||
_combatManager = new CombatManager(plugin);
|
||||
_hologramManager = hologramManager;
|
||||
|
||||
_chat = chat;
|
||||
_blockRestore = blockRestore;
|
||||
@ -176,14 +179,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_warManager = new WarManager(plugin, this);
|
||||
|
||||
_goldManager = new GoldManager(this, _clientManager, donationManager);
|
||||
LootManager lootManager = new LootManager(gearManager, _goldManager);
|
||||
_gearManager = gearManager;
|
||||
_lootManager = new LootManager(gearManager, _goldManager);
|
||||
PacketHandler packetHandler = new PacketHandler(plugin);
|
||||
_disguiseManager = new DisguiseManager(plugin, packetHandler);
|
||||
Creature creature = new Creature(plugin);
|
||||
_npcManager = new NpcManager(plugin, creature);
|
||||
_condition = new SkillConditionManager(plugin);
|
||||
DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
|
||||
_worldEvent = new WorldEventManager(plugin, this, damageManager, lootManager, blockRestore);
|
||||
_worldEvent = new WorldEventManager(plugin, this, damageManager, _lootManager, blockRestore);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager);
|
||||
new MurderManager(plugin, this);
|
||||
@ -713,6 +717,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
return _worldEvent;
|
||||
}
|
||||
|
||||
public HologramManager getHologramManager()
|
||||
{
|
||||
return _hologramManager;
|
||||
}
|
||||
|
||||
public GearManager getGearManager()
|
||||
{
|
||||
return _gearManager;
|
||||
}
|
||||
|
||||
public LootManager getLootManager()
|
||||
{
|
||||
return _lootManager;
|
||||
}
|
||||
|
||||
public Chat getChat()
|
||||
{
|
||||
return _chat;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.loot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
|
||||
@ -18,4 +19,10 @@ public class GearLoot implements ILoot
|
||||
{
|
||||
_gearManager.spawnItem(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return _gearManager.generateItem().toItemStack();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.loot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
@ -24,4 +25,10 @@ public class GoldLoot implements ILoot
|
||||
int count = _min + UtilMath.r(_max - _min);
|
||||
_goldManager.dropGold(location, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.loot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.game.clans.items.economy.GoldToken;
|
||||
@ -24,4 +25,12 @@ public class GoldTokenLoot implements ILoot
|
||||
GoldToken token = new GoldToken(gold);
|
||||
location.getWorld().dropItemNaturally(location, token.toItemStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
int gold = _minGold + UtilMath.r(_maxGold - _minGold);
|
||||
GoldToken token = new GoldToken(gold);
|
||||
return token.toItemStack();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package mineplex.game.clans.clans.loot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface ILoot
|
||||
{
|
||||
public void dropLoot(Location location);
|
||||
|
||||
public ItemStack getItemStack();
|
||||
|
||||
}
|
||||
|
@ -38,4 +38,11 @@ public class ItemLoot implements ILoot
|
||||
ItemStack item = new ItemStack(_material, count, (short) 0, _data);
|
||||
location.getWorld().dropItemNaturally(location, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
int count = UtilMath.rRange(_min, _max);
|
||||
return new ItemStack(_material, count, (short) 0, _data);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.clans.loot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
@ -46,13 +47,14 @@ public class LootManager
|
||||
|
||||
// Gold
|
||||
// _commonSet.add(5, new GoldLoot(_goldManager, 100, 1000));
|
||||
_commonSet.add(1, new GoldTokenLoot(100, 1000));
|
||||
_commonSet.add(1, new GoldTokenLoot(5000, 10000));
|
||||
}
|
||||
|
||||
private void populateRare()
|
||||
{
|
||||
// Gear
|
||||
_rareSet.add(10, new GearLoot(_gearManager));
|
||||
_rareSet.add(100, new GearLoot(_gearManager));
|
||||
_rareSet.add(10, new GoldTokenLoot(50000, 100000));
|
||||
}
|
||||
|
||||
public void dropCommon(Location location)
|
||||
@ -65,4 +67,9 @@ public class LootManager
|
||||
_rareSet.generateRandom().dropLoot(location);
|
||||
}
|
||||
|
||||
public ItemStack getRareItemStack()
|
||||
{
|
||||
return _rareSet.generateRandom().getItemStack();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,75 +1,166 @@
|
||||
package mineplex.game.clans.clans.supplyDrop;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||
import net.minecraft.server.v1_7_R4.TileEntityBeacon;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class SupplyDrop
|
||||
public class SupplyDrop implements Listener
|
||||
{
|
||||
private static int DROP_TICKS = 20 * 50;
|
||||
private static int REMOVE_TICKS = DROP_TICKS + (20 * 120); // 2 Minutes
|
||||
public static Material SUPPLY_DROP_MATERIAL = Material.BEACON;
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
private Block _block;
|
||||
private Player _owner;
|
||||
private int _ticks;
|
||||
private boolean _running;
|
||||
private Hologram _hologram;
|
||||
private Random _random;
|
||||
|
||||
public SupplyDrop(Player owner, Block block)
|
||||
protected SupplyDrop(Player owner, Block block, ClansManager clansManager, HologramManager hologramManager)
|
||||
{
|
||||
_owner = owner;
|
||||
_block = block;
|
||||
_ticks = 0;
|
||||
_running = true;
|
||||
_hologram = new Hologram(hologramManager, _block.getLocation().add(0.5, 1.5, 0.5));
|
||||
_hologram.start();
|
||||
_random = new Random();
|
||||
_clansManager = clansManager;
|
||||
|
||||
System.out.println("supply drop");
|
||||
|
||||
block.setType(SUPPLY_DROP_MATERIAL);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
Block b = block.getRelative(x, -1, z);
|
||||
clansManager.getBlockRestore().add(b, Material.DIAMOND_BLOCK.getId(), (byte) 0, 60000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tick()
|
||||
{
|
||||
if (getTicks() == 10)
|
||||
if (getTicks() < DROP_TICKS)
|
||||
{
|
||||
try
|
||||
if (getTicks() == 10)
|
||||
{
|
||||
TileEntity tileEntity = ((CraftWorld) _block.getWorld()).getHandle().getTileEntity(_block.getX(), _block.getY(), _block.getZ());
|
||||
Field k = TileEntityBeacon.class.getDeclaredField("k");
|
||||
k.setAccessible(true);
|
||||
|
||||
Field l = TileEntityBeacon.class.getDeclaredField("l");
|
||||
l.setAccessible(true);
|
||||
|
||||
if (tileEntity instanceof TileEntityBeacon)
|
||||
try
|
||||
{
|
||||
k.set(tileEntity, true);
|
||||
l.set(tileEntity, 3);
|
||||
tileEntity.update();
|
||||
TileEntity tileEntity = ((CraftWorld) _block.getWorld()).getHandle().getTileEntity(_block.getX(), _block.getY(), _block.getZ());
|
||||
Field k = TileEntityBeacon.class.getDeclaredField("k");
|
||||
k.setAccessible(true);
|
||||
|
||||
Field l = TileEntityBeacon.class.getDeclaredField("l");
|
||||
l.setAccessible(true);
|
||||
|
||||
if (tileEntity instanceof TileEntityBeacon)
|
||||
{
|
||||
k.set(tileEntity, true);
|
||||
l.set(tileEntity, 3);
|
||||
tileEntity.update();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
if (getTicks() > 15 && getTicks() % 10 == 0)
|
||||
{
|
||||
e.printStackTrace();
|
||||
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BURST).withColor(Color.AQUA, Color.WHITE, Color.GRAY).withFade(Color.BLACK).withFlicker().build();
|
||||
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5), effect);
|
||||
}
|
||||
|
||||
if (getTicks() % 20 == 0)
|
||||
{
|
||||
long millis = (DROP_TICKS - getTicks()) * 50; // Multiply by 50 to convert ticks to ms
|
||||
_hologram.setText(getChatColor(millis) + UtilTime.convertString(millis, 0, UtilTime.TimeUnit.SECONDS) + " Until Drop");
|
||||
}
|
||||
}
|
||||
|
||||
if (getTicks() > 15 && getTicks() % 10 == 0)
|
||||
else
|
||||
{
|
||||
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BURST).withColor(Color.AQUA, Color.WHITE, Color.GRAY).withFade(Color.BLACK).withFlicker().build();
|
||||
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5), effect);
|
||||
}
|
||||
if (getTicks() == DROP_TICKS)
|
||||
{
|
||||
placeChest();
|
||||
}
|
||||
|
||||
if (getTicks() >= DROP_TICKS)
|
||||
{
|
||||
// Drop supply drop
|
||||
_running = false;
|
||||
if (getTicks() % 20 == 0)
|
||||
{
|
||||
long millis = (REMOVE_TICKS - getTicks()) * 50; // Multiply by 50 to convert ticks to ms
|
||||
_hologram.setText(getChatColor(millis) + UtilTime.convertString(millis, 0, UtilTime.TimeUnit.SECONDS) + " Remaining");
|
||||
}
|
||||
|
||||
if (getTicks() >= REMOVE_TICKS)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
_ticks++;
|
||||
}
|
||||
|
||||
private void placeChest()
|
||||
{
|
||||
getBlock().setType(Material.TRAPPED_CHEST);
|
||||
Chest chest = (Chest) getBlock().getState();
|
||||
|
||||
Inventory inventory = chest.getBlockInventory();
|
||||
int slots = inventory.getSize();
|
||||
int drops = 5 + _random.nextInt(11); // 5 -> 15
|
||||
|
||||
for (int i = 0; i < drops; i++)
|
||||
{
|
||||
int slot = _random.nextInt(slots);
|
||||
ItemStack item = _clansManager.getLootManager().getRareItemStack();
|
||||
inventory.setItem(slot, item);
|
||||
}
|
||||
}
|
||||
|
||||
private void finish()
|
||||
{
|
||||
_running = false;
|
||||
_hologram.stop();
|
||||
getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
private String getChatColor(long millis)
|
||||
{
|
||||
if (millis > 30000)
|
||||
return C.cAqua;
|
||||
else if (millis > 10000)
|
||||
return C.cYellow;
|
||||
else
|
||||
return C.cRed;
|
||||
}
|
||||
|
||||
public boolean isRunning()
|
||||
{
|
||||
return _running;
|
||||
@ -90,4 +181,8 @@ public class SupplyDrop
|
||||
return _ticks;
|
||||
}
|
||||
|
||||
public boolean contains(Block block)
|
||||
{
|
||||
return _block.equals(block);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@ -29,8 +30,6 @@ import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
|
||||
public class SupplyDropManager extends MiniPlugin
|
||||
{
|
||||
public static Material SUPPLY_DROP_MATERIAL = Material.BEACON;
|
||||
|
||||
private ClansManager _clansManager;
|
||||
private List<SupplyDrop> _supplyDrops;
|
||||
|
||||
@ -92,7 +91,8 @@ public class SupplyDropManager extends MiniPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
supplyDrop.getBlock().setType(Material.AIR);
|
||||
// supplyDrop.getBlock().setType(Material.AIR);
|
||||
HandlerList.unregisterAll(supplyDrop);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class SupplyDropManager extends MiniPlugin
|
||||
{
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == SUPPLY_DROP_MATERIAL)
|
||||
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == SupplyDrop.SUPPLY_DROP_MATERIAL)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class SupplyDropManager extends MiniPlugin
|
||||
{
|
||||
for (SupplyDrop supplyDrop : _supplyDrops)
|
||||
{
|
||||
if (supplyDrop.getBlock().equals(event.getBlock()))
|
||||
if (supplyDrop.contains(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -124,19 +124,9 @@ public class SupplyDropManager extends MiniPlugin
|
||||
|
||||
private void placeSupplyDrop(Player player, Block block)
|
||||
{
|
||||
SupplyDrop supplyDrop = new SupplyDrop(player, block);
|
||||
SupplyDrop supplyDrop = new SupplyDrop(player, block, _clansManager, _clansManager.getHologramManager());
|
||||
getPlugin().getServer().getPluginManager().registerEvents(supplyDrop, getPlugin());
|
||||
_supplyDrops.add(supplyDrop);
|
||||
|
||||
block.setType(SUPPLY_DROP_MATERIAL);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
Block b = block.getRelative(x, -1, z);
|
||||
_clansManager.getBlockRestore().add(b, Material.DIAMOND_BLOCK.getId(), (byte) 0, 60000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void giveSupplyDropItem(Player player)
|
||||
@ -150,7 +140,7 @@ public class SupplyDropManager extends MiniPlugin
|
||||
if (item == null)
|
||||
return false;
|
||||
|
||||
return item.getType() == SUPPLY_DROP_MATERIAL;
|
||||
return item.getType() == SupplyDrop.SUPPLY_DROP_MATERIAL;
|
||||
|
||||
// if (item.getType() == SUPPLY_DROP_MATERIAL)
|
||||
// {
|
||||
|
Loading…
Reference in New Issue
Block a user