- Huge amount of stuff
This commit is contained in:
parent
2b365e4afd
commit
b84ec01597
@ -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;
|
||||
@ -89,11 +90,48 @@ 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 (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
|
||||
|
@ -674,6 +674,11 @@ public class DamageManager extends MiniPlugin
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean IsEnabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public void SetEnabled(boolean var)
|
||||
{
|
||||
|
@ -146,6 +146,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
private BlockRestore _blockRestore;
|
||||
private Blood _blood;
|
||||
private Chat _chat;
|
||||
private GameChatManager _gamechat;
|
||||
private CoreClientManager _clientManager;
|
||||
private DisguiseManager _disguiseManager;
|
||||
private DonationManager _donationManager;
|
||||
@ -285,7 +286,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
|
||||
|
||||
// Managers
|
||||
new GameChatManager(this);
|
||||
_gamechat = new GameChatManager(this);
|
||||
_gameCreationManager = new GameCreationManager(this);
|
||||
_gameGemManager = new GameGemManager(this);
|
||||
_gameManager = new GameManager(this);
|
||||
@ -385,6 +386,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
return _chat;
|
||||
}
|
||||
|
||||
public GameChatManager GetGameChat()
|
||||
{
|
||||
return _gamechat;
|
||||
}
|
||||
|
||||
public BlockRestore GetBlockRestore()
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.minecraftleague;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -12,24 +13,31 @@ 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.map.TeamMap;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.Spawner;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -42,23 +50,26 @@ 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.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapView.Scale;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
@ -67,12 +78,19 @@ public class MinecraftLeague extends TeamGame
|
||||
{
|
||||
private ConcurrentHashMap<GameTeam, TeamCrystal> _crystals = new ConcurrentHashMap<GameTeam, TeamCrystal>();
|
||||
private ConcurrentHashMap<Player, PlayerRespawnPoint> _customRespawns = new ConcurrentHashMap<Player, PlayerRespawnPoint>();
|
||||
private ConcurrentHashMap<GameTeam, TeamMap> _maps = new ConcurrentHashMap<GameTeam, TeamMap>();
|
||||
//private ConcurrentHashMap<GameTeam, TeamMap> _maps = new ConcurrentHashMap<GameTeam, TeamMap>();
|
||||
private ConcurrentHashMap<Player, List<ItemStack>> _gear = new ConcurrentHashMap<Player, List<ItemStack>>();
|
||||
private ConcurrentHashMap<GameTeam, TeamBeacon> _beacons = new ConcurrentHashMap<GameTeam, TeamBeacon>();
|
||||
private List<Spawner> _spawners = new ArrayList<Spawner>();
|
||||
|
||||
private long _liveTime = 0;
|
||||
private boolean _overTime = false;
|
||||
private MinecraftLeagueCommand _cmd;
|
||||
private long _lastIncrease;
|
||||
private boolean _yellow = false;
|
||||
|
||||
public List<OreDeposit> Ore = new ArrayList<OreDeposit>();
|
||||
public ItemMapManager MapManager;
|
||||
public boolean OverTime = false;
|
||||
|
||||
public MinecraftLeague(ArcadeManager manager)
|
||||
{
|
||||
@ -94,7 +112,7 @@ public class MinecraftLeague extends TeamGame
|
||||
|
||||
this.DeathOut = false;
|
||||
this.DamageSelf = false;
|
||||
this.DeathSpectateSecs = 0;
|
||||
this.DeathSpectateSecs = 5;
|
||||
this.WorldBoundaryKill = false;
|
||||
this.DeathDropItems = true;
|
||||
this.CreatureAllow = true;
|
||||
@ -119,12 +137,14 @@ public class MinecraftLeague extends TeamGame
|
||||
this.StrictAntiHack = true;
|
||||
this.AllowParticles = false;
|
||||
this.SoupEnabled = false;
|
||||
this.GameTimeout = -1;
|
||||
|
||||
_help = new String[]
|
||||
{
|
||||
"Respawn Crystals have 500 health!",
|
||||
"Respawn Crystals have 50 health per person in-game!",
|
||||
"The better the sword you have, the more damage you deal to Respawn Crystals!",
|
||||
"Right-click a bed in order to change your personal spawn location."
|
||||
"Right-click a bed in order to change your personal spawn location!",
|
||||
"Your map will display the locations of your enemies in OverTime!"
|
||||
};
|
||||
|
||||
|
||||
@ -207,57 +227,124 @@ public class MinecraftLeague extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
public TeamMap getMap(GameTeam team)
|
||||
private ItemStack getNewItemStack(ItemStack item)
|
||||
{
|
||||
ItemStack ret = item.clone();
|
||||
String type = ret.getType().toString();
|
||||
boolean damage = false;
|
||||
boolean itemD = false;
|
||||
if (type.contains("HELMET") || type.contains("CHESTPLATE") || type.contains("LEGGINGS") || type.contains("BOOTS"))
|
||||
damage = true;
|
||||
if (DamageType.getDamageType(ret.getType()) != DamageType.NONE)
|
||||
itemD = true;
|
||||
|
||||
if (damage)
|
||||
{
|
||||
ret.setDurability((short) (ret.getDurability() + (ret.getDurability() * .25)));
|
||||
}
|
||||
if (itemD)
|
||||
{
|
||||
ret.setDurability((short) (ret.getDurability() + 25));
|
||||
}
|
||||
|
||||
if (ret.getDurability() > ret.getType().getMaxDurability())
|
||||
ret = new ItemStack(Material.AIR);
|
||||
|
||||
if (ret.getType() == Material.MAP)
|
||||
ret = new ItemStack(Material.AIR);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*public TeamMap getMap(GameTeam team)
|
||||
{
|
||||
return _maps.get(team);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
Location redLoc = WorldData.GetDataLocs("RED").get(0);
|
||||
Location blueLoc = WorldData.GetDataLocs("BLUE").get(0);
|
||||
Location center = WorldData.GetDataLocs("ORANGE").get(0);
|
||||
//Location center = WorldData.GetDataLocs("ORANGE").get(0);
|
||||
|
||||
_crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc));
|
||||
_crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc));
|
||||
|
||||
_maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList<Player>(), center, Scale.CLOSE));
|
||||
_maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList<Player>(), center, Scale.CLOSE));
|
||||
_beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs("PINK").get(0).getBlock(), redLoc));
|
||||
_beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs("CYAN").get(0).getBlock(), redLoc));
|
||||
|
||||
_spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER));
|
||||
//_maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList<Player>(), center, Scale.CLOSE));
|
||||
//_maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList<Player>(), center, Scale.CLOSE));
|
||||
|
||||
//_spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER));
|
||||
_spawners.add(new Spawner(this, WorldData.GetDataLocs("BLACK").get(0), EntityType.SKELETON));
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs("LIGHT_BLUE"))
|
||||
{
|
||||
Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255}));
|
||||
}
|
||||
for (Location loc : WorldData.GetDataLocs("SILVER"))
|
||||
{
|
||||
Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190}));
|
||||
}
|
||||
|
||||
MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void ScoreboardUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
scoreboardWrite();
|
||||
if (event.getType() == UpdateType.FAST || event.getType() == UpdateType.SEC)
|
||||
scoreboardWrite(event.getType() == UpdateType.SEC);
|
||||
}
|
||||
|
||||
private void scoreboardWrite()
|
||||
private void scoreboardWrite(boolean sec)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
{
|
||||
if (!sec)
|
||||
return;
|
||||
Scoreboard.Reset();
|
||||
Scoreboard.WriteBlank();
|
||||
Scoreboard.Write(C.cDRedB + "Minecraft League");
|
||||
Scoreboard.WriteBlank();
|
||||
|
||||
if (_yellow)
|
||||
{
|
||||
Scoreboard.Write(C.cYellow + "Loading...");
|
||||
_yellow = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scoreboard.Write("Loading...");
|
||||
_yellow = true;
|
||||
}
|
||||
|
||||
Scoreboard.Draw();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sec)
|
||||
return;
|
||||
|
||||
GameTeam red = GetTeam(ChatColor.RED);
|
||||
GameTeam blue = GetTeam(ChatColor.AQUA);
|
||||
TeamCrystal redc = _crystals.get(red);
|
||||
TeamCrystal bluec = _crystals.get(blue);
|
||||
|
||||
if (IsLive())
|
||||
_liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0);
|
||||
_liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0);
|
||||
|
||||
Scoreboard.Reset();
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
Scoreboard.Write(C.cYellowB + "Time Elapsed");
|
||||
Scoreboard.Write(UtilTime.MakeStr(_liveTime));
|
||||
if (_overTime)
|
||||
if (OverTime)
|
||||
Scoreboard.Write(C.cDRedB + "Overtime");
|
||||
|
||||
Scoreboard.WriteBlank();
|
||||
@ -339,6 +426,43 @@ public class MinecraftLeague extends TeamGame
|
||||
return true;
|
||||
}
|
||||
|
||||
public void restoreGear(Player player)
|
||||
{
|
||||
if (!_gear.containsKey(player))
|
||||
return;
|
||||
List<ItemStack> items = _gear.get(player);
|
||||
if (items.get(0) == null)
|
||||
UtilInv.insert(player, new ItemStack(Material.AIR));
|
||||
else
|
||||
UtilInv.insert(player, getNewItemStack(items.get(0)));
|
||||
|
||||
for (int i = 1; i < items.size(); i++)
|
||||
{
|
||||
ItemStack item;
|
||||
if (items.get(i) != null)
|
||||
item = items.get(i);
|
||||
else
|
||||
item = new ItemStack(Material.AIR);
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 1:
|
||||
player.getInventory().setHelmet(getNewItemStack(item));
|
||||
break;
|
||||
case 2:
|
||||
player.getInventory().setChestplate(getNewItemStack(item));
|
||||
break;
|
||||
case 3:
|
||||
player.getInventory().setLeggings(getNewItemStack(item));
|
||||
break;
|
||||
case 4:
|
||||
player.getInventory().setBoots(getNewItemStack(item));
|
||||
break;
|
||||
}
|
||||
}
|
||||
_gear.remove(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEditSettings(GameStateChangeEvent event)
|
||||
{
|
||||
@ -347,12 +471,14 @@ public class MinecraftLeague extends TeamGame
|
||||
|
||||
if (event.GetState() == GameState.Live)
|
||||
{
|
||||
_lastIncrease = System.currentTimeMillis();
|
||||
Manager.GetExplosion().setEnabled(false);
|
||||
Manager.GetDamage().SetEnabled(false);
|
||||
Manager.GetCreature().SetForce(true);
|
||||
Manager.GetCreature().SetDisableCustomDrops(true);
|
||||
_cmd = new MinecraftLeagueCommand(Manager, this);
|
||||
Manager.addCommand(_cmd);
|
||||
Manager.GetGameChat().TeamSpy = false;
|
||||
}
|
||||
|
||||
if (event.GetState() == GameState.End)
|
||||
@ -362,6 +488,8 @@ public class MinecraftLeague extends TeamGame
|
||||
Manager.GetCreature().SetForce(false);
|
||||
Manager.GetCreature().SetDisableCustomDrops(false);
|
||||
Manager.removeCommand(_cmd);
|
||||
Manager.GetGameChat().TeamSpy = true;
|
||||
HandlerList.unregisterAll(MapManager);
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,6 +499,14 @@ public class MinecraftLeague extends TeamGame
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
for (OreDeposit od : Ore)
|
||||
{
|
||||
od.update();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.FASTEST)
|
||||
{
|
||||
for (TeamCrystal crystal : _crystals.values())
|
||||
@ -378,24 +514,44 @@ public class MinecraftLeague extends TeamGame
|
||||
crystal.update();
|
||||
}
|
||||
|
||||
for (TeamMap map : _maps.values())
|
||||
/*for (TeamMap map : _maps.values())
|
||||
{
|
||||
map.update(null);
|
||||
}
|
||||
}*/
|
||||
|
||||
for (Spawner spawner : _spawners)
|
||||
{
|
||||
spawner.update();
|
||||
}
|
||||
|
||||
if (!_overTime)
|
||||
for (TeamBeacon beacon : _beacons.values())
|
||||
{
|
||||
beacon.update();
|
||||
}
|
||||
|
||||
if (!OverTime)
|
||||
{
|
||||
if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_overTime = true;
|
||||
OverTime = true;
|
||||
UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!");
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilTime.elapsed(_lastIncrease, UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
_lastIncrease = System.currentTimeMillis();
|
||||
this.DeathSpectateSecs = Math.max(0, this.DeathSpectateSecs + 2.5);
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
player.setFireTicks(-1);
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,7 +605,7 @@ public class MinecraftLeague extends TeamGame
|
||||
if (!crystal.canDamage(player))
|
||||
return;
|
||||
|
||||
if (!crystal.damage(event.getDamage(), player))
|
||||
if (!crystal.damage(event.getDamage(), player, true))
|
||||
player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0);
|
||||
}
|
||||
}
|
||||
@ -463,7 +619,7 @@ public class MinecraftLeague extends TeamGame
|
||||
|
||||
if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR)
|
||||
{
|
||||
if (!crystal.damage(1, player))
|
||||
if (!crystal.damage(1, player, true))
|
||||
player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
||||
return;
|
||||
}
|
||||
@ -472,12 +628,17 @@ public class MinecraftLeague extends TeamGame
|
||||
int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
|
||||
double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type));
|
||||
|
||||
if (!crystal.damage(damage, player))
|
||||
if (!crystal.damage(damage, player, true))
|
||||
player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
||||
|
||||
if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE)
|
||||
{
|
||||
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1));
|
||||
if (player.getItemInHand().getDurability() > player.getItemInHand().getType().getMaxDurability())
|
||||
{
|
||||
player.getInventory().remove(player.getItemInHand());
|
||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0);
|
||||
}
|
||||
UtilInv.Update(player);
|
||||
}
|
||||
}
|
||||
@ -525,7 +686,7 @@ public class MinecraftLeague extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
/*@EventHandler
|
||||
public void onRespawn(PlayerGameRespawnEvent event)
|
||||
{
|
||||
if (event.GetGame() != this)
|
||||
@ -548,12 +709,20 @@ public class MinecraftLeague extends TeamGame
|
||||
UtilAction.velocity(player, new Vector(0,1.2,0));
|
||||
|
||||
getMap(GetTeam(player)).update(player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(new ItemStack[]
|
||||
{
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR)
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (_overTime)
|
||||
_crystals.get(GetTeam(player)).damage(20, null);
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent event)
|
||||
@ -633,6 +802,10 @@ public class MinecraftLeague extends TeamGame
|
||||
if (item.getType() == Material.MAP)
|
||||
continue;
|
||||
|
||||
if (_gear.get(event.getEntity()) != null)
|
||||
if (_gear.get(event.getEntity()).contains(item))
|
||||
continue;
|
||||
|
||||
newDrops.add(item);
|
||||
}
|
||||
|
||||
@ -681,6 +854,18 @@ public class MinecraftLeague extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void controlMobRate(CreatureSpawnEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getSpawnReason() != SpawnReason.NATURAL)
|
||||
return;
|
||||
|
||||
Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void controlPvP(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
@ -727,7 +912,7 @@ public class MinecraftLeague extends TeamGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void protectSpectators(EntityDamageEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
@ -742,27 +927,200 @@ public class MinecraftLeague extends TeamGame
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void equip(GameStateChangeEvent event)
|
||||
public void editHealth(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Prepare)
|
||||
return;
|
||||
|
||||
if (event.GetGame() != this)
|
||||
return;
|
||||
|
||||
for (TeamCrystal c : _crystals.values())
|
||||
{
|
||||
double playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size();
|
||||
c.setMaxHealth(50 * 2 * playercount);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void dropBow(EntityDeathEvent event)
|
||||
{
|
||||
if (event.getEntityType() != EntityType.SKELETON)
|
||||
return;
|
||||
|
||||
boolean addbow = true;
|
||||
for (ItemStack check : event.getDrops())
|
||||
{
|
||||
if (check.getType() == Material.BOW)
|
||||
addbow = false;
|
||||
}
|
||||
|
||||
if (addbow)
|
||||
{
|
||||
if (new Random().nextDouble() > .5)
|
||||
event.getDrops().add(new ItemStack(Material.BOW));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveGear(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetGame() != this)
|
||||
return;
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
for (Player red : GetTeam(ChatColor.RED).GetPlayers(true))
|
||||
for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true))
|
||||
{
|
||||
red.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||
red.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||
red.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||
red.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
|
||||
red.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
|
||||
player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.BLUE).build());
|
||||
player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLUE).build());
|
||||
player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).build());
|
||||
player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).build());
|
||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
|
||||
player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5));
|
||||
}
|
||||
|
||||
for (Player blue : GetTeam(ChatColor.AQUA).GetPlayers(true))
|
||||
for (Player player : GetTeam(ChatColor.RED).GetPlayers(true))
|
||||
{
|
||||
blue.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||
blue.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
|
||||
blue.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
|
||||
blue.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS));
|
||||
blue.getInventory().addItem(new ItemStack(Material.IRON_SWORD));
|
||||
player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.RED).build());
|
||||
player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.RED).build());
|
||||
player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).build());
|
||||
player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).build());
|
||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
|
||||
player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void storeGear(EntityDamageEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player)event.getEntity();
|
||||
List<ItemStack> gear = new ArrayList<ItemStack>();
|
||||
|
||||
gear.add(player.getItemInHand());
|
||||
gear.add(player.getInventory().getHelmet());
|
||||
gear.add(player.getInventory().getChestplate());
|
||||
gear.add(player.getInventory().getLeggings());
|
||||
gear.add(player.getInventory().getBoots());
|
||||
|
||||
_gear.put(player, gear);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockDeadPvt(PrivateMessageEvent event)
|
||||
{
|
||||
boolean onedead = false;
|
||||
boolean onelive = false;
|
||||
|
||||
if (event.getSender() != null)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getSender()))
|
||||
onedead = true;
|
||||
else
|
||||
onelive = true;
|
||||
}
|
||||
if (event.getRecipient() != null)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getRecipient()))
|
||||
onedead = true;
|
||||
else
|
||||
onelive = true;
|
||||
}
|
||||
|
||||
if (onedead)
|
||||
{
|
||||
if (onelive)
|
||||
{
|
||||
if (event.getSender() != null)
|
||||
{
|
||||
UtilPlayer.message(event.getSender(), F.main("Game", "You cannot message a player if you are not both alive/dead!"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void blockDeadTalk(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if (GetTeam(event.getPlayer()) == null)
|
||||
{
|
||||
for (Player player : GetTeam(ChatColor.RED).GetPlayers(true))
|
||||
{
|
||||
event.getRecipients().remove(player);
|
||||
}
|
||||
for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true))
|
||||
{
|
||||
event.getRecipients().remove(player);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (!GetTeam(event.getPlayer()).IsAlive(event.getPlayer()))
|
||||
{
|
||||
for (Player player : GetTeam(ChatColor.RED).GetPlayers(true))
|
||||
{
|
||||
event.getRecipients().remove(player);
|
||||
}
|
||||
for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true))
|
||||
{
|
||||
event.getRecipients().remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleDeath(CombatDeathEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
event.SetBroadcastType(DeathMessageType.Detailed);
|
||||
|
||||
if (event.GetLog().GetPlayer() == null)
|
||||
return;
|
||||
if (Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()) == null)
|
||||
return;
|
||||
Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName());
|
||||
|
||||
if (!_crystals.get(GetTeam(player)).Alive)
|
||||
{
|
||||
SetPlayerState(player, PlayerState.OUT);
|
||||
|
||||
Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false);
|
||||
Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false);
|
||||
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
((CraftPlayer)player).getHandle().spectating = true;
|
||||
((CraftPlayer)player).getHandle().k = false;
|
||||
|
||||
UtilAction.velocity(player, new Vector(0,1.2,0));
|
||||
|
||||
//getMap(GetTeam(player)).update(player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(new ItemStack[]
|
||||
{
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR),
|
||||
new ItemStack(Material.AIR)
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (OverTime)
|
||||
_crystals.get(GetTeam(player)).damage(20, null, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class OreDeposit
|
||||
{
|
||||
private Location _loc;
|
||||
private Material _ore;
|
||||
private int[] _rgb;
|
||||
private boolean _valid;
|
||||
|
||||
public OreDeposit(Location loc, Material type, int[] rgb)
|
||||
{
|
||||
_loc = loc;
|
||||
_ore = type;
|
||||
_rgb = rgb;
|
||||
}
|
||||
|
||||
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 <= 10)
|
||||
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 update()
|
||||
{
|
||||
int found = 0;
|
||||
for (Block block : UtilBlock.getInSquare(_loc.getBlock(), 10))
|
||||
{
|
||||
if (block.getType() == _ore)
|
||||
found++;
|
||||
}
|
||||
|
||||
_valid = found >= 1;
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ public class Spawner
|
||||
|
||||
if (_canSpawn)
|
||||
{
|
||||
if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(20, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
_canSpawn = false;
|
||||
else
|
||||
_canSpawn = true;
|
||||
|
@ -0,0 +1,75 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class TeamBeacon
|
||||
{
|
||||
private GameTeam _team;
|
||||
private Block _block;
|
||||
private List<Block> _valuables;
|
||||
private Location _core;
|
||||
|
||||
public TeamBeacon(GameTeam team, Block block, Location core)
|
||||
{
|
||||
_team = team;
|
||||
_block = block;
|
||||
_core = core;
|
||||
_valuables = UtilBlock.getInSquare(_block.getRelative(BlockFace.DOWN), 1);
|
||||
|
||||
_block.setType(Material.BEACON);
|
||||
for (Block v : _valuables)
|
||||
{
|
||||
v.setType(Material.IRON_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void hideValuables()
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
for (Block v : _valuables)
|
||||
{
|
||||
player.sendBlockChange(v.getLocation(), Material.DIRT, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 void update()
|
||||
{
|
||||
hideValuables();
|
||||
|
||||
for (Player player : _team.GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().distance(_core) < 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ 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.UtilTextBottom;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
@ -31,17 +32,20 @@ public class TeamCrystal
|
||||
private MinecraftLeague _host;
|
||||
private Location _spawn;
|
||||
private GameTeam _team;
|
||||
private Double _health;
|
||||
private Double _health, _maxHealth;
|
||||
private EnderCrystal _entity;
|
||||
private Hologram _name, _healthTag;
|
||||
public boolean Alive;
|
||||
|
||||
private long _lastAlert = -1;
|
||||
|
||||
public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn)
|
||||
{
|
||||
_host = host;
|
||||
_spawn = spawn.clone().add(0.5, 1.2, 0.5);
|
||||
_team = team;
|
||||
_health = 1000D;
|
||||
_maxHealth = 11111D;
|
||||
_health = 11111D;
|
||||
_name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal");
|
||||
_healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health));
|
||||
|
||||
@ -53,7 +57,7 @@ public class TeamCrystal
|
||||
_name.start();
|
||||
_healthTag.start();
|
||||
_entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL);
|
||||
_health = 500D;
|
||||
_health = _maxHealth;
|
||||
Alive = true;
|
||||
}
|
||||
|
||||
@ -102,6 +106,29 @@ public class TeamCrystal
|
||||
}
|
||||
}
|
||||
|
||||
private void alert()
|
||||
{
|
||||
if (UtilTime.elapsed(_lastAlert, UtilTime.convert(15, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||
{
|
||||
long s = System.currentTimeMillis();
|
||||
long e = UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS);
|
||||
|
||||
for (Player player : _team.GetPlayers(true))
|
||||
{
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0);
|
||||
while (!UtilTime.elapsed(s, e))
|
||||
{
|
||||
UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Entity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
|
||||
public boolean isEntity(Entity e)
|
||||
{
|
||||
return e.getEntityId() == _entity.getEntityId();
|
||||
@ -136,9 +163,9 @@ public class TeamCrystal
|
||||
{
|
||||
String tag = healthNumber.toString();
|
||||
|
||||
if (healthNumber > 450)
|
||||
if (healthNumber > (.9 * _maxHealth))
|
||||
tag = C.cGreen + tag;
|
||||
else if (healthNumber < 225)
|
||||
else if (healthNumber < (.45 * _maxHealth))
|
||||
tag = C.cRed + tag;
|
||||
else
|
||||
tag = C.cYellow + tag;
|
||||
@ -146,7 +173,7 @@ public class TeamCrystal
|
||||
return tag;
|
||||
}
|
||||
|
||||
public boolean damage(double damage, Player player)
|
||||
public boolean damage(double damage, Player player, boolean hit)
|
||||
{
|
||||
Double newHealth = Math.max(_health - damage, 0);
|
||||
|
||||
@ -156,8 +183,12 @@ public class TeamCrystal
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hit)
|
||||
alert();
|
||||
|
||||
_health = newHealth;
|
||||
Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false);
|
||||
if (player != null)
|
||||
Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -176,14 +207,24 @@ public class TeamCrystal
|
||||
{
|
||||
_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 handleDebug(Player dev, Double damage, boolean kill)
|
||||
{
|
||||
if (damage != null)
|
||||
{
|
||||
damage(damage, dev);
|
||||
damage(damage, dev, false);
|
||||
UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been damaged"));
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,675 @@
|
||||
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.C;
|
||||
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.portal.ServerTransferEvent;
|
||||
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 will freeze the Team Map!");
|
||||
p.sendMessage(C.cYellow + "If you want to play Minecraft League again, 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,149 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.data.map;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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 (OreDeposit od : _host.Ore)
|
||||
{
|
||||
if (od.isInRadius(blockX - 20, blockZ + 15)) // 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;
|
||||
|
||||
if (player == other)
|
||||
{
|
||||
cursorDisplay = MapCursor.Type.WHITE_POINTER;
|
||||
}
|
||||
else if (_host.GetTeam(player) == _host.GetTeam(other))
|
||||
{
|
||||
cursorDisplay = MapCursor.Type.BLUE_POINTER;
|
||||
}
|
||||
else if (_host.GetTeam(player) != _host.GetTeam(other))
|
||||
{
|
||||
if (_host.OverTime)
|
||||
cursorDisplay = MapCursor.Type.RED_POINTER;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.kit;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.map.TeamMap;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
@ -15,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class KitPlayer extends Kit
|
||||
{
|
||||
{
|
||||
public KitPlayer(ArcadeManager manager)
|
||||
{
|
||||
super(manager, "Player", KitAvailability.Free,
|
||||
@ -24,7 +22,6 @@ public class KitPlayer extends Kit
|
||||
{
|
||||
"",
|
||||
"Entirely vanilla combat!",
|
||||
"Spawns with full iron!",
|
||||
""
|
||||
},
|
||||
|
||||
@ -37,12 +34,25 @@ public class KitPlayer extends Kit
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
TeamMap tmap = ((MinecraftLeague)Manager.GetGame()).getMap(Manager.GetGame().GetTeam(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.");
|
||||
tmap.giveMap(player, true, C.cGold + "Team Map", C.cGray + "This map contains", C.cGray + "the locations of", C.cGray + "your teammates.");*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,28 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
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 abstract void deregister();
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Random;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
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;
|
||||
|
||||
public class VariationManager implements Listener
|
||||
{
|
||||
private MinecraftLeague _host;
|
||||
|
||||
private GameVariation _variation;
|
||||
|
||||
public VariationManager(MinecraftLeague host)
|
||||
{
|
||||
_host = host;
|
||||
Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin());
|
||||
}
|
||||
|
||||
public void selectVariation()
|
||||
{
|
||||
VariationType type = VariationType.values()[new Random().nextInt(VariationType.values().length)];
|
||||
if (type.getVariation() == null)
|
||||
{
|
||||
Bukkit.broadcastMessage(type.getDisplayMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_variation = type.getVariation().getConstructor(MinecraftLeague.class).newInstance(_host);
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
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(null, "Standard Gameplay", ChatColor.GREEN),
|
||||
WITHER(WitherVariation.class, "Wither Variation", ChatColor.RED)
|
||||
;
|
||||
|
||||
private String _name;
|
||||
private ChatColor _color;
|
||||
private Class<? extends GameVariation> _variation;
|
||||
|
||||
private VariationType(Class<? extends GameVariation> variationClass, String displayName, ChatColor displayColor)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WitherPathfinder
|
||||
{
|
||||
private Wither _ent;
|
||||
private LinkedList<Location> _waypoints;
|
||||
private GameTeam _team;
|
||||
private Entity _enemy;
|
||||
private int _current;
|
||||
private Vector _trajectory;
|
||||
|
||||
public WitherPathfinder(Wither ent, LinkedList<Location> waypoints, GameTeam team, Entity enemy)
|
||||
{
|
||||
_ent = ent;
|
||||
_current = 0;
|
||||
_waypoints = waypoints;
|
||||
_team = team;
|
||||
_enemy = enemy;
|
||||
}
|
||||
|
||||
private boolean closer(Wither wither, Location to, Location than)
|
||||
{
|
||||
return wither.getLocation().distance(to) < wither.getLocation().distance(than);
|
||||
}
|
||||
|
||||
private void advance()
|
||||
{
|
||||
if (_waypoints.isEmpty())
|
||||
return;
|
||||
if (_waypoints.get(_current + 1) == null)
|
||||
return;
|
||||
if (!closer(_ent, _waypoints.get(_current + 1), _waypoints.get(_current)))
|
||||
return;
|
||||
|
||||
_trajectory = UtilAlg.getTrajectory(_waypoints.get(_current), _waypoints.get(_current + 1)).normalize();
|
||||
}
|
||||
|
||||
private void retarget()
|
||||
{
|
||||
if (closer(_ent, _waypoints.getLast(), _waypoints.get(_waypoints.size() - 2)))
|
||||
{
|
||||
_ent.setTarget(null);
|
||||
return;
|
||||
}
|
||||
if (_ent.getTarget() instanceof Player)
|
||||
{
|
||||
Player target = (Player)_ent.getTarget();
|
||||
if (_team.HasPlayer(target))
|
||||
_ent.setTarget(null);
|
||||
|
||||
if (UtilPlayer.isSpectator(target))
|
||||
_ent.setTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
advance();
|
||||
_ent.setVelocity(_trajectory);
|
||||
retarget();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package nautilus.game.arcade.game.games.minecraftleague.variation.wither;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||
import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation;
|
||||
|
||||
public class WitherVariation extends GameVariation
|
||||
{
|
||||
public WitherVariation(MinecraftLeague host)
|
||||
{
|
||||
super(host);
|
||||
}
|
||||
|
||||
public void deregister()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
@ -21,12 +21,15 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
public class GameChatManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
public boolean TeamSpy;
|
||||
|
||||
public GameChatManager(ArcadeManager manager)
|
||||
{
|
||||
Manager = manager;
|
||||
|
||||
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
||||
|
||||
TeamSpy = true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -159,7 +162,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);
|
||||
|
@ -1,7 +1,5 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -14,7 +12,6 @@ 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.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.teleport.event.MineplexTeleportEvent;
|
||||
@ -32,6 +29,7 @@ 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.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -53,6 +51,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;
|
||||
@ -918,6 +917,11 @@ public class GameFlagManager implements Listener
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.VOID, 4, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
if (!Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
}
|
||||
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
@ -927,6 +931,12 @@ public class GameFlagManager implements Listener
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.VOID, 9001, false, false, false,
|
||||
"Border", "Border Damage");
|
||||
if (!Manager.GetDamage().IsEnabled())
|
||||
{
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4);
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user