Merge remote-tracking branch 'remotes/origin/alex-mcl' into develop
This commit is contained in:
commit
260c617007
@ -1,5 +1,6 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -46,6 +47,15 @@ public class UtilEvent
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isBowDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (!(event instanceof EntityDamageByEntityEvent))
|
||||
return false;
|
||||
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event;
|
||||
return e.getDamager() instanceof Arrow;
|
||||
}
|
||||
|
||||
public static LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged)
|
||||
{
|
||||
if (!(event instanceof EntityDamageByEntityEvent))
|
||||
|
@ -306,10 +306,10 @@ public class UtilItem
|
||||
_materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
|
||||
_materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR));
|
||||
_materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM));
|
||||
_materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD));
|
||||
_materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE));
|
||||
@ -550,7 +550,7 @@ public class UtilItem
|
||||
|
||||
public static boolean isSword(ItemStack stack)
|
||||
{
|
||||
return isEdible(stack == null ? null : stack.getType());
|
||||
return isSword(stack == null ? null : stack.getType());
|
||||
}
|
||||
|
||||
public static boolean isSword(Material material)
|
||||
|
@ -164,6 +164,43 @@ public enum Achievement
|
||||
new int[]{10},
|
||||
AchievementCategory.UHC),
|
||||
|
||||
//MC League
|
||||
MC_LEAGUE_STRIKE("First Strike", 600,
|
||||
new String[] {"MC League.FirstStrike"},
|
||||
new String[] {"Earn 30 First Bloods"},
|
||||
new int[] {30},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
MC_LEAGUE_HEAD("Head Hunter", 600,
|
||||
new String[] {"MC League.HeadHunter"},
|
||||
new String[] {"Grab 25 Wither Skulls"},
|
||||
new int[] {25},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
MC_LEAGUE_ALTAR("Altar Builder", 600,
|
||||
new String[] {"MC League.AltarBuilder"},
|
||||
new String[] {"Place 50 Wither Skulls", "on your Altar"},
|
||||
new int[] {50},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
MC_LEAGUE_WINS("Mineplex Champion", 900,
|
||||
new String[] {"MC League.Wins"},
|
||||
new String[] {"Win 25 Games"},
|
||||
new int[] {25},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
MC_LEAGUE_TOWER("Tower Defender", 800,
|
||||
new String[] {"MC League.TowerDefender"},
|
||||
new String[] {"Get a double kill", "inside your Active Tower"},
|
||||
new int[] {1},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
MC_LEAGUE_SAVING("Saving Up", 900,
|
||||
new String[] {"MC League.SavingUp"},
|
||||
new String[] {"Craft a Diamond Chestplate"},
|
||||
new int[] {1},
|
||||
AchievementCategory.MC_LEAGUE),
|
||||
|
||||
//UHC
|
||||
WIZARDS_WINS("Supreme Wizard", 600,
|
||||
new String[]{"Wizards.Wins"},
|
||||
@ -834,7 +871,7 @@ public enum Achievement
|
||||
new int[]{15},
|
||||
AchievementCategory.GLADIATORS),
|
||||
|
||||
TYPE_WARS_SPEED_DEMON("Speed Demon", 1000,
|
||||
/*TYPE_WARS_SPEED_DEMON("Speed Demon", 1000,
|
||||
new String[]{"Type Wars.Demon"},
|
||||
new String[]{"Kill 5 Mobs in 8 seconds", "by typing"},
|
||||
new int[]{1},
|
||||
@ -868,7 +905,7 @@ public enum Achievement
|
||||
new String[]{"Type Wars.Wins"},
|
||||
new String[]{"Win 30 Games"},
|
||||
new int[]{30},
|
||||
AchievementCategory.TYPE_WARS),
|
||||
AchievementCategory.TYPE_WARS),*/
|
||||
|
||||
SPEED_BUILDERS_SPEED_MASTER("Speed Master", 800,
|
||||
new String[]{"Speed Builders.Wins"},
|
||||
|
@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.game.GameCategory;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.stats.PlayerStats;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
@ -49,6 +50,10 @@ public enum AchievementCategory
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"),
|
||||
|
||||
MC_LEAGUE("MC League", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None"),
|
||||
|
||||
WIZARDS("Wizards", null,
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit"),
|
||||
@ -155,9 +160,9 @@ public enum AchievementCategory
|
||||
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED },
|
||||
Material.IRON_SWORD, 0, GameCategory.ARCADE, null),
|
||||
|
||||
TYPE_WARS("Type Wars", null,
|
||||
/*TYPE_WARS("Type Wars", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED},
|
||||
Material.NAME_TAG, 0, GameCategory.CLASSICS, null),
|
||||
Material.NAME_TAG, 0, GameCategory.CLASSICS, null),*/
|
||||
|
||||
SPEED_BUILDERS("Speed Builders", null,
|
||||
new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")},
|
||||
|
@ -9,14 +9,13 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -32,7 +31,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -234,7 +232,7 @@ public class Explosion extends MiniPlugin
|
||||
fallingIterator.remove();
|
||||
|
||||
//Expire
|
||||
if (cur.getTicksLived() > 400 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
if (cur.getTicksLived() > 100 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4))
|
||||
{
|
||||
cur.remove();
|
||||
return;
|
||||
@ -362,4 +360,16 @@ public class Explosion extends MiniPlugin
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean var)
|
||||
{
|
||||
if (var)
|
||||
{
|
||||
registerSelf();
|
||||
}
|
||||
else
|
||||
{
|
||||
deregisterSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,14 +69,17 @@ public enum GameDisplay
|
||||
|
||||
Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54),
|
||||
|
||||
Minecraft_League("MC League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 62),
|
||||
|
||||
ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56),
|
||||
|
||||
BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57),
|
||||
Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58),
|
||||
TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59),
|
||||
|
||||
SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60),
|
||||
|
||||
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 60),
|
||||
Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61),
|
||||
|
||||
Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
|
||||
|
||||
|
106
Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java
Normal file
106
Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java
Normal file
@ -0,0 +1,106 @@
|
||||
package mineplex.core.map;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.map.MapView.Scale;
|
||||
|
||||
public class TeamMap
|
||||
{
|
||||
List<Player> _players;
|
||||
final ItemStack _map;
|
||||
|
||||
public TeamMap(List<Player> display, Location loc, Scale scale)
|
||||
{
|
||||
_players = display;
|
||||
MapView view = Bukkit.createMap(loc.getWorld());
|
||||
view.setCenterX(loc.getBlockX());
|
||||
view.setCenterZ(loc.getBlockZ());
|
||||
view.setScale(scale);
|
||||
|
||||
_map = new ItemStack(Material.MAP);
|
||||
_map.setDurability(view.getId());
|
||||
}
|
||||
|
||||
public void update(Player... forceRemove)
|
||||
{
|
||||
if (forceRemove != null)
|
||||
{
|
||||
for (Player remove : forceRemove)
|
||||
{
|
||||
_players.remove(remove);
|
||||
}
|
||||
}
|
||||
|
||||
List<Player> confirmed = new ArrayList<Player>();
|
||||
|
||||
for (Player check : _players)
|
||||
{
|
||||
if (!UtilPlayer.isOnline(check.getName()))
|
||||
continue;
|
||||
|
||||
if (UtilPlayer.isSpectator(check))
|
||||
continue;
|
||||
|
||||
confirmed.add(check);
|
||||
}
|
||||
|
||||
_players.clear();
|
||||
for (Player add : confirmed)
|
||||
_players.add(add);
|
||||
}
|
||||
|
||||
public void giveMaps()
|
||||
{
|
||||
update(null);
|
||||
|
||||
for (Player player : _players)
|
||||
{
|
||||
UtilInv.insert(player, _map);
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveMap(Player player)
|
||||
{
|
||||
giveMap(player, true, "");
|
||||
}
|
||||
|
||||
public void giveMap(Player player, boolean add, String displayName, String... lore)
|
||||
{
|
||||
if (!_players.contains(player))
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
_players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack map = _map.clone();
|
||||
ItemMeta im = map.getItemMeta();
|
||||
if (!displayName.equalsIgnoreCase(""))
|
||||
im.setDisplayName(displayName);
|
||||
|
||||
List<String> lores = new ArrayList<String>();
|
||||
for (String s : lore)
|
||||
lores.add(s);
|
||||
|
||||
if (!lores.isEmpty())
|
||||
im.setLore(lores);
|
||||
|
||||
map.setItemMeta(im);
|
||||
|
||||
UtilInv.insert(player, map);
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
@ -226,7 +226,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
Get(from).LastToTime = System.currentTimeMillis();
|
||||
|
||||
// Chiss or defek7
|
||||
if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("fooify") || to.getName().equals("sampepere"))
|
||||
if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder"))
|
||||
{
|
||||
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
|
||||
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
|
||||
|
@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.combat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Fireball;
|
||||
@ -90,10 +91,52 @@ public class CombatManager extends MiniPlugin
|
||||
if (damagerEnt instanceof Player)
|
||||
Get((Player)damagerEnt).SetLastCombat(System.currentTimeMillis());
|
||||
|
||||
String cause = "";
|
||||
switch(event.getCause())
|
||||
{
|
||||
case ENTITY_ATTACK:
|
||||
cause = "Attack";
|
||||
break;
|
||||
case ENTITY_EXPLOSION:
|
||||
cause = "Explosion";
|
||||
break;
|
||||
case MAGIC:
|
||||
cause = "Thrown Potion";
|
||||
break;
|
||||
case PROJECTILE:
|
||||
cause = "Ranged Weapon";
|
||||
break;
|
||||
case THORNS:
|
||||
cause = "Thorns Enchantment";
|
||||
break;
|
||||
default:
|
||||
cause = event.getCause() + "";
|
||||
break;
|
||||
}
|
||||
|
||||
if (UtilEvent.isBowDamage(event))
|
||||
{
|
||||
cause = "Bow";
|
||||
}
|
||||
|
||||
if (damagerEnt instanceof Player)
|
||||
{
|
||||
if (event.getCause() == DamageCause.ENTITY_ATTACK)
|
||||
{
|
||||
Player player = (Player) damagerEnt;
|
||||
if (player.getItemInHand() == null)
|
||||
cause = "Fists";
|
||||
else if (player.getItemInHand().getType() == Material.AIR)
|
||||
cause = "Fists";
|
||||
else
|
||||
cause = ItemStackFactory.Instance.GetName(player.getItemInHand(), false);
|
||||
}
|
||||
}
|
||||
|
||||
Get(damagee).Attacked(
|
||||
UtilEnt.getName(damagerEnt),
|
||||
event.getDamage(), damagerEnt,
|
||||
event.getCause() + "", null);
|
||||
cause, null);
|
||||
}
|
||||
// Damager is WORLD
|
||||
else
|
||||
|
@ -693,6 +693,11 @@ public class DamageManager extends MiniPlugin
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean IsEnabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public void SetEnabled(boolean var)
|
||||
{
|
||||
_enabled = var;
|
||||
|
@ -58,6 +58,7 @@ import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
import nautilus.game.arcade.game.GameServerConfig;
|
||||
import net.minecraft.server.v1_8_R3.BiomeBase;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
@ -161,6 +162,8 @@ public class Arcade extends JavaPlugin
|
||||
PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, incognito, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, customDataManager, punish);
|
||||
|
||||
//new BroadcastManager(this, _gameManager);
|
||||
|
||||
new MemoryFix(this);
|
||||
new CustomTagFix(this, packetHandler);
|
||||
new PacketsInteractionFix(this, packetHandler);
|
||||
@ -254,6 +257,11 @@ public class Arcade extends JavaPlugin
|
||||
return config;
|
||||
}
|
||||
|
||||
public ArcadeManager getArcadeManager()
|
||||
{
|
||||
return _gameManager;
|
||||
}
|
||||
|
||||
private void DeleteFolders()
|
||||
{
|
||||
File curDir = new File(".");
|
||||
|
@ -199,6 +199,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
// Observers
|
||||
private HashSet<Player> _specList = new HashSet<Player>();
|
||||
private HashSet<Player> _fakeObserve = new HashSet<Player>();
|
||||
|
||||
// Server Games
|
||||
private GameServerConfig _serverConfig;
|
||||
@ -1140,13 +1141,21 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_specList.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
public void toggleFakeObserver(Player player)
|
||||
{
|
||||
if (!_fakeObserve.remove(player))
|
||||
_fakeObserve.add(player);
|
||||
}
|
||||
|
||||
public boolean IsObserver(Player player)
|
||||
{
|
||||
if (_fakeObserve.contains(player))
|
||||
return true;
|
||||
|
||||
if (_incognitoManager.Get(player).Status)
|
||||
{
|
||||
_specList.add(player);
|
||||
}
|
||||
|
||||
return _specList.contains(player);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import nautilus.game.arcade.game.games.horsecharge.Horse;
|
||||
import nautilus.game.arcade.game.games.lobbers.BombLobbers;
|
||||
import nautilus.game.arcade.game.games.micro.Micro;
|
||||
import nautilus.game.arcade.game.games.milkcow.MilkCow;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minestrike.MineStrike;
|
||||
import nautilus.game.arcade.game.games.mineware.MineWare;
|
||||
import nautilus.game.arcade.game.games.monsterleague.MonsterLeague;
|
||||
@ -120,6 +121,7 @@ public enum GameType
|
||||
Pair.create(MinecraftVersion.Version1_9, "http://chivebox.com/mineplex/ResMinestrike19.zip")
|
||||
}, true),
|
||||
MineWare(MineWare.class, GameDisplay.MineWare),
|
||||
MinecraftLeague(MinecraftLeague.class, GameDisplay.Minecraft_League),
|
||||
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
|
||||
Paintball(Paintball.class, GameDisplay.Paintball),
|
||||
Quiver(Quiver.class, GameDisplay.Quiver),
|
||||
@ -203,6 +205,7 @@ public enum GameType
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display, Pair<MinecraftVersion, String>[] resourcePackUrls, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps)
|
||||
{
|
||||
_display = display;
|
||||
_gameId = display.getGameId();
|
||||
_gameClass = gameClass;
|
||||
_resourcePacks = resourcePackUrls;
|
||||
_enforceResourcePack = enforceResourcePack;
|
||||
|
@ -0,0 +1,97 @@
|
||||
package nautilus.game.arcade.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutCamera;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BroadcastData
|
||||
{
|
||||
private Player _player;
|
||||
private BroadcastManager _plugin;
|
||||
|
||||
private boolean _rotate;
|
||||
|
||||
private List<Player> _gamePlayers;
|
||||
private List<Player> _recentlyViewed;
|
||||
private Player _currentlyViewing;
|
||||
|
||||
public BroadcastData(Player player, BroadcastManager plugin)
|
||||
{
|
||||
_player = player;
|
||||
_plugin = plugin;
|
||||
|
||||
_recentlyViewed = new ArrayList<Player>();
|
||||
|
||||
setRotating(false);
|
||||
}
|
||||
|
||||
private void setRotating(boolean rotate)
|
||||
{
|
||||
_rotate = rotate;
|
||||
UtilPlayer.message(_player, F.main(_plugin.getName(), "Player Rotation: " + rotate));
|
||||
}
|
||||
|
||||
public boolean isRotating()
|
||||
{
|
||||
return _rotate;
|
||||
}
|
||||
|
||||
public Player currentView()
|
||||
{
|
||||
return _currentlyViewing;
|
||||
}
|
||||
|
||||
public Player nextPlayer()
|
||||
{
|
||||
if (_gamePlayers.size() == _recentlyViewed.size())
|
||||
_recentlyViewed.clear();
|
||||
|
||||
for (Player player : _gamePlayers)
|
||||
{
|
||||
if (!player.isOnline() || !player.isValid() || player.isDead())
|
||||
continue;
|
||||
|
||||
if (!_recentlyViewed.contains(player))
|
||||
return player;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void toggleRotating(List<Player> gamePlayers)
|
||||
{
|
||||
if (!isRotating())
|
||||
{
|
||||
if (gamePlayers == null)
|
||||
return;
|
||||
|
||||
if (gamePlayers.size() == 0)
|
||||
return;
|
||||
|
||||
_gamePlayers = gamePlayers;
|
||||
}
|
||||
if (isRotating())
|
||||
{
|
||||
PacketPlayOutCamera restore = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)_player);
|
||||
((CraftPlayer)_player).getHandle().playerConnection.sendPacket(restore);
|
||||
}
|
||||
setRotating(!isRotating());
|
||||
}
|
||||
|
||||
public void goToNext(Player player)
|
||||
{
|
||||
Recharge.Instance.useForce(_player, "Broadcaster Rotation", UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false);
|
||||
_currentlyViewing = player;
|
||||
PacketPlayOutCamera view = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)player);
|
||||
((CraftPlayer)_player).getHandle().playerConnection.sendPacket(view);
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package nautilus.game.arcade.broadcast;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BroadcastManager extends MiniPlugin
|
||||
{
|
||||
ArcadeManager ArcadeManager;
|
||||
private ConcurrentHashMap<Player, BroadcastData> _broadcasters;
|
||||
|
||||
public BroadcastManager(JavaPlugin plugin, ArcadeManager manager)
|
||||
{
|
||||
super("Broadcasting Manager", plugin);
|
||||
ArcadeManager = manager;
|
||||
_broadcasters = new ConcurrentHashMap<Player, BroadcastData>();
|
||||
}
|
||||
|
||||
public boolean isBroadcaster(Player player)
|
||||
{
|
||||
return _broadcasters.containsKey(player);
|
||||
}
|
||||
|
||||
public void addBroadcaster(Player player)
|
||||
{
|
||||
_broadcasters.put(player, new BroadcastData(player, this));
|
||||
if (ArcadeManager.GetGame() != null)
|
||||
{
|
||||
ArcadeManager.GetGame().RemoveTeamPreference(player);
|
||||
ArcadeManager.GetGame().GetPlayerKits().remove(player);
|
||||
ArcadeManager.GetGame().GetPlayerGems().remove(player);
|
||||
try
|
||||
{
|
||||
ArcadeManager.GetGame().GetTeam(player).RemovePlayer(player);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
ArcadeManager.Clear(player);
|
||||
ArcadeManager.toggleFakeObserver(player);
|
||||
}
|
||||
player.getInventory().clear();
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
public void removeBroadcaster(Player player)
|
||||
{
|
||||
_broadcasters.remove(player);
|
||||
ArcadeManager.toggleFakeObserver(player);
|
||||
if (ArcadeManager.GetGame().InProgress())
|
||||
ArcadeManager.addSpectator(player, true);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleBroadcasting(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Dead)
|
||||
{
|
||||
for (BroadcastData data : _broadcasters.values())
|
||||
{
|
||||
if (data.isRotating())
|
||||
data.toggleRotating(null);
|
||||
}
|
||||
_broadcasters.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleRotation(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FASTEST)
|
||||
{
|
||||
Game game = ArcadeManager.GetGame();
|
||||
if (game == null)
|
||||
return;
|
||||
if (!game.InProgress())
|
||||
return;
|
||||
|
||||
for (Player player : _broadcasters.keySet())
|
||||
{
|
||||
if (!Recharge.Instance.usable(player, "Broadcaster Rotation", false))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleRotation(PlayerQuitEvent event)
|
||||
{
|
||||
Game game = ArcadeManager.GetGame();
|
||||
if (game == null)
|
||||
return;
|
||||
if (!game.InProgress())
|
||||
return;
|
||||
|
||||
if (_broadcasters.containsKey(event.getPlayer()))
|
||||
_broadcasters.remove(event.getPlayer());
|
||||
|
||||
for (BroadcastData data : _broadcasters.values())
|
||||
{
|
||||
if (data.currentView() == null)
|
||||
continue;
|
||||
|
||||
if (data.currentView() == event.getPlayer());
|
||||
data.goToNext(data.nextPlayer());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package nautilus.game.arcade.broadcast.command;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
import nautilus.game.arcade.broadcast.command.manage.AddCommand;
|
||||
import nautilus.game.arcade.broadcast.command.manage.RemoveCommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BroadcastCommand extends MultiCommandBase<BroadcastManager>
|
||||
{
|
||||
public BroadcastCommand(BroadcastManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.TWITCH, Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.JNR_DEV}, "broadcaster");
|
||||
AddCommand(new AddCommand(plugin));
|
||||
AddCommand(new RemoveCommand(plugin));
|
||||
AddCommand(new RotateCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:"));
|
||||
UtilPlayer.message(caller, F.help("/broadcaster add <Player>", "Puts a player in Broadcast mode for this game", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/broadcaster remove <Player>", "Takes a player out of Broadcast mode", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/broadcaster rotate", "Toggles rotating view between game players", Rank.TWITCH));
|
||||
UtilPlayer.message(caller, F.main("Tip", "Rotation is great for a background to commentary!"));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package nautilus.game.arcade.broadcast.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
|
||||
public class RotateCommand extends CommandBase<BroadcastManager>
|
||||
{
|
||||
public RotateCommand(BroadcastManager plugin) {
|
||||
super(plugin, Rank.TWITCH, "rotate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package nautilus.game.arcade.broadcast.command.manage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
|
||||
public class AddCommand extends CommandBase<BroadcastManager>
|
||||
{
|
||||
public AddCommand(BroadcastManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package nautilus.game.arcade.broadcast.command.manage;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.broadcast.BroadcastManager;
|
||||
|
||||
public class RemoveCommand extends CommandBase<BroadcastManager>
|
||||
{
|
||||
public RemoveCommand(BroadcastManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "remove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -893,7 +893,7 @@ public abstract class Game implements Listener
|
||||
public void RespawnPlayer(final Player player)
|
||||
{
|
||||
player.eject();
|
||||
player.teleport(GetTeam(player).GetSpawn());
|
||||
RespawnPlayerTeleport(player);
|
||||
|
||||
Manager.Clear(player);
|
||||
|
||||
@ -911,6 +911,11 @@ public abstract class Game implements Listener
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void RespawnPlayerTeleport(Player player)
|
||||
{
|
||||
player.teleport(GetTeam(player).GetSpawn());
|
||||
}
|
||||
|
||||
public boolean IsPlaying(Player player)
|
||||
{
|
||||
return GetTeam(player) != null;
|
||||
|
@ -0,0 +1,42 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague;
|
||||
|
||||
public enum DataLoc
|
||||
{
|
||||
//Base
|
||||
RED_CRYSTAL(" RED CRYSTAL"),
|
||||
RED_TOWER(" RED TOWER"),
|
||||
BLUE_CRYSTAL(" BLUE CRYSTAL"),
|
||||
BLUE_TOWER(" BLUE TOWER"),
|
||||
VARIANT_BASE("GAMEMODE "),
|
||||
//RED_BEACON("PINK"),
|
||||
/*BLUE_*/BEACON("CYAN"),
|
||||
SKELETON_SPAWNER("BROWN"),
|
||||
//MAP_DIAMOND("LIGHT_BLUE"),
|
||||
//MAP_IRON("SILVER"),
|
||||
RED_ORE("15"),
|
||||
BLUE_ORE("14"),
|
||||
DIAMOND_ORE("56"),
|
||||
COAL_ORE("16"),
|
||||
MOSH_IRON("129"),
|
||||
GRIND_AREA(" GRIND"),
|
||||
|
||||
//Wither
|
||||
WITHER_WAYPOINT("PURPLE"),
|
||||
TOWER_WAYPOINT(" $team$ WITHER $number$"),
|
||||
WITHER_SKELETON("BLACK"),
|
||||
BLUE_ALTAR("LIME"),
|
||||
RED_ALTAR("YELLOW")
|
||||
;
|
||||
|
||||
private String _key;
|
||||
|
||||
private DataLoc(String key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DebugCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public DebugCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "debug");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller.getWorld().spawnEntity(caller.getLocation(), EntityType.ENDER_CRYSTAL);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeCommand;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.commands.panel.GUICommand;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MinecraftLeagueCommand extends MultiCommandBase<ArcadeManager>
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
public MinecraftLeagueCommand(ArcadeManager plugin, MinecraftLeague host)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "mcLeague");
|
||||
AddCommand(new GUICommand(plugin, host));
|
||||
AddCommand(new FreezeCommand(plugin, host));
|
||||
AddCommand(new StatusCommand(plugin, host));
|
||||
AddCommand(new DebugCommand(plugin));
|
||||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:"));
|
||||
UtilPlayer.message(caller, F.help("/mcLeague gui", "Opens a GUI for controlling Respawn Crystals", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/mcLeague freeze <player>", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/mcLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER));
|
||||
UtilPlayer.message(caller, F.help("/mcLeague debug", "Spawns a Tower Mob at your position", Rank.DEVELOPER));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StatusCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
public StatusCommand(ArcadeManager plugin, MinecraftLeague host)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "status");
|
||||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
_host.handleCommand(caller);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands.freeze;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FreezeCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
public FreezeCommand(ArcadeManager plugin, MinecraftLeague host)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "freeze");
|
||||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.help("/mcLeague freeze <player>", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN));
|
||||
return;
|
||||
}
|
||||
|
||||
String name = args[0];
|
||||
Player get = UtilPlayer.searchOnline(caller, name, true);
|
||||
|
||||
if (get != null)
|
||||
{
|
||||
_host.getFreezeManager().toggleFreeze(get, caller);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands.freeze;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent.Action;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class FreezeManager implements Listener
|
||||
{
|
||||
private ConcurrentHashMap<String, String> _frozen = new ConcurrentHashMap<String, String>();
|
||||
|
||||
private void showBan(String player, Player staff)
|
||||
{
|
||||
ClickEvent prep = new ClickEvent(Action.SUGGEST_COMMAND, "/p " + player + " Logging out during Freeze [MCL]");
|
||||
TextComponent message = new TextComponent(player + " has logged out while frozen! Click here for a ready-made punishment command!");
|
||||
message.setColor(ChatColor.DARK_RED);
|
||||
message.setClickEvent(prep);
|
||||
|
||||
staff.spigot().sendMessage(message);
|
||||
}
|
||||
|
||||
public boolean isFrozen(Player player)
|
||||
{
|
||||
return _frozen.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void toggleFreeze(Player player, Player staff)
|
||||
{
|
||||
if (isFrozen(player))
|
||||
{
|
||||
_frozen.remove(player.getName());
|
||||
UtilPlayer.message(staff, F.main("Freeze", "You have unfrozen " + player.getName()));
|
||||
UtilPlayer.message(player, F.main("Freeze", "You have been unfrozen by " + staff.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
_frozen.put(player.getName(), staff.getName());
|
||||
UtilPlayer.message(staff, F.main("Freeze", "You have frozen " + player.getName()));
|
||||
UtilPlayer.message(player, F.main("Freeze", "You have been frozen by " + staff.getName()));
|
||||
player.teleport(UtilBlock.getHighest(player.getWorld(), player.getLocation().getBlockX(), player.getLocation().getBlockZ()).getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
Location move = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ());
|
||||
move.setPitch(to.getPitch());
|
||||
move.setYaw(to.getYaw());
|
||||
|
||||
event.setTo(move);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogout(PlayerQuitEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
if (UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName())) != null)
|
||||
{
|
||||
showBan(event.getPlayer().getName(), UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName())));
|
||||
_frozen.remove(event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
if (isFrozen((Player)event.getEntity()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPVP(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Player dmg = null;
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
dmg = (Player)event.getDamager();
|
||||
}
|
||||
if (event.getDamager() instanceof Projectile)
|
||||
{
|
||||
if (((Projectile)event.getDamager()).getShooter() instanceof Player)
|
||||
{
|
||||
dmg = (Player) ((Projectile)event.getDamager()).getShooter();
|
||||
}
|
||||
}
|
||||
|
||||
if (dmg == null)
|
||||
return;
|
||||
|
||||
if (isFrozen(dmg))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBuild(BlockPlaceEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands.panel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class AdminPanel implements Listener
|
||||
{
|
||||
private Player _admin;
|
||||
private MinecraftLeague _host;
|
||||
private Inventory _menu;
|
||||
private ConcurrentHashMap<ItemStack, GameTeam> _buttons;
|
||||
private ConcurrentHashMap<GameTeam, Integer> _slots;
|
||||
|
||||
public AdminPanel(Player admin, MinecraftLeague host)
|
||||
{
|
||||
_admin = admin;
|
||||
_host = host;
|
||||
_menu = Bukkit.createInventory(admin, 9, C.cRed + "Admin Panel: Minecraft League");
|
||||
_buttons = new ConcurrentHashMap<ItemStack, GameTeam>();
|
||||
_slots = new ConcurrentHashMap<GameTeam, Integer>();
|
||||
|
||||
ItemStack red = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation())
|
||||
.setTitle(C.cRed + "Red Core")
|
||||
.setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().Alive,
|
||||
C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().getHealth())
|
||||
.build();
|
||||
|
||||
ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation())
|
||||
.setTitle(C.cAqua + "Blue Core")
|
||||
.setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().Alive,
|
||||
C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().getHealth())
|
||||
.build();
|
||||
|
||||
_buttons.put(red, host.GetTeam(ChatColor.RED));
|
||||
_buttons.put(blue, host.GetTeam(ChatColor.AQUA));
|
||||
_slots.put(host.GetTeam(ChatColor.RED), 2);
|
||||
_slots.put(host.GetTeam(ChatColor.AQUA), 6);
|
||||
|
||||
_menu.setItem(2, red);
|
||||
_menu.setItem(6, blue);
|
||||
//2, 6
|
||||
|
||||
admin.openInventory(_menu);
|
||||
Bukkit.getPluginManager().registerEvents(this, _host.Manager.getPlugin());
|
||||
}
|
||||
|
||||
public boolean updateInv()
|
||||
{
|
||||
if (!_admin.getOpenInventory().getTopInventory().getName().equalsIgnoreCase(_menu.getName()))
|
||||
return false;
|
||||
for (ItemStack item : _buttons.keySet())
|
||||
{
|
||||
GameTeam team = _buttons.get(item);
|
||||
ItemMeta im = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
lore.add(C.cGray + "Alive: " + _host.getTowerManager().getTeamTowers(team).getLast().Alive);
|
||||
lore.add(C.cGray + "Health: " + _host.getTowerManager().getTeamTowers(team).getLast().getHealth());
|
||||
im.setLore(lore);
|
||||
item.setItemMeta(im);
|
||||
_buttons.remove(item);
|
||||
_buttons.put(item, team);
|
||||
_menu.setItem(_slots.get(team), item);
|
||||
}
|
||||
_admin.updateInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUseButton(InventoryClickEvent event)
|
||||
{
|
||||
if (!_host.IsLive())
|
||||
return;
|
||||
|
||||
if (!event.getClickedInventory().equals(_menu))
|
||||
return;
|
||||
|
||||
if (!event.getWhoClicked().getName().equals(_admin.getName()))
|
||||
return;
|
||||
|
||||
if (event.getCurrentItem() == null)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (!UtilPlayer.isOnline(_admin.getName()))
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
return;
|
||||
}
|
||||
if (!_host.IsLive())
|
||||
{
|
||||
if (_host.GetState() == GameState.Dead)
|
||||
HandlerList.unregisterAll(this);
|
||||
if (_host.GetState() == GameState.End)
|
||||
_admin.closeInventory();
|
||||
return;
|
||||
}
|
||||
if (!updateInv())
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
private enum MenuButton
|
||||
{
|
||||
CRYSTAL(Material.EYE_OF_ENDER);
|
||||
|
||||
private Material _rep;
|
||||
|
||||
private MenuButton(Material representation)
|
||||
{
|
||||
_rep = representation;
|
||||
}
|
||||
|
||||
public Material getRepresentation()
|
||||
{
|
||||
return _rep;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.commands.panel;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GUICommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
public GUICommand(ArcadeManager plugin, MinecraftLeague host)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "gui");
|
||||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
new AdminPanel(caller, _host);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockProtection
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
private Player _player;
|
||||
private List<Block> _blocks = new ArrayList<Block>();
|
||||
|
||||
public BlockProtection(MinecraftLeague host, Player player)
|
||||
{
|
||||
_host = host;
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public Player getOwner()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public boolean hasBlock(Block block)
|
||||
{
|
||||
for (Block b : _blocks)
|
||||
{
|
||||
if (ProtectionUtil.isSameBlock(block, b))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLockedTo(Player opening, Block block, boolean ignoreTeam)
|
||||
{
|
||||
if (!hasBlock(block))
|
||||
return false;
|
||||
if (_host.GetTeam(_player).GetColor() != _host.GetTeam(opening).GetColor())
|
||||
return ignoreTeam;
|
||||
if (opening.getName().equalsIgnoreCase(_player.getName()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void lockBlock(Block block)
|
||||
{
|
||||
if (_blocks.size() > 5)
|
||||
return;
|
||||
|
||||
_blocks.add(block);
|
||||
_player.playSound(_player.getLocation(), Sound.ANVIL_USE, 5, 1);
|
||||
UtilPlayer.message(_player, F.main("Game", "You have locked this block to your team! Right-click it while sneaking to unlock it!"));
|
||||
}
|
||||
|
||||
public boolean unlockBlock(Block block)
|
||||
{
|
||||
if (_blocks.remove(block))
|
||||
{
|
||||
_player.playSound(_player.getLocation(), Sound.ANVIL_USE, 5, 1);
|
||||
UtilPlayer.message(_player, F.main("Game", "You have unlocked this block!"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,182 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class DefenderAI
|
||||
{
|
||||
private TowerManager _manager;
|
||||
private TeamTowerBase _tower;
|
||||
private int _number;
|
||||
private long _lastAttack;
|
||||
private long _procTime;
|
||||
private DefenseAnimation _animation;
|
||||
|
||||
public DefenderAI(TowerManager manager, TeamTowerBase tower)
|
||||
{
|
||||
_manager = manager;
|
||||
_tower = tower;
|
||||
|
||||
if (tower instanceof TeamTower)
|
||||
_number = ((TeamTower)tower).Number;
|
||||
else
|
||||
_number = 3;
|
||||
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
_procTime = -1;
|
||||
_animation = new DefenseAnimation();
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (!_tower.Alive)
|
||||
return;
|
||||
|
||||
attack();
|
||||
_animation.update();
|
||||
}
|
||||
|
||||
private void animate()
|
||||
{
|
||||
_animation.activate();
|
||||
}
|
||||
|
||||
private void attack()
|
||||
{
|
||||
if (!_tower.Vulnerable)
|
||||
return;
|
||||
|
||||
if (_procTime != -1)
|
||||
{
|
||||
if (System.currentTimeMillis() >= _procTime)
|
||||
{
|
||||
_procTime = -1;
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
attackProc();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!_manager.Attack)
|
||||
return;
|
||||
if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
return;
|
||||
/*if (UtilMath.random.nextDouble() < .75)
|
||||
return;*/
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
_procTime = System.currentTimeMillis() + UtilTime.convert(4, TimeUnit.SECONDS, TimeUnit.MILLISECONDS);
|
||||
animate();
|
||||
}
|
||||
|
||||
private void attackProc()
|
||||
{
|
||||
_animation.deactivate();
|
||||
for (LivingEntity le : UtilEnt.getInRadius(_tower.getLocation(), 7).keySet())
|
||||
{
|
||||
if (!(le instanceof Player))
|
||||
continue;
|
||||
|
||||
Player player = (Player)le;
|
||||
if (_manager.Host.GetTeam(player).GetColor() == _tower.getTeam().GetColor())
|
||||
continue;
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
_manager.Host.storeGear(player);
|
||||
player.getWorld().strikeLightningEffect(player.getLocation());
|
||||
player.damage(Math.min(6 * 2, player.getHealth()));
|
||||
}
|
||||
}
|
||||
|
||||
private class DefenseAnimation
|
||||
{
|
||||
private Location _base;
|
||||
private double _step;
|
||||
//private final double _baseRadius;
|
||||
private double _radius;
|
||||
private long _lastStepIncrease;
|
||||
private boolean _active;
|
||||
|
||||
public DefenseAnimation()
|
||||
{
|
||||
_step = 0;
|
||||
_lastStepIncrease = System.currentTimeMillis();
|
||||
_base = _tower.getLocation().clone();
|
||||
/*if (_tower instanceof TeamTower)
|
||||
{
|
||||
//_baseRadius = -1;
|
||||
_base = _tower.getLocation().clone().add(0, 10, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//_baseRadius = 11;
|
||||
_base = _tower.getLocation().clone();
|
||||
}*/
|
||||
_radius = /*_baseRadius*/2;
|
||||
}
|
||||
|
||||
public void activate()
|
||||
{
|
||||
_active = true;
|
||||
}
|
||||
|
||||
public void deactivate()
|
||||
{
|
||||
_active = false;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_number != 3)
|
||||
drawBeam();
|
||||
|
||||
if (!_active)
|
||||
return;
|
||||
|
||||
if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_step++;
|
||||
_lastStepIncrease = System.currentTimeMillis();
|
||||
}
|
||||
drawHelix();
|
||||
}
|
||||
|
||||
private void drawHelix()
|
||||
{
|
||||
double height = Math.min(_step * 2, 15D);
|
||||
|
||||
for (double y = 0; y <= height; y += .5)
|
||||
{
|
||||
double x = _radius * Math.cos(y);
|
||||
double z = _radius * Math.sin(y);
|
||||
Location play = new Location(_base.getWorld(), _base.getX() + x, _base.getY() + y, _base.getZ() + z);
|
||||
|
||||
UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 3, ViewDist.MAX);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawBeam()
|
||||
{
|
||||
Location base = _base.clone().add(0, 10, 0);
|
||||
Location target = _manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0);
|
||||
Location display = base.clone();
|
||||
while (UtilMath.offset(base, target) > UtilMath.offset(base, display))
|
||||
{
|
||||
Vector v = UtilAlg.getTrajectory(display, target);
|
||||
UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, display, null, 0, 1, ViewDist.MAX);
|
||||
display.add(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class MapZone
|
||||
{
|
||||
private Location _loc;
|
||||
private int[] _rgb;
|
||||
private boolean _valid;
|
||||
|
||||
public MapZone(Location center, int[] rgb)
|
||||
{
|
||||
_loc = center;
|
||||
_rgb = rgb;
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return _valid;
|
||||
}
|
||||
|
||||
public boolean isInRadius(int x, int z)
|
||||
{
|
||||
int diffX = Math.max(x, _loc.getBlockX()) - Math.min(x, _loc.getBlockX());
|
||||
int diffZ = Math.max(z, _loc.getBlockZ()) - Math.min(z, _loc.getBlockZ());
|
||||
|
||||
if (diffX <= 5)
|
||||
if (diffZ <= 5)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public boolean isBase(int x, int z)
|
||||
{
|
||||
if (_loc.getBlockX() == x)
|
||||
if (_loc.getBlockZ() == z)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
/*public Location getBase()
|
||||
{
|
||||
return _loc;
|
||||
}*/
|
||||
|
||||
public int getRed()
|
||||
{
|
||||
return _rgb[0];
|
||||
}
|
||||
|
||||
public int getGreen()
|
||||
{
|
||||
return _rgb[1];
|
||||
}
|
||||
|
||||
public int getBlue()
|
||||
{
|
||||
return _rgb[2];
|
||||
}
|
||||
|
||||
public void setValid(boolean valid)
|
||||
{
|
||||
_valid = valid;
|
||||
}
|
||||
|
||||
public void setCenter(Location center)
|
||||
{
|
||||
_loc = center;
|
||||
}
|
||||
|
||||
/*public void update()
|
||||
{
|
||||
int found = 0;
|
||||
for (Block block : UtilBlock.getInSquare(_loc.getBlock(), 10))
|
||||
{
|
||||
if (block.getType() == _ore)
|
||||
found++;
|
||||
}
|
||||
|
||||
_valid = found >= 1;
|
||||
}*/
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class OreGenerator
|
||||
{
|
||||
private List<Location> _choices = new ArrayList<Location>();
|
||||
|
||||
public void generateOre(Material oreType, List<Location> possible, int amount)
|
||||
{
|
||||
_choices.clear();
|
||||
for (Location loc : possible)
|
||||
{
|
||||
if (loc.getBlock().getType() == Material.WORKBENCH || loc.getBlock().getType() == Material.CHEST || loc.getBlock().getType() == Material.TRAPPED_CHEST || loc.getBlock().getType() == Material.FURNACE || loc.getBlock().getType() == Material.BURNING_FURNACE)
|
||||
continue;
|
||||
loc.getBlock().setType(Material.STONE);
|
||||
_choices.add(loc);
|
||||
}
|
||||
for (int i = 0; i < (amount + 1); i++)
|
||||
{
|
||||
if (_choices.size() == 0)
|
||||
continue;
|
||||
Location selected = _choices.remove(UtilMath.random.nextInt(_choices.size()));
|
||||
selected.getBlock().setType(oreType);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerRespawnPoint
|
||||
{
|
||||
private Player _owner;
|
||||
private Location _loc;
|
||||
|
||||
public PlayerRespawnPoint(Player owner, Location loc)
|
||||
{
|
||||
_owner = owner;
|
||||
_loc = loc;
|
||||
UtilPlayer.message(owner, F.main("Game", "You have set your bed respawn point. The next time you die you will respawn here!"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isBedType(Block bedBlock, boolean foot)
|
||||
{
|
||||
boolean head = (bedBlock.getData() & 0x8) != 0;
|
||||
|
||||
if (foot)
|
||||
return !head;
|
||||
else
|
||||
return head;
|
||||
}
|
||||
|
||||
private Block getOtherBedBlock(Block b1)
|
||||
{
|
||||
if (b1.getType() != Material.BED_BLOCK)
|
||||
return null;
|
||||
|
||||
boolean lookingForFoot = isBedType(b1, false);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
Block b2 = b1.getRelative(x, 0, z);
|
||||
if (!(b1.getLocation().equals(b2.getLocation())))
|
||||
{
|
||||
if (b2.getType().equals(Material.BED_BLOCK))
|
||||
{
|
||||
if (lookingForFoot && isBedType(b2, true))
|
||||
return b2;
|
||||
|
||||
if (!lookingForFoot && isBedType(b2, false))
|
||||
return b2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean respawnPlayer()
|
||||
{
|
||||
if (_loc.getBlock().getType() != Material.BED_BLOCK)
|
||||
{
|
||||
UtilPlayer.message(_owner, F.main("Game", "Your bed has been destroyed, and your respawn point has been reset!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
_owner.teleport(_loc.clone().add(0.5, 1.5, 0.5));
|
||||
UtilPlayer.message(_owner, F.main("Game", "You have been respawned at your bed location!"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean breakBed(Block block)
|
||||
{
|
||||
boolean isOther = false;
|
||||
|
||||
if (getOtherBedBlock(_loc.getBlock()) != null)
|
||||
if (getOtherBedBlock(_loc.getBlock()).equals(block))
|
||||
isOther = true;
|
||||
|
||||
if (block.getLocation().equals(_loc) || isOther)
|
||||
{
|
||||
UtilPlayer.message(_owner, F.main("Game", "Your bed respawn point has been broken!"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void overWrite(Location newLocation)
|
||||
{
|
||||
if (newLocation.distance(_loc) <= .2)
|
||||
return;
|
||||
|
||||
if (getOtherBedBlock(_loc.getBlock()) != null)
|
||||
if (getOtherBedBlock(_loc.getBlock()).getLocation().distance(newLocation) <= .2)
|
||||
return;
|
||||
|
||||
UtilPlayer.message(_owner, F.main("Game", "You have set your bed respawn point. The next time you die you will respawn here!"));
|
||||
if (_loc.getBlock().getType() == Material.BED_BLOCK)
|
||||
_loc.getBlock().breakNaturally();
|
||||
|
||||
_loc = newLocation;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class ProtectionUtil {
|
||||
|
||||
public static boolean isSameBlock(Block a, Block b)
|
||||
{
|
||||
if (a.getX() == b.getX())
|
||||
if (a.getY() == b.getY())
|
||||
return (a.getZ() == b.getZ());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class Spawner
|
||||
{
|
||||
protected MinecraftLeague Host;
|
||||
private Location _spawnerBlock;
|
||||
private EntityType _toSpawn;
|
||||
private long _lastSpawned;
|
||||
private boolean _canSpawn = true;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Spawner(MinecraftLeague host, Location spawnerBlock, EntityType toSpawn)
|
||||
{
|
||||
Host = host;
|
||||
_spawnerBlock = spawnerBlock;
|
||||
_toSpawn = toSpawn;
|
||||
_lastSpawned = System.currentTimeMillis();
|
||||
spawnerBlock.getBlock().setTypeIdAndData(Material.MOB_SPAWNER.getId(), (byte)toSpawn.getTypeId(), false);
|
||||
}
|
||||
|
||||
private List<Location> getLocations(Location base, int changeX, int changeY, int changeZ)
|
||||
{
|
||||
List<Location> locs = new ArrayList<Location>();
|
||||
for(int x = (base.getBlockX() - changeX); x <= (base.getBlockX() + changeX); x++)
|
||||
{
|
||||
for(int y = (base.getBlockY() - changeY); y <= (base.getBlockY() + changeY); y++)
|
||||
{
|
||||
for(int z = (base.getBlockZ() - changeZ); z <= (base.getBlockZ() + changeZ); z++)
|
||||
{
|
||||
Location loc = new Location(base.getWorld(), x, y, z);
|
||||
locs.add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return locs;
|
||||
}
|
||||
|
||||
private boolean canSpawnMob(Location l)
|
||||
{
|
||||
Block b = l.getBlock();
|
||||
if ((b.getType() != Material.AIR) && !b.getType().toString().contains("WATER") && !UtilBlock.airFoliage(b))
|
||||
return false;
|
||||
|
||||
Block b2 = b.getRelative(BlockFace.UP);
|
||||
if ((b2.getType() != Material.AIR) && !b2.getType().toString().contains("WATER") && !UtilBlock.airFoliage(b2))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void spawn()
|
||||
{
|
||||
if (!_canSpawn)
|
||||
return;
|
||||
|
||||
List<Location> possible = getLocations(_spawnerBlock, 2, 1, 2);
|
||||
boolean spawned = false;
|
||||
int i = UtilMath.r(possible.size());
|
||||
while (!spawned)
|
||||
{
|
||||
Location l = possible.get(i);
|
||||
if (canSpawnMob(l))
|
||||
{
|
||||
Entity e = Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn);
|
||||
UtilEnt.Vegetate(e);
|
||||
spawned = true;
|
||||
_lastSpawned = System.currentTimeMillis();
|
||||
continue;
|
||||
}
|
||||
|
||||
int newi = 0;
|
||||
if (i == (possible.size() - 1))
|
||||
i = newi;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_spawnerBlock.getBlock().getType() != Material.MOB_SPAWNER)
|
||||
_canSpawn = false;
|
||||
else
|
||||
_canSpawn = true;
|
||||
|
||||
if (_canSpawn)
|
||||
{
|
||||
if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
_canSpawn = false;
|
||||
else
|
||||
_canSpawn = true;
|
||||
}
|
||||
|
||||
spawn();
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class TeamBeacon
|
||||
{
|
||||
private GameTeam _team;
|
||||
private Block _block;
|
||||
//private Location _core;
|
||||
|
||||
public TeamBeacon(GameTeam team, Block block/*, Location core*/)
|
||||
{
|
||||
_team = team;
|
||||
_block = block;
|
||||
//_core = core;
|
||||
|
||||
_block.setType(Material.BEACON);
|
||||
}
|
||||
|
||||
/*public boolean isBlock(Block match)
|
||||
{
|
||||
if (match.getX() == _block.getX())
|
||||
if (match.getZ() == _block.getZ())
|
||||
if (match.getY() == _block.getY())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
/*public Block getBlock()
|
||||
{
|
||||
return _block;
|
||||
}*/
|
||||
|
||||
public void setBlock(Block block)
|
||||
{
|
||||
_block = block;
|
||||
block.setType(Material.BEACON);
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_block.getType() != Material.BEACON)
|
||||
return;
|
||||
|
||||
HashSet<Material> ignore = new HashSet<Material>();
|
||||
ignore.add(Material.GLASS);
|
||||
ignore.add(Material.THIN_GLASS);
|
||||
ignore.add(Material.STAINED_GLASS);
|
||||
ignore.add(Material.STAINED_GLASS_PANE);
|
||||
//Bukkit.broadcastMessage(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore) + "");
|
||||
//if (!isBlock(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).getRelative(BlockFace.DOWN)))
|
||||
//return;
|
||||
|
||||
for (Player player : _team.GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().distance(_block.getLocation()) < 15)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 0));
|
||||
//player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5 * 20, 0));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 0));
|
||||
//player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class TeamCrystal extends TeamTowerBase
|
||||
{
|
||||
public TeamCrystal(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn)
|
||||
{
|
||||
super(host, manager, team, spawn);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class TeamTower extends TeamTowerBase
|
||||
{
|
||||
public Integer Number;
|
||||
|
||||
public TeamTower(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn, Integer number)
|
||||
{
|
||||
super(host, manager, team, spawn);
|
||||
Number = number;
|
||||
}
|
||||
}
|
@ -0,0 +1,312 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
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.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class TeamTowerBase
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
private TowerManager _manager;
|
||||
private Location _spawn;
|
||||
private GameTeam _team;
|
||||
private Double _health, _maxHealth;
|
||||
private EnderCrystal _entity;
|
||||
private Hologram _name, _healthTag;
|
||||
private String _type;
|
||||
public boolean Alive;
|
||||
public boolean Vulnerable;
|
||||
|
||||
public TeamTowerBase(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn)
|
||||
{
|
||||
_host = host;
|
||||
_manager = manager;
|
||||
_spawn = spawn.clone().add(0, 3.2, 0);
|
||||
_team = team;
|
||||
_maxHealth = 11111D;
|
||||
_health = 11111D;
|
||||
_type = "Tower";
|
||||
if (this instanceof TeamCrystal)
|
||||
_type = "Core";
|
||||
_name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(1, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type);
|
||||
_healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(1, 2, 0), formatHealth(_health));
|
||||
|
||||
spawn();
|
||||
}
|
||||
|
||||
private void spawn()
|
||||
{
|
||||
_name.start();
|
||||
_healthTag.start();
|
||||
_entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL);
|
||||
_health = _maxHealth;
|
||||
Alive = true;
|
||||
}
|
||||
|
||||
private void kill(Player player)
|
||||
{
|
||||
String message = "";
|
||||
if (player != null)
|
||||
message = _host.GetTeam(player).GetColor() + player.getName() + _team.GetColor() + " has destroyed " + _team.getDisplayName() + "'s " + _type + "!";
|
||||
else
|
||||
message = _team.GetColor() + _team.getDisplayName() + "'s " + _type + " has been destroyed!";
|
||||
|
||||
//Bukkit.broadcastMessage(message);
|
||||
UtilTextMiddle.display("", message);
|
||||
|
||||
if (!_type.equalsIgnoreCase("Tower"))
|
||||
{
|
||||
for (Player inform : _team.GetPlayers(true))
|
||||
UtilTextMiddle.display(C.cGold + "Team Crystal Destroyed", C.cGold + "You will no longer respawn and will be poisoned in 5 minutes!", inform);
|
||||
}
|
||||
|
||||
Alive = false;
|
||||
_entity.remove();
|
||||
_healthTag.stop();
|
||||
_name.stop();
|
||||
Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
playDeathAnimation(_spawn);
|
||||
}
|
||||
}, 20 * 5);
|
||||
detonate();
|
||||
_manager.handleTowerDeath(this);
|
||||
}
|
||||
|
||||
private void playDeathAnimation(Location loc)
|
||||
{
|
||||
_spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0);
|
||||
//GFX subject to change
|
||||
Location loc1 = loc.clone().add(-2, 3, -2);
|
||||
Location loc2 = loc.clone().add(2, 0, 2);
|
||||
Location loc3 = loc.clone().add(2, 3, 2);
|
||||
Location loc4 = loc.clone().add(-2, 0, -2);
|
||||
Location particle1 = loc2.clone();
|
||||
Location particle2 = loc4.clone();
|
||||
while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc))
|
||||
{
|
||||
Vector v = UtilAlg.getTrajectory(particle1, loc1);
|
||||
//UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
|
||||
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers());
|
||||
particle1.add(v);
|
||||
}
|
||||
while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc))
|
||||
{
|
||||
Vector v = UtilAlg.getTrajectory(particle2, loc3);
|
||||
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers());
|
||||
particle2.add(v);
|
||||
}
|
||||
}
|
||||
|
||||
private void detonate()
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL);
|
||||
_spawn.getWorld().playSound(_spawn, Sound.EXPLODE, 10, 0);
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
Location bottom = _spawn.clone().subtract(0, -3.2, 0);
|
||||
for (int i = 0; i < 23; i++)
|
||||
{
|
||||
blocks.addAll(UtilBlock.getInSquare(bottom.clone().add(0, i, 0).getBlock(), 4));
|
||||
}
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
getBeacon().clone().add(0, i, 0).getBlock().setType(Material.BEDROCK);
|
||||
}
|
||||
_host.Manager.GetExplosion().BlockExplosion(blocks, _spawn, false, true);
|
||||
for (Entity e : _host.WorldData.World.getEntities())
|
||||
{
|
||||
if (e instanceof Wither)
|
||||
{
|
||||
LivingEntity le = (LivingEntity) e;
|
||||
le.setHealth(le.getHealth() / 2);
|
||||
}
|
||||
}
|
||||
for (LivingEntity le : UtilEnt.getInRadius(_spawn, 5).keySet())
|
||||
{
|
||||
if (UtilMath.offset(le.getLocation(), _spawn) <= 5)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(le))
|
||||
continue;
|
||||
if (le instanceof Player)
|
||||
{
|
||||
_host.storeGear((Player)le);
|
||||
}
|
||||
le.damage(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getBeacon()
|
||||
{
|
||||
Location ret = null;
|
||||
for (Location loc : _host.WorldData.GetDataLocs(DataLoc.BEACON.getKey()))
|
||||
{
|
||||
if (ret == null || UtilMath.offset(ret, _spawn) > UtilMath.offset(loc, _spawn))
|
||||
ret = loc;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
|
||||
public boolean isEntity(Entity e)
|
||||
{
|
||||
return e.getEntityId() == _entity.getEntityId();
|
||||
}
|
||||
|
||||
public boolean canDamage(Player player)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
return false;
|
||||
|
||||
if (_host.GetTeam(player) == _team)
|
||||
return false;
|
||||
|
||||
if (!_host.IsPlaying(player))
|
||||
return false;
|
||||
|
||||
if (!Recharge.Instance.usable(player, "Damage TeamTower"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Double getHealth()
|
||||
{
|
||||
if (!Alive)
|
||||
return 0D;
|
||||
|
||||
return _health;
|
||||
}
|
||||
|
||||
public String formatHealth(Double healthNumber)
|
||||
{
|
||||
String tag = healthNumber.toString();
|
||||
|
||||
if (healthNumber > (.9 * _maxHealth))
|
||||
tag = C.cGreen + tag;
|
||||
else if (healthNumber < (.45 * _maxHealth))
|
||||
tag = C.cRed + tag;
|
||||
else
|
||||
tag = C.cYellow + tag;
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ChatColor getHealthColor()
|
||||
{
|
||||
if (!Alive)
|
||||
return ChatColor.GRAY;
|
||||
|
||||
ChatColor color = ChatColor.YELLOW;
|
||||
|
||||
if (_health > (.9 * _maxHealth))
|
||||
color = ChatColor.GREEN;
|
||||
else if (_health < (.45 * _maxHealth))
|
||||
color = ChatColor.RED;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
public boolean damage(double damage, Player player)
|
||||
{
|
||||
if (!Vulnerable)
|
||||
return false;
|
||||
|
||||
Double newHealth = Math.max(_health - damage, 0);
|
||||
|
||||
if (newHealth == 0)
|
||||
{
|
||||
kill(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
_health = newHealth;
|
||||
if (player != null)
|
||||
Recharge.Instance.use(player, "Damage TeamTower", 400, false, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _spawn;
|
||||
}
|
||||
|
||||
public GameTeam getTeam()
|
||||
{
|
||||
return _team;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
_healthTag.setText(formatHealth(_health));
|
||||
|
||||
if (Alive)
|
||||
{
|
||||
if (_entity.isDead() || !_entity.isValid())
|
||||
{
|
||||
_entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL);
|
||||
}
|
||||
|
||||
if (_health > _maxHealth)
|
||||
{
|
||||
_health = _maxHealth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxHealth(Double health)
|
||||
{
|
||||
_maxHealth = Math.abs(health);
|
||||
}
|
||||
|
||||
public void setVulnerable(boolean vulnerable)
|
||||
{
|
||||
if (vulnerable)
|
||||
{
|
||||
getBeacon().getBlock().setType(Material.BEACON);
|
||||
Vulnerable = vulnerable;
|
||||
}
|
||||
else
|
||||
{
|
||||
getBeacon().getBlock().setType(Material.BEDROCK);
|
||||
Vulnerable = vulnerable;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Note.Tone;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TowerAlert
|
||||
{
|
||||
private ConcurrentHashMap<GameTeam, Long> _alerts = new ConcurrentHashMap<GameTeam, Long>();
|
||||
//private ConcurrentHashMap<GameTeam, String> _alertType = new ConcurrentHashMap<GameTeam, String>();
|
||||
|
||||
public void alert(GameTeam team, TeamTowerBase tower)
|
||||
{
|
||||
if (!UtilTime.elapsed(_alerts.getOrDefault(team, (long) 1), UtilTime.convert(7, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
for (Player player : team.GetPlayers(true))
|
||||
playSound(player);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_alerts.put(team, System.currentTimeMillis());
|
||||
|
||||
String type = "";
|
||||
if (tower instanceof TeamTower)
|
||||
{
|
||||
int number = ((TeamTower)tower).Number;
|
||||
if (number == 1)
|
||||
/*_alertType.put(team, */type = "First Tower";//);
|
||||
else
|
||||
/*_alertType.put(team, */type = "Second Tower";//);
|
||||
}
|
||||
else
|
||||
/*_alertType.put(team, */type = "Crystal";//);
|
||||
|
||||
showAlert(team, type);
|
||||
}
|
||||
|
||||
private void showAlert(GameTeam team, String type)
|
||||
{
|
||||
/*for (GameTeam team : _alerts.keySet())
|
||||
{*/
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
UtilTextMiddle.display("", C.cGold + "Your " + /*_alertType.get(team)*/type + " is under attack!", 0, 20 * 5, 0, player);
|
||||
playSound(player);
|
||||
}
|
||||
|
||||
/*if (UtilTime.elapsed(_alerts.get(team), UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_alerts.remove(team);
|
||||
_alertType.remove(team);
|
||||
}*/
|
||||
//}
|
||||
}
|
||||
|
||||
private void playSound(Player player)
|
||||
{
|
||||
player.playNote(player.getLocation(), Instrument.PIANO, Note.sharp(1, Tone.A));
|
||||
}
|
||||
}
|
@ -0,0 +1,307 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TowerManager implements Listener
|
||||
{
|
||||
public MinecraftLeague Host;
|
||||
private ConcurrentHashMap<TeamTowerBase, GameTeam> _towers = new ConcurrentHashMap<TeamTowerBase, GameTeam>();
|
||||
private ConcurrentHashMap<GameTeam, Integer> _vulnerableTower = new ConcurrentHashMap<GameTeam, Integer>();
|
||||
private ConcurrentHashMap<TeamTowerBase, DefenderAI> _def = new ConcurrentHashMap<TeamTowerBase, DefenderAI>();
|
||||
//private ConcurrentHashMap<TeamTowerBase, MapZone> _mapZone = new ConcurrentHashMap<TeamTowerBase, MapZone>();
|
||||
private ConcurrentHashMap<GameTeam, TeamBeacon> _beacons = new ConcurrentHashMap<GameTeam, TeamBeacon>();
|
||||
private OreGenerator _ore;
|
||||
public boolean Attack = false;
|
||||
|
||||
public TowerManager(MinecraftLeague host)
|
||||
{
|
||||
Host = host;
|
||||
_ore = new OreGenerator();
|
||||
}
|
||||
|
||||
private void makeVulnerable(TeamTowerBase base)
|
||||
{
|
||||
if (base instanceof TeamTower)
|
||||
_vulnerableTower.put(base.getTeam(), ((TeamTower)base).Number);
|
||||
else
|
||||
_vulnerableTower.put(base.getTeam(), 3);
|
||||
|
||||
base.Vulnerable = true;
|
||||
_beacons.get(base.getTeam()).setBlock(base.getBeacon().getBlock());
|
||||
}
|
||||
|
||||
public void ironOreGen(GameTeam team, boolean start)
|
||||
{
|
||||
int amount = 20;
|
||||
if (start)
|
||||
amount = 50;
|
||||
|
||||
for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey()))
|
||||
{
|
||||
loc.getBlock().setType(Material.DIAMOND_ORE);
|
||||
}
|
||||
|
||||
if (start)
|
||||
{
|
||||
if (team.GetColor() == ChatColor.RED)
|
||||
_ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), amount);
|
||||
else
|
||||
_ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), amount);
|
||||
|
||||
for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.MOSH_IRON.getKey()))
|
||||
{
|
||||
loc.getBlock().setType(Material.STONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.MOSH_IRON.getKey()), amount);
|
||||
UtilTextMiddle.display("", "Valuable Ores have respawned in the middle!");
|
||||
}
|
||||
}
|
||||
|
||||
private List<TeamTowerBase> getAllTeamTowers(GameTeam team)
|
||||
{
|
||||
List<TeamTowerBase> ret = new ArrayList<TeamTowerBase>();
|
||||
|
||||
for (TeamTowerBase tower : _towers.keySet())
|
||||
{
|
||||
if (_towers.get(tower).GetColor() == team.GetColor())
|
||||
{
|
||||
ret.add(tower);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LinkedList<TeamTowerBase> getTeamTowers(GameTeam team)
|
||||
{
|
||||
LinkedList<TeamTowerBase> ret = new LinkedList<TeamTowerBase>();
|
||||
TeamTower one = null;
|
||||
TeamTower two = null;
|
||||
TeamCrystal three = null;
|
||||
|
||||
for (TeamTowerBase tower : getAllTeamTowers(team))
|
||||
{
|
||||
if (tower instanceof TeamCrystal)
|
||||
{
|
||||
three = (TeamCrystal) tower;
|
||||
continue;
|
||||
}
|
||||
if (one == null)
|
||||
{
|
||||
one = (TeamTower) tower;
|
||||
continue;
|
||||
}
|
||||
if (one.Number > ((TeamTower)tower).Number)
|
||||
{
|
||||
two = one;
|
||||
one = (TeamTower) tower;
|
||||
continue;
|
||||
}
|
||||
two = (TeamTower) tower;
|
||||
}
|
||||
|
||||
ret.add(one);
|
||||
ret.add(two);
|
||||
ret.add(three);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Integer getAmountAlive(GameTeam team)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (TeamTowerBase tower : getAllTeamTowers(team))
|
||||
{
|
||||
if (tower.Alive)
|
||||
i++;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public TeamTowerBase getVulnerable(GameTeam team)
|
||||
{
|
||||
return getTeamTowers(team).get(_vulnerableTower.get(team) - 1);
|
||||
}
|
||||
|
||||
public void parseTowers(WorldData data)
|
||||
{
|
||||
GameTeam red = Host.GetTeam(ChatColor.RED);
|
||||
GameTeam blue = Host.GetTeam(ChatColor.AQUA);
|
||||
//int[] redRGB = new int[] {255, 0, 0};
|
||||
//int[] blueRGB = new int[] {0, 0, 255};
|
||||
|
||||
_towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 1").get(0), 1), red);
|
||||
_towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 2").get(0), 2), red);
|
||||
_towers.put(new TeamCrystal(Host, this, red, data.GetCustomLocs(DataLoc.RED_CRYSTAL.getKey()).get(0)), red);
|
||||
|
||||
_towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 1").get(0), 1), blue);
|
||||
_towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 2").get(0), 2), blue);
|
||||
_towers.put(new TeamCrystal(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0)), blue);
|
||||
|
||||
for (TeamTowerBase tower : _towers.keySet())
|
||||
{
|
||||
_def.put(tower, new DefenderAI(this, tower));
|
||||
/*int[] rgb;
|
||||
if (tower.getTeam().GetColor() == red.GetColor())
|
||||
rgb = redRGB;
|
||||
else
|
||||
rgb = blueRGB;
|
||||
|
||||
MapZone zone = new MapZone(tower.getLocation(), rgb);
|
||||
Host.MapZones.add(zone);
|
||||
_mapZone.put(tower, zone);*/
|
||||
}
|
||||
|
||||
TeamBeacon redb = new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock());
|
||||
_beacons.put(red, redb);
|
||||
Host.Beacons.put(red, redb);
|
||||
TeamBeacon blueb = new TeamBeacon(blue, getTeamTowers(blue).getFirst().getBeacon().getBlock());
|
||||
_beacons.put(blue, blueb);
|
||||
Host.Beacons.put(blue, blueb);
|
||||
makeVulnerable(getTeamTowers(red).getFirst());
|
||||
makeVulnerable(getTeamTowers(blue).getFirst());
|
||||
ironOreGen(red, true);
|
||||
ironOreGen(blue, true);
|
||||
}
|
||||
|
||||
public void prepareHealth(int players, double multiplier)
|
||||
{
|
||||
for (TeamTowerBase tower : _towers.keySet())
|
||||
{
|
||||
if (tower instanceof TeamCrystal)
|
||||
tower.setMaxHealth(players * multiplier);
|
||||
else
|
||||
{
|
||||
int divisor = 3 - ((TeamTower)tower).Number;
|
||||
double rawHealth = (.67 * multiplier) * players;
|
||||
Double health = new BigDecimal(rawHealth / divisor).intValue() * 1D;
|
||||
tower.setMaxHealth(health);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleTowerDeath(TeamTowerBase towerBase)
|
||||
{
|
||||
towerBase.setVulnerable(false);
|
||||
//ironOreGen(towerBase.getTeam());
|
||||
/*for (Player player : towerBase.getTeam().GetPlayers(true))
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20 * 60, 1));
|
||||
}*/
|
||||
/*Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!", UtilServer.getPlayers());
|
||||
}
|
||||
}, 20 * 5);*/
|
||||
//_mapZone.get(towerBase).setValid(false);
|
||||
if (towerBase instanceof TeamCrystal)
|
||||
{
|
||||
GameTeam enemy = null;
|
||||
if (towerBase.getTeam() == Host.GetTeam(ChatColor.RED))
|
||||
enemy = Host.GetTeam(ChatColor.AQUA);
|
||||
else
|
||||
enemy = Host.GetTeam(ChatColor.RED);
|
||||
|
||||
Host.ScoreboardAutoWrite = false;
|
||||
Host.writeEndSb(enemy.GetColor() + enemy.getDisplayName());
|
||||
Host.AnnounceEnd(enemy);
|
||||
|
||||
for (GameTeam team : Host.GetTeamList())
|
||||
{
|
||||
if (enemy != null && team.equals(enemy))
|
||||
{
|
||||
for (Player player : team.GetPlayers(false))
|
||||
Host.AddGems(player, 10, "Winning Team", false, false);
|
||||
}
|
||||
|
||||
for (Player player : team.GetPlayers(false))
|
||||
if (player.isOnline())
|
||||
Host.AddGems(player, 10, "Participation", false, false);
|
||||
}
|
||||
Host.SetState(GameState.End);
|
||||
|
||||
//Host.Objective.setTeamObjective(enemy, new KillObjective());
|
||||
|
||||
//Host.TeamPoison.put(towerBase.getTeam(), System.currentTimeMillis() + (UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS) - UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)));
|
||||
|
||||
return;
|
||||
}
|
||||
for (Player player : towerBase.getTeam().GetPlayers(true))
|
||||
{
|
||||
if (!UtilPlayer.isSpectator(player))
|
||||
{
|
||||
boolean replaced = false;
|
||||
if (UtilItem.isLeatherProduct(player.getInventory().getHelmet()))
|
||||
{
|
||||
if (replaced)
|
||||
continue;
|
||||
replaced = true;
|
||||
player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build());
|
||||
}
|
||||
if (UtilItem.isLeatherProduct(player.getInventory().getLeggings()))
|
||||
{
|
||||
if (replaced)
|
||||
continue;
|
||||
replaced = true;
|
||||
player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build());
|
||||
}
|
||||
if (UtilItem.isLeatherProduct(player.getInventory().getChestplate()))
|
||||
{
|
||||
if (replaced)
|
||||
continue;
|
||||
replaced = true;
|
||||
player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build());
|
||||
}
|
||||
if (UtilItem.isLeatherProduct(player.getInventory().getBoots()))
|
||||
{
|
||||
if (replaced)
|
||||
continue;
|
||||
replaced = true;
|
||||
player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
makeVulnerable(getTeamTowers(towerBase.getTeam()).get(_vulnerableTower.get(towerBase.getTeam())));
|
||||
}
|
||||
|
||||
public void toggleAttack()
|
||||
{
|
||||
//Attack = !Attack;
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
for (TeamTowerBase tower : _towers.keySet())
|
||||
{
|
||||
tower.update();
|
||||
_def.get(tower).update();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,673 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data.map;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
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 mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import net.minecraft.server.v1_8_R3.Block;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.Blocks;
|
||||
import net.minecraft.server.v1_8_R3.IBlockData;
|
||||
import net.minecraft.server.v1_8_R3.MaterialMapColor;
|
||||
import net.minecraft.server.v1_8_R3.PersistentCollection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Multisets;
|
||||
|
||||
public class ItemMapManager /*extends MiniPlugin*/ implements Listener
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
private int _blocksScan = 16;
|
||||
private Comparator<Entry<Integer, Integer>> _comparator;
|
||||
private int _halfMapSize;
|
||||
private int[][] _heightMap;
|
||||
private boolean _loadWorld = true;
|
||||
private HashMap<Integer, Byte[][]> _map = new HashMap<Integer, Byte[][]>();
|
||||
private short _mapId = (short) UtilMath.r(Short.MAX_VALUE);
|
||||
private ArrayList<Entry<Integer, Integer>> _scanList = new ArrayList<Entry<Integer, Integer>>();
|
||||
private World _world;
|
||||
private int _centerX;
|
||||
private int _centerZ;
|
||||
private int _scale;
|
||||
|
||||
public ItemMapManager(MinecraftLeague host, World world, int minX, int minZ, int maxX, int maxZ)
|
||||
{
|
||||
//super("ItemMapManager", host.getArcadeManager().getPlugin());
|
||||
Bukkit.getPluginManager().registerEvents(this, host.getArcadeManager().getPlugin());
|
||||
|
||||
_host = host;
|
||||
|
||||
_centerX = minX + ((maxX - minX) / 2);
|
||||
_centerZ = minZ + ((maxZ - minZ) / 2);
|
||||
_centerX = (int) (Math.round(_centerX / 16D) * 16);
|
||||
_centerZ = (int) (Math.round(_centerZ / 16D) * 16);
|
||||
|
||||
_halfMapSize = (int) (Math.ceil(Math.max((maxX - minX) / 2D, (maxZ - minZ) / 2D) / 16D) * 16);
|
||||
|
||||
ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer, Integer>>();
|
||||
|
||||
for (int scale = 1; scale <= 16; scale++)
|
||||
{
|
||||
int s = _halfMapSize;
|
||||
|
||||
if ((s / scale) > 127)
|
||||
continue;
|
||||
|
||||
while (s < 10000 && (s % 16 != 0 || s % scale != 0))
|
||||
{
|
||||
s += 16;
|
||||
}
|
||||
|
||||
if (s < 10000)
|
||||
{
|
||||
list.add(new HashMap.SimpleEntry(scale, s));
|
||||
}
|
||||
}
|
||||
|
||||
if (list.isEmpty())
|
||||
{
|
||||
_scale = 16;
|
||||
_halfMapSize = 127 * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
Collections.sort(list, new Comparator<Entry<Integer, Integer>>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2)
|
||||
{
|
||||
return Integer.compare(o1.getValue(), o2.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
_scale = list.get(0).getKey();
|
||||
_halfMapSize = list.get(0).getValue();
|
||||
|
||||
System.out.print(
|
||||
"Using scale " + _scale + ", Size: " + _halfMapSize + ", CenterX: " + _centerX + ", CenterZ: " + _centerZ);
|
||||
}
|
||||
|
||||
_heightMap = new int[(_halfMapSize * 2) + 16][];
|
||||
|
||||
_comparator = new Comparator<Entry<Integer, Integer>>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(Entry<Integer, Integer> o1, Entry<Integer, Integer> o2)
|
||||
{
|
||||
// Render the places outside the map first to speed up visual errors fixing
|
||||
int outsideMap = Boolean.compare(o1.getValue() < -_halfMapSize, o2.getValue() < -_halfMapSize);
|
||||
|
||||
if (outsideMap != 0)
|
||||
{
|
||||
return -outsideMap;
|
||||
}
|
||||
|
||||
double dist1 = 0;
|
||||
double dist2 = 0;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
dist1 += getDistance(o1, player.getLocation().getX(), player.getLocation().getZ());
|
||||
dist2 += getDistance(o2, player.getLocation().getX(), player.getLocation().getZ());
|
||||
}
|
||||
|
||||
if (dist1 != dist2)
|
||||
{
|
||||
return Double.compare(dist1, dist2);
|
||||
}
|
||||
|
||||
dist1 = getDistance(o1, 0, 0);
|
||||
dist2 = getDistance(o2, 0, 0);
|
||||
|
||||
return Double.compare(dist1, dist2);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
|
||||
{
|
||||
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
|
||||
{
|
||||
_scanList.add(new HashMap.SimpleEntry(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
for (int s = 1; s <= 2; s++)
|
||||
{
|
||||
if (s == 2)
|
||||
{
|
||||
s = getScale();
|
||||
|
||||
if (s == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
int size = (_halfMapSize * 2) / s;
|
||||
Byte[][] bytes = new Byte[size][];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
bytes[i] = new Byte[size];
|
||||
}
|
||||
|
||||
_map.put(s, bytes);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _heightMap.length; i++)
|
||||
{
|
||||
_heightMap[i] = new int[_heightMap.length];
|
||||
}
|
||||
|
||||
_world = world;
|
||||
|
||||
try
|
||||
{
|
||||
File foundFile = null;
|
||||
|
||||
for (File f : new File("world/data").listFiles())
|
||||
{
|
||||
if (f.getName().startsWith("map_"))
|
||||
{
|
||||
foundFile = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundFile == null)
|
||||
{
|
||||
PersistentCollection collection = ((CraftWorld) _world).getHandle().worldMaps;
|
||||
Field f = collection.getClass().getDeclaredField("d");
|
||||
f.setAccessible(true);
|
||||
((HashMap) f.get(collection)).put("map", (short) 0);
|
||||
}
|
||||
|
||||
MapView view = Bukkit.createMap(_world);
|
||||
_mapId = view.getId();
|
||||
setupRenderer(view);
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
setupRenderer(Bukkit.createMap(_world));// Ensures the following 100 maps are unused
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
rebuildScan();
|
||||
}
|
||||
|
||||
private void setupRenderer(MapView view)
|
||||
{
|
||||
for (MapRenderer renderer : view.getRenderers())
|
||||
{
|
||||
view.removeRenderer(renderer);
|
||||
}
|
||||
|
||||
view.addRenderer(new ItemMapRenderer(this, _host));
|
||||
}
|
||||
|
||||
public int getScale()
|
||||
{
|
||||
return _scale;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return _centerX;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return _centerZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the center of the map.
|
||||
*/
|
||||
public int calcMapCenter(int zoom, int cord)
|
||||
{
|
||||
int mapSize = _halfMapSize / zoom; // This is how large the map is in pixels
|
||||
|
||||
int mapCord = cord / zoom; // This is pixels from true center of map, not held map
|
||||
|
||||
int fDiff = mapSize - -mapCord;
|
||||
int sDiff = mapSize - mapCord;
|
||||
|
||||
double chunkBlock = cord & 0xF;
|
||||
cord -= chunkBlock;
|
||||
chunkBlock /= zoom;
|
||||
|
||||
/*if ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1))
|
||||
{
|
||||
cord += (fDiff > sDiff ? Math.floor(chunkBlock) : Math.ceil(chunkBlock));
|
||||
}
|
||||
else*/
|
||||
{
|
||||
cord += (int) Math.floor(chunkBlock) * zoom;
|
||||
}
|
||||
|
||||
while ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1))
|
||||
{
|
||||
int change = (fDiff > sDiff ? -zoom : zoom);
|
||||
cord += change;
|
||||
|
||||
mapCord = cord / zoom;
|
||||
|
||||
fDiff = mapSize - -mapCord;
|
||||
sDiff = mapSize - mapCord;
|
||||
}
|
||||
|
||||
return cord;
|
||||
}
|
||||
|
||||
private void colorWorldHeight(int zoom, int startingX, int startingZ)
|
||||
{
|
||||
if (zoom == 0)
|
||||
zoom = 1;
|
||||
|
||||
Byte[][] map = _map.get(zoom);
|
||||
|
||||
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
|
||||
{
|
||||
double d0 = 0;
|
||||
|
||||
// Prevents ugly lines for the first line of Z
|
||||
|
||||
for (int addX = 0; addX < zoom; addX++)
|
||||
{
|
||||
for (int addZ = 0; addZ < zoom; addZ++)
|
||||
{
|
||||
int hX = x + addX + _halfMapSize;
|
||||
int hZ = (startingZ - zoom) + addZ + _halfMapSize;
|
||||
|
||||
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
d0 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
|
||||
{
|
||||
// Water depth colors not included
|
||||
double d1 = 0;
|
||||
|
||||
for (int addX = 0; addX < zoom; addX++)
|
||||
{
|
||||
for (int addZ = 0; addZ < zoom; addZ++)
|
||||
{
|
||||
int hX = x + addX + _halfMapSize;
|
||||
int hZ = z + addZ + _halfMapSize;
|
||||
|
||||
if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
d1 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom);
|
||||
}
|
||||
}
|
||||
|
||||
double d2 = (d1 - d0) * 4.0D / (zoom + 4) + ((x + z & 0x1) - 0.5D) * 0.4D;
|
||||
byte b0 = 1;
|
||||
|
||||
d0 = d1;
|
||||
|
||||
if (d2 > 0.6D)
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
else if (d2 > 1.2D)
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
else if (d2 < -0.6D)
|
||||
{
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1;
|
||||
|
||||
/*if (color < 4)
|
||||
{
|
||||
d2 = waterDepth * 0.1D + (k1 + j2 & 0x1) * 0.2D;
|
||||
b0 = 1;
|
||||
if (d2 < 0.5D)
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (d2 > 0.9D)
|
||||
{
|
||||
b0 = 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
byte color = (byte) (origColor + b0);
|
||||
map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawWorldScale(int zoom, int startingX, int startingZ)
|
||||
{
|
||||
Byte[][] first = _map.get(1);
|
||||
Byte[][] second = _map.get(zoom);
|
||||
|
||||
for (int x = startingX; x < startingX + _blocksScan; x += zoom)
|
||||
{
|
||||
for (int z = startingZ; z < startingZ + _blocksScan; z += zoom)
|
||||
{
|
||||
HashMultiset<Byte> hashmultiset = HashMultiset.create();
|
||||
|
||||
for (int addX = 0; addX < zoom; addX++)
|
||||
{
|
||||
for (int addZ = 0; addZ < zoom; addZ++)
|
||||
{
|
||||
int pX = x + addX + _halfMapSize;
|
||||
int pZ = z + addZ + _halfMapSize;
|
||||
|
||||
if (pX >= first.length || pZ >= first.length)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Byte b = first[pX][pZ];
|
||||
|
||||
if (b == null)
|
||||
continue;
|
||||
|
||||
hashmultiset.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||
|
||||
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double getDistance(double x1, double z1, double x2, double z2)
|
||||
{
|
||||
x1 = (x1 - x2);
|
||||
z1 = (z1 - z2);
|
||||
|
||||
return (x1 * x1) + (z1 * z1);
|
||||
}
|
||||
|
||||
private double getDistance(Entry<Integer, Integer> entry, double x1, double z1)
|
||||
{
|
||||
return getDistance(x1 + _centerX, z1 + _centerZ, entry.getKey() + (_blocksScan / 2),
|
||||
entry.getValue() + (_blocksScan / 2));
|
||||
}
|
||||
|
||||
public Byte[][] getMap(int scale)
|
||||
{
|
||||
return _map.get(scale);
|
||||
}
|
||||
|
||||
public int getMapSize()
|
||||
{
|
||||
return _halfMapSize;
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
public void onServerTransfer(ServerTransferEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
p.sendMessage(C.cDRed + C.Bold + "WARNING!");
|
||||
p.sendMessage(C.cYellow + "There's a bug where switching servers may freeze the Team Map!");
|
||||
p.sendMessage(C.cYellow + "If you want to play Minecraft League again and this error occurs, rejoin the Mineplex server!");
|
||||
}*/
|
||||
|
||||
private void rebuildScan()
|
||||
{
|
||||
for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan)
|
||||
{
|
||||
for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan))
|
||||
{
|
||||
_scanList.add(new HashMap.SimpleEntry(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
if (!_loadWorld)
|
||||
{
|
||||
Iterator<Entry<Integer, Integer>> itel = _scanList.iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<Integer, Integer> entry = itel.next();
|
||||
boolean removeEntry = true;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (Math.sqrt(getDistance(entry, player.getLocation().getX(), player.getLocation().getZ())) < 200)
|
||||
{
|
||||
removeEntry = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removeEntry)
|
||||
{
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(_scanList, _comparator);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void renderMap(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
if (_scanList.isEmpty())
|
||||
{
|
||||
if (_loadWorld)
|
||||
{
|
||||
_loadWorld = false;
|
||||
System.out.print("Finished first map scan and render");
|
||||
}
|
||||
|
||||
if (UtilServer.getPlayers().length == 0)
|
||||
return;
|
||||
|
||||
rebuildScan();
|
||||
}
|
||||
else if (_scanList.size() % 20 == 0)
|
||||
{
|
||||
Collections.sort(_scanList, _comparator);
|
||||
}
|
||||
|
||||
Entry<Integer, Integer> entry = _scanList.remove(0);
|
||||
|
||||
int startingX = entry.getKey();
|
||||
int startingZ = entry.getValue();
|
||||
|
||||
boolean outsideMap = startingZ < -_halfMapSize;
|
||||
|
||||
scanWorldMap(startingX, startingZ, !outsideMap);
|
||||
|
||||
if (outsideMap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int s = 1; s <= 2; s++)
|
||||
{
|
||||
if (s == 2)
|
||||
{
|
||||
s = getScale();
|
||||
|
||||
if (s == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (s == 13 && _loadWorld)
|
||||
continue;
|
||||
|
||||
if (!outsideMap)
|
||||
{
|
||||
drawWorldScale(s, startingX, startingZ);
|
||||
}
|
||||
|
||||
colorWorldHeight(s, startingX, startingZ);
|
||||
}
|
||||
|
||||
colorWorldHeight(0, startingX, startingZ);
|
||||
}
|
||||
|
||||
public void scanWorldMap(int startingX, int startingZ, boolean setColors)
|
||||
{
|
||||
Byte[][] map = _map.get(1);
|
||||
|
||||
for (int beginX = startingX; beginX < startingX + _blocksScan; beginX += 16)
|
||||
{
|
||||
for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ
|
||||
+ (setColors ? _blocksScan : 16); beginZ += 16)
|
||||
{
|
||||
Chunk chunk = _world.getChunkAt((beginX + _centerX) / 16, (beginZ + _centerZ) / 16);
|
||||
boolean loaded = false;
|
||||
|
||||
if (!chunk.isLoaded())
|
||||
{
|
||||
if (_loadWorld)
|
||||
{
|
||||
loaded = chunk.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
|
||||
|
||||
for (int x = beginX; x < beginX + 16; x++)
|
||||
{
|
||||
for (int z = beginZ; z < beginZ + 16; z++)
|
||||
{
|
||||
int color = 0;
|
||||
|
||||
if (!nmsChunk.isEmpty())
|
||||
{
|
||||
int k3 = x & 0xF;
|
||||
int l3 = z & 0xF;
|
||||
|
||||
int l4 = nmsChunk.b(k3, l3) + 1;
|
||||
IBlockData iblockdata = Blocks.AIR.getBlockData();
|
||||
|
||||
if (l4 > 1)
|
||||
{
|
||||
do
|
||||
{
|
||||
l4--;
|
||||
iblockdata = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
|
||||
}
|
||||
while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0));
|
||||
|
||||
if ((l4 > 0) && (iblockdata.getBlock().getMaterial().isLiquid()))
|
||||
{
|
||||
int j5 = l4 - 1;
|
||||
Block block1;
|
||||
do
|
||||
{
|
||||
block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3));
|
||||
}
|
||||
while ((j5 > 0) && (block1.getMaterial().isLiquid()));
|
||||
}
|
||||
}
|
||||
|
||||
_heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4;
|
||||
|
||||
if (setColors)
|
||||
{
|
||||
// color = block.f(i5).M;
|
||||
IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3));
|
||||
color = data.getBlock().g(data).M;
|
||||
|
||||
color = (byte) ((color * 4) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (setColors && beginZ >= startingZ)
|
||||
{
|
||||
map[x + _halfMapSize][z + _halfMapSize] = (byte) color;
|
||||
}
|
||||
}
|
||||
|
||||
if (loaded)
|
||||
{
|
||||
chunk.unload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMap(Player player)
|
||||
{
|
||||
for (ItemStack item : UtilInv.getItems(player))
|
||||
{
|
||||
if (item.getType() == Material.MAP && item.getDurability() == _mapId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack item = new ItemBuilder(Material.MAP, 1, _mapId).setTitle("Team Map").build();
|
||||
|
||||
int slot = player.getInventory().firstEmpty();
|
||||
|
||||
if (slot >= 0)
|
||||
{
|
||||
ItemStack mapSlot = player.getInventory().getItem(8);
|
||||
|
||||
if (mapSlot == null || mapSlot.getType() == Material.AIR)
|
||||
{
|
||||
slot = 8;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(slot, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data.map;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.MapZone;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapCursor;
|
||||
import org.bukkit.map.MapCursorCollection;
|
||||
import org.bukkit.map.MapPalette;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
public class ItemMapRenderer extends MapRenderer
|
||||
{
|
||||
private ItemMapManager _manager;
|
||||
private MinecraftLeague _host;
|
||||
|
||||
public ItemMapRenderer(ItemMapManager itemMapManager, MinecraftLeague host)
|
||||
{
|
||||
super(true);
|
||||
|
||||
_manager = itemMapManager;
|
||||
_host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView mapView, MapCanvas canvas, Player player)
|
||||
{
|
||||
int zoom = _manager.getScale();
|
||||
|
||||
Byte[][] map = _manager.getMap(zoom);
|
||||
|
||||
int centerX = 0;
|
||||
int centerZ = 0;
|
||||
|
||||
// We have this cooldown to squeeze out every single bit of performance from the server.
|
||||
if (Recharge.Instance.use(player, "Draw Map", 4000, false, false))
|
||||
{
|
||||
for (int mapX = 0; mapX < 128; mapX++)
|
||||
{
|
||||
for (int mapZ = 0; mapZ < 128; mapZ++)
|
||||
{
|
||||
int blockX = centerX + (mapX - 64);
|
||||
int blockZ = centerZ + (mapZ - 64);
|
||||
|
||||
int pixelX = blockX + (map.length / 2);
|
||||
int pixelZ = blockZ + (map.length / 2);
|
||||
|
||||
Byte color;
|
||||
|
||||
if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length)
|
||||
&& map[pixelX][pixelZ] != null)
|
||||
{
|
||||
color = map[pixelX][pixelZ];
|
||||
|
||||
blockX *= zoom;
|
||||
blockZ *= zoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = (byte) 0;
|
||||
}
|
||||
|
||||
for (MapZone od : _host.MapZones)
|
||||
{
|
||||
if (od.isInRadius(blockX, blockZ)) // TODO Some math to figure out if this pixel is going to be colored in for the circle or not.
|
||||
{
|
||||
if (od.isValid())
|
||||
color = MapPalette.matchColor(od.getRed(), od.getGreen(), od.getBlue());
|
||||
}
|
||||
|
||||
/*if (od.isBase(blockX - 20, blockZ + 15))
|
||||
{
|
||||
color = MapPalette.matchColor(Color.PINK);
|
||||
Bukkit.broadcastMessage("X:" + blockX + " Z:" + blockZ + "/" + od.getBase());
|
||||
}*/
|
||||
}
|
||||
|
||||
canvas.setPixel(mapX, mapZ, color);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMap(mapView);
|
||||
}
|
||||
|
||||
MapCursorCollection cursors = canvas.getCursors();
|
||||
|
||||
while (cursors.size() > 0)
|
||||
|
||||
{
|
||||
cursors.removeCursor(cursors.getCursor(0));
|
||||
}
|
||||
|
||||
// TODO If you want players to see each other as cursors. Otherwise delete this bit.
|
||||
for (
|
||||
|
||||
Player other : Bukkit.getOnlinePlayers())
|
||||
|
||||
{
|
||||
if (player.canSee(other) && other.isValid())
|
||||
{
|
||||
Location l = other.getLocation();
|
||||
|
||||
double mapX = (l.getX() - _manager.getX()) / zoom;
|
||||
double mapZ = (l.getZ() - _manager.getZ()) / zoom;
|
||||
|
||||
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
|
||||
{
|
||||
MapCursor.Type cursorDisplay;
|
||||
MapCursor.Type friend;
|
||||
MapCursor.Type foe;
|
||||
|
||||
if (_host.GetTeam(player).GetColor() == ChatColor.RED)
|
||||
{
|
||||
friend = MapCursor.Type.RED_POINTER;
|
||||
foe = MapCursor.Type.BLUE_POINTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
friend = MapCursor.Type.BLUE_POINTER;
|
||||
foe = MapCursor.Type.RED_POINTER;
|
||||
}
|
||||
|
||||
if (player == other)
|
||||
{
|
||||
cursorDisplay = MapCursor.Type.WHITE_POINTER;
|
||||
}
|
||||
else if (_host.GetTeam(player) == _host.GetTeam(other))
|
||||
{
|
||||
cursorDisplay = friend;
|
||||
}
|
||||
else if (_host.GetTeam(player) != _host.GetTeam(other))
|
||||
{
|
||||
if (_host.OverTime)
|
||||
cursorDisplay = foe;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
|
||||
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
|
||||
|
||||
byte rotation = (byte) (int) ((l.getYaw() * 16D) / 360D);
|
||||
|
||||
MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), cursorDisplay.getValue(), true);
|
||||
|
||||
cursors.addCursor(cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data.objectives;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective;
|
||||
|
||||
public class GearObjective extends GameObjective
|
||||
{
|
||||
public GearObjective()
|
||||
{
|
||||
super("GEAR", "Gear Up");
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data.objectives;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective;
|
||||
|
||||
public class KillObjective extends GameObjective
|
||||
{
|
||||
public KillObjective()
|
||||
{
|
||||
super("KILL_ENEMY", "Kill Enemy");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.kit;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class KitPlayer extends Kit
|
||||
{
|
||||
public KitPlayer(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Player", KitAvailability.Free,
|
||||
|
||||
new String[]
|
||||
{
|
||||
"",
|
||||
"Entirely vanilla combat!",
|
||||
""
|
||||
},
|
||||
|
||||
new Perk[]
|
||||
{
|
||||
|
||||
}, EntityType.PLAYER, new ItemStack(Material.DIAMOND_SWORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
MinecraftLeague game = (MinecraftLeague)Manager.GetGame();
|
||||
/*player.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET));
|
||||
player.getInventory().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
|
||||
player.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
|
||||
player.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS));
|
||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));*/
|
||||
|
||||
if (game != null)
|
||||
{
|
||||
game.restoreGear(player);
|
||||
game.MapManager.setMap(player);
|
||||
}
|
||||
|
||||
/*TeamMap tmap = game.getMap(game.GetTeam(player));
|
||||
|
||||
if (tmap == null)
|
||||
return;
|
||||
|
||||
tmap.giveMap(player, true, C.cGold + "Team Map", C.cGray + "This map contains", C.cGray + "the locations of", C.cGray + "your teammates.");*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpawnCustom(LivingEntity ent)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.objective;
|
||||
|
||||
|
||||
public abstract class GameObjective
|
||||
{
|
||||
private String _displayText, _id;
|
||||
|
||||
public GameObjective(String id, String displayText)
|
||||
{
|
||||
_id = id;
|
||||
_displayText = displayText;
|
||||
}
|
||||
|
||||
public String getID()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public String getDisplayText()
|
||||
{
|
||||
return _displayText;
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.objective;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class ObjectiveManager implements Listener
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
private GameObjective _main;
|
||||
private ConcurrentHashMap<Player, GameObjective> _specificObjectives = new ConcurrentHashMap<Player, GameObjective>();
|
||||
private ConcurrentHashMap<GameTeam, GameObjective> _teamObjectives = new ConcurrentHashMap<GameTeam, GameObjective>();
|
||||
|
||||
public ObjectiveManager(MinecraftLeague host)
|
||||
{
|
||||
_host = host;
|
||||
Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin());
|
||||
}
|
||||
|
||||
private void displayObjective(Player player)
|
||||
{
|
||||
GameObjective obj = _main;
|
||||
if (_teamObjectives.containsKey(_host.GetTeam(player)))
|
||||
obj = _teamObjectives.get(_host.GetTeam(player));
|
||||
if (_specificObjectives.containsKey(player))
|
||||
obj = _specificObjectives.get(player);
|
||||
|
||||
UtilTextBottom.display(C.cGold + "Objective: " + obj.getDisplayText(), player);
|
||||
}
|
||||
|
||||
public String getMainObjective()
|
||||
{
|
||||
return _main.getID();
|
||||
}
|
||||
|
||||
public String getTeamObjective(GameTeam team)
|
||||
{
|
||||
if (_teamObjectives.containsKey(team))
|
||||
return _teamObjectives.get(team).getID();
|
||||
|
||||
return getMainObjective();
|
||||
}
|
||||
|
||||
public String getPlayerObjective(Player player)
|
||||
{
|
||||
if (_specificObjectives.containsKey(player))
|
||||
return _specificObjectives.get(player).getID();
|
||||
|
||||
return getTeamObjective(_host.GetTeam(player));
|
||||
}
|
||||
|
||||
public void setMainObjective(GameObjective objective)
|
||||
{
|
||||
_main = objective;
|
||||
}
|
||||
|
||||
public void setPlayerObjective(Player player, GameObjective objective)
|
||||
{
|
||||
resetPlayerToMainObjective(player);
|
||||
_specificObjectives.put(player, objective);
|
||||
}
|
||||
|
||||
public void resetPlayerToMainObjective(Player player)
|
||||
{
|
||||
if (!_specificObjectives.containsKey(player))
|
||||
return;
|
||||
_specificObjectives.remove(player);
|
||||
}
|
||||
|
||||
public void setTeamObjective(GameTeam team, GameObjective objective)
|
||||
{
|
||||
if (getTeamObjective(team).equalsIgnoreCase("KILL_ENEMY"))
|
||||
return;
|
||||
|
||||
resetTeamToMainObjective(team);
|
||||
_teamObjectives.put(team, objective);
|
||||
}
|
||||
|
||||
public void resetTeamToMainObjective(GameTeam team)
|
||||
{
|
||||
if (!_teamObjectives.containsKey(team))
|
||||
return;
|
||||
_teamObjectives.remove(team);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!_host.IsLive())
|
||||
return;
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
{
|
||||
if (_main != null || _specificObjectives.containsKey(player) || _teamObjectives.containsKey(_host.GetTeam(player)))
|
||||
displayObjective(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleDeregister(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() != _host)
|
||||
return;
|
||||
|
||||
if (event.GetState() != GameState.Dead)
|
||||
return;
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class AltarBuilderTracker extends StatTracker<MinecraftLeague>
|
||||
{
|
||||
public AltarBuilderTracker(MinecraftLeague game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void build(PlaceSkullEvent e)
|
||||
{
|
||||
addStat(e.getPlayer(), "AltarBuilder", 1, false, false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import nautilus.game.arcade.events.FirstBloodEvent;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class FirstStrikeTracker extends StatTracker<MinecraftLeague>
|
||||
{
|
||||
public FirstStrikeTracker(MinecraftLeague game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blood(FirstBloodEvent e)
|
||||
{
|
||||
addStat(e.getPlayer(), "FirstStrike", 1, false, false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class GrabSkullEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player _player;
|
||||
|
||||
public GrabSkullEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class HeadHunterTracker extends StatTracker<MinecraftLeague>
|
||||
{
|
||||
public HeadHunterTracker(MinecraftLeague game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void build(GrabSkullEvent e)
|
||||
{
|
||||
addStat(e.getPlayer(), "HeadHunter", 1, false, false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlaceSkullEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player _player;
|
||||
|
||||
public PlaceSkullEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
|
||||
public class SavingUpTracker extends StatTracker<MinecraftLeague>
|
||||
{
|
||||
public SavingUpTracker(MinecraftLeague game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void build(CraftItemEvent e)
|
||||
{
|
||||
if (e.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE)
|
||||
addStat((Player)e.getWhoClicked(), "SavingUp", 1, false, false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.tracker;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class TowerDefenderTracker extends StatTracker<MinecraftLeague>
|
||||
{
|
||||
private final int _killCount;
|
||||
private final String _stat;
|
||||
private final int _timeLimit;
|
||||
|
||||
private final ConcurrentHashMap<UUID, Integer> _kills = new ConcurrentHashMap<UUID, Integer>();
|
||||
private final ConcurrentHashMap<UUID, Long> _lastKill = new ConcurrentHashMap<UUID, Long>();
|
||||
|
||||
public TowerDefenderTracker(MinecraftLeague game, int killCount, int timeLimit, String stat)
|
||||
{
|
||||
super(game);
|
||||
|
||||
_killCount = killCount;
|
||||
_stat = stat;
|
||||
_timeLimit = timeLimit * 1000;
|
||||
}
|
||||
|
||||
public int getKillCount()
|
||||
{
|
||||
return _killCount;
|
||||
}
|
||||
|
||||
public int getTimeLimit()
|
||||
{
|
||||
return _timeLimit;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onCombatDeath(CombatDeathEvent event)
|
||||
{
|
||||
if (getGame().GetState() != Game.GameState.Live)
|
||||
return;
|
||||
|
||||
if (event.GetLog().GetKiller() == null)
|
||||
return;
|
||||
|
||||
if (!event.GetLog().GetKiller().IsPlayer())
|
||||
return;
|
||||
|
||||
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
Integer killCount = _kills.get(player.getUniqueId());
|
||||
Long lastKill = _lastKill.get(player.getUniqueId());
|
||||
|
||||
killCount = (killCount == null ? 0 : killCount) + 1;
|
||||
lastKill = (lastKill == null ? System.currentTimeMillis() : lastKill);
|
||||
|
||||
_kills.put(player.getUniqueId(), killCount);
|
||||
_lastKill.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
|
||||
if (killCount == getKillCount() && System.currentTimeMillis() - lastKill < getTimeLimit())
|
||||
{
|
||||
if (UtilMath.offset2d(player.getLocation(), getGame().getActiveTower(getGame().GetTeam(player)).getLocation()) <= 7)
|
||||
{
|
||||
addStat(player, getStat(), 1, true, false);
|
||||
_lastKill.remove(player.getUniqueId());
|
||||
_kills.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
|
||||
public abstract class ExtraScoreboardData
|
||||
{
|
||||
public GameScoreboard Scoreboard;
|
||||
|
||||
public ExtraScoreboardData(GameScoreboard sb)
|
||||
{
|
||||
Scoreboard = sb;
|
||||
}
|
||||
|
||||
public abstract void write();
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class GameVariation implements Listener
|
||||
{
|
||||
public MinecraftLeague Host;
|
||||
public ArcadeManager Manager;
|
||||
public WorldData WorldData;
|
||||
|
||||
public GameVariation(MinecraftLeague host)
|
||||
{
|
||||
Host = host;
|
||||
Manager = host.getArcadeManager();
|
||||
WorldData = host.WorldData;
|
||||
}
|
||||
|
||||
public void ParseData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String[] getTeamScoreboardAdditions(GameTeam team)
|
||||
{
|
||||
return new String[]{};
|
||||
}
|
||||
|
||||
public void deregister()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
public abstract void customDeregister();
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
public class StandardGameplay extends GameVariation
|
||||
{
|
||||
public StandardGameplay(MinecraftLeague host)
|
||||
{
|
||||
super(host);
|
||||
}
|
||||
|
||||
public void customDeregister() {}
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class VariationManager implements Listener
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
private GameVariation _variation;
|
||||
//private VariationType _selected;
|
||||
|
||||
public VariationManager(MinecraftLeague host)
|
||||
{
|
||||
_host = host;
|
||||
Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin());
|
||||
}
|
||||
|
||||
public GameVariation getSelected()
|
||||
{
|
||||
return _variation;
|
||||
}
|
||||
|
||||
public void selectVariation()
|
||||
{
|
||||
VariationType type = null;
|
||||
if (_host.getMapVariantIDS().size() != 1)
|
||||
type = VariationType.STANDARD;
|
||||
else
|
||||
{
|
||||
type = VariationType.getFromID(_host.getMapVariantIDS().get(0).replace(DataLoc.VARIANT_BASE.getKey(), ""));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_variation = type.getVariation().getConstructor(MinecraftLeague.class).newInstance(_host);
|
||||
//_selected = type;
|
||||
}
|
||||
catch (NoSuchMethodException ex)
|
||||
{
|
||||
System.err.println("Is the constructor for " + type.toString() + " using only one argument?");
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
catch (InvocationTargetException ex)
|
||||
{
|
||||
ex.getCause().printStackTrace();
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
//Bukkit.broadcastMessage(type.getDisplayMessage());
|
||||
Bukkit.getPluginManager().registerEvents(_variation, _host.getArcadeManager().getPlugin());
|
||||
_variation.ParseData();
|
||||
}
|
||||
|
||||
public void deregister()
|
||||
{
|
||||
if (_variation != null)
|
||||
_variation.deregister();
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleDeregister(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() != _host)
|
||||
return;
|
||||
|
||||
if (event.GetState() != GameState.Dead)
|
||||
return;
|
||||
|
||||
deregister();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInform(PlayerJoinEvent event)
|
||||
{
|
||||
if (_variation != null)
|
||||
{
|
||||
//event.getPlayer().sendMessage(_selected.getDisplayMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public enum VariationType
|
||||
{
|
||||
STANDARD("STANDARD", StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN),
|
||||
WITHER("WITHER", WitherVariation.class, "Wither Variation", ChatColor.RED),
|
||||
//GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA)
|
||||
;
|
||||
|
||||
private String _id;
|
||||
private String _name;
|
||||
private ChatColor _color;
|
||||
private Class<? extends GameVariation> _variation;
|
||||
|
||||
private VariationType(String id, Class<? extends GameVariation> variationClass, String displayName, ChatColor displayColor)
|
||||
{
|
||||
_id = id;
|
||||
_name = displayName;
|
||||
_color = displayColor;
|
||||
_variation = variationClass;
|
||||
}
|
||||
|
||||
public Class<? extends GameVariation> getVariation()
|
||||
{
|
||||
return _variation;
|
||||
}
|
||||
|
||||
public String getDisplayMessage()
|
||||
{
|
||||
return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name;
|
||||
}
|
||||
|
||||
public static VariationType getFromID(String id)
|
||||
{
|
||||
for (VariationType type : VariationType.values())
|
||||
{
|
||||
if (type._id.equalsIgnoreCase(id))
|
||||
return type;
|
||||
}
|
||||
|
||||
return VariationType.STANDARD;
|
||||
}
|
||||
}
|
@ -0,0 +1,465 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherPathfinder;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class WitherVariation extends GameVariation
|
||||
{
|
||||
private ConcurrentHashMap<GameTeam, TeamAltar> _altars = new ConcurrentHashMap<GameTeam, TeamAltar>();
|
||||
|
||||
private Wither _wither;
|
||||
private WitherPathfinder _pathfinder;
|
||||
|
||||
private WitherMinionManager _skellyMan;
|
||||
|
||||
public boolean WitherSpawned;
|
||||
|
||||
private GameTeam _wowner = null;
|
||||
|
||||
public WitherVariation(MinecraftLeague host)
|
||||
{
|
||||
super(host);
|
||||
WitherSpawned = false;
|
||||
_skellyMan = new WitherMinionManager(this, WorldData.GetDataLocs(DataLoc.WITHER_SKELETON.getKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customDeregister()
|
||||
{
|
||||
HandlerList.unregisterAll(_skellyMan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
_altars.put(Host.GetTeam(ChatColor.AQUA), new TeamAltar(this, Host.GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_ALTAR.getKey()).get(0)));
|
||||
_altars.put(Host.GetTeam(ChatColor.RED), new TeamAltar(this, Host.GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_ALTAR.getKey()).get(0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTeamScoreboardAdditions(GameTeam team)
|
||||
{
|
||||
String skulls = "";
|
||||
for (int i = 1; i < 4; i++)
|
||||
{
|
||||
if (!skulls.equalsIgnoreCase(""))
|
||||
skulls = skulls + " ";
|
||||
|
||||
if (_altars.get(team).getPlacedSkulls() >= i)
|
||||
skulls = skulls + ChatColor.GREEN + "☠";
|
||||
else
|
||||
skulls = skulls + ChatColor.GRAY + "☠";
|
||||
}
|
||||
|
||||
return new String[] {"Skulls: " + skulls};
|
||||
}
|
||||
|
||||
private Location getNearest(Location to, ConcurrentHashMap<Location, Double> options)
|
||||
{
|
||||
Location ret = null;
|
||||
double dist = Double.MAX_VALUE;
|
||||
|
||||
for (Location check : options.keySet())
|
||||
{
|
||||
if (options.get(check) < dist)
|
||||
{
|
||||
ret = check;
|
||||
dist = options.get(check);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private LinkedList<Location> getWaypoints(Location altar)
|
||||
{
|
||||
LinkedList<Location> waypoints = new LinkedList<Location>();
|
||||
ConcurrentHashMap<Location, Double> distances = new ConcurrentHashMap<Location, Double>();
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs(DataLoc.WITHER_WAYPOINT.getKey()))
|
||||
{
|
||||
distances.put(loc, altar.distance(loc));
|
||||
}
|
||||
|
||||
while (distances.size() >= 1)
|
||||
{
|
||||
Location act = getNearest(altar, distances);
|
||||
waypoints.add(act);
|
||||
distances.remove(act);
|
||||
}
|
||||
|
||||
return waypoints;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (player.hasPotionEffect(PotionEffectType.WITHER))
|
||||
{
|
||||
player.removePotionEffect(PotionEffectType.WITHER);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * 6, 0));
|
||||
}
|
||||
if (!Host.IsAlive(player))
|
||||
continue;
|
||||
/*GameTeam enemy = null;
|
||||
if (Host.GetTeam(player).GetColor() == ChatColor.RED)
|
||||
{
|
||||
enemy = Host.GetTeam(ChatColor.AQUA);
|
||||
}
|
||||
else
|
||||
{
|
||||
enemy = Host.GetTeam(ChatColor.RED);
|
||||
}
|
||||
if (UtilMath.offset(player, Host.getActiveTower(enemy).getEntity()) <= 7)
|
||||
{
|
||||
for (Location loc : UtilShapes.getCircle(player.getEyeLocation(), true, 3))
|
||||
{
|
||||
if (new Random().nextInt(5) <= 3)
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.DRIP_LAVA, loc, null, 0, 2, ViewDist.SHORT, player);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
if (_pathfinder != null)
|
||||
if (_pathfinder.update())
|
||||
{
|
||||
GameTeam team = _pathfinder.getTeam();
|
||||
_pathfinder = null;
|
||||
WitherSpawned = false;
|
||||
_wowner = null;
|
||||
_skellyMan.onWitherDeath();
|
||||
UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + "'s Wither has been Defeated!");
|
||||
//Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED));
|
||||
//Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWitherSpawn(EntitySpawnEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
if (WitherSpawned)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (GameTeam team : _altars.keySet())
|
||||
{
|
||||
GameTeam enemy = null;
|
||||
if (team.GetColor() == ChatColor.AQUA)
|
||||
{
|
||||
enemy = Host.GetTeam(ChatColor.RED);
|
||||
}
|
||||
else if (team.GetColor() == ChatColor.RED)
|
||||
{
|
||||
enemy = Host.GetTeam(ChatColor.AQUA);
|
||||
}
|
||||
if (_altars.get(team).ownsWither(event))
|
||||
{
|
||||
if (Host.getTowerManager().getAmountAlive(enemy) < 1)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
WitherSpawned = true;
|
||||
_wowner = team;
|
||||
_wither = (Wither)event.getEntity();
|
||||
_wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither");
|
||||
_wither.setCustomNameVisible(true);
|
||||
UtilTextMiddle.display("", C.cWhite + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers());
|
||||
_pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, enemy, Host.getTowerManager());
|
||||
_skellyMan.onWitherSpawn();
|
||||
//Host.Objective.setMainObjective(new GearObjective());
|
||||
//Host.Objective.setTeamObjective(team, new WitherObjective("Attack Enemy Towers"));
|
||||
//Host.Objective.setTeamObjective(enemy, new WitherObjective("Kill Wither"));
|
||||
/*for (Player player : Host.GetPlayers(true))
|
||||
{
|
||||
Host.Objective.resetPlayerToMainObjective(player);
|
||||
}*/
|
||||
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Host.CreatureAllowOverride = false;
|
||||
}
|
||||
}, 20 * 3);
|
||||
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_altars.get(team).spawnSoulsand();
|
||||
}
|
||||
}, 20 * 35);
|
||||
}
|
||||
}
|
||||
|
||||
if (_wither == null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleWitherDrops(EntityDeathEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
event.setDroppedExp(0);
|
||||
event.getDrops().clear();
|
||||
}
|
||||
}
|
||||
|
||||
//@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof WitherSkull)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!((WitherSkull)event.getEntity()).isCharged())
|
||||
return;
|
||||
|
||||
LinkedList<TeamTowerBase> red = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.RED));
|
||||
LinkedList<TeamTowerBase> blue = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.AQUA));
|
||||
HashMap<Block, Double> inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false);
|
||||
|
||||
double dmg = 10 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size());
|
||||
for (TeamTowerBase tb : red)
|
||||
{
|
||||
if (inside.containsKey(tb.getLocation().getBlock()))
|
||||
{
|
||||
tb.damage(dmg, null);
|
||||
Host.Alert.alert(tb.getTeam(), tb);
|
||||
}
|
||||
}
|
||||
for (TeamTowerBase tb : blue)
|
||||
{
|
||||
if (inside.containsKey(tb.getLocation().getBlock()))
|
||||
{
|
||||
tb.damage(dmg, null);
|
||||
Host.Alert.alert(tb.getTeam(), tb);
|
||||
}
|
||||
}
|
||||
for (Block b : inside.keySet())
|
||||
{
|
||||
if (inside.get(b) > 2)
|
||||
continue;
|
||||
|
||||
for (TeamAltar altar : _altars.values())
|
||||
{
|
||||
if (altar.isInsideAltar(b.getLocation()))
|
||||
continue;
|
||||
}
|
||||
for (GameTeam owner : Host.GetTeamList())
|
||||
{
|
||||
for (TeamTowerBase tb : Host.getTowerManager().getTeamTowers(owner))
|
||||
{
|
||||
if (!tb.Vulnerable)
|
||||
continue;
|
||||
|
||||
if (tb.getLocation().distance(b.getLocation()) < 7)
|
||||
{
|
||||
if (b.getType() == Material.BEDROCK)
|
||||
continue;
|
||||
if (b.getType() == Material.OBSIDIAN)
|
||||
{
|
||||
if (new Random().nextDouble() > (.75 / 2))
|
||||
continue;
|
||||
}
|
||||
if (b.getType() == Material.AIR)
|
||||
continue;
|
||||
if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER)
|
||||
continue;
|
||||
if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA)
|
||||
continue;
|
||||
//WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build());
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getEntity() instanceof TNTPrimed)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
for (TeamAltar altar : _altars.values())
|
||||
{
|
||||
if (!altar.canPlace(event.getPlayer(), event.getBlock().getType(), event.getBlock().getLocation(), true))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
for (TeamAltar altar : _altars.values())
|
||||
{
|
||||
if (!altar.canBreak(event.getPlayer(), event.getBlock(), true))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onShoot(ProjectileLaunchEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity()instanceof WitherSkull)
|
||||
{
|
||||
final WitherSkull entity = (WitherSkull)event.getEntity();
|
||||
if (entity.isCharged())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!((Wither)entity.getShooter()).hasMetadata("Shooting"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preserveAltars(EntityChangeBlockEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
for (TeamAltar altar : _altars.values())
|
||||
{
|
||||
if (altar.isInsideAltar(event.getBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void protectWither(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
if (!WitherSpawned)
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
Player dmg = (Player)event.getDamager();
|
||||
if (_wowner.HasPlayer(dmg))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getDamager() instanceof Projectile)
|
||||
{
|
||||
if (((Projectile)event.getDamager()).getShooter() instanceof Player)
|
||||
{
|
||||
Player dmg = (Player) ((Projectile)event.getDamager()).getShooter();
|
||||
if (_wowner.HasPlayer(dmg))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setDamage(event.getDamage() * .8);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerGameRespawnEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
Manager.GetCondition().Clean(event.GetPlayer());
|
||||
/*if (Host.Objective.getPlayerObjective(event.GetPlayer()).equals("RETURN_SKULL"))
|
||||
{
|
||||
Host.Objective.resetPlayerToMainObjective(event.GetPlayer());
|
||||
}*/
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PathfinderData
|
||||
{
|
||||
public Wither Wither;
|
||||
|
||||
public Location Target = null;
|
||||
public Location Location = null;
|
||||
|
||||
public float Pitch = 0;
|
||||
public Vector Velocity = new Vector(0,0,0);
|
||||
|
||||
//private long _lastReview;
|
||||
|
||||
public PathfinderData(Wither wither, Location target)
|
||||
{
|
||||
Wither = wither;
|
||||
UtilEnt.ghost(wither, true, false);
|
||||
UtilEnt.Vegetate(wither, false);
|
||||
|
||||
Location temp = wither.getLocation();
|
||||
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(wither.getLocation(), target)));
|
||||
wither.teleport(temp);
|
||||
|
||||
Velocity = wither.getLocation().getDirection().setY(0).normalize();
|
||||
Pitch = UtilAlg.GetPitch(wither.getLocation().getDirection());
|
||||
|
||||
Location = wither.getLocation();
|
||||
//_lastReview = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void move()
|
||||
{
|
||||
turn();
|
||||
|
||||
//Speed
|
||||
double speed = 0.325 / 2;
|
||||
|
||||
Location.add(Velocity.clone().multiply(speed));
|
||||
Location.add(0, -Pitch, 0);
|
||||
|
||||
Location.setPitch(-1 * Pitch);
|
||||
Location.setYaw(/*180 +*/ UtilAlg.GetYaw(Velocity));
|
||||
|
||||
//
|
||||
if (!UtilBlock.airFoliage(Location.getBlock()))
|
||||
{
|
||||
Location.setY(UtilBlock.getHighest(Location.getWorld(), Location.getBlockX(), Location.getBlockZ()).getY());
|
||||
}
|
||||
|
||||
Wither.teleport(Location);
|
||||
}
|
||||
|
||||
private void turn()
|
||||
{
|
||||
//Pitch
|
||||
float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target));
|
||||
if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05);
|
||||
if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05);
|
||||
if (Pitch > 0.5) Pitch = 0.5f;
|
||||
if (Pitch < -0.5) Pitch = -0.5f;
|
||||
|
||||
//Flat
|
||||
Vector desired = UtilAlg.getTrajectory2d(Location, Target);
|
||||
desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ())));
|
||||
desired.multiply(0.2);
|
||||
|
||||
Velocity.add(desired);
|
||||
|
||||
//Speed
|
||||
UtilAlg.Normalize(Velocity);
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.tracker.PlaceSkullEvent;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
public class TeamAltar
|
||||
{
|
||||
private WitherVariation _host;
|
||||
private GameTeam _team;
|
||||
private Location _center;
|
||||
|
||||
//private List<Location> _protected;
|
||||
|
||||
private Location[] _skullSpots;
|
||||
|
||||
private int _placed;
|
||||
|
||||
public TeamAltar(WitherVariation host, GameTeam team, Location center)
|
||||
{
|
||||
_host = host;
|
||||
_team = team;
|
||||
_center = center;
|
||||
|
||||
spawnSoulsand();
|
||||
|
||||
//_protected = UtilShapes.getSphereBlocks(center, 7, 7, false);
|
||||
|
||||
Location labelLoc = center.clone().add(0/*.5*/, 5, 0.5);
|
||||
String labelStr = team.GetColor() + team.getDisplayName() + "'s Altar";
|
||||
Hologram label = new Hologram(host.Host.getArcadeManager().getHologramManager(), labelLoc, labelStr);
|
||||
label.start();
|
||||
}
|
||||
|
||||
public boolean isInsideAltar(Location location)
|
||||
{
|
||||
return UtilMath.offset(_center, location) <= 7;
|
||||
//return _protected.contains(location);
|
||||
}
|
||||
|
||||
public void spawnSoulsand()
|
||||
{
|
||||
_placed = 0;
|
||||
Location s1 = null;
|
||||
Location s2 = null;
|
||||
Location s3 = null;
|
||||
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
_center.getBlock().getRelative(i, 1, 0).setType(Material.SOUL_SAND);
|
||||
if (i == -1)
|
||||
s1 = _center.getBlock().getRelative(i, 2, 0).getLocation();
|
||||
if (i == 0)
|
||||
s2 = _center.getBlock().getRelative(i, 2, 0).getLocation();
|
||||
if (i == 1)
|
||||
s3 = _center.getBlock().getRelative(i, 2, 0).getLocation();
|
||||
}
|
||||
_center.getBlock().setType(Material.SOUL_SAND);
|
||||
|
||||
_skullSpots = new Location[] {s1, s2, s3};
|
||||
}
|
||||
|
||||
public boolean canBreak(Player player, Block block, boolean notify)
|
||||
{
|
||||
if (isInsideAltar(block.getLocation()))
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "You cannot break blocks inside an Altar!"));
|
||||
return false;
|
||||
/*if (!_team.HasPlayer(player))
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "This is not your Altar!"));
|
||||
return false;
|
||||
}
|
||||
if (block.getType() != Material.SKULL)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "You cannot break that block inside an Altar!"));
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlace(Player player, Material blockType, Location location, boolean notify)
|
||||
{
|
||||
if (isInsideAltar(location))
|
||||
{
|
||||
if (!_team.HasPlayer(player))
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "This is not your Altar!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_host.WitherSpawned)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blockType != Material.SKULL)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean passes = false;
|
||||
for (Location l : _skullSpots)
|
||||
{
|
||||
if (l.equals(location))
|
||||
passes = true;
|
||||
}
|
||||
|
||||
if (!passes)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "That doesn't go there!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_team.GetColor() == ChatColor.RED)
|
||||
{
|
||||
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) < 1)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_team.GetColor() == ChatColor.AQUA)
|
||||
{
|
||||
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1)
|
||||
{
|
||||
if (notify)
|
||||
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_team.HasPlayer(player) && blockType == Material.SKULL)
|
||||
{
|
||||
//_host.Host.Objective.resetPlayerToMainObjective(player);
|
||||
Bukkit.getPluginManager().callEvent(new PlaceSkullEvent(player));
|
||||
if (_placed < 2)
|
||||
{
|
||||
UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!");
|
||||
for (Player scare : UtilServer.getPlayers())
|
||||
{
|
||||
scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_host.Host.CreatureAllowOverride = true;
|
||||
}
|
||||
_placed++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean ownsWither(EntitySpawnEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
Location base = event.getLocation();
|
||||
return (isInsideAltar(base.getBlock().getLocation()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
return _center.clone();
|
||||
}
|
||||
|
||||
public int getPlacedSkulls()
|
||||
{
|
||||
return _placed;
|
||||
}
|
||||
}
|
@ -0,0 +1,488 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.MapZone;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class WitherMinionManager implements Listener
|
||||
{
|
||||
private WitherVariation _host;
|
||||
private List<Location> _spawns;
|
||||
private long _lastDied;
|
||||
private int _lastUsed;
|
||||
private int _selected;
|
||||
|
||||
private Skeleton _entity;
|
||||
|
||||
private ItemStack _witherItem;
|
||||
|
||||
private WitherSkeletonTimer _sbTimer;
|
||||
//private MapZone _skellyZone;
|
||||
|
||||
private Block _cb;
|
||||
private Material _changed = Material.AIR;
|
||||
|
||||
private boolean _witherBlocked = false;
|
||||
|
||||
private boolean _spawned = false;
|
||||
|
||||
public WitherMinionManager(WitherVariation host, List<Location> spawns)
|
||||
{
|
||||
_host = host;
|
||||
_spawns = spawns;
|
||||
_lastDied = System.currentTimeMillis();
|
||||
_lastUsed = -1;
|
||||
_witherItem = new ItemBuilder(Material.SKULL_ITEM).setTitle(C.cDRedB + "Wither Skeleton Head").setData((short) 1).setLore(C.cGray + "Bring this back", C.cGray + "to your team's Altar", C.cGray + "To summon a Wither!").build();
|
||||
_sbTimer = new WitherSkeletonTimer(host.Host.GetScoreboard());
|
||||
host.Host.ExtraSb.put(_sbTimer, host);
|
||||
//_skellyZone = new MapZone(spawns.get(0), new int[] {0, 0, 0});
|
||||
//_skellyZone.setValid(false);
|
||||
//host.Host.MapZones.add(_skellyZone);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, host.Manager.getPlugin());
|
||||
}
|
||||
|
||||
private void preSpawn()
|
||||
{
|
||||
Location chosen = null;
|
||||
while (chosen == null)
|
||||
{
|
||||
int check = new Random().nextInt(_spawns.size());
|
||||
if (check != _lastUsed)
|
||||
{
|
||||
chosen = _spawns.get(check);
|
||||
_lastUsed = check;
|
||||
_selected = check;
|
||||
}
|
||||
}
|
||||
|
||||
_cb = chosen.clone().add(0, -2, 0).getBlock();
|
||||
_changed = _cb.getType();
|
||||
chosen.clone().add(0, -2, 0).getBlock().setType(Material.BEACON);
|
||||
}
|
||||
|
||||
private void spawn(boolean respawn)
|
||||
{
|
||||
Location chosen = null;
|
||||
if (!respawn)
|
||||
chosen = _spawns.get(_selected);
|
||||
else
|
||||
chosen = _spawns.get(_lastUsed);
|
||||
_host.Host.CreatureAllowOverride = true;
|
||||
Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON);
|
||||
_host.Host.CreatureAllowOverride = false;
|
||||
((Skeleton)e).setSkeletonType(SkeletonType.WITHER);
|
||||
_entity = (Skeleton)e;
|
||||
UtilEnt.ghost(e, true, false);
|
||||
UtilEnt.Vegetate(e);
|
||||
e.setCustomName(C.cRed + "Wither Skeleton");
|
||||
((Skeleton)e).setMaxHealth(/*100*/65);
|
||||
((Skeleton)e).setHealth(/*100*/65);
|
||||
((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||
((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||
//((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 7));
|
||||
|
||||
if (!respawn)
|
||||
{
|
||||
UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!");
|
||||
//_skellyZone.setCenter(chosen);
|
||||
//_skellyZone.setValid(true);
|
||||
//_host.Host.Objective.setMainObjective(new GrabSkullObjective());
|
||||
}
|
||||
_selected = -1;
|
||||
_spawned = true;
|
||||
}
|
||||
|
||||
public void onWitherDeath()
|
||||
{
|
||||
_lastDied = System.currentTimeMillis();
|
||||
_witherBlocked = false;
|
||||
_host.Host.getTowerManager().toggleAttack();
|
||||
_sbTimer.freezeTime(-1);
|
||||
}
|
||||
|
||||
public void onWitherSpawn()
|
||||
{
|
||||
_host.Host.getTowerManager().toggleAttack();
|
||||
_witherBlocked = true;
|
||||
if (_entity != null)
|
||||
{
|
||||
_spawned = false;
|
||||
_entity.remove();
|
||||
_lastDied = System.currentTimeMillis();
|
||||
//_skellyZone.setValid(false);
|
||||
_entity = null;
|
||||
}
|
||||
if (_cb != null)
|
||||
{
|
||||
_cb.setType(_changed);
|
||||
_cb = null;
|
||||
_changed = Material.AIR;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLive(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() != _host.Host)
|
||||
return;
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
_lastDied = System.currentTimeMillis() + UtilTime.convert(60, TimeUnit.SECONDS, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
if (_entity == null || !_entity.isValid())
|
||||
{
|
||||
if (_spawned)
|
||||
spawn(true);
|
||||
}
|
||||
|
||||
if (_entity != null)
|
||||
{
|
||||
_entity.teleport(_spawns.get(_lastUsed));
|
||||
}
|
||||
|
||||
try {
|
||||
if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||
noUse = false;
|
||||
if (!_witherBlocked && !noUse)
|
||||
{
|
||||
if (_entity == null)
|
||||
{
|
||||
if (_selected != _lastUsed)
|
||||
{
|
||||
preSpawn();
|
||||
}
|
||||
long end = _lastDied + UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
|
||||
end =- System.currentTimeMillis();
|
||||
long secLeft = UtilTime.convert(end, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
|
||||
if (secLeft <= 3)
|
||||
{
|
||||
if (secLeft > 0)
|
||||
{
|
||||
UtilTextMiddle.display(secLeft + " Seconds", "Until Wither Skeleton Spawn");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(_lastDied, UtilTime.convert(90, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||
noUse = false;
|
||||
if (!_witherBlocked && !noUse)
|
||||
{
|
||||
if (_entity == null)
|
||||
spawn(false);
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (UtilInv.contains(player, Material.SKULL_ITEM, (byte) 1, 1))
|
||||
{
|
||||
UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation(), new Random().nextFloat(), new Random().nextFloat(), new Random().nextFloat(), 0, 1, ViewDist.MAX);
|
||||
if (Recharge.Instance.usable(player, "FIREWORK_ALERT", false))
|
||||
{
|
||||
Recharge.Instance.use(player, "FIREWORK_ALERT", UtilTime.convert(2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false);
|
||||
UtilFirework.playFirework(player.getEyeLocation().add(0, 3, 0), Type.BURST, _host.Host.GetTeam(player).GetColorBase(), false, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*if (_host.Host.Objective.getPlayerObjective(player) != null)
|
||||
{
|
||||
if (_host.Host.Objective.getPlayerObjective(player).equalsIgnoreCase("GRAB_SKULL"))
|
||||
{
|
||||
_host.Host.Objective.resetPlayerToMainObjective(player);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (player.getInventory().getHelmet() != null)
|
||||
{
|
||||
if (UtilInv.IsItem(player.getInventory().getHelmet(), Material.SKULL_ITEM, (byte) 1))
|
||||
{
|
||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
UtilInv.insert(player, _witherItem.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleTimer(UpdateEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||
noUse = false;
|
||||
|
||||
if (_entity != null || noUse)
|
||||
{
|
||||
_sbTimer.freezeTime(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_host.WitherSpawned || _witherBlocked)
|
||||
{
|
||||
_sbTimer.freezeTime(-2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_entity == null)
|
||||
_sbTimer.freezeTime(-1);
|
||||
|
||||
_sbTimer.setEnd((_lastDied + UtilTime.convert(90, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onSkellyDie(EntityDeathEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Skeleton)
|
||||
{
|
||||
Skeleton skelly = (Skeleton)event.getEntity();
|
||||
if (skelly.getSkeletonType() == SkeletonType.WITHER)
|
||||
{
|
||||
if (_entity != null)
|
||||
{
|
||||
if (skelly.getEntityId() == _entity.getEntityId())
|
||||
{
|
||||
_spawned = false;
|
||||
_lastDied = System.currentTimeMillis();
|
||||
_entity = null;
|
||||
event.getDrops().clear();
|
||||
event.getDrops().add(_witherItem.clone());
|
||||
event.setDroppedExp(10);
|
||||
//_skellyZone.setValid(false);
|
||||
|
||||
_cb.setType(_changed);
|
||||
_cb = null;
|
||||
_changed = Material.AIR;
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
_host.Host.getTowerManager().ironOreGen(null, false);
|
||||
}
|
||||
}, 20 * 10);
|
||||
|
||||
//_host.Host.Objective.setMainObjective(new GearObjective());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
String com = UtilItem.itemToStr(event.getItem().getItemStack());
|
||||
String com1 = UtilItem.itemToStr(_witherItem.clone());
|
||||
String[] compare = com.split(":");
|
||||
String[] compare1 = com1.split(":");
|
||||
String fin = compare[0] + ":" + compare[2] + ":" + compare[3];
|
||||
String fin1 = compare1[0] + ":" + compare1[2] + ":" + compare1[3];
|
||||
if (fin.equalsIgnoreCase(fin1))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You have the Wither Skull! Return the skull to your base and place it on your Altar to summon the Wither!"));
|
||||
UtilTextMiddle.display("", C.cGray + "You have picked up the Wither Skull!", event.getPlayer());
|
||||
Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
UtilTextMiddle.display("", "Place the skull on top of", event.getPlayer());
|
||||
}
|
||||
}, 20 * 5);
|
||||
Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
UtilTextMiddle.display("", "Your Altar's Soul Sand!", event.getPlayer());
|
||||
}
|
||||
}, 20 * 8);
|
||||
//_host.Host.Objective.setPlayerObjective(event.getPlayer(), new ReturnSkullObjective());
|
||||
if (!event.getItem().hasMetadata("Dropped"))
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(new GrabSkullEvent(event.getPlayer()));
|
||||
UtilTextMiddle.display("", _host.Host.GetTeam(event.getPlayer()).GetColor() + _host.Host.GetTeam(event.getPlayer()).getDisplayName() + " has picked up a Wither Skull!", 20, 20 * 5, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
String com = UtilItem.itemToStr(event.getItemDrop().getItemStack());
|
||||
String com1 = UtilItem.itemToStr(_witherItem.clone());
|
||||
String[] compare = com.split(":");
|
||||
String[] compare1 = com1.split(":");
|
||||
String fin = compare[0] + ":" + compare[2] + ":" + compare[3];
|
||||
String fin1 = compare1[0] + ":" + compare1[2] + ":" + compare1[3];
|
||||
if (fin.equalsIgnoreCase(fin1))
|
||||
{
|
||||
event.getItemDrop().setMetadata("Dropped", new FixedMetadataValue(_host.Manager.getPlugin(), true));
|
||||
//_host.Host.Objective.resetPlayerToMainObjective(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
//if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation()))
|
||||
if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
//if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation()))
|
||||
if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExp(EntityExplodeEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (event.getEntity() instanceof Wither)
|
||||
{
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntity(EntityChangeBlockEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
//if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation()))
|
||||
if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void fixDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (!_host.Host.IsLive())
|
||||
return;
|
||||
|
||||
if (_entity == null)
|
||||
return;
|
||||
if (event.getEntity().getEntityId() != _entity.getEntityId())
|
||||
return;
|
||||
|
||||
UtilAction.zeroVelocity(event.getEntity());
|
||||
}
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
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.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class WitherPathfinder
|
||||
{
|
||||
private PathfinderData _pathData;
|
||||
private WitherVariation _host;
|
||||
private Wither _ent;
|
||||
private LinkedList<Location> _waypoints;
|
||||
private GameTeam _team;
|
||||
private GameTeam _enemy;
|
||||
private TowerManager _towerManager;
|
||||
private long _lastAttack;
|
||||
private long _lastTowerAttack;
|
||||
|
||||
private boolean _startedJourney = false;
|
||||
|
||||
private double _health;
|
||||
|
||||
public WitherPathfinder(WitherVariation host, Wither ent, LinkedList<Location> waypoints, GameTeam team, GameTeam enemy, TowerManager towerManager)
|
||||
{
|
||||
_host = host;
|
||||
_ent = ent;
|
||||
_waypoints = waypoints;
|
||||
_team = team;
|
||||
_enemy = enemy;
|
||||
_towerManager = towerManager;
|
||||
_lastAttack = -1;
|
||||
_lastTowerAttack = -1;
|
||||
_pathData = new PathfinderData(ent, waypoints.getFirst());
|
||||
_health = ent.getHealth();
|
||||
}
|
||||
|
||||
private int getWaypointIndex(Location loc)
|
||||
{
|
||||
int best = -1;
|
||||
double bestDist = 0;
|
||||
|
||||
for (int i=0 ; i<_waypoints.size() ; i++)
|
||||
{
|
||||
Location waypoint = _waypoints.get(i);
|
||||
|
||||
double dist = UtilMath.offset(waypoint, loc);
|
||||
|
||||
if (best == -1 || dist < bestDist)
|
||||
{
|
||||
best = i;
|
||||
bestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
private void advance()
|
||||
{
|
||||
_pathData.Target = _waypoints.get(Math.min(_waypoints.size()-1, (getWaypointIndex(_pathData.Location) + 1)));
|
||||
_pathData.move();
|
||||
}
|
||||
|
||||
private void retarget()
|
||||
{
|
||||
_ent.setTarget(null);
|
||||
|
||||
LivingEntity target = null;
|
||||
HashMap<LivingEntity, Double> inside = UtilEnt.getInRadius(_ent.getLocation(), 30);
|
||||
for (LivingEntity ent : inside.keySet())
|
||||
{
|
||||
if (UtilPlayer.isSpectator(ent))
|
||||
continue;
|
||||
|
||||
if (ent instanceof Player)
|
||||
{
|
||||
if (_team.HasPlayer((Player)ent))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
if (target == null)
|
||||
target = ent;
|
||||
|
||||
if (inside.get(target) > inside.get(ent))
|
||||
target = ent;
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
if (UtilTime.elapsed(_lastAttack, UtilTime.convert(2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_lastAttack = System.currentTimeMillis();
|
||||
shootAt(target.getLocation(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void shootAt(Location loc, boolean charged)
|
||||
{
|
||||
Location old = _ent.getLocation();
|
||||
Location temp = _ent.getLocation();
|
||||
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc)));
|
||||
temp.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc)));
|
||||
_ent.teleport(temp);
|
||||
_ent.setMetadata("Shooting", new FixedMetadataValue(_host.Manager.getPlugin(), "1"));
|
||||
WitherSkull skull = _ent.launchProjectile(WitherSkull.class);
|
||||
skull.setCharged(charged);
|
||||
_ent.removeMetadata("Shooting", _host.Manager.getPlugin());
|
||||
_ent.teleport(old);
|
||||
//skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize());
|
||||
}
|
||||
|
||||
private TeamTowerBase getProperTarget()
|
||||
{
|
||||
for (TeamTowerBase t : _towerManager.getTeamTowers(_enemy))
|
||||
{
|
||||
if (t.Alive)
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public GameTeam getTeam()
|
||||
{
|
||||
return _team;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the entity is dead or invalid
|
||||
*/
|
||||
public boolean update()
|
||||
{
|
||||
if ((_ent == null) || _ent.isDead() || !_ent.isValid())
|
||||
return true;
|
||||
|
||||
Entity eTower = getProperTarget().getEntity();
|
||||
if (eTower == null || !eTower.isValid() || eTower.isDead())
|
||||
{
|
||||
_ent.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_ent.getHealth() < _ent.getMaxHealth())
|
||||
{
|
||||
if (!_startedJourney)
|
||||
{
|
||||
_health = _ent.getMaxHealth();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_startedJourney = true;
|
||||
|
||||
_health = Math.min(_health, _ent.getHealth());
|
||||
_ent.setHealth(_health);
|
||||
|
||||
for (Entity e : UtilEnt.getAllInRadius(_ent.getLocation(), 3).keySet())
|
||||
{
|
||||
if (e instanceof Arrow)
|
||||
{
|
||||
Arrow arrow = (Arrow)e;
|
||||
if (arrow.getShooter() instanceof Player)
|
||||
{
|
||||
if (!_team.HasPlayer((Player)arrow.getShooter()))
|
||||
{
|
||||
arrow.remove();
|
||||
_ent.damage(5, (Player)arrow.getShooter());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_ent.getLocation().distance(eTower.getLocation()) <= 10)
|
||||
{
|
||||
_ent.setTarget(null);
|
||||
String tName = "";
|
||||
if (_team.GetColor() == ChatColor.RED)
|
||||
tName = "RED";
|
||||
if (_team.GetColor() == ChatColor.AQUA)
|
||||
tName = "BLUE";
|
||||
Integer cNumber = -1;
|
||||
if (getProperTarget() instanceof TeamTower)
|
||||
cNumber = ((TeamTower)getProperTarget()).Number;
|
||||
else
|
||||
cNumber = 3;
|
||||
Location finalize = _host.Host.WorldData.GetCustomLocs(DataLoc.TOWER_WAYPOINT.getKey().replace("$team$", tName).replace("$number$", cNumber + "")).get(0);
|
||||
finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, eTower)));
|
||||
finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, eTower)));
|
||||
_ent.teleport(finalize);
|
||||
if (UtilTime.elapsed(_lastTowerAttack, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_lastTowerAttack = System.currentTimeMillis();
|
||||
shootAt(eTower.getLocation(), true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
advance();
|
||||
retarget();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData;
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
|
||||
public class WitherSkeletonTimer extends ExtraScoreboardData
|
||||
{
|
||||
private long _end;
|
||||
private int _frozen;
|
||||
|
||||
public WitherSkeletonTimer(GameScoreboard sb)
|
||||
{
|
||||
super(sb);
|
||||
_end = 0;
|
||||
_frozen = -1;
|
||||
}
|
||||
|
||||
public void setEnd(long end)
|
||||
{
|
||||
_end = end;
|
||||
}
|
||||
|
||||
public void freezeTime(int seconds)
|
||||
{
|
||||
_frozen = seconds;
|
||||
}
|
||||
|
||||
public void write()
|
||||
{
|
||||
Scoreboard.Write(C.cYellowB + "Wither Skeleton Spawn");
|
||||
if (_frozen != -1)
|
||||
{
|
||||
if (_frozen == -2)
|
||||
Scoreboard.Write("WITHER ALIVE");
|
||||
else
|
||||
Scoreboard.Write(_frozen + " Seconds");
|
||||
}
|
||||
else
|
||||
{
|
||||
long seconds = 0;
|
||||
if (_end - System.currentTimeMillis() > 0)
|
||||
seconds = UtilTime.convert(_end - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
|
||||
|
||||
Scoreboard.Write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective;
|
||||
|
||||
public class GrabSkullObjective extends GameObjective
|
||||
{
|
||||
public GrabSkullObjective()
|
||||
{
|
||||
super("GRAB_SKULL", "Collect Wither Skull");
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective;
|
||||
|
||||
public class ReturnSkullObjective extends GameObjective
|
||||
{
|
||||
public ReturnSkullObjective()
|
||||
{
|
||||
super("RETURN_SKULL", "Return the Skull to your Altar!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective;
|
||||
|
||||
public class WitherObjective extends GameObjective
|
||||
{
|
||||
public WitherObjective(String instruction)
|
||||
{
|
||||
super("WITHER_OBJ", instruction);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
@ -14,8 +14,10 @@ import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.teleport.event.MineplexTeleportEvent;
|
||||
@ -33,6 +35,8 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -46,6 +50,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
@ -54,6 +59,7 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -73,6 +79,9 @@ import org.bukkit.util.Vector;
|
||||
public class GameFlagManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
SecondaryDamageManager Secondary;
|
||||
private ConcurrentHashMap<Player, Long> _respawnTimers = new ConcurrentHashMap<Player, Long>();
|
||||
private ConcurrentHashMap<Player, Integer> _respawnRunnables = new ConcurrentHashMap<Player, Integer>();
|
||||
|
||||
public GameFlagManager(ArcadeManager manager)
|
||||
{
|
||||
@ -81,6 +90,33 @@ public class GameFlagManager implements Listener
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void triggerSecondary(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
if (Secondary == null)
|
||||
{
|
||||
if (!Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
Secondary = new SecondaryDamageManager(Manager);
|
||||
Bukkit.getPluginManager().registerEvents(Secondary, Manager.getPlugin());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
if (Secondary != null)
|
||||
{
|
||||
HandlerList.unregisterAll(Secondary);
|
||||
Secondary = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void DamageEvent(CustomDamageEvent event)
|
||||
{
|
||||
@ -738,6 +774,8 @@ public class GameFlagManager implements Listener
|
||||
if (game.GetTeam(player).GetRespawnTime() > time)
|
||||
time = game.GetTeam(player).GetRespawnTime();
|
||||
|
||||
final double timeF = time;
|
||||
|
||||
UtilInv.Clear(player);
|
||||
Manager.GetCondition().Factory().Cloak("Ghost", player, player, time, false, false);
|
||||
player.setAllowFlight(true);
|
||||
@ -762,8 +800,15 @@ public class GameFlagManager implements Listener
|
||||
UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds...");
|
||||
UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player);
|
||||
}
|
||||
|
||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Long t = Double.valueOf(timeF).longValue();
|
||||
_respawnTimers.put(player, System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
}, 6);
|
||||
int run = Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -779,8 +824,11 @@ public class GameFlagManager implements Listener
|
||||
|
||||
player.setFireTicks(0);
|
||||
UtilAction.zeroVelocity(player);
|
||||
|
||||
_respawnRunnables.remove(player);
|
||||
}
|
||||
}, (int)(time * 20d));
|
||||
_respawnRunnables.put(player, run);
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,11 +962,21 @@ public class GameFlagManager implements Listener
|
||||
DamageCause.VOID, 4, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
|
||||
if (!Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 4));
|
||||
}
|
||||
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 9001));
|
||||
}
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.VOID, 9001, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
@ -1210,4 +1268,52 @@ public class GameFlagManager implements Listener
|
||||
|
||||
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void displayRespawnTimer(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
if (Manager.GetGame() == null)
|
||||
{
|
||||
_respawnTimers.clear();
|
||||
for (Integer r : _respawnRunnables.values())
|
||||
{
|
||||
Bukkit.getScheduler().cancelTask(r);
|
||||
}
|
||||
_respawnRunnables.clear();
|
||||
return;
|
||||
}
|
||||
if (!Manager.GetGame().IsLive())
|
||||
{
|
||||
_respawnTimers.clear();
|
||||
for (Integer r : _respawnRunnables.values())
|
||||
{
|
||||
Bukkit.getScheduler().cancelTask(r);
|
||||
}
|
||||
_respawnRunnables.clear();
|
||||
return;
|
||||
}
|
||||
for (Player player : _respawnTimers.keySet())
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
_respawnTimers.remove(player);
|
||||
continue;
|
||||
}
|
||||
if (System.currentTimeMillis() >= _respawnTimers.get(player))
|
||||
{
|
||||
_respawnTimers.remove(player);
|
||||
continue;
|
||||
}
|
||||
long sec = UtilTime.convert(_respawnTimers.get(player) - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
|
||||
ChatColor color = ChatColor.RED;
|
||||
if (sec < 8)
|
||||
color = ChatColor.YELLOW;
|
||||
if (sec < 4)
|
||||
color = ChatColor.GREEN;
|
||||
UtilTextBottom.display(color + "Respawning In: " + sec + " Seconds", player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public class GameHostManager implements Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void whitelistJoin(PlayerLoginEvent event)
|
||||
public void handleLogin(PlayerLoginEvent event)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
if (Manager.GetServerConfig().PlayerServerWhitelist){
|
||||
@ -220,6 +220,8 @@ public class GameHostManager implements Listener
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted.");
|
||||
}
|
||||
}
|
||||
if (_blacklist.contains(p.getName()))
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You were removed from this Mineplex Private Server.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -792,12 +794,6 @@ public class GameHostManager implements Listener
|
||||
if (!isPrivateServer())
|
||||
return;
|
||||
|
||||
if (_blacklist.contains(event.getPlayer().getName()))
|
||||
{
|
||||
Manager.GetPortal().sendToHub(event.getPlayer(), "You were kicked from this Mineplex Private Server.");
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = Manager.getPlugin().getConfig().getString("serverstatus.name");
|
||||
UtilPlayer.message(event.getPlayer(), ChatColor.BOLD + "Welcome to Mineplex Private Servers!");
|
||||
UtilPlayer.message(event.getPlayer(), C.Bold + "Friends can connect with " + C.cGreen + C.Bold + "/server " + serverName);
|
||||
|
@ -0,0 +1,187 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
public class SecondaryDamageManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
public SecondaryDamageManager(ArcadeManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void EntDamage(EntityDamageEvent event)
|
||||
{
|
||||
Game game = Manager.GetGame();
|
||||
if (game == null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
LivingEntity ent = (LivingEntity) event.getEntity();
|
||||
if (ent.getWorld().getName().equals("world"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getCause() == DamageCause.VOID)
|
||||
ent.teleport(Manager.GetLobby().GetSpawn());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.isSpectator(ent))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if (ent.getFireTicks() > 0)
|
||||
{
|
||||
ent.setFireTicks(-1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (game.GetState() != GameState.Live)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!game.Damage)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent instanceof Player)
|
||||
{
|
||||
if (!game.IsAlive((Player)ent))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getCause() == DamageCause.FALL)
|
||||
{
|
||||
if (!game.DamageFall)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void DamageEvent(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Game game = Manager.GetGame();
|
||||
if (game == null)
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
LivingEntity damagee = (LivingEntity)event.getEntity();
|
||||
|
||||
if (event.getDamager() instanceof LivingEntity || event.getDamager() instanceof Projectile)
|
||||
{
|
||||
LivingEntity damager = null;
|
||||
if (event.getDamager() instanceof LivingEntity)
|
||||
{
|
||||
damager = (LivingEntity)event.getDamager();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Projectile)event.getDamager()).getShooter() instanceof LivingEntity)
|
||||
{
|
||||
damager = (LivingEntity)((Projectile)event.getDamager()).getShooter();
|
||||
}
|
||||
}
|
||||
//Damager Spec
|
||||
if (damager != null && Manager.isSpectator(damager))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (damager != null && damager instanceof Player && !game.IsAlive((Player)damager))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
//Entity vs Entity
|
||||
if (damagee != null && damager != null)
|
||||
{
|
||||
//PvP
|
||||
if (damagee instanceof Player && damager instanceof Player)
|
||||
{
|
||||
if (!Manager.canHurt((Player)damagee, (Player)damager))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//PvE
|
||||
else if (damager instanceof Player)
|
||||
{
|
||||
if (!game.DamagePvE)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//EvP
|
||||
else if (damagee instanceof Player)
|
||||
{
|
||||
if (!game.DamageEvP)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void DamageExplosion(ConditionApplyEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.GetCondition().GetType() != ConditionType.EXPLOSION)
|
||||
return;
|
||||
|
||||
LivingEntity damagee = event.GetCondition().GetEnt();
|
||||
if (damagee == null) return;
|
||||
if (!(damagee instanceof Player)) return;
|
||||
|
||||
LivingEntity damager = event.GetCondition().GetSource();
|
||||
if (damager == null) return;
|
||||
if (!(damager instanceof Player)) return;
|
||||
|
||||
if (Manager.canHurt((Player)damagee, (Player)damager))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -34,6 +34,8 @@ public class GameChatManager implements Listener
|
||||
|
||||
private LinkedList<ChatStatData> _chatStats;
|
||||
|
||||
public boolean TeamSpy;
|
||||
|
||||
public GameChatManager(ArcadeManager manager)
|
||||
{
|
||||
_manager = manager;
|
||||
@ -41,6 +43,8 @@ public class GameChatManager implements Listener
|
||||
_manager.getPluginManager().registerEvents(this, _manager.getPlugin());
|
||||
|
||||
_chatStats = new LinkedList<ChatStatData>();
|
||||
|
||||
TeamSpy = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -157,7 +161,10 @@ public class GameChatManager implements Listener
|
||||
format = event.getFormat().split(rankStr)[0];
|
||||
|
||||
name = _manager.GetColor(sender) + sender.getName() + C.Reset;
|
||||
message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage());
|
||||
if (event.getMessage().charAt(0) == '@')
|
||||
message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length()));
|
||||
else
|
||||
message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage());
|
||||
|
||||
if (_manager.GetGame() == null || _manager.GetGame().GetState() != GameState.Live)
|
||||
{
|
||||
@ -230,7 +237,10 @@ public class GameChatManager implements Listener
|
||||
Player receiver = recipientIterator.next();
|
||||
|
||||
if (!_manager.GetServerConfig().Tournament && _manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR))
|
||||
continue;
|
||||
{
|
||||
if (TeamSpy)
|
||||
continue;
|
||||
}
|
||||
|
||||
GameTeam recTeam = _manager.GetGame().GetTeam(receiver);
|
||||
GameTeam sendTeam = _manager.GetGame().GetTeam(sender);
|
||||
|
Loading…
Reference in New Issue
Block a user