Bridge the gap with MineplexWorld and WorldData

This commit is contained in:
Sam 2018-07-26 17:07:15 +01:00 committed by Alexander Meech
parent 9feecc32a1
commit cb20fc7d0a
31 changed files with 58 additions and 1765 deletions

View File

@ -4,13 +4,15 @@ import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import mineplex.core.common.util.C;
public class MineplexWorld public class MineplexWorld
{ {
@ -24,9 +26,9 @@ public class MineplexWorld
public MineplexWorld(World world) public MineplexWorld(World world)
{ {
_world = world; _world = world;
_ironLocations = new HashMap<>(); _ironLocations = new LinkedHashMap<>();
_goldLocations = new HashMap<>(); _goldLocations = new LinkedHashMap<>();
_spongeLocations = new HashMap<>(); _spongeLocations = new LinkedHashMap<>();
} }
public void loadWorldConfig() public void loadWorldConfig()
@ -195,6 +197,11 @@ public class MineplexWorld
return _mapAuthor; return _mapAuthor;
} }
public String getFormattedName()
{
return C.cGreen + "Map - " + C.cWhiteB + getMapName() + C.cGray + " created by " + C.cWhiteB + getMapAuthor();
}
public Location getIronLocation(String key) public Location getIronLocation(String key)
{ {
List<Location> locations = getIronLocations(key); List<Location> locations = getIronLocations(key);

View File

@ -50,7 +50,6 @@ import nautilus.game.arcade.game.games.minestrike.Minestrike;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.moba.MobaClassic; import nautilus.game.arcade.game.games.moba.MobaClassic;
import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.Quiver;
import nautilus.game.arcade.game.games.quiver.QuiverTeamBase; import nautilus.game.arcade.game.games.quiver.QuiverTeamBase;
@ -153,7 +152,6 @@ public enum GameType implements Voteable
}, true), }, true),
BawkBawkBattles(BawkBawkBattles.class, GameDisplay.BawkBawkBattles), BawkBawkBattles(BawkBawkBattles.class, GameDisplay.BawkBawkBattles),
MinecraftLeague(MinecraftLeague.class, GameDisplay.Minecraft_League), MinecraftLeague(MinecraftLeague.class, GameDisplay.Minecraft_League),
OldMineWare(OldMineWare.class, GameDisplay.OldMineWare),
Paintball(Paintball.class, GameDisplay.Paintball), Paintball(Paintball.class, GameDisplay.Paintball),
Quiver(Quiver.class, GameDisplay.Quiver), Quiver(Quiver.class, GameDisplay.Quiver),
QuiverPayload(QuiverTeamBase.class, GameDisplay.QuiverPayload), QuiverPayload(QuiverTeamBase.class, GameDisplay.QuiverPayload),
@ -229,7 +227,7 @@ public enum GameType implements Voteable
GameType.DeathTag, GameType.DragonEscape, GameType.Dragons, GameType.DeathTag, GameType.DragonEscape, GameType.Dragons,
GameType.Draw, GameType.Evolution, GameType.Gravity, GameType.Halloween, GameType.HideSeek, GameType.Draw, GameType.Evolution, GameType.Gravity, GameType.Halloween, GameType.HideSeek,
GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.BawkBawkBattles, GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.BawkBawkBattles,
GameType.OldMineWare, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner,
GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams, GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams,
GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef, GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef,
GameType.SurvivalGames, GameType.SurvivalGamesTeams, GameType.TurfWars, GameType.UHC, GameType.SurvivalGames, GameType.SurvivalGamesTeams, GameType.TurfWars, GameType.UHC,

View File

