Merge branch 'clans-beta' of http://184.154.0.242:7990/scm/min/mineplex into clans_custom_gear
Conflicts: Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java
This commit is contained in:
commit
227a077dba
@ -5,7 +5,6 @@
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" />
|
||||
<directory url="file://$PROJECT_DIR$/Nautilus.Game.Arcade" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
|
@ -42,7 +42,7 @@ public class UtilAlg
|
||||
|
||||
public static Vector getTrajectory(Vector from, Vector to)
|
||||
{
|
||||
return to.subtract(from).normalize();
|
||||
return to.clone().subtract(from).normalize();
|
||||
}
|
||||
|
||||
public static Vector getTrajectory2d(Entity from, Entity to)
|
||||
@ -57,7 +57,7 @@ public class UtilAlg
|
||||
|
||||
public static Vector getTrajectory2d(Vector from, Vector to)
|
||||
{
|
||||
return to.subtract(from).setY(0).normalize();
|
||||
return to.clone().subtract(from).setY(0).normalize();
|
||||
}
|
||||
|
||||
public static boolean HasSight(Location from, Player to)
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilWorld
|
||||
@ -46,6 +47,54 @@ public class UtilWorld
|
||||
}
|
||||
}
|
||||
|
||||
public static String blockToStr(Block block)
|
||||
{
|
||||
if (block == null)
|
||||
return "";
|
||||
|
||||
return block.getWorld().getName() + "," +
|
||||
block.getX() + "," +
|
||||
block.getY() + "," +
|
||||
block.getZ();
|
||||
}
|
||||
|
||||
public static String blockToStrClean(Block block)
|
||||
{
|
||||
if (block == null)
|
||||
return "";
|
||||
|
||||
return "(" + block.getX() + "," +
|
||||
block.getY() + "," +
|
||||
block.getZ() + ")";
|
||||
}
|
||||
|
||||
public static Block strToBlock(String string)
|
||||
{
|
||||
if (string.length() == 0)
|
||||
return null;
|
||||
|
||||
String[] parts = string.split(",");
|
||||
|
||||
try
|
||||
{
|
||||
for (World cur : UtilServer.getServer().getWorlds())
|
||||
{
|
||||
if (cur.getName().equalsIgnoreCase(parts[0]))
|
||||
{
|
||||
int x = Integer.parseInt(parts[1]);
|
||||
int y = Integer.parseInt(parts[2]);
|
||||
int z = Integer.parseInt(parts[3]);
|
||||
return cur.getBlockAt(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String locToStr(Location loc)
|
||||
{
|
||||
if (loc == null)
|
||||
@ -65,6 +114,14 @@ public class UtilWorld
|
||||
return "(" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")";
|
||||
}
|
||||
|
||||
public static String vecToStrClean(Vector loc)
|
||||
{
|
||||
if (loc == null)
|
||||
return "Null";
|
||||
|
||||
return "(" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ")";
|
||||
}
|
||||
|
||||
public static Location strToLoc(String string)
|
||||
{
|
||||
if (string.length() == 0)
|
||||
|
@ -41,9 +41,10 @@ public class ClanRepository extends RepositoryBase
|
||||
private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverId INT NOT NULL, chunk VARCHAR(100), safe BIT(1), PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverId));";
|
||||
private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BIT(1), PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||
|
||||
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverId = ? OR c.admin = 1;";
|
||||
private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;";
|
||||
private static String RETRIEVE_PLAYER_CLAN_INFO = "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = ?;";
|
||||
private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverId = ?;";
|
||||
|
||||
private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverId = ?;";
|
||||
private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverId = ?;";
|
||||
private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverId = ?;";
|
||||
@ -70,6 +71,7 @@ public class ClanRepository extends RepositoryBase
|
||||
private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;";
|
||||
private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverId = ? AND chunk = ?;";
|
||||
private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '' WHERE id = ?;";
|
||||
private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorStock = ? WHERE id = ?;";
|
||||
|
||||
private static String GET_CLAN_SERVER = "SELECT id FROM clanServer WHERE clanServer.serverName = ?";
|
||||
private static String ADD_CLAN_SERVER = "INSERT INTO clanServer (serverName) VALUES (?);";
|
||||
@ -251,13 +253,15 @@ public class ClanRepository extends RepositoryBase
|
||||
token.Deaths = resultSet.getInt(9);
|
||||
token.WarWins = resultSet.getInt(10);
|
||||
token.WarLosses = resultSet.getInt(11);
|
||||
token.DateCreated = resultSet.getTimestamp(12);
|
||||
token.LastOnline = resultSet.getTimestamp(13);
|
||||
token.Generator = resultSet.getString(12);
|
||||
token.GeneratorStock = resultSet.getInt(13);
|
||||
token.DateCreated = resultSet.getTimestamp(14);
|
||||
token.LastOnline = resultSet.getTimestamp(15);
|
||||
|
||||
ClanTerritoryToken territoryToken = new ClanTerritoryToken();
|
||||
territoryToken.ClanName = token.Name;
|
||||
territoryToken.Chunk = resultSet.getString(14);
|
||||
territoryToken.Safe = resultSet.getBoolean(15);
|
||||
territoryToken.Chunk = resultSet.getString(16);
|
||||
territoryToken.Safe = resultSet.getBoolean(17);
|
||||
|
||||
if (!clans.containsKey(token.Name))
|
||||
{
|
||||
@ -517,6 +521,12 @@ public class ClanRepository extends RepositoryBase
|
||||
new ColumnInt("otherClanKills", otherClanKills), new ColumnInt("clanId", clanId), new ColumnInt("otherClanId", otherClanId));
|
||||
}
|
||||
|
||||
public boolean updateClanGenerator(int clanId, String generator, int generatorStock)
|
||||
{
|
||||
return executeUpdate(UPDATE_CLAN_GENERATOR, new ColumnVarChar("generator", 140, generator), new ColumnInt("generatorStock", generatorStock), new ColumnInt("clanId", clanId))
|
||||
> 0;
|
||||
}
|
||||
|
||||
public void updateTerritoryClaim(String chunk, boolean safe)
|
||||
{
|
||||
executeUpdate(UPDATE_CLAN_TERRITORY, new ColumnBoolean("safe", safe), new ColumnInt("serverId", _serverId), new ColumnVarChar("chunk", 100, chunk));
|
||||
|
@ -17,6 +17,8 @@ public class ClanToken
|
||||
public int Deaths;
|
||||
public int WarWins;
|
||||
public int WarLosses;
|
||||
public String Generator;
|
||||
public int GeneratorStock;
|
||||
public Timestamp DateCreated;
|
||||
public Timestamp LastOnline;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -27,6 +28,8 @@ import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
||||
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
|
||||
|
||||
public class ClanInfo
|
||||
{
|
||||
private int _id = -1;
|
||||
@ -47,6 +50,8 @@ public class ClanInfo
|
||||
private Timestamp _dateCreated;
|
||||
private Timestamp _lastOnline = null;
|
||||
|
||||
private TntGenerator _generator;
|
||||
|
||||
// Loaded from Client
|
||||
private NautHashMap<String, ClanRole> _memberMap = new NautHashMap<String, ClanRole>();
|
||||
private NautHashMap<String, Boolean> _allyMap = new NautHashMap<String, Boolean>();
|
||||
@ -79,6 +84,23 @@ public class ClanInfo
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (token.Generator != null && token.Generator.length() > 0)
|
||||
{
|
||||
Block block = UtilWorld.strToBlock(token.Generator);
|
||||
if (block != null)
|
||||
{
|
||||
_generator = new TntGenerator(block);
|
||||
_generator.setStock(token.GeneratorStock);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
_energy = token.Energy;
|
||||
_admin = token.Admin;
|
||||
|
||||
@ -433,6 +455,16 @@ public class ClanInfo
|
||||
TimeUnit.FIT) + " to Protection";
|
||||
}
|
||||
|
||||
public TntGenerator getGenerator()
|
||||
{
|
||||
return _generator;
|
||||
}
|
||||
|
||||
public void setGenerator(TntGenerator generator)
|
||||
{
|
||||
_generator = generator;
|
||||
}
|
||||
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return _admin;
|
||||
@ -581,6 +613,12 @@ public class ClanInfo
|
||||
if (p != null) playerOffline(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _id + "," + _name;
|
||||
}
|
||||
|
||||
public void playerOffline(Player player)
|
||||
{
|
||||
_onlinePlayers.remove(player.getUniqueId());
|
||||
|
@ -2,12 +2,14 @@ package mineplex.game.clans.clans;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
|
||||
@ -19,6 +21,9 @@ import mineplex.game.clans.core.repository.ClanRepository;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanEnemyToken;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanToken;
|
||||
import mineplex.game.clans.clans.event.ClanDeleteEvent;
|
||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGenerator;
|
||||
|
||||
public class ClansDataAccessLayer
|
||||
{
|
||||
@ -40,18 +45,26 @@ public class ClansDataAccessLayer
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
boolean out = _repository.deleteClan(clan.getId());
|
||||
final boolean out = _repository.deleteClan(clan.getId());
|
||||
|
||||
if (out)
|
||||
{
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
deleteLocally(clan);
|
||||
}
|
||||
|
||||
if (callback != null) callback.run(out);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteLocally(ClanInfo clan)
|
||||
{
|
||||
//Territory Unclaim
|
||||
@ -79,6 +92,9 @@ public class ClansDataAccessLayer
|
||||
|
||||
//Log
|
||||
_manager.log("Deleted [" + clan.getName() + "].");
|
||||
|
||||
ClanDeleteEvent event = new ClanDeleteEvent(clan);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public void createAndJoin(final Player player, final String name, final Callback<ClanInfo> callback)
|
||||
@ -451,6 +467,7 @@ public class ClansDataAccessLayer
|
||||
ClanTerritory claim = new ClanTerritory();
|
||||
claim.Owner = name;
|
||||
claim.Safe = safe;
|
||||
claim.Chunk = chunk;
|
||||
clan.getClaimSet().add(chunk);
|
||||
_manager.getClaimMap().put(chunk, claim);
|
||||
|
||||
@ -606,6 +623,44 @@ public class ClansDataAccessLayer
|
||||
_manager.log("Updated Enemy Data for [" + clan.getName() + ", " + otherClan.getName() + "]");
|
||||
}
|
||||
|
||||
public void updateGenerator(final ClanInfo clanInfo, final Callback<Boolean> callback)
|
||||
{
|
||||
TntGenerator generator = clanInfo.getGenerator();
|
||||
final String location;
|
||||
final int generatorStock;
|
||||
|
||||
if (generator != null)
|
||||
{
|
||||
location = UtilWorld.blockToStr(generator.getBlock());
|
||||
generatorStock = generator.getStock();
|
||||
}
|
||||
else
|
||||
{
|
||||
location = "";
|
||||
generatorStock = 0;
|
||||
}
|
||||
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final boolean ran = _repository.updateClanGenerator(clanInfo.getId(), location, generatorStock);
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(ran);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateEnergy(ClanInfo clan)
|
||||
{
|
||||
//Save
|
||||
|
@ -80,7 +80,7 @@ public class ClansGame extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void SkillTrigger(SkillTriggerEvent event)
|
||||
{
|
||||
if (!Clans.getClanUtility().isSafe(event.GetPlayer()))
|
||||
|
@ -6,6 +6,7 @@ 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;
|
||||
@ -37,6 +38,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
@ -55,6 +57,7 @@ import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansLoginManager;
|
||||
import mineplex.game.clans.clans.commands.MapCommand;
|
||||
import mineplex.game.clans.clans.commands.RegionsCommand;
|
||||
import mineplex.game.clans.clans.commands.ServerTimeCommand;
|
||||
@ -64,6 +67,7 @@ import mineplex.game.clans.clans.murder.MurderManager;
|
||||
import mineplex.game.clans.clans.redis.ClanServerChangeHandler;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager;
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
@ -95,8 +99,6 @@ import mineplex.minecraft.game.core.fire.Fire;
|
||||
import mineplex.minecraft.game.core.mechanics.Weapon;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.PlayerServerInfo;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
@ -125,7 +127,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private Teleport _teleport;
|
||||
private ConditionManager _condition;
|
||||
private ClassCombatShop _classShop;
|
||||
private DataRepository<PlayerServerInfo> _playerRepository; //
|
||||
|
||||
private ClassManager _classManager;
|
||||
public ClassManager getClassManager() { return _classManager; }
|
||||
@ -191,9 +192,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_clanGame = new ClansGame(plugin, this);
|
||||
_clanUtility = new ClansUtility(this);
|
||||
_itemMapManager = new ItemMapManager(this, _worldEvent);
|
||||
new TntGeneratorManager(plugin, this);
|
||||
|
||||
_explosion = new Explosion(plugin, blockRestore);
|
||||
|
||||
new ClansLoginManager(getPlugin(), clientManager, _serverName);
|
||||
|
||||
Energy energy = new Energy(plugin);
|
||||
// TODO: Re-enable customtagfix with NCP update?
|
||||
//new CustomTagFix(plugin, packetHandler);
|
||||
@ -243,7 +247,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
|
||||
}
|
||||
|
||||
_playerRepository = new RedisDataRepository<PlayerServerInfo>(Region.ALL, PlayerServerInfo.class, "ClansServerCache");
|
||||
//RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class<T> elementType, String elementLabel)
|
||||
// Initialize default region factions and territory (spawn/fields/borderlands)
|
||||
_clanRegions = new ClansRegions(plugin, this);
|
||||
@ -735,19 +738,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.getPlayer().getName().equals("Eniloo"))
|
||||
{
|
||||
ItemStack item = event.getPlayer().getItemInHand();
|
||||
event.getPlayer().sendMessage("Item: " + item.getType().toString());
|
||||
event.getPlayer().sendMessage("Id: " + item.getTypeId());
|
||||
event.getPlayer().sendMessage("Durability: " + item.getDurability());
|
||||
event.getPlayer().sendMessage("Data: " + ((CraftItemStack) item).getHandle().getData());
|
||||
}
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
public void blockBreak(BlockBreakEvent event)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
|
@ -0,0 +1,73 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.database.Tables;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
public class ClansLoginManager extends MiniPlugin implements ILoginProcessor
|
||||
{
|
||||
private boolean _enabled;
|
||||
private String _serverName;
|
||||
|
||||
public ClansLoginManager(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
||||
{
|
||||
super("Clans Login Manager", plugin);
|
||||
|
||||
_serverName = serverName;
|
||||
_enabled = true;
|
||||
clientManager.addStoredProcedureLoginProcessor(this);
|
||||
}
|
||||
|
||||
private void kickPlayer(Player player, String homeServer)
|
||||
{
|
||||
player.kickPlayer("This is not your home server. To play clans, connect to " + homeServer);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processLoginResultSet(final String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
while (resultSet.next())
|
||||
{
|
||||
final String serverName = resultSet.getString(1);
|
||||
|
||||
if (serverName != null)
|
||||
{
|
||||
System.out.println("Player " + playerName + " is from server: " + serverName);
|
||||
|
||||
|
||||
if (!serverName.equals(_serverName))
|
||||
{
|
||||
runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Player player = UtilPlayer.searchExact(playerName);
|
||||
if (player != null)
|
||||
kickPlayer(player, serverName);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery(int accountId, String uuid, String name)
|
||||
{
|
||||
return "SELECT `clanServer`.`serverName` FROM `accountClan` JOIN `clans` ON `clans`.`id` = `accountClan`.`clanId` JOIN `clanServer` ON `clanServer`.`id` = `clans`.`serverId` WHERE `accountClan`.`accountId` = " + accountId + ";";
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.clans.event;
|
||||
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ClanDeleteEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private ClanInfo _clanInfo;
|
||||
|
||||
public ClanDeleteEvent(ClanInfo clanInfo)
|
||||
{
|
||||
_clanInfo = clanInfo;
|
||||
}
|
||||
|
||||
public ClanInfo getClanInfo()
|
||||
{
|
||||
return _clanInfo;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package mineplex.game.clans.clans.tntGenerator;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class TntGenerator
|
||||
{
|
||||
private Block _block;
|
||||
private int _ticks;
|
||||
private int _stock;
|
||||
|
||||
public TntGenerator(Block block)
|
||||
{
|
||||
_block = block;
|
||||
}
|
||||
|
||||
public int getTicks()
|
||||
{
|
||||
return _ticks;
|
||||
}
|
||||
|
||||
public void setTicks(int ticks)
|
||||
{
|
||||
_ticks = ticks;
|
||||
}
|
||||
|
||||
public void incrementTicks()
|
||||
{
|
||||
_ticks++;
|
||||
}
|
||||
|
||||
public int getStock()
|
||||
{
|
||||
return _stock;
|
||||
}
|
||||
|
||||
public void setStock(int stock)
|
||||
{
|
||||
_stock = stock;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
}
|
@ -0,0 +1,278 @@
|
||||
package mineplex.game.clans.clans.tntGenerator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.TileEntityBrewingStand;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClanDeleteEvent;
|
||||
|
||||
public class TntGeneratorManager extends MiniPlugin
|
||||
{
|
||||
public static final Material GENERATOR_MATERIAL = Material.BREWING_STAND;
|
||||
public static final Material GENERATOR_DROP_MATERIAL = Material.BREWING_STAND_ITEM;
|
||||
public static final int TICKS_PER_TNT = 60 * 60 * 10; // 10 Hours
|
||||
public static final int MAX_GENERATOR_STOCK = 3;
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public TntGeneratorManager(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("Tnt Generator", plugin);
|
||||
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateGenerators(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (ClanInfo clanInfo : _clansManager.getClanMap().values())
|
||||
{
|
||||
TntGenerator generator = clanInfo.getGenerator();
|
||||
if (generator != null)
|
||||
{
|
||||
// Check that generator still exists
|
||||
if (generator.getBlock().getType() != GENERATOR_MATERIAL)
|
||||
{
|
||||
clanInfo.setGenerator(null);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clanInfo, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check that generator is still in clan territory
|
||||
ClanInfo owner = _clansManager.getClanUtility().getOwner(generator.getBlock().getLocation());
|
||||
if (!clanInfo.equals(owner))
|
||||
{
|
||||
_clansManager.messageClan(clanInfo, F.main("Clans", "Your " + F.elem("TNT Generator") + " has been destroyed due to the land no longer being claimed"));
|
||||
destroyGenerator(generator);
|
||||
clanInfo.setGenerator(null);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clanInfo, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (generator.getStock() >= MAX_GENERATOR_STOCK)
|
||||
{
|
||||
generator.setTicks(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (generator.getTicks() >= TICKS_PER_TNT)
|
||||
{
|
||||
_clansManager.messageClan(clanInfo, F.main("Clans", "Your " + F.elem("TNT Generator") + " has a new TNT available"));
|
||||
generator.setStock(generator.getStock() + 1);
|
||||
generator.setTicks(0);
|
||||
updateBrewingStand(generator);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clanInfo, null);
|
||||
}
|
||||
|
||||
generator.incrementTicks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.getBlockPlaced().getType() == GENERATOR_MATERIAL)
|
||||
{
|
||||
ClanInfo clan = _clansManager.getClan(event.getPlayer());
|
||||
|
||||
if (clan == null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You must be in a clan to place a " + F.elem("TNT Generator")));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Confirm they are placing in their own land
|
||||
ClanInfo owner = _clansManager.getClanUtility().getOwner(event.getBlock().getLocation());
|
||||
if (!clan.equals(owner))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You must place the " + F.elem("TNT Generator") + " on your own land"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
TntGenerator oldGenerator = clan.getGenerator();
|
||||
|
||||
if (oldGenerator != null)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "Your clan already has a " + F.elem("TNT Generator")));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// event.getBlockPlaced().setType(GENERATOR_MATERIAL);
|
||||
|
||||
TntGenerator generator = new TntGenerator(event.getBlock());
|
||||
clan.setGenerator(generator);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, null);
|
||||
|
||||
_clansManager.messageClan(clan, F.main("Clans", F.name(event.getPlayer().getName()) + " placed a " + F.elem("TNT Generator") + " at " + F.elem(UtilWorld.blockToStrClean(event.getBlock()))));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.getBlock() != null && event.getBlock().getType() == GENERATOR_MATERIAL)
|
||||
{
|
||||
ClanInfo clan = getGenerator(event.getBlock());
|
||||
if (clan != null)
|
||||
{
|
||||
destroyGenerator(clan.getGenerator());
|
||||
clan.setGenerator(null);
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your " + F.elem("TNT Generator") + " has been destroyed by " + F.elem(event.getPlayer().getName())));
|
||||
}
|
||||
|
||||
clearStand(event.getBlock());
|
||||
event.getBlock().setTypeId(0);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && event.getClickedBlock().getType() == GENERATOR_MATERIAL)
|
||||
{
|
||||
ClanInfo clan = getGenerator(event.getClickedBlock());
|
||||
if (clan != null)
|
||||
{
|
||||
final TntGenerator generator = clan.getGenerator();
|
||||
final int stock = generator.getStock();
|
||||
|
||||
if (stock > 0)
|
||||
{
|
||||
generator.setStock(stock - 1);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
updateBrewingStand(generator);
|
||||
dropItem(event.getClickedBlock(), new ItemStack(Material.TNT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed
|
||||
generator.setStock(stock);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
int secondLeft = TICKS_PER_TNT - generator.getTicks();
|
||||
int msLeft = secondLeft * 1000;
|
||||
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDelete(ClanDeleteEvent event)
|
||||
{
|
||||
ClanInfo clan = event.getClanInfo();
|
||||
|
||||
if (clan != null && clan.getGenerator() != null)
|
||||
{
|
||||
clearStand(clan.getGenerator().getBlock());
|
||||
clan.getGenerator().getBlock().setTypeId(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(Block dropLocation, ItemStack item)
|
||||
{
|
||||
dropLocation.getWorld().dropItemNaturally(dropLocation.getLocation().add(0.5, 0.5, 0.5), item);
|
||||
}
|
||||
|
||||
public ClanInfo getGenerator(Block block)
|
||||
{
|
||||
for (ClanInfo clanInfo : _clansManager.getClanMap().values())
|
||||
{
|
||||
TntGenerator generator = clanInfo.getGenerator();
|
||||
|
||||
if (generator != null && block.equals(generator.getBlock()))
|
||||
return clanInfo;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void destroyGenerator(TntGenerator generator)
|
||||
{
|
||||
for (int i = 0; i < generator.getStock(); i++)
|
||||
{
|
||||
dropItem(generator.getBlock(), new ItemStack(Material.TNT));
|
||||
}
|
||||
|
||||
generator.setStock(0);
|
||||
dropItem(generator.getBlock(), new ItemStack(GENERATOR_DROP_MATERIAL));
|
||||
clearStand(generator.getBlock());
|
||||
generator.getBlock().setTypeId(0);
|
||||
}
|
||||
|
||||
private void clearStand(Block block)
|
||||
{
|
||||
TileEntityBrewingStand tileEntity = (TileEntityBrewingStand)((CraftWorld)block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
|
||||
if (tileEntity != null)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
tileEntity.items[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBrewingStand(TntGenerator generator)
|
||||
{
|
||||
Block block = generator.getBlock();
|
||||
|
||||
if (block != null && block.getType() == Material.BREWING_STAND)
|
||||
{
|
||||
TileEntityBrewingStand tileEntity = (TileEntityBrewingStand)((CraftWorld)block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ItemStack item = new ItemStack(Material.TNT);
|
||||
net.minecraft.server.v1_7_R4.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
|
||||
int itemSlot = i;
|
||||
tileEntity.items[itemSlot] = (generator.getStock() > i) ? nmsItem : null;
|
||||
}
|
||||
tileEntity.update();
|
||||
}
|
||||
}
|
||||
}
|
@ -332,21 +332,6 @@ public class Gameplay extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BrewingBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.getBlock().getType() != Material.BREWING_STAND)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
event.getBlock().setTypeId(0);
|
||||
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.BREWING_STAND));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void AnvilDisable(PlayerInteractEvent event)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.minecraft.game.core.boss.ironwizard.abilities;
|
||||
package mineplex.minecraft.game.core.boss;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@ -16,9 +16,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class GolemAbility implements Listener
|
||||
public abstract class BossAbility<T extends EventCreature, Y extends Entity> implements Listener
|
||||
{
|
||||
private GolemCreature _creature;
|
||||
private T _creature;
|
||||
private HashMap<UUID, Long> _damaged = new HashMap<UUID, Long>();
|
||||
|
||||
public boolean canDamage(Entity player)
|
||||
@ -36,7 +36,7 @@ public abstract class GolemAbility implements Listener
|
||||
return true;
|
||||
}
|
||||
|
||||
public GolemAbility(GolemCreature creature)
|
||||
public BossAbility(T creature)
|
||||
{
|
||||
_creature = creature;
|
||||
}
|
||||
@ -50,12 +50,12 @@ public abstract class GolemAbility implements Listener
|
||||
return 60;
|
||||
}
|
||||
|
||||
public IronGolem getEntity()
|
||||
public Y getEntity()
|
||||
{
|
||||
return getGolem().getEntity();
|
||||
return (Y) getBoss().getEntity();
|
||||
}
|
||||
|
||||
public GolemCreature getGolem()
|
||||
public T getBoss()
|
||||
{
|
||||
return _creature;
|
||||
}
|
||||
@ -70,7 +70,7 @@ public abstract class GolemAbility implements Listener
|
||||
return getTarget(30);
|
||||
}
|
||||
|
||||
public Player getTarget(double maxDistance)
|
||||
public Player getTarget(double minDistance, double maxDistance)
|
||||
{
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
@ -84,6 +84,11 @@ public abstract class GolemAbility implements Listener
|
||||
|
||||
double d = player.getLocation().distance(getLocation());
|
||||
|
||||
if (d < minDistance)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (target == null || dist > d)
|
||||
{
|
||||
target = player;
|
||||
@ -94,6 +99,11 @@ public abstract class GolemAbility implements Listener
|
||||
return target;
|
||||
}
|
||||
|
||||
public Player getTarget(double maxDistance)
|
||||
{
|
||||
return getTarget(0, maxDistance);
|
||||
}
|
||||
|
||||
public abstract boolean hasFinished();
|
||||
|
||||
public abstract void setFinished();
|
@ -56,7 +56,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
||||
return getEvent().getDifficulty();
|
||||
}
|
||||
|
||||
protected final void spawnEntity()
|
||||
protected void spawnEntity()
|
||||
{
|
||||
Location spawnLocation = _entity == null ? _spawnLocation : _entity.getLocation();
|
||||
T entity = _spawnLocation.getWorld().spawn(spawnLocation, getEntityClass());
|
||||
|
@ -279,6 +279,11 @@ public abstract class WorldEvent implements Listener
|
||||
_lastActive = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public EventMap getEventMap()
|
||||
{
|
||||
return _map;
|
||||
}
|
||||
|
||||
public void setMap(EventMap map, final Runnable onComplete)
|
||||
{
|
||||
_map = map;
|
||||
|
@ -15,8 +15,8 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockShot;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn;
|
||||
@ -35,6 +35,7 @@ import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemCreature extends EventCreature<IronGolem>
|
||||
@ -49,7 +50,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
private HashMap<Class, Class[]> _preferedCombos = new HashMap<Class, Class[]>();
|
||||
private Class _lastAttack;
|
||||
private boolean _usedFinalAttack;
|
||||
private ArrayList<GolemAbility> _currentAbilities = new ArrayList<GolemAbility>();
|
||||
private ArrayList<BossAbility> _currentAbilities = new ArrayList<BossAbility>();
|
||||
private double _canCaveIn = 450;
|
||||
private Vector _afkWalk = new Vector();
|
||||
private long _lastSlam;
|
||||
@ -108,12 +109,12 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
|
||||
// if (_currentAbility == null || _currentAbility.hasFinished())
|
||||
// {
|
||||
Iterator<GolemAbility> itel = _currentAbilities.iterator();
|
||||
Iterator<BossAbility> itel = _currentAbilities.iterator();
|
||||
boolean canDoNew = _currentAbilities.size() < 3;
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
GolemAbility ability = itel.next();
|
||||
BossAbility ability = itel.next();
|
||||
|
||||
if (ability.hasFinished())
|
||||
{
|
||||
@ -179,9 +180,9 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
}
|
||||
|
||||
{ // Wall explode
|
||||
if (!getPlayers(dist, 12).isEmpty() && getPlayers(dist, 4).isEmpty())
|
||||
if (!getPlayers(dist, 13).isEmpty() && getPlayers(dist, 4).isEmpty())
|
||||
{
|
||||
weight.put(GolemWallExplode.class, 5);
|
||||
weight.put(GolemWallExplode.class, 8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +221,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
{
|
||||
ArrayList<Player> players = getPlayers(dist, 30);
|
||||
|
||||
for (GolemAbility ability : _currentAbilities)
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
if (ability instanceof GolemExplodingAura)
|
||||
{
|
||||
@ -270,12 +271,12 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
}
|
||||
}
|
||||
|
||||
for (GolemAbility ability : _currentAbilities)
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
weight.remove(ability.getClass());
|
||||
}
|
||||
|
||||
GolemAbility ability = null;
|
||||
BossAbility ability = null;
|
||||
|
||||
if (!weight.isEmpty())
|
||||
{
|
||||
@ -298,7 +299,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
{
|
||||
try
|
||||
{
|
||||
ability = (GolemAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this);
|
||||
ability = (BossAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this);
|
||||
|
||||
if (ability.getTarget() == null)
|
||||
{
|
||||
@ -350,7 +351,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
|
||||
boolean canMove = true;
|
||||
|
||||
for (GolemAbility ability : _currentAbilities)
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
|
||||
@ -527,7 +528,7 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
|
||||
private void endAbility()
|
||||
{
|
||||
for (GolemAbility ability : _currentAbilities)
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.setFinished();
|
||||
HandlerList.unregisterAll(ability);
|
||||
@ -548,4 +549,25 @@ public class GolemCreature extends EventCreature<IronGolem>
|
||||
endAbility();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetCause() != DamageCause.FALL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getEvent().getEventMap().isInMap(event.GetDamageeEntity().getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.AddMod("Fall negation", 0.5);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||
@ -46,7 +47,7 @@ import org.bukkit.util.Vector;
|
||||
* Rumble is where the golem picks a target then starts playing a animation for a second where its obviously preparing to use it.
|
||||
* Copy this from Wizards
|
||||
*/
|
||||
public class GolemBlockHail extends GolemAbility
|
||||
public class GolemBlockHail extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private int _currentBlock;
|
||||
private int _currentLevel;
|
||||
@ -221,14 +222,14 @@ public class GolemBlockHail extends GolemAbility
|
||||
|
||||
// if (canDamage(victim))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Block Hail",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Block Hail",
|
||||
"Iron Wizard Block Hail");
|
||||
}
|
||||
|
||||
if (victim instanceof Player)
|
||||
{
|
||||
getGolem().getEvent().getCondition().Factory().Slow("Iron Wizard Block Hail", (LivingEntity) victim,
|
||||
getBoss().getEvent().getCondition().Factory().Slow("Iron Wizard Block Hail", (LivingEntity) victim,
|
||||
getEntity(), 3, 2, false, false, false, false);
|
||||
}
|
||||
|
||||
@ -304,8 +305,8 @@ public class GolemBlockHail extends GolemAbility
|
||||
{
|
||||
if (canDamage(player))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false,
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null,
|
||||
DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false,
|
||||
"Iron Wizard Protection", "Iron Wizard Protection");
|
||||
|
||||
loc.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.OBSIDIAN.getId());
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||
@ -43,13 +44,14 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
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.util.Vector;
|
||||
|
||||
public class GolemBlockShot extends GolemAbility
|
||||
public class GolemBlockShot extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private HashMap<Integer, Location> _blockLoc = new HashMap<Integer, Location>();
|
||||
private HashMap<Integer, Material> _blockType = new HashMap<Integer, Material>();
|
||||
@ -225,8 +227,8 @@ public class GolemBlockShot extends GolemAbility
|
||||
{
|
||||
cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId());
|
||||
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Block Shot",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Block Shot",
|
||||
"Iron Wizard Block Shot");
|
||||
|
||||
cur.remove();
|
||||
|
@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
@ -27,10 +28,12 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -38,7 +41,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemCaveIn extends GolemAbility
|
||||
public class GolemCaveIn extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private ArrayList<Block> _blocks = new ArrayList<Block>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
@ -165,8 +168,8 @@ public class GolemCaveIn extends GolemAbility
|
||||
|
||||
if (canDamage(victim))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Cave In",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Cave In",
|
||||
"Iron Wizard Cave In");
|
||||
}
|
||||
|
||||
@ -217,15 +220,6 @@ public class GolemCaveIn extends GolemAbility
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysics(BlockPhysicsEvent event)
|
||||
{
|
||||
if (_blocks.contains(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
@ -289,7 +283,7 @@ public class GolemCaveIn extends GolemAbility
|
||||
|
||||
List<Player> players = UtilPlayer.getNearby(getLocation(), 50, true);
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
for (int i = 0; i < players.size() * 4; i++)
|
||||
{
|
||||
int dist = UtilMath.r(10);
|
||||
|
||||
@ -317,7 +311,7 @@ public class GolemCaveIn extends GolemAbility
|
||||
{
|
||||
if (l.getBlock().getType() == Material.AIR)
|
||||
{
|
||||
if (UtilAlg.HasSight(l, getLocation().add(0, 8, 0)))
|
||||
if (UtilAlg.HasSight(l, getLocation().add(0, 4, 0)))
|
||||
{
|
||||
FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, -1, 0.5), b.getTypeId(),
|
||||
b.getData());
|
||||
|
@ -10,6 +10,7 @@ import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,12 +18,13 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemEarthquake extends GolemAbility
|
||||
public class GolemEarthquake extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private Location _center;
|
||||
private float _range;
|
||||
@ -138,11 +140,11 @@ public class GolemEarthquake extends GolemAbility
|
||||
{
|
||||
_damaged.add(player.getUniqueId());
|
||||
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) player, getEntity(), null,
|
||||
DamageCause.CONTACT, 12 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Earthquake",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) player, getEntity(), null,
|
||||
DamageCause.CONTACT, 14 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Earthquake",
|
||||
"Iron Wizard Earthquake");
|
||||
|
||||
getGolem().getEvent().getCondition().Factory().Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false,
|
||||
getBoss().getEvent().getCondition().Factory().Slow("Earthquake", (LivingEntity) player, getEntity(), 3, 1, false,
|
||||
false, false, false);
|
||||
|
||||
// Velocity
|
||||
@ -150,7 +152,7 @@ public class GolemEarthquake extends GolemAbility
|
||||
1.8, true, 0, 0.5, 0.5, true);
|
||||
|
||||
// Condition
|
||||
getGolem().getEvent().getCondition().Factory().Falling("Earthquake", player, getEntity(), 10, false, true);
|
||||
getBoss().getEvent().getCondition().Factory().Falling("Earthquake", player, getEntity(), 10, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -44,10 +45,11 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class GolemExplodingAura extends GolemAbility
|
||||
public class GolemExplodingAura extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
|
||||
private HashMap<Integer, Integer> _blocks = new HashMap<Integer, Integer>();
|
||||
@ -105,7 +107,7 @@ public class GolemExplodingAura extends GolemAbility
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_tick < 25 * 25 && getGolem().getHealth() > 30)
|
||||
if (_tick < 25 * 25 && getBoss().getHealth() > 30)
|
||||
{
|
||||
double angle = (2 * Math.PI) / UtilMath.random.nextDouble();
|
||||
double x = 1.7 * Math.cos(angle);
|
||||
@ -117,8 +119,8 @@ public class GolemExplodingAura extends GolemAbility
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getLocation(), 3, true))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT,
|
||||
2 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Protection", "Iron Wizard Protection");
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent(player, getEntity(), null, DamageCause.CONTACT,
|
||||
6 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Protection", "Iron Wizard Protection");
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(getEntity(), player), 1, true, 0.3, 0, 0.3, false);
|
||||
}
|
||||
}
|
||||
@ -346,17 +348,11 @@ public class GolemExplodingAura extends GolemAbility
|
||||
|
||||
// if (canDamage(victim))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Blocky Iron Wizard Aura",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getBoss().getDifficulty(), true, true, false, "Blocky Iron Wizard Aura",
|
||||
"Blocky Iron Wizard Aura");
|
||||
}
|
||||
|
||||
if (victim instanceof Player)
|
||||
{
|
||||
getGolem().getEvent().getCondition().Factory().Slow("Blocky Iron Wizard Aura", (LivingEntity) victim,
|
||||
getEntity(), 3, 2, false, false, false, false);
|
||||
}
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
|
||||
|
@ -17,6 +17,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
@ -52,7 +53,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemExplosiveBlock extends GolemAbility
|
||||
public class GolemExplosiveBlock extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private HashMap<Integer, Vector> _blocksLocation = new HashMap<Integer, Vector>();
|
||||
private Location _center;
|
||||
@ -170,7 +171,7 @@ public class GolemExplosiveBlock extends GolemAbility
|
||||
{
|
||||
_explosionsLeft++;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getGolem().getEvent().getPlugin(), new Runnable()
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getBoss().getEvent().getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
|
@ -3,16 +3,18 @@ package mineplex.minecraft.game.core.boss.ironwizard.abilities;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemMeleeAttack extends GolemAbility
|
||||
public class GolemMeleeAttack extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private boolean _attacked;
|
||||
|
||||
@ -64,15 +66,15 @@ public class GolemMeleeAttack extends GolemAbility
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), target);
|
||||
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
6 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
10 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Melee Attack", "Iron Wizard Melee Attack");
|
||||
|
||||
Vector vec = getLocation().getDirection();
|
||||
vec.setY(0).normalize().setY(0.5).multiply(2.4);
|
||||
|
||||
UtilAction.velocity(target, vec);
|
||||
|
||||
getGolem().getEvent().getCondition().Factory().Falling("Iron Wizard Throw", target, getEntity(), 3, false, false);
|
||||
getBoss().getEvent().getCondition().Factory().Falling("Iron Wizard Throw", target, getEntity(), 3, false, false);
|
||||
|
||||
target.getWorld().playSound(target.getLocation(), Sound.IRONGOLEM_THROW, 3, 0.9F);
|
||||
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||
|
||||
@ -28,7 +29,7 @@ import org.bukkit.util.Vector;
|
||||
* Rumble is where the golem picks a target then starts playing a animation for a second where its obviously preparing to use it.
|
||||
* Copy this from Wizards
|
||||
*/
|
||||
public class GolemRumble extends GolemAbility
|
||||
public class GolemRumble extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private Location _loc;
|
||||
private int _ticks;
|
||||
@ -185,8 +186,8 @@ public class GolemRumble extends GolemAbility
|
||||
|
||||
if (canDamage(entity))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) entity, getEntity(), null,
|
||||
DamageCause.CONTACT, 4 * getGolem().getDifficulty(), false, true, false, "Iron Wizard Rumble",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) entity, getEntity(), null,
|
||||
DamageCause.CONTACT, 8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard Rumble",
|
||||
"Iron Wizard Rumble");
|
||||
}
|
||||
|
||||
@ -194,7 +195,7 @@ public class GolemRumble extends GolemAbility
|
||||
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
getGolem().getEvent().getCondition().Factory().Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1,
|
||||
getBoss().getEvent().getCondition().Factory().Slow("Rumble", (LivingEntity) entity, getEntity(), 3, 1,
|
||||
false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftIronGolem;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -36,10 +37,11 @@ import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
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 BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private ArrayList<Entry<Location, Location>> _ruptures = new ArrayList<Entry<Location, Location>>();
|
||||
private HashMap<Location, Long> _ruptureTime = new HashMap<Location, Long>();
|
||||
@ -287,11 +289,11 @@ public class GolemRupture extends GolemAbility
|
||||
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);
|
||||
getBoss().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");
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM,
|
||||
8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard", "Rupture");
|
||||
}
|
||||
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
@ -11,6 +11,7 @@ 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.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -28,7 +30,7 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GolemSlam extends GolemAbility
|
||||
public class GolemSlam extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private ArrayList<Item> _items = new ArrayList<Item>();
|
||||
private int _ticksFinished;
|
||||
@ -190,11 +192,11 @@ public class GolemSlam extends GolemAbility
|
||||
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);
|
||||
getBoss().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");
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent(cur, getEntity(), null, DamageCause.CUSTOM,
|
||||
8 * getBoss().getDifficulty(), false, true, false, "Iron Wizard", "Rupture");
|
||||
}
|
||||
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
@ -18,6 +18,7 @@ import mineplex.core.common.util.UtilShapes;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
@ -34,13 +35,14 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
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.util.Vector;
|
||||
|
||||
public class GolemWallExplode extends GolemAbility
|
||||
public class GolemWallExplode extends BossAbility<GolemCreature, IronGolem>
|
||||
{
|
||||
private HashMap<BlockFace, ArrayList<Block>> _blockWalls = new HashMap<BlockFace, ArrayList<Block>>();
|
||||
private ArrayList<String> _dontTarget = new ArrayList<String>();
|
||||
@ -192,8 +194,8 @@ public class GolemWallExplode extends GolemAbility
|
||||
|
||||
if (canDamage(victim))
|
||||
{
|
||||
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Wall Explosion",
|
||||
getBoss().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
|
||||
DamageCause.CONTACT, 10 * getBoss().getDifficulty(), true, true, false, "Iron Wizard Wall Explosion",
|
||||
"Iron Wizard Wall Explosion");
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
package mineplex.minecraft.game.core.boss.snake;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class SnakeBoss extends WorldEvent
|
||||
{
|
||||
|
||||
public SnakeBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Snaaaake", cornerLocation, "schematic/Golem.schematic");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
Bukkit.broadcastMessage("Custom Start");
|
||||
spawn(getCenterLocation());
|
||||
setState(EventState.LIVE);
|
||||
announceStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this slime boss has been defeated
|
||||
*/
|
||||
private void checkDeath()
|
||||
{
|
||||
if (getCreatures().size() == 0)
|
||||
{
|
||||
setState(EventState.COMPLETE);
|
||||
Bukkit.broadcastMessage("FINISHED!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCreature(EventCreature creature)
|
||||
{
|
||||
super.removeCreature(creature);
|
||||
|
||||
if (creature instanceof SnakeCreature)
|
||||
{
|
||||
checkDeath();
|
||||
}
|
||||
}
|
||||
|
||||
private SnakeCreature spawn(Location location)
|
||||
{
|
||||
SnakeCreature slimeCreature = new SnakeCreature(this, location);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
package mineplex.minecraft.game.core.boss.snake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
|
||||
|
||||
public class SnakeCreature extends EventCreature<Silverfish>
|
||||
{
|
||||
private ArrayList<SnakeSegment> _segments = new ArrayList<SnakeSegment>();
|
||||
private double _seperator = 0.5;
|
||||
private ArrayList<Player> _canSee = new ArrayList<Player>();
|
||||
|
||||
private Location _waypoint;
|
||||
|
||||
private boolean _enabled = false;
|
||||
|
||||
public SnakeCreature(WorldEvent event, Location spawnLocation)
|
||||
{
|
||||
super(event, spawnLocation, "Serpent Lord", false, 2000, Silverfish.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
getEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 10000, 0));
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
UtilEnt.ghost(getEntity(), true, false);
|
||||
Vector dir = new Vector(UtilMath.rr(1, true), 0, UtilMath.rr(1, true)).normalize().multiply(_seperator);
|
||||
|
||||
getNewWaypoint();
|
||||
|
||||
for (int i = 0; i < getHealth() / 50; i++)
|
||||
{
|
||||
SnakeSegment tail = new SnakeSegment(getSpawnLocation().toVector().subtract(dir.clone().multiply(-i)),
|
||||
new ItemStack(i == 0 ? Material.EMERALD_BLOCK : Material.STONE));
|
||||
|
||||
_segments.add(tail);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void getNewWaypoint()
|
||||
{
|
||||
Bukkit.broadcastMessage("NEW WAYPOINT!");
|
||||
_waypoint = getSpawnLocation().clone().add(Math.random() * 40 - 20, Math.random() * 24 - 8, Math.random() * 40 - 20);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSecond(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = _segments.get(0).getLocation().toLocation(getSpawnLocation().getWorld());
|
||||
|
||||
ArrayList<Player> canSee = new ArrayList<Player>();
|
||||
|
||||
for (Player player : loc.getWorld().getPlayers())
|
||||
{
|
||||
if (player.getLocation().distance(loc) < 120)
|
||||
{
|
||||
canSee.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Player> iter2 = _canSee.iterator();
|
||||
|
||||
int[] ids = new int[_segments.size()];
|
||||
|
||||
for (int a = 0; a < _segments.size(); a++)
|
||||
{
|
||||
ids[a] = _segments.get(a).getId();
|
||||
}
|
||||
|
||||
Packet destroy = new PacketPlayOutEntityDestroy(ids);
|
||||
|
||||
while (iter2.hasNext())
|
||||
{
|
||||
Player player = iter2.next();
|
||||
if (!canSee.contains(player))
|
||||
{
|
||||
iter2.remove();
|
||||
UtilPlayer.sendPacket(player, destroy);
|
||||
}
|
||||
}
|
||||
for (Player player : canSee)
|
||||
{
|
||||
if (!_canSee.contains(player))
|
||||
{
|
||||
_canSee.add(player);
|
||||
|
||||
for (SnakeSegment tail : _segments)
|
||||
{
|
||||
UtilPlayer.sendPacket(player, tail.getSpawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
int[] ids = new int[_segments.size()];
|
||||
|
||||
for (int a = 0; a < _segments.size(); a++)
|
||||
{
|
||||
ids[a] = _segments.get(a).getId();
|
||||
}
|
||||
|
||||
Packet destroy = new PacketPlayOutEntityDestroy(ids);
|
||||
|
||||
for (Player player : _canSee)
|
||||
{
|
||||
UtilPlayer.sendPacket(player, destroy);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickMove(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK || !_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Packet[] packets = new Packet[_segments.size()];
|
||||
|
||||
|
||||
for (int i = _segments.size()-1; i>=0; i--)
|
||||
{
|
||||
SnakeSegment seg = _segments.get(i);
|
||||
|
||||
Vector vec = seg.getLocation();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
vec.add(UtilAlg.getTrajectory(vec, _waypoint.toVector()).multiply(0.1));
|
||||
|
||||
Bukkit.broadcastMessage("Loc: " + UtilWorld.vecToStrClean(vec));
|
||||
|
||||
if (UtilMath.offset(vec, _waypoint.toVector()) < 5)
|
||||
{
|
||||
getNewWaypoint();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vec = _segments.get(i-1).getLocation();
|
||||
}
|
||||
|
||||
packets[i] = seg.moveEntity(new Vector(UtilMath.rr(10, true), 12, UtilMath.rr(10, true)));
|
||||
}
|
||||
|
||||
for (Player player : _canSee)
|
||||
{
|
||||
UtilPlayer.sendPacket(player, packets);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void command(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().contains("start"))
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package mineplex.minecraft.game.core.boss.snake;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||
import net.minecraft.server.v1_7_R4.Packet;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
|
||||
|
||||
public class SnakeSegment
|
||||
{
|
||||
private int _entityId = UtilEnt.getNewEntityId();
|
||||
private Vector _entityLocation;
|
||||
private ItemStack _item;
|
||||
|
||||
public SnakeSegment(Vector location, ItemStack item)
|
||||
{
|
||||
_entityLocation = location.clone();
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _entityId;
|
||||
}
|
||||
|
||||
public Packet moveEntity(Vector newLocation)
|
||||
{
|
||||
Vector toMove = newLocation.clone().subtract(_entityLocation);
|
||||
|
||||
int x = (int) Math.floor(32 * toMove.getX());
|
||||
int y = (int) Math.floor(32 * toMove.getY());
|
||||
int z = (int) Math.floor(32 * toMove.getZ());
|
||||
|
||||
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
|
||||
{
|
||||
_entityLocation.add(new Vector(x / 32D, y / 32D, z / 32D));
|
||||
|
||||
PacketPlayOutRelEntityMoveLook relMove = new PacketPlayOutRelEntityMoveLook();
|
||||
|
||||
relMove.a = getId();
|
||||
relMove.b = (byte) x;
|
||||
relMove.c = (byte) y;
|
||||
relMove.d = (byte) z;
|
||||
relMove.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
|
||||
relMove.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
|
||||
|
||||
return relMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
_entityLocation = newLocation.clone();
|
||||
|
||||
x = (int) Math.floor(_entityLocation.getX() * 32);
|
||||
y = (int) Math.floor(_entityLocation.getY() * 32);
|
||||
z = (int) Math.floor(_entityLocation.getZ() * 32);
|
||||
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
||||
teleportPacket.a = getId();
|
||||
teleportPacket.b = x;
|
||||
teleportPacket.c = y;
|
||||
teleportPacket.d = z;
|
||||
teleportPacket.e = (byte) (int) (UtilAlg.GetYaw(toMove) * 256.0F / 360.0F);
|
||||
teleportPacket.f = (byte) (int) (UtilAlg.GetPitch(toMove) * 256.0F / 360.0F);
|
||||
|
||||
return teleportPacket;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector getLocation()
|
||||
{
|
||||
return _entityLocation.clone();
|
||||
}
|
||||
|
||||
public Packet[] getSpawn()
|
||||
{
|
||||
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
|
||||
|
||||
DataWatcher watcher = new DataWatcher(null);
|
||||
watcher.a(0, (byte) 0);
|
||||
watcher.a(1, 0);
|
||||
|
||||
packet.a = getId();
|
||||
packet.c = (int) Math.floor(_entityLocation.getX() * 32);
|
||||
packet.d = (int) Math.floor(_entityLocation.getY() * 32);
|
||||
packet.e = (int) Math.floor(_entityLocation.getZ() * 32);
|
||||
packet.l = watcher;
|
||||
|
||||
if (_item != null)
|
||||
{
|
||||
watcher.a(10, (byte) 0);
|
||||
|
||||
for (int i = 11; i < 17; i++)
|
||||
{
|
||||
watcher.a(i, new Vector(0, 0, 0));
|
||||
}
|
||||
|
||||
packet.b = 30;
|
||||
|
||||
PacketPlayOutEntityEquipment packet2 = new PacketPlayOutEntityEquipment();
|
||||
|
||||
packet2.a = getId();
|
||||
packet2.b = 4;
|
||||
packet2.c = CraftItemStack.asNMSCopy(_item);
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
packet, packet2
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.b = EntityType.MAGMA_CUBE.getTypeId();
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
packet
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.EventState;
|
||||
import mineplex.minecraft.game.core.boss.WorldEvent;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
|
||||
public class SpiderBoss extends WorldEvent
|
||||
{
|
||||
|
||||
public SpiderBoss(DamageManager damageManager, BlockRestore blockRestore, ConditionManager conditionManager,
|
||||
Location cornerLocation)
|
||||
{
|
||||
super(damageManager, blockRestore, conditionManager, "Brood Mother", cornerLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customStart()
|
||||
{
|
||||
Bukkit.broadcastMessage("Custom Start");
|
||||
spawnGolem(getCenterLocation());
|
||||
setState(EventState.LIVE);
|
||||
announceStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this slime boss has been defeated
|
||||
*/
|
||||
private void checkDeath()
|
||||
{
|
||||
if (getCreatures().size() == 0)
|
||||
{
|
||||
setState(EventState.COMPLETE);
|
||||
Bukkit.broadcastMessage("FINISHED!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCreature(EventCreature creature)
|
||||
{
|
||||
super.removeCreature(creature);
|
||||
|
||||
if (creature instanceof GolemCreature)
|
||||
{
|
||||
checkDeath();
|
||||
}
|
||||
}
|
||||
|
||||
public SpiderMinionCreature spawnMinion(Location location)
|
||||
{
|
||||
SpiderMinionCreature slimeCreature = new SpiderMinionCreature(this, location, 2500);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
||||
private SpiderCreature spawnGolem(Location location)
|
||||
{
|
||||
SpiderCreature slimeCreature = new SpiderCreature(this, location, 2500);
|
||||
registerCreature(slimeCreature);
|
||||
return slimeCreature;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,316 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemBlockHail;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemCaveIn;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemEarthquake;
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.abilities.GolemSlam;
|
||||
import mineplex.minecraft.game.core.boss.spider.attacks.SpiderEggplosm;
|
||||
|
||||
public class SpiderCreature extends EventCreature<Spider>
|
||||
{
|
||||
private ArrayList<BossAbility> _currentAbilities = new ArrayList<BossAbility>();
|
||||
private int _lastAbility;
|
||||
private long _lastWalked;
|
||||
private long _reverseWalk;
|
||||
private Location _standing;
|
||||
private Vector _afkWalk = new Vector();
|
||||
|
||||
public SpiderCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Brood Mother", true, maxHealth, Spider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<BossAbility> itel = _currentAbilities.iterator();
|
||||
boolean canDoNew = _currentAbilities.size() < 3;
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
BossAbility ability = itel.next();
|
||||
|
||||
if (ability.hasFinished())
|
||||
{
|
||||
itel.remove();
|
||||
ability.setFinished();
|
||||
_lastAbility = 20;// _currentAbility.getCooldown();
|
||||
|
||||
HandlerList.unregisterAll(ability);
|
||||
System.out.print("Unregistered golem ability " + ability.getClass().getSimpleName());
|
||||
}
|
||||
else if (!ability.inProgress())
|
||||
{
|
||||
canDoNew = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_lastAbility-- <= 0 && canDoNew && UtilBlock.solid(getEntity().getLocation().getBlock().getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
HashMap<Class, Integer> weight = new HashMap<Class, Integer>();
|
||||
HashMap<Player, Double> dist = new HashMap<Player, Double>();
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
if (player.hasLineOfSight(getEntity()))
|
||||
{
|
||||
dist.put(player, player.getLocation().distance(getEntity().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
if (!dist.isEmpty())
|
||||
{
|
||||
{// Egg explosion
|
||||
ArrayList<Player> players = getPlayers(dist, 30);
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
weight.put(SpiderEggplosm.class, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
weight.remove(ability.getClass());
|
||||
}
|
||||
|
||||
BossAbility ability = null;
|
||||
|
||||
if (!weight.isEmpty())
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (Integer entry : weight.values())
|
||||
{
|
||||
i += entry;
|
||||
}
|
||||
|
||||
for (int a = 0; a < 10; a++)
|
||||
{
|
||||
int luckyNumber = UtilMath.r(i);
|
||||
|
||||
for (Entry<Class, Integer> entry : weight.entrySet())
|
||||
{
|
||||
luckyNumber -= entry.getValue();
|
||||
|
||||
if (luckyNumber <= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
ability = (BossAbility) entry.getKey().getConstructor(GolemCreature.class).newInstance(this);
|
||||
|
||||
if (ability.getTarget() == null)
|
||||
{
|
||||
ability = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ability != null && ability.getTarget() != null)
|
||||
{
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(ability, getEvent().getPlugin());
|
||||
|
||||
System.out.print("Spider boss is using " + ability.getClass().getSimpleName());
|
||||
|
||||
_currentAbilities.add(ability);
|
||||
}
|
||||
|
||||
_lastAbility = 10;
|
||||
}
|
||||
|
||||
boolean canMove = true;
|
||||
|
||||
for (BossAbility ability : _currentAbilities)
|
||||
{
|
||||
ability.tick();
|
||||
|
||||
if (!ability.canMove())
|
||||
{
|
||||
canMove = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canMove)
|
||||
{
|
||||
Player target = null;
|
||||
double dist = 0;
|
||||
|
||||
for (Player player : UtilPlayer.getNearby(getEntity().getLocation(), 50, true))
|
||||
{
|
||||
if (!player.hasLineOfSight(getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double d = player.getLocation().distance(getEntity().getLocation());
|
||||
|
||||
if (d > 1.5 && (d < 7 || d > 15) && (target == null || (d < 50 && dist > d)))
|
||||
{
|
||||
target = player;
|
||||
dist = d;
|
||||
}
|
||||
}
|
||||
|
||||
Vector vec = null;
|
||||
boolean superWalk = false;
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
vec = target.getLocation().subtract(getEntity().getLocation()).toVector();
|
||||
vec.setY(getEntity().getLocation().getY());
|
||||
|
||||
double len = vec.length();
|
||||
|
||||
vec.setX(vec.getX() * (UtilMath.random.nextDouble() / 3D));
|
||||
vec.setZ(vec.getZ() * (UtilMath.random.nextDouble() / 3D));
|
||||
|
||||
vec.multiply(len);
|
||||
|
||||
if (target != null && dist < 8)
|
||||
{
|
||||
vec.multiply(-1);
|
||||
superWalk = true;
|
||||
}
|
||||
|
||||
if (!UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vec.clone().normalize().multiply(2))))
|
||||
{
|
||||
_reverseWalk = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(_reverseWalk, 4000))
|
||||
{
|
||||
vec.multiply(-1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!UtilTime.elapsed(_lastWalked, 7000))
|
||||
{
|
||||
vec = _afkWalk;
|
||||
}
|
||||
else if (UtilTime.elapsed(_lastWalked, 12000))
|
||||
{
|
||||
_afkWalk = new Vector();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Vector vector = new Vector(UtilMath.r(20) - 10, 0, UtilMath.r(20) - 10);
|
||||
|
||||
if (UtilAlg.HasSight(getEntity().getLocation(),
|
||||
getEntity().getLocation().add(vector.clone().normalize().multiply(2))))
|
||||
{
|
||||
vec = _afkWalk = vector;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_lastWalked = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (vec != null)
|
||||
{
|
||||
// if (vec.length() > 1)
|
||||
{
|
||||
UtilEnt.CreatureMoveFast(getEntity(), getEntity().getLocation().add(vec),
|
||||
(target != null ? 1.8F : 1.1F) + (superWalk ? 0.4F : 0));
|
||||
}
|
||||
}
|
||||
|
||||
_standing = getEntity().getLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
Location l = getEntity().getLocation();
|
||||
|
||||
_standing.setYaw(l.getYaw());
|
||||
_standing.setPitch(l.getPitch());
|
||||
_standing.setY(l.getY());
|
||||
|
||||
getEntity().teleport(_standing);
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Player> getPlayers(final HashMap<Player, Double> map, double maxDist)
|
||||
{
|
||||
ArrayList<Player> list = new ArrayList<Player>();
|
||||
|
||||
for (Player p : map.keySet())
|
||||
{
|
||||
if (map.get(p) <= maxDist)
|
||||
{
|
||||
list.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(list, new Comparator<Player>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Player o1, Player o2)
|
||||
{
|
||||
return Double.compare(map.get(o2), map.get(o1));
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.minecraft.game.core.boss.spider;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.EventCreature;
|
||||
|
||||
public class SpiderMinionCreature extends EventCreature<CaveSpider>
|
||||
{
|
||||
public SpiderMinionCreature(SpiderBoss boss, Location location, double maxHealth)
|
||||
{
|
||||
super(boss, location, "Spider Minion", false, maxHealth, CaveSpider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnCustom()
|
||||
{
|
||||
UtilEnt.Vegetate(getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dieCustom()
|
||||
{
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player target = UtilPlayer.getClosest(getEntity().getLocation());
|
||||
|
||||
UtilEnt.CreatureMoveFast(getEntity(), target.getLocation(), 1.4F);
|
||||
|
||||
if (UtilMath.r(50) == 0)
|
||||
{
|
||||
getEntity().getWorld().playSound(getEntity().getLocation(), Sound.SPIDER_IDLE, 2.5F, 1);
|
||||
}
|
||||
|
||||
if (target.getLocation().distance(getEntity().getLocation()) < 2)
|
||||
{
|
||||
Vector vec = UtilAlg.getTrajectory2d(getEntity(), target);
|
||||
vec.multiply(0.4).setY(0.3);
|
||||
|
||||
getEntity().setVelocity(vec);
|
||||
|
||||
getEvent().getDamageManager().NewDamageEvent(target, getEntity(), null, DamageCause.ENTITY_ATTACK,
|
||||
6 * getDifficulty(), true, false, false, "Spider Minion Attack", "Spider Minion Attack");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package mineplex.minecraft.game.core.boss.spider.attacks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.boss.BossAbility;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderCreature;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
import net.minecraft.server.v1_7_R4.MovingObjectPosition;
|
||||
import net.minecraft.server.v1_7_R4.Vec3D;
|
||||
|
||||
public class SpiderEggplosm extends BossAbility<SpiderCreature, Spider>
|
||||
{
|
||||
private int _eggsToSpray = 30;
|
||||
private HashMap<Block, Long> _eggs = new HashMap<Block, Long>();
|
||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||
private int _tick;
|
||||
private float _yaw;
|
||||
private float _addYaw;
|
||||
|
||||
public SpiderEggplosm(SpiderCreature creature)
|
||||
{
|
||||
super(creature);
|
||||
|
||||
_addYaw = 360F / _eggsToSpray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMove()
|
||||
{
|
||||
return inProgress();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
|
||||
return;
|
||||
|
||||
Block block = event.getTo().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!_eggs.containsKey(block))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_eggs.remove(block);
|
||||
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.FALL_BIG, 2.5F, 0F);
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.DRAGON_EGG, 0),
|
||||
block.getLocation().add(0.5, 0.6, 0.5), 0.6F, 0.5F, 0.6F, 0, 100, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inProgress()
|
||||
{
|
||||
return _eggsToSpray > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFinished()
|
||||
{
|
||||
return _eggsToSpray <= 0 && _fallingBlocks.isEmpty() && _eggs.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFinished()
|
||||
{
|
||||
for (FallingBlock block : _fallingBlocks)
|
||||
{
|
||||
block.remove();
|
||||
}
|
||||
|
||||
for (Block b : _eggs.keySet())
|
||||
{
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
if (_eggsToSpray > 0 && _tick % 10 == 0)
|
||||
{
|
||||
_eggsToSpray--;
|
||||
|
||||
UtilEnt.CreatureLook(getEntity(), 0, _yaw);
|
||||
|
||||
_yaw += _addYaw;
|
||||
|
||||
Vector vec = getEntity().getLocation().getDirection();
|
||||
|
||||
vec.setY(0).normalize().setY(0.4 + (UtilMath.rr(0.4, false)));
|
||||
|
||||
FallingBlock block = getLocation().getWorld().spawnFallingBlock(vec.toLocation(getLocation().getWorld()),
|
||||
Material.WEB, (byte) 0);
|
||||
block.setDropItem(false);
|
||||
|
||||
_fallingBlocks.add(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
Iterator<Entry<Block, Long>> itel = _eggs.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Block, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
itel.remove();
|
||||
entry.getKey().setType(Material.AIR);
|
||||
entry.getKey().getWorld().playEffect(entry.getKey().getLocation(), Effect.STEP_SOUND,
|
||||
Material.DRAGON_EGG.getId());
|
||||
((SpiderBoss) getBoss().getEvent()).spawnMinion(entry.getKey().getLocation().add(0.5, 0.1, 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<FallingBlock> fallingIterator = _fallingBlocks.iterator();
|
||||
|
||||
while (fallingIterator.hasNext())
|
||||
{
|
||||
FallingBlock cur = fallingIterator.next();
|
||||
|
||||
if (cur.isDead() || !cur.isValid() || cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
fallingIterator.remove();
|
||||
|
||||
Block block = cur.getLocation().getBlock();
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
// Expire
|
||||
if (cur.getTicksLived() > 400
|
||||
|| !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
cur.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
|
||||
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
|
||||
nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
|
||||
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
|
||||
vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ + nmsEntity.motZ);
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
|
||||
}
|
||||
|
||||
if (finalObjectPosition != null)
|
||||
{
|
||||
Block block = cur.getWorld().getBlockAt(finalObjectPosition.b, finalObjectPosition.c, finalObjectPosition.d);
|
||||
|
||||
if (!UtilBlock.airFoliage(block) && !block.isLiquid())
|
||||
{
|
||||
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
|
||||
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
|
||||
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
|
||||
float f2 = MathHelper.sqrt(
|
||||
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
|
||||
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
|
||||
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
|
||||
|
||||
block.setType(Material.DRAGON_EGG);
|
||||
_eggs.put(block, System.currentTimeMillis() + 10000 + UtilMath.r(10000));
|
||||
|
||||
fallingIterator.remove();
|
||||
cur.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
|
||||
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
|
||||
UtilServer.getPlayers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,30 +2,30 @@ package nautilus.game.arcade.game.games.bossbattles;
|
||||
|
||||
import mineplex.minecraft.game.core.boss.ironwizard.GolemBoss;
|
||||
import mineplex.minecraft.game.core.boss.slimeking.SlimeBoss;
|
||||
import nautilus.game.arcade.game.games.bossbattles.displays.BossDisplay;
|
||||
import nautilus.game.arcade.game.games.bossbattles.displays.IronWizardDisplay;
|
||||
import nautilus.game.arcade.game.games.bossbattles.displays.SlimeKingDisplay;
|
||||
import mineplex.minecraft.game.core.boss.snake.SnakeBoss;
|
||||
import mineplex.minecraft.game.core.boss.spider.SpiderBoss;
|
||||
import nautilus.game.arcade.game.games.bossbattles.displays.*;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum BattleBoss
|
||||
{
|
||||
GOLEM(GolemBoss.class, IronWizardDisplay.class, new ItemStack(
|
||||
Material.IRON_BLOCK)),
|
||||
GOLEM(GolemBoss.class, IronWizardDisplay.class),
|
||||
|
||||
SLIME(SlimeBoss.class, SlimeKingDisplay.class, new ItemStack(
|
||||
Material.EMERALD_BLOCK));
|
||||
SNAKE(SnakeBoss.class, SnakeDisplay.class),
|
||||
|
||||
SLIME(SlimeBoss.class, SlimeKingDisplay.class),
|
||||
|
||||
SPIDER(SpiderBoss.class, SpiderDisplay.class);
|
||||
|
||||
private Class _bossClass;
|
||||
private ItemStack _bossHead;
|
||||
private Class<? extends BossDisplay> _bossDisplay;
|
||||
|
||||
private BattleBoss(Class bossClass,
|
||||
Class<? extends BossDisplay> displayClass, ItemStack bossHead)
|
||||
Class<? extends BossDisplay> displayClass)
|
||||
{
|
||||
_bossClass = bossClass;
|
||||
_bossHead = bossHead;
|
||||
_bossDisplay = displayClass;
|
||||
}
|
||||
|
||||
@ -39,8 +39,4 @@ public enum BattleBoss
|
||||
return _bossDisplay;
|
||||
}
|
||||
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return _bossHead;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -52,6 +53,16 @@ public class BossBattles extends TeamGame
|
||||
{
|
||||
"Fight some bosses"
|
||||
});
|
||||
|
||||
HungerSet = 20;
|
||||
CreatureAllowOverride = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
if (event.getSpawnReason() != event.getSpawnReason().CUSTOM)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,12 +121,10 @@ public class BossBattles extends TeamGame
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureAllowOverride = false;
|
||||
|
||||
HandlerList.unregisterAll(_currentBoss);
|
||||
|
||||
// If the event was cancelled, we don't need to run a cleanup
|
||||
if (_currentBoss.getState() == EventState.COMPLETE)
|
||||
if (_currentBoss.getState() != EventState.CANCELLED)
|
||||
_currentBoss.cleanup();
|
||||
}
|
||||
|
||||
@ -224,7 +233,7 @@ public class BossBattles extends TeamGame
|
||||
int i = 0;
|
||||
ArrayList<Location> locations = UtilShapes.getPointsInCircle(
|
||||
new Location(UtilWorld.getWorld("world"), 0, 104, 0),
|
||||
BattleBoss.values().length, 5);
|
||||
BattleBoss.values().length, 4.5);
|
||||
|
||||
for (BattleBoss boss : BattleBoss.values())
|
||||
{
|
||||
@ -242,12 +251,12 @@ public class BossBattles extends TeamGame
|
||||
BossDisplay bossDisplay = constructor.newInstance(this,
|
||||
BattleBoss.values()[i], loc);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(bossDisplay,
|
||||
getArcadeManager().getPlugin());
|
||||
|
||||
bossDisplay.start();
|
||||
bossDisplay.spawnHologram();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(bossDisplay,
|
||||
getArcadeManager().getPlugin());
|
||||
|
||||
_displays.add(bossDisplay);
|
||||
|
||||
System.out.print(
|
||||
@ -281,14 +290,10 @@ public class BossBattles extends TeamGame
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureAllowOverride = true;
|
||||
|
||||
_currentBoss.start();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(_currentBoss,
|
||||
getArcadeManager().getPlugin());
|
||||
|
||||
CreatureAllowOverride = false;
|
||||
}
|
||||
|
||||
public WorldEvent createInstance(Class clazz, Location centerLocation)
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
@ -31,6 +32,15 @@ public abstract class BossDisplay implements Listener
|
||||
_bossLocation = location;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityInteractEvent(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (_entities.contains(event.getRightClicked()))
|
||||
{
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public void addEntity(Entity entity)
|
||||
{
|
||||
_entities.add(entity);
|
||||
|
@ -21,29 +21,14 @@ public class IronWizardDisplay extends BossDisplay
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!event.getRightClicked().equals(_golem))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Plugin.CreatureAllowOverride = true;
|
||||
|
||||
_golem = (IronGolem) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.IRON_GOLEM);
|
||||
_golem.teleport(getLocation());
|
||||
UtilEnt.Vegetate(_golem);
|
||||
|
||||
Plugin.CreatureAllowOverride = false;
|
||||
|
||||
addEntity(_golem);
|
||||
}
|
||||
|
||||
|
@ -22,22 +22,9 @@ public class SlimeKingDisplay extends BossDisplay
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!event.getRightClicked().equals(_slime))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setChosen(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Plugin.CreatureAllowOverride = true;
|
||||
|
||||
_slime = (Slime) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SLIME);
|
||||
_slime.setSize(4);
|
||||
@ -46,8 +33,6 @@ public class SlimeKingDisplay extends BossDisplay
|
||||
|
||||
UtilEnt.Vegetate(_slime);
|
||||
|
||||
Plugin.CreatureAllowOverride = false;
|
||||
|
||||
addEntity(_slime);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
package nautilus.game.arcade.game.games.bossbattles.displays;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
|
||||
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class SnakeDisplay extends BossDisplay
|
||||
{
|
||||
private Sheep _sheep;
|
||||
|
||||
public SnakeDisplay(BossBattles plugin, BattleBoss boss, Location location)
|
||||
{
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
_sheep = (Sheep) getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SHEEP);
|
||||
|
||||
_sheep.teleport(getLocation());
|
||||
|
||||
UtilEnt.Vegetate(_sheep);
|
||||
|
||||
addEntity(_sheep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return C.cDGreen + "SNAAAAAAAAAAAAAAAAAKE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnHologram()
|
||||
{
|
||||
super.spawnHologram();
|
||||
|
||||
getHologram().setFollowEntity(_sheep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getHologramLocation()
|
||||
{
|
||||
return _sheep.getEyeLocation().add(0, 0.1, 0);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package nautilus.game.arcade.game.games.bossbattles.displays;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import nautilus.game.arcade.game.games.bossbattles.BattleBoss;
|
||||
import nautilus.game.arcade.game.games.bossbattles.BossBattles;
|
||||
|
||||
public class SpiderDisplay extends BossDisplay
|
||||
{
|
||||
|
||||
public SpiderDisplay(BossBattles plugin, BattleBoss boss, Location location)
|
||||
{
|
||||
super(plugin, boss, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return C.cDBlue + "Brood Mother";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
Entity entity = getLocation().getWorld().spawnEntity(getLocation(),
|
||||
EntityType.SPIDER);
|
||||
|
||||
UtilEnt.Vegetate(entity);
|
||||
this.addEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getHologramLocation()
|
||||
{
|
||||
return getLocation().clone().add(0, 2, 0);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user