@ -693,8 +693,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed
{ {
int count = 1; int count = 1;
for (String team : WorldData.SpawnLocs.keySet()) for (Entry<String, List<Location>> entry : WorldData.getAllSpawnLocations().entrySet())
{ {
String team = entry.getKey();
ChatColor color; ChatColor color;
if (team.equalsIgnoreCase("RED")) color = ChatColor.RED; if (team.equalsIgnoreCase("RED")) color = ChatColor.RED;
@ -710,7 +711,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
color = ChatColor.DARK_GREEN; color = ChatColor.DARK_GREEN;
int modulo = GetTeamList().size() % 14; int modulo = GetTeamList().size() % 14;
if (modulo == 0) if (WorldData.SpawnLocs.size() > 1) color = ChatColor.RED; if (modulo == 0) if (WorldData.getAllSpawnLocations().size() > 1) color = ChatColor.RED;
if (modulo == 1) color = ChatColor.YELLOW; if (modulo == 1) color = ChatColor.YELLOW;
if (modulo == 2) color = ChatColor.GREEN; if (modulo == 2) color = ChatColor.GREEN;
if (modulo == 3) color = ChatColor.AQUA; if (modulo == 3) color = ChatColor.AQUA;
@ -727,13 +728,13 @@ public abstract class Game extends ListenerComponent implements Lifetimed
//Random Names //Random Names
String teamName = team; String teamName = team;
if (WorldData.SpawnLocs.size() > 12) if (WorldData.getAllSpawnLocations().size() > 12)
{ {
teamName = String.valueOf(count); teamName = String.valueOf(count);
count++; count++;
} }
GameTeam newTeam = new GameTeam(this, teamName, color, WorldData.SpawnLocs.get(team)); GameTeam newTeam = new GameTeam(this, teamName, color, entry.getValue());
AddTeam(newTeam); AddTeam(newTeam);
} }

View File

@ -818,7 +818,7 @@ public class CakeWars extends TeamGame
public boolean isNearSpawn(Location location) public boolean isNearSpawn(Location location)
{ {
for (List<Location> locations : WorldData.SpawnLocs.values()) for (List<Location> locations : WorldData.getAllSpawnLocations().values())
{ {
for (Location spawn : locations) for (Location spawn : locations)
{ {

View File

@ -288,7 +288,7 @@ public class Halloween2016 extends Halloween
double firstEntry = Double.MAX_VALUE; double firstEntry = Double.MAX_VALUE;
Location first = null; Location first = null;
for(Entry<String, ArrayList<Location>> point : WorldData.GetAllCustomLocs().entrySet()) for(Entry<String, List<Location>> point : WorldData.GetAllCustomLocs().entrySet())
{ {
String[] args = point.getKey().split(" "); String[] args = point.getKey().split(" ");
if(args.length < 2) continue; if(args.length < 2) continue;

View File

@ -195,7 +195,7 @@ public class Moba extends TeamGame
public void ParseData() public void ParseData()
{ {
// Make all spawns face the center of the map // Make all spawns face the center of the map
for (List<Location> locations : WorldData.SpawnLocs.values()) for (List<Location> locations : WorldData.getAllSpawnLocations().values())
{ {
locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())))); locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation()))));
} }

View File

@ -1,359 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
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.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
import nautilus.game.arcade.game.games.oldmineware.random.*;
import nautilus.game.arcade.game.games.runner.kits.KitLeaper;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
public class OldMineWare extends SoloGame
{
private HashMap<Player, Integer> _lives = new HashMap<Player, Integer>();
private Order _order = null;
private long _orderTime = 0;
private int _orderCount = 0;
private ArrayList<Order> _orders = new ArrayList<Order>();
private ArrayList<Order> _ordersCopy = new ArrayList<Order>();
private Location _ghastLoc = null;
private Location _ghastTarget = null;
private Ghast _ghast = null;
private ArrayList<Location> _mobLocs = new ArrayList<Location>();
private ArrayList<Creature> _mobs = new ArrayList<Creature>();
public OldMineWare(ArcadeManager manager)
{
super(manager, GameType.OldMineWare,
new Kit[]
{
new KitLeaper(manager),
},
new String[]
{
"Follow the orders given in chat!",
"First half to follow it win the round.",
"Other players lose one life.",
"Last player with lives wins!"
});
this.PrepareFreeze = false;
this.DamagePvP = false;
this.BlockPlace = true;
this.BlockBreak = true;
this.ItemDrop = true;
this.ItemPickup = true;
InventoryOpenBlock = true;
InventoryOpenChest = true;
InventoryClick = true;
PopulateOrders();
registerChatStats();
new CompassModule()
.setGiveCompass(true)
.setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false)
.register(this);
}
@Override
public void ParseData()
{
_ghastLoc = WorldData.GetDataLocs("WHITE").get(0);
while (_mobLocs.size() < 100)
{
Location loc = WorldData.GetRandomXZ();
while (UtilBlock.airFoliage(loc.getBlock()))
loc.add(0, -1, 0);
Material mat = loc.getBlock().getType();
if (mat == Material.STONE ||
mat == Material.GRASS ||
mat == Material.SAND)
_mobLocs.add(loc);
}
}
public void PopulateOrders()
{
_orders.add(new ActionMilkCow(this));
_orders.add(new ActionShearSheep(this));
_orders.add(new CraftLadder(this));
_orders.add(new CraftStoneShovel(this));
_orders.add(new DamageChicken(this));
_orders.add(new DamageFall(this));
_orders.add(new DamageGhast(this));
_orders.add(new GatherCobble(this));
_orders.add(new GatherRedFlower(this));
_orders.add(new GatherYellowFlower(this));
_orders.add(new GatherSand(this));
_orders.add(new PlaceDoor(this));
_orders.add(new RideBoat(this));
_orders.add(new RidePig(this));
_orders.add(new StandAlone(this));
_orders.add(new StandShelter(this));
_orders.add(new StandStone(this));
_orders.add(new StandWater(this));
}
public Order GetOrder()
{
if (_ordersCopy.isEmpty())
{
for (Order order : _orders)
{
_ordersCopy.add(order);
}
}
return _ordersCopy.remove(UtilMath.r(_ordersCopy.size()));
}
@EventHandler(priority = EventPriority.HIGH)
public void GameStateChange(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
return;
for (Player player : GetPlayers(true))
_lives.put(player, 10);
}
@EventHandler
public void UpdateOrder(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (!IsLive())
return;
//New Order
if (_order == null)
{
if (!UtilTime.elapsed(_orderTime, 1000))
return;
_order = GetOrder();
if (_order == null)
{
SetState(GameState.Dead);
return;
}
//Register
UtilServer.getServer().getPluginManager().registerEvents(_order, Manager.getPlugin());
_order.StartOrder(_orderCount++);
Announce(C.cYellow + C.Bold + _order.GetOrder().toUpperCase());
/* XXX
GetObjectiveSide().setDisplayName(
ChatColor.WHITE + "§lMineWare " + C.cGreen + "§l"
+ "Round " + _orderCount);
*/
}
//Update Order
else
{
if (_order.Finish())
{
_orderTime = System.currentTimeMillis();
if (_order.PlayerHasCompleted())
{
for (Player player : GetPlayers(true))
{
if (!_order.IsCompleted(player))
{
LoseLife(player);
if (IsAlive(player))
_order.FailItems(player);
}
}
}
//Deregister
HandlerList.unregisterAll(_order);
_order.EndOrder();
_order = null;
}
else
{
//Set Level
for (Player player : UtilServer.getPlayers())
{
player.setLevel(_order.GetRemainingPlaces());
player.setExp(_order.GetTimeLeftPercent());
}
}
}
}
private int GetLives(Player player)
{
if (!_lives.containsKey(player))
return 0;
if (!IsAlive(player))
return 0;
return _lives.get(player);
}
private void LoseLife(Player player)
{
int lives = GetLives(player) - 1;
if (lives > 0)
{
UtilPlayer.message(player, C.cRed + C.Bold + "You failed the task!");
UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!");
player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f);
_lives.put(player, lives);
}
else
{
UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!");
player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f);
player.damage(5000);
}
}
@EventHandler
public void UpdateMobs(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!InProgress())
return;
Iterator<Creature> mobIterator = _mobs.iterator();
while (mobIterator.hasNext())
{
Creature mob = mobIterator.next();
if (!mob.isValid())
{
mob.remove();
mobIterator.remove();
}
}
if (_mobs.size() < 200)
{
Location loc = _mobLocs.get(UtilMath.r(_mobLocs.size())).clone().add(new Vector(0.5,1,0.5));
double r = Math.random();
this.CreatureAllowOverride = true;
if (r > 0.75) _mobs.add(loc.getWorld().spawn(loc, Pig.class));
else if (r > 0.5) _mobs.add(loc.getWorld().spawn(loc, Cow.class));
else if (r > 0.25) _mobs.add(loc.getWorld().spawn(loc, Chicken.class));
else _mobs.add(loc.getWorld().spawn(loc, Sheep.class));
this.CreatureAllowOverride = false;
}
if (_ghast == null || !_ghast.isValid())
{
if (_ghast != null)
_ghast.remove();
this.CreatureAllowOverride = true;
_ghast = _ghastLoc.getWorld().spawn(_ghastLoc, Ghast.class);
this.CreatureAllowOverride = false;
_ghast.setMaxHealth(10000);
_ghast.setHealth(_ghast.getMaxHealth());
}
else
{
//New Target
if (_ghastTarget == null || UtilMath.offset(_ghast.getLocation(), _ghastTarget) < 5)
{
_ghastTarget = _ghastLoc.clone().add(40 - 80*Math.random(), -20*Math.random(), 40 - 80*Math.random());
}
_ghast.teleport(_ghast.getLocation().add(UtilAlg.getTrajectory(_ghast.getLocation(), _ghastTarget).multiply(0.1)));
}
}
@EventHandler
public void GhastTarget(EntityTargetEvent event)
{
if (event.getEntity().equals(_ghast))
event.setCancelled(true);
}
@Override
public int GetScoreboardScore(Player player)
{
return GetLives(player);
}
@EventHandler
public void ItemDrop(PlayerDropItemEvent event)
{
event.getItemDrop().remove();
}
}

View File

@ -1,112 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.order;
import java.util.HashSet;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
public abstract class Order implements Listener
{
public OldMineWare Host;
private String _order;
private long _startTime;
private long _duration;
private HashSet<Player> _completed = new HashSet<Player>();
public Order(OldMineWare host, String order)
{
Host = host;
_order = order;
}
public void StartOrder(int stage)
{
_completed.clear();
_startTime = System.currentTimeMillis();
_duration = 60000;
SubInitialize();
Initialize();
}
public void SubInitialize()
{
}
public void EndOrder()
{
Host.BlockBreakAllow.clear();
Host.BlockPlaceAllow.clear();
Host.ItemDropAllow.clear();
Host.ItemPickupAllow.clear();
Uninitialize();
}
public abstract void Initialize();
public abstract void Uninitialize();
public String GetOrder()
{
return _order;
}
public boolean Finish()
{
if (GetRemainingPlaces() <= 0)
return true;
return UtilTime.elapsed(_startTime, _duration);
}
public int GetTimeLeft()
{
return (int)((_duration - (System.currentTimeMillis() - _startTime))/1000);
}
public void SetCompleted(Player player)
{
if (_completed.contains(player))
return;
_completed.add(player);
UtilPlayer.message(player, C.cGreen + C.Bold + "You completed the task!");
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
}
public boolean IsCompleted(Player player)
{
return _completed.contains(player);
}
public abstract void FailItems(Player player);
public float GetTimeLeftPercent()
{
float a = (float)(_duration - (System.currentTimeMillis() - _startTime));
float b = (float)(_duration);
return a/b;
}
public int GetRemainingPlaces()
{
return (int) Math.max(0, (Host.GetPlayers(true).size()*0.5) - _completed.size());
}
public boolean PlayerHasCompleted()
{
return !_completed.isEmpty();
}
}

View File

@ -1,104 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.order;
import java.util.HashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
public abstract class OrderCraft extends Order
{
private HashMap<Player, Integer> _counter = new HashMap<Player, Integer>();
private int _id;
private byte _data;
private int _req;
public OrderCraft(OldMineWare host, String order, int id, int data, int required)
{
super(host, order);
_id = id;
_data = (byte)data;
_req = required;
}
@Override
public void SubInitialize()
{
_counter.clear();
}
@Override
public void FailItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(_id, _data, _req));
}
@EventHandler
public void Craft(InventoryClickEvent event)
{
if (event.getSlotType() != SlotType.RESULT)
return;
if (!UtilInv.IsItem(event.getCurrentItem(), null, _id, _data))
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player)event.getWhoClicked();
if (!event.isShiftClick())
{
Add(player, event.getCurrentItem().getAmount());
}
else
{
CraftingInventory inv = (CraftingInventory)event.getInventory();
int make = 128;
//Find Lowest Amount
for (ItemStack item : inv.getMatrix())
if (item != null && item.getType() != Material.AIR)
if (item.getAmount() < make)
make = item.getAmount();
make = make * event.getCurrentItem().getAmount();
Add(player, make);
}
if (Has(player))
SetCompleted(player);
}
public void Add(Player player, int add)
{
if (!_counter.containsKey(player))
_counter.put(player, add);
else
_counter.put(player, _counter.get(player) + add);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
}
public boolean Has(Player player)
{
if (!_counter.containsKey(player))
return false;
return _counter.get(player) >= _req;
}
}

View File

@ -1,81 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.order;
import java.util.HashMap;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerPickupItemEvent;
public abstract class OrderGather extends Order
{
private HashMap<Player, Integer> _counter = new HashMap<Player, Integer>();
private int _id;
private byte _data;
private int _req;
public OrderGather(OldMineWare host, String order, int id, int data, int required)
{
super(host, order);
_id = id;
_data = (byte)data;
_req = required;
}
@Override
public void SubInitialize()
{
_counter.clear();
Host.BlockBreakAllow.add(_id);
Host.ItemPickupAllow.add(_id);
}
@Override
public void FailItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(_id, _data, _req));
}
@EventHandler
public void Pickup(PlayerPickupItemEvent event)
{
if (!UtilInv.IsItem(event.getItem().getItemStack(), null, _id, _data))
return;
if (Has(event.getPlayer()))
{
event.setCancelled(true);
return;
}
Add(event.getPlayer(), event.getItem().getItemStack().getAmount());
if (Has(event.getPlayer()))
SetCompleted(event.getPlayer());
}
public void Add(Player player, int add)
{
if (!_counter.containsKey(player))
_counter.put(player, add);
else
_counter.put(player, _counter.get(player) + add);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
}
public boolean Has(Player player)
{
if (!_counter.containsKey(player))
return false;
return _counter.get(player) >= _req;
}
}

View File

@ -1,78 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.order;
import java.util.HashMap;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
public abstract class OrderPlace extends Order
{
private HashMap<Player, Integer> _counter = new HashMap<Player, Integer>();
private int _id;
private byte _data;
private int _req;
public OrderPlace(OldMineWare host, String order, int id, int data, int required)
{
super(host, order);
_id = id;
_data = (byte)data;
_req = required;
}
@Override
public void SubInitialize()
{
_counter.clear();
Host.BlockPlaceAllow.add(_id);
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Place(BlockPlaceEvent event)
{
if (event.isCancelled())
return;
if (event.getBlock().getTypeId() != _id)
return;
if (_data != -1 && event.getBlock().getData() != _data)
return;
Add(event.getPlayer(), 1);
if (Has(event.getPlayer()))
SetCompleted(event.getPlayer());
}
public void Add(Player player, int add)
{
if (!_counter.containsKey(player))
_counter.put(player, add);
else
_counter.put(player, _counter.get(player) + add);
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
}
public boolean Has(Player player)
{
if (!_counter.containsKey(player))
return false;
return _counter.get(player) >= _req;
}
}

View File

@ -1,54 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.Material;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilGear;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class ActionMilkCow extends Order
{
public ActionMilkCow(OldMineWare host)
{
super(host, "milk a cow");
}
@Override
public void Initialize()
{
for (Player player : Host.GetPlayers(true))
{
if (!player.getInventory().contains(Material.BUCKET))
player.getInventory().addItem(new ItemStack(Material.BUCKET));
}
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(PlayerInteractEntityEvent event)
{
if (!(event.getRightClicked() instanceof Cow))
return;
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BUCKET))
return;
SetCompleted(event.getPlayer());
}
}

View File

@ -1,46 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class ActionShearSheep extends Order
{
public ActionShearSheep(OldMineWare host)
{
super(host, "shear a sheep");
}
@Override
public void Initialize()
{
for (Player player : Host.GetPlayers(true))
{
if (!player.getInventory().contains(Material.SHEARS))
player.getInventory().addItem(new ItemStack(Material.SHEARS));
}
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(PlayerShearEntityEvent event)
{
SetCompleted(event.getPlayer());
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderCraft;
public class CraftLadder extends OrderCraft
{
public CraftLadder(OldMineWare host)
{
super(host, "Craft some ladders", 65, -1, 1);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderCraft;
public class CraftStoneShovel extends OrderCraft
{
public CraftStoneShovel(OldMineWare host)
{
super(host, "Craft a stone shovel", 273, -1, 1);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,55 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class DamageChicken extends Order
{
public DamageChicken(OldMineWare host)
{
super(host, "punch a chicken");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
return;
Player player = event.GetDamagerPlayer(false);
if (player == null) return;
LivingEntity ent = event.GetDamageeEntity();
if (ent == null) return;
if (!(ent instanceof Chicken))
return;
SetCompleted(player);
}
}

View File

@ -1,47 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class DamageFall extends Order
{
public DamageFall(OldMineWare host)
{
super(host, "Take fall damage");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.FALL)
return;
Player player = event.GetDamageePlayer();
if (player == null) return;
SetCompleted(player);
}
}

View File

@ -1,74 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.Material;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class DamageGhast extends Order
{
public DamageGhast(OldMineWare host)
{
super(host, "shoot the ghast");
}
@Override
public void Initialize()
{
for (Player player : Host.GetPlayers(true))
{
if (!player.getInventory().contains(Material.BOW))
player.getInventory().addItem(new ItemStack(Material.BOW));
}
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
if (!player.getInventory().contains(Material.ARROW))
player.getInventory().addItem(new ItemStack(Material.ARROW));
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.PROJECTILE)
return;
Player player = event.GetDamagerPlayer(true);
if (player == null) return;
LivingEntity ent = event.GetDamageeEntity();
if (ent == null) return;
if (!(ent instanceof Ghast))
return;
SetCompleted(player);
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderGather;
public class GatherCobble extends OrderGather
{
public GatherCobble(OldMineWare host)
{
super(host, "Pick up 10 Cobblestone", 4, -1, 10);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderGather;
public class GatherRedFlower extends OrderGather
{
public GatherRedFlower(OldMineWare host)
{
super(host, "Pick 3 Red Roses", 38, -1, 3);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderGather;
public class GatherSand extends OrderGather
{
public GatherSand(OldMineWare host)
{
super(host, "Pick up 16 Sand", 12, -1, 16);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderGather;
public class GatherYellowFlower extends OrderGather
{
public GatherYellowFlower(OldMineWare host)
{
super(host, "Pick 4 Yellow Flowers", 37, -1, 4);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,24 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.OrderPlace;
public class PlaceDoor extends OrderPlace
{
public PlaceDoor(OldMineWare host)
{
super(host, "Place a wooden door", 64, -1, 1);
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
}

View File

@ -1,48 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class RideBoat extends Order
{
public RideBoat(OldMineWare host)
{
super(host, "Sit in a Boat");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
if (player.isInsideVehicle())
if (player.getVehicle() instanceof Boat)
SetCompleted(player);
}
}

View File

@ -1,54 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.Material;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class RidePig extends Order
{
public RidePig(OldMineWare host)
{
super(host, "ride a pig");
}
@Override
public void Initialize()
{
for (Player player : Host.GetPlayers(true))
{
if (!player.getInventory().contains(Material.SADDLE))
player.getInventory().addItem(new ItemStack(Material.SADDLE));
}
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
if (player.isInsideVehicle())
if (player.getVehicle() instanceof Pig)
SetCompleted(player);
}
}

View File

@ -1,63 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class StandAlone extends Order
{
public StandAlone(OldMineWare host)
{
super(host, "Run away from everyone");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
{
boolean alone = true;
for (Player other : Host.GetPlayers(true))
{
if (other.equals(player))
continue;
if (UtilMath.offset(player, other) < 16)
{
alone = false;
break;
}
}
if (alone)
SetCompleted(player);
}
}
}

View File

@ -1,63 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class StandShelter extends Order
{
public StandShelter(OldMineWare host)
{
super(host, "take shelter from rain");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
Host.WorldData.World.setStorm(false);
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Host.WorldData.World.setStorm(true);
for (Player player : Host.GetPlayers(true))
{
Block block = player.getLocation().add(0, 2, 0).getBlock();
while (block.getTypeId() == 0 && block.getLocation().getY() < 255)
{
block = block.getRelative(BlockFace.UP);
if (block.getTypeId() != 0)
{
SetCompleted(player);
break;
}
}
}
}
}

View File

@ -1,48 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class StandStone extends Order
{
public StandStone(OldMineWare host)
{
super(host, "Stand on stone");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STONE)
SetCompleted(player);
}
}

View File

@ -1,46 +0,0 @@
package nautilus.game.arcade.game.games.oldmineware.random;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.oldmineware.order.Order;
public class StandWater extends Order
{
public StandWater(OldMineWare host)
{
super(host, "Go for a swim");
}
@Override
public void Initialize()
{
}
@Override
public void Uninitialize()
{
}
@Override
public void FailItems(Player player)
{
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : Host.GetPlayers(true))
if (player.getLocation().getBlock().isLiquid())
SetCompleted(player);
}
}

View File

@ -270,7 +270,7 @@ public class SpeedBuilders extends SoloGame
} }
} }
for (Entry<String, ArrayList<Location>> entry : WorldData.GetAllCustomLocs().entrySet()) for (Entry<String, List<Location>> entry : WorldData.GetAllCustomLocs().entrySet())
{ {
BuildData buildData = new BuildData(entry.getValue().get(0).clone().subtract(0.5, 0, 0.5), ChatColor.translateAlternateColorCodes('&', entry.getKey()), this); BuildData buildData = new BuildData(entry.getValue().get(0).clone().subtract(0.5, 0, 0.5), ChatColor.translateAlternateColorCodes('&', entry.getKey()), this);
boolean add = false; boolean add = false;

View File

@ -8,7 +8,7 @@ import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Difficulty; import org.bukkit.Difficulty;
@ -20,45 +20,40 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.api.enderchest.EnderchestWorldLoader; import mineplex.core.common.api.enderchest.EnderchestWorldLoader;
import mineplex.core.common.timing.TimingManager; import mineplex.core.common.timing.TimingManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.FileUtil;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.WorldUtil; import mineplex.core.common.util.WorldUtil;
import mineplex.core.common.util.ZipUtil; import mineplex.core.common.util.ZipUtil;
import mineplex.core.common.util.worldgen.WorldGenCleanRoom; import mineplex.core.common.util.worldgen.WorldGenCleanRoom;
import mineplex.core.world.MineplexWorld;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.game.games.uhc.UHC;
/**
* WorldData is a legacy class to bridge the standardised {@link MineplexWorld} system, and the Arcade's games.
*/
public class WorldData public class WorldData
{ {
public final Game Host; public final Game Host;
private final int Id; private final int Id;
private MineplexWorld _mineplexWorld;
public String File = null; public String File;
private String Folder = null; private String Folder;
public World World; public World World;
public int MinX = 0; public int MinX = 0;
public int MinZ = 0; public int MinZ = 0;
public int MaxX = 0; public int MaxX = 0;
public int MaxZ = 0; public int MaxZ = 0;
public int MinY = -1; public int MinY = -1;
public int MaxY = 256; public int MaxY = 256;
public String MapName; public String MapName;
public String MapAuthor; public GameType Game;
public GameType Game = null;
public final Map<String, ArrayList<Location>> SpawnLocs = new LinkedHashMap<>();
private final Map<String, ArrayList<Location>> DataLocs = new LinkedHashMap<>();
private final Map<String, ArrayList<Location>> CustomLocs = new LinkedHashMap<>();
private final Map<String, String> _dataEntries = new LinkedHashMap<>();
public WorldData(Game game) public WorldData(Game game)
{ {
@ -102,8 +97,21 @@ public class WorldData
World.setGameRuleValue("showDeathMessages", "false"); World.setGameRuleValue("showDeathMessages", "false");
TimingManager.start("WorldData loading WorldConfig."); TimingManager.start("WorldData loading WorldConfig.");
//Load World Data //Load World Data
worldData.LoadWorldConfig(); _mineplexWorld = new MineplexWorld(World);
Location min = _mineplexWorld.getMin(), max = _mineplexWorld.getMax();
MinX = min.getBlockX();
MinY = min.getBlockY();
MinZ = min.getBlockZ();
MaxX = max.getBlockX();
MaxY = max.getBlockY();
MaxZ = max.getBlockZ();
MapName = _mineplexWorld.getMapName();
TimingManager.stop("WorldData loading WorldConfig."); TimingManager.stop("WorldData loading WorldConfig.");
}); });
}); });
@ -134,11 +142,6 @@ public class WorldData
return success; return success;
} }
protected GameType GetGame()
{
return Game;
}
private String GetFile() private String GetFile()
{ {
if (File == null) if (File == null)
@ -155,7 +158,7 @@ public class WorldData
{ {
if (Folder == null) if (Folder == null)
{ {
Folder = "Game" + Id + "_" + GetGame().getName() + "_" + GetFile(); Folder = "Game" + Id + "_" + Game.getName() + "_" + GetFile();
} }
return Folder; return Folder;
} }
@ -170,212 +173,19 @@ public class WorldData
TimingManager.stop("UnzipWorld creating folders"); TimingManager.stop("UnzipWorld creating folders");
TimingManager.start("UnzipWorld UnzipToDirectory"); TimingManager.start("UnzipWorld UnzipToDirectory");
ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().getName() + "/" + GetFile() + ".zip", folder); ZipUtil.UnzipToDirectory("../../update/maps/" + Game.getName() + "/" + GetFile() + ".zip", folder);
TimingManager.stop("UnzipWorld UnzipToDirectory"); TimingManager.stop("UnzipWorld UnzipToDirectory");
} }
public void LoadWorldConfig()
{
//Load Track Data
String line = null;
try
{
FileInputStream fstream = new FileInputStream(GetFolder() + java.io.File.separator + "WorldConfig.dat");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
ArrayList<Location> currentTeam = null;
ArrayList<Location> currentData = null;
int currentDirection = 0;
while ((line = br.readLine()) != null)
{
String[] tokens = line.split(":");
if (tokens.length < 2)
continue;
if (tokens[0].length() == 0)
continue;
//Name & Author
if (tokens[0].equalsIgnoreCase("MAP_NAME"))
{
MapName = tokens[1];
}
else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR"))
{
MapAuthor = tokens[1];
}
//Spawn Locations
else if (tokens[0].equalsIgnoreCase("TEAM_NAME"))
{
SpawnLocs.put(tokens[1], new ArrayList<>());
currentTeam = SpawnLocs.get(tokens[1]);
currentDirection = 0;
}
else if (tokens[0].equalsIgnoreCase("TEAM_DIRECTION"))
{
currentDirection = Integer.parseInt(tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("TEAM_SPAWNS"))
{
for (int i = 1; i < tokens.length; i++)
{
Location loc = StrToLoc(tokens[i]);
if (loc == null) continue;
loc.setYaw(currentDirection);
currentTeam.add(loc);
}
}
//Data Locations
else if (tokens[0].equalsIgnoreCase("DATA_NAME"))
{
DataLocs.put(tokens[1], new ArrayList<>());
currentData = DataLocs.get(tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("DATA_LOCS"))
{
for (int i = 1; i < tokens.length; i++)
{
Location loc = StrToLoc(tokens[i]);
if (loc == null) continue;
currentData.add(loc);
}
}
//Custom Locations
else if (tokens[0].equalsIgnoreCase("CUSTOM_NAME"))
{
CustomLocs.put(tokens[1], new ArrayList<>());
currentData = CustomLocs.get(tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("CUSTOM_LOCS"))
{
for (int i = 1; i < tokens.length; i++)
{
Location loc = StrToLoc(tokens[i]);
if (loc == null) continue;
currentData.add(loc);
}
}
//Map Bounds
else if (tokens[0].equalsIgnoreCase("MIN_X"))
{
try
{
MinX = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MinX [" + tokens[1] + "]");
}
}
else if (tokens[0].equalsIgnoreCase("MAX_X"))
{
try
{
MaxX = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MaxX [" + tokens[1] + "]");
}
}
else if (tokens[0].equalsIgnoreCase("MIN_Z"))
{
try
{
MinZ = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MinZ [" + tokens[1] + "]");
}
}
else if (tokens[0].equalsIgnoreCase("MAX_Z"))
{
try
{
MaxZ = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MaxZ [" + tokens[1] + "]");
}
}
else if (tokens[0].equalsIgnoreCase("MIN_Y"))
{
try
{
MinY = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MinY [" + tokens[1] + "]");
}
}
else if (tokens[0].equalsIgnoreCase("MAX_Y"))
{
try
{
MaxY = Integer.parseInt(tokens[1]);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid MaxY [" + tokens[1] + "]");
}
}
else
{
_dataEntries.put(tokens[0], tokens[1]);
}
}
in.close();
Host.Manager.GetGameWorldManager().RegisterWorld(this);
}
catch (Exception e)
{
e.printStackTrace();
System.err.println("Line: " + line);
}
}
protected Location StrToLoc(String loc)
{
String[] coords = loc.split(",");
try
{
return new Location(World, Integer.valueOf(coords[0]) + 0.5, Integer.valueOf(coords[1]), Integer.valueOf(coords[2]) + 0.5);
}
catch (Exception e)
{
System.out.println("World Data Read Error: Invalid Location String [" + loc + "]");
}
return null;
}
public void Uninitialize() public void Uninitialize()
{ {
if (World == null) if (World == null)
{
return; return;
}
//Wipe World //Wipe World
MapUtil.UnloadWorld(Host.Manager.getPlugin(), World); MapUtil.UnloadWorld(Host.getArcadeManager().getPlugin(), World);
MapUtil.ClearWorldReferences(World.getName()); MapUtil.ClearWorldReferences(World.getName());
FileUtil.DeleteFolder(new File(World.getName())); FileUtil.DeleteFolder(new File(World.getName()));
@ -443,54 +253,31 @@ public class WorldData
public ArrayList<Location> GetDataLocs(String data) public ArrayList<Location> GetDataLocs(String data)
{ {
if (!DataLocs.containsKey(data)) return (ArrayList<Location>) _mineplexWorld.getIronLocations(data);
{
return new ArrayList<>(0);
}
return DataLocs.get(data);
} }
public ArrayList<Location> GetCustomLocs(String id) public ArrayList<Location> GetCustomLocs(String id)
{ {
if (!CustomLocs.containsKey(id)) return (ArrayList<Location>) _mineplexWorld.getSpongeLocations(id);
{
return new ArrayList<>(0);
} }
return CustomLocs.get(id); public Map<String, List<Location>> GetAllCustomLocs()
{
return _mineplexWorld.getSpongeLocations();
} }
public Map<String, ArrayList<Location>> GetAllCustomLocs() public Map<String, List<Location>> GetAllDataLocs()
{ {
return CustomLocs; return _mineplexWorld.getIronLocations();
} }
public Map<String, ArrayList<Location>> GetAllDataLocs() public Map<String, List<Location>> getAllSpawnLocations()
{ {
return DataLocs; return _mineplexWorld.getGoldLocations();
}
public Location GetRandomXZ()
{
Location loc = new Location(World, 0, 250, 0);
int xVar = MaxX - MinX;
int zVar = MaxZ - MinZ;
loc.setX(MinX + UtilMath.r(xVar));
loc.setZ(MinZ + UtilMath.r(zVar));
return loc;
}
public String get(String key)
{
return _dataEntries.get(key);
} }
public String getFormattedName() public String getFormattedName()
{ {
return C.cGreen + "Map - " + C.cWhiteB + MapName + C.cGray + " created by " + C.cWhiteB + MapAuthor; return _mineplexWorld.getFormattedName();
} }
} }