Update MapParser to 1.12, refactor out some common base utilities.

This commit is contained in:
md_5 2017-06-23 13:55:48 +10:00 committed by cnr
parent 0374506879
commit a6493ed18a
54 changed files with 254 additions and 183 deletions

View File

@ -0,0 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-parent</artifactId>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>mineplex-core-common-base</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
public enum Rank
{
@ -122,7 +122,7 @@ public enum Rank
if (inform)
{
UtilPlayer.message(player, C.mHead + "Permissions> " +
UtilPlayerBase.message(player, C.mHead + "Permissions> " +
C.mBody + "This requires Permission Rank [" +
C.mHead + rank.Name.toUpperCase() +
C.mBody + "].");

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map.Entry;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang.Validate;
import java.util.Set;

View File

@ -0,0 +1,38 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
public class UtilBlockBase
{
public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
{
ArrayList<Block> blocks = new ArrayList<Block>();
if (diagonals)
{
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++)
for (int y = 1; y >= -1; y--)
{
if (x == 0 && y == 0 && z == 0) continue;
blocks.add(block.getRelative(x, y, z));
}
}
else
{
blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
}
return blocks;
}
}

View File

@ -0,0 +1,97 @@
package mineplex.core.common.util;
import java.util.LinkedList;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import mineplex.core.common.events.PlayerMessageEvent;
import org.bukkit.Bukkit;
public class UtilPlayerBase
{
public static void message(Entity client, LinkedList<String> messageList)
{
message(client, messageList, false);
}
public static void message(Entity client, String message)
{
message(client, message, false);
}
public static void message(Entity client, LinkedList<String> messageList, boolean wiki)
{
for (String curMessage : messageList)
{
message(client, curMessage, wiki);
}
}
public static void message(Entity client, String message, boolean wiki)
{
if (client == null)
return;
if (!(client instanceof Player))
return;
/*
if (wiki)
message = UtilWiki.link(message);
*/
PlayerMessageEvent event = new PlayerMessageEvent((Player) client, message);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
((Player) client).sendMessage(message);
}
public static Player searchOnline(Player caller, String player, boolean inform)
{
LinkedList<Player> matchList = new LinkedList<Player>();
for (Player cur : Bukkit.getOnlinePlayers())
{
if (cur.getName().equalsIgnoreCase(player))
return cur;
if (cur.getName().toLowerCase().contains(player.toLowerCase()))
matchList.add(cur);
}
// No / Non-Unique
if (matchList.size() != 1)
{
if (!inform)
return null;
// Inform
message(caller,
F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem
+ player + C.mBody + "]."));
if (matchList.size() > 0)
{
String matchString = "";
for (Player cur : matchList)
matchString += F.elem(cur.getName()) + ", ";
if (matchString.length() > 1)
matchString = matchString.substring(0, matchString.length() - 2);
message(caller,
F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
}
return matchList.get(0);
}
}

View File

@ -6,8 +6,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class UtilTime
{
public static final ZoneId CENTRAL_ZONE = ZoneId.of("America/Chicago"); // This means "CST"
@ -54,15 +52,6 @@ public class UtilTime
}
}
/**
*
* @return Returns the current global server tick. Is reset on server restart. Starts out negative. Counts upwards.
*/
public static int getServerTick()
{
return MinecraftServer.currentTick;
}
/**
* Converts a {@link Timestamp} to a {@link LocalDateTime}.
* This method will only work for timestamp's stored using {@link #CENTRAL_ZONE}, if stored using

View File

@ -3,6 +3,7 @@ package mineplex.core.common.util;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@ -10,19 +11,16 @@ import org.bukkit.World.Environment;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
public class UtilWorld
{
public static World getWorld(String world)
{
return UtilServer.getServer().getWorld(world);
return Bukkit.getServer().getWorld(world);
}
public static boolean areChunksEqual(Location first, Location second)
@ -100,7 +98,7 @@ public class UtilWorld
try
{
for (World cur : UtilServer.getServer().getWorlds())
for (World cur : Bukkit.getServer().getWorlds())
{
if (cur.getName().equalsIgnoreCase(parts[0]))
{
@ -154,7 +152,7 @@ public class UtilWorld
try
{
for (World cur : UtilServer.getServer().getWorlds())
for (World cur : Bukkit.getServer().getWorlds())
{
if (cur.getName().equalsIgnoreCase(tokens[0]))
{
@ -188,7 +186,7 @@ public class UtilWorld
public static World getWorldType(Environment env)
{
for (World cur : UtilServer.getServer().getWorlds())
for (World cur : Bukkit.getServer().getWorlds())
if (cur.getEnvironment() == env)
return cur;
@ -305,16 +303,4 @@ public class UtilWorld
return startX >= minX && startZ <= maxX && endX >= minZ && endZ <= maxZ;
}
public static double distanceSquared(Entity a, Entity b)
{
if (a.getWorld() != b.getWorld())
throw new IllegalArgumentException("Different worlds: " + a.getWorld().getName() + " and " + b.getWorld().getName());
net.minecraft.server.v1_8_R3.Entity entityA = ((CraftEntity) a).getHandle();
net.minecraft.server.v1_8_R3.Entity entityB = ((CraftEntity) b).getHandle();
double dx = entityA.locX - entityB.locX;
double dy = entityA.locY - entityB.locY;
double dz = entityA.locZ - entityB.locZ;
return (dx * dx) + (dy * dy) + (dz * dz);
}
}

View File

@ -20,6 +20,11 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core-common-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-serverdata</artifactId>

View File

@ -615,30 +615,7 @@ public class UtilBlock
public static ArrayList<Block> getSurrounding(Block block, boolean diagonals)
{
ArrayList<Block> blocks = new ArrayList<Block>();
if (diagonals)
{
for (int x = -1; x <= 1; x++)
for (int z = -1; z <= 1; z++)
for (int y = 1; y >= -1; y--)
{
if (x == 0 && y == 0 && z == 0) continue;
blocks.add(block.getRelative(x, y, z));
}
}
else
{
blocks.add(block.getRelative(BlockFace.UP));
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.WEST));
blocks.add(block.getRelative(BlockFace.DOWN));
}
return blocks;
return UtilBlockBase.getSurrounding(block, diagonals);
}
public static boolean isVisible(Block block)

View File

@ -348,42 +348,22 @@ public class UtilPlayer
public static void message(Entity client, LinkedList<String> messageList)
{
message(client, messageList, false);
UtilPlayerBase.message(client, messageList);
}
public static void message(Entity client, String message)
{
message(client, message, false);
UtilPlayerBase.message(client, message);
}
public static void message(Entity client, LinkedList<String> messageList, boolean wiki)
{
for (String curMessage : messageList)
{
message(client, curMessage, wiki);
}
UtilPlayerBase.message(client, messageList, wiki);
}
public static void message(Entity client, String message, boolean wiki)
{
if (client == null)
return;
if (!(client instanceof Player))
return;
/*
if (wiki)
message = UtilWiki.link(message);
*/
PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message));
if (event.isCancelled())
return;
((Player) client).sendMessage(message);
UtilPlayerBase.message(client, message, wiki);
}
public static Player searchExact(String name)
@ -454,44 +434,7 @@ public class UtilPlayer
public static Player searchOnline(Player caller, String player, boolean inform)
{
LinkedList<Player> matchList = new LinkedList<Player>();
for (Player cur : UtilServer.getPlayers())
{
if (cur.getName().equalsIgnoreCase(player))
return cur;
if (cur.getName().toLowerCase().contains(player.toLowerCase()))
matchList.add(cur);
}
// No / Non-Unique
if (matchList.size() != 1)
{
if (!inform)
return null;
// Inform
message(caller,
F.main("Online Player Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem
+ player + C.mBody + "]."));
if (matchList.size() > 0)
{
String matchString = "";
for (Player cur : matchList)
matchString += F.elem(cur.getName()) + ", ";
if (matchString.length() > 1)
matchString = matchString.substring(0, matchString.length() - 2);
message(caller,
F.main("Online Player Search", "" + C.mBody + "Matches [" + C.mElem + matchString + C.mBody + "]."));
}
return null;
}
return matchList.get(0);
return UtilPlayerBase.searchOnline(caller, player, inform);
}
public static void searchOffline(List<String> matches, final Callback<String> callback, final Player caller,

View File

@ -10,10 +10,11 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.ArrowEffectGadget;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class ArrowTrailCandyCane extends ArrowEffectGadget
{
@ -29,7 +30,7 @@ public class ArrowTrailCandyCane extends ArrowEffectGadget
public void doTrail(Arrow arrow)
{
int data = 15;
int tick = Math.abs(UtilTime.getServerTick()%3);
int tick = Math.abs(MinecraftServer.currentTick%3);
if(tick == 1) data = 1;
if(tick == 2) data = 2;
Location loc = arrow.getLocation();

View File

@ -13,6 +13,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Location;
public class WorldManager extends MiniPlugin
{
@ -77,6 +78,9 @@ public class WorldManager extends MiniPlugin
{
List<Player> players = world.getPlayers();
Map<EntityType, Set<Entity>> entities = new HashMap<>();
// For optimization reasons reuse location objects
Location entityLocation = new Location(world, 0, 0, 0);
Location playerLocation = new Location(world, 0, 0, 0);
for (Entity entity : world.getEntities())
{
@ -104,11 +108,11 @@ public class WorldManager extends MiniPlugin
else if (CULL_LIMITS.containsKey(entityType))
{
boolean cull = true;
entity.getLocation(entityLocation);
for (Player player : players)
{
// Using NMS because this is going to be called quite a few times
// and each getLocation() call creates a new Location object
if (UtilWorld.distanceSquared(player, entity) <= MIN_RANGE_SQUARED)
player.getLocation(playerLocation);
if (playerLocation.distanceSquared(entityLocation) <= MIN_RANGE_SQUARED)
{
cull = false;
break;

View File

@ -14,9 +14,13 @@
<artifactId>mineplex-mapparser</artifactId>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core-common</artifactId>
<artifactId>mineplex-core-common-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -23,9 +24,8 @@ import com.google.common.collect.Sets;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilBlockBase;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.command.AddLoreCommand;
import mineplex.mapparser.command.AddSplashTextCommand;
import mineplex.mapparser.command.AdminCommand;
@ -144,7 +144,7 @@ public class MapParser extends JavaPlugin
public void sendValidGameTypes(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Valid Game Types;"));
UtilPlayerBase.message(player, F.main("Parser", "Valid Game Types;"));
String gameTypes = "";
@ -256,7 +256,7 @@ public class MapParser extends JavaPlugin
public void announce(String msg)
{
for (Player player : UtilServer.getPlayers())
for (Player player : Bukkit.getOnlinePlayers())
{
player.sendMessage(C.cGold + msg);
}
@ -390,7 +390,7 @@ public class MapParser extends JavaPlugin
if (!blocks.add(current))
return blocks;
for (Block other : UtilBlock.getSurrounding(current, true))
for (Block other : UtilBlockBase.getSurrounding(current, true))
{
if (current.getType() != Material.LOG && current.getType() != Material.LEAVES)
continue;

View File

@ -1,6 +1,5 @@
package mineplex.mapparser;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.ZipUtil;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
@ -24,7 +23,7 @@ public class WorldManager
public World prepMapParse(World world)
{
//Unload World
MapUtil.UnloadWorld(Host, world, true);
Host.getServer().unloadWorld(world, true);
//Delete Non-Map Files
String[] folders = new File(world.getName()).list();
@ -69,7 +68,7 @@ public class WorldManager
public void finalizeParsedWorld(World world)
{
MapUtil.UnloadWorld(Host, world, true);
Host.getServer().unloadWorld(world, true);
ArrayList<String> fileList = new ArrayList<String>();
ArrayList<String> dirList = new ArrayList<String>();

View File

@ -4,7 +4,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
@ -42,7 +42,7 @@ public class AdminCommand extends BaseCommand
return true;
}
Player other = UtilPlayer.searchOnline(player, args[0], true);
Player other = UtilPlayerBase.searchOnline(player, args[0], true);
if (player != null)
{

View File

@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapParser;
/**
@ -59,6 +59,6 @@ public abstract class BaseCommand
protected void message(Player player, String message)
{
UtilPlayer.message(player, F.main("Parser", message));
UtilPlayerBase.message(player, F.main("Parser", message));
}
}

View File

@ -7,7 +7,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils;
@ -73,7 +72,7 @@ public class CopyCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for copy...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
}
File source = new File(worldName);

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils;
@ -66,7 +65,7 @@ public class DeleteCommand extends BaseCommand
//Unload World
//Things break if this isn't set to true for saving the world
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
}
//Delete

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
@ -69,7 +68,7 @@ public class GameTypeCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation());
message(player, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
File typeFolder = new File("map/" + type.GetName());
if (!typeFolder.exists())

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
@ -28,7 +28,7 @@ public class ListCommand extends BaseCommand
{
if (args.length == 0)
{
UtilPlayer.message(player, F.main("Parser", "Listing Maps;"));
UtilPlayerBase.message(player, F.main("Parser", "Listing Maps;"));
boolean colorSwitch = false;
@ -60,7 +60,7 @@ public class ListCommand extends BaseCommand
}
}
UtilPlayer.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName())));
UtilPlayerBase.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName())));
listMaps(player, gameType, false);
}

View File

@ -1,7 +1,7 @@
package mineplex.mapparser.command;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
@ -32,7 +32,7 @@ public class MapCommand extends BaseCommand
{
if (args.length < 1)
{
//UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]")));
//UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]")));
return false;
}
@ -50,7 +50,7 @@ public class MapCommand extends BaseCommand
{
message(player, "Found more than one possible match:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
UtilPlayerBase.message(player, s);
return true;
}
@ -126,9 +126,9 @@ public class MapCommand extends BaseCommand
MapData data = getPlugin().getData(worldName);
UtilPlayer.message(player, F.value("Map Name", data.MapName));
UtilPlayer.message(player, F.value("Author", data.MapCreator));
UtilPlayer.message(player, F.value("Game Type", data.MapGameType.GetName()));
UtilPlayerBase.message(player, F.value("Map Name", data.MapName));
UtilPlayerBase.message(player, F.value("Author", data.MapCreator));
UtilPlayerBase.message(player, F.value("Game Type", data.MapGameType.GetName()));
return true;
}
}

View File

@ -2,7 +2,6 @@ package mineplex.mapparser.command;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.MapParser;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -38,14 +37,14 @@ public class PMCommand extends BaseCommand
{
builder.append(s).append(" ");
}
for (Player ops : UtilServer.getPlayers())
for (Player ops : getPlugin().getServer().getOnlinePlayers())
{
if (!ops.isOp())
{
continue;
}
ops.sendMessage(F.main("Message", builder.toString().trim()));
ops.playSound(ops.getLocation(), Sound.NOTE_PLING, 1.0f, 1.0f);
ops.playSound(ops.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f);
}
return true;

View File

@ -6,7 +6,6 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
@ -56,7 +55,7 @@ public class RenameCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
message(player, "World unloaded!");

View File

@ -6,8 +6,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapParser;
/**
@ -37,7 +36,7 @@ public class SaveCommand extends BaseCommand
{
message(player, "More than one map found:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
UtilPlayerBase.message(player, s);
return true;
}
@ -63,7 +62,7 @@ public class SaveCommand extends BaseCommand
other.teleport(getPlugin().getSpawnLocation());
//Unload World
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
}
else
{

View File

@ -3,8 +3,6 @@ package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**

View File

@ -2,7 +2,7 @@ package mineplex.mapparser.module.modules;
import com.google.common.collect.Maps;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.MapParser;
import mineplex.mapparser.command.BaseCommand;
import mineplex.mapparser.module.Module;
@ -38,7 +38,7 @@ public class CommandModule extends Module
if (getPlugin().getCurParse() != null)
{
UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
UtilPlayerBase.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
return;
}
if (event.getMessage().toLowerCase().startsWith("/help"))
@ -83,8 +83,8 @@ public class CommandModule extends Module
if (!baseCommand.execute(player, commandLabel, args))
{
UtilPlayer.message(player, F.main("Parser", "Invalid Input."));
UtilPlayer.message(player, F.elem(baseCommand.getUsage()));
UtilPlayerBase.message(player, F.main("Parser", "Invalid Input."));
UtilPlayerBase.message(player, F.elem(baseCommand.getUsage()));
}
}

View File

@ -27,9 +27,7 @@ import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.mapparser.BackupTask;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
@ -135,7 +133,7 @@ public class EventModule extends Module
if (world.getPlayers().isEmpty())
{
getPlugin().announce("Saving & Closing World: " + F.elem(world.getName()));
MapUtil.UnloadWorld(getPlugin(), world, true);
getPlugin().getServer().unloadWorld(world, true);
_updated.remove(world);
getPlugin()._mapsBeingZipped.add(world.getName());
System.out.println("Starting backup of " + world);
@ -164,7 +162,7 @@ public class EventModule extends Module
String grayName = C.cBlue + event.getPlayer().getName();
String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName();
for (Player player : UtilServer.getPlayers())
for (Player player : getPlugin().getServer().getOnlinePlayers())
{
if (player.getWorld().equals(event.getPlayer().getWorld()))
{
@ -212,7 +210,7 @@ public class EventModule extends Module
event.setCancelled(true);
Player target = UtilPlayer.searchOnline(player, tokens[1], true);
Player target = UtilPlayerBase.searchOnline(player, tokens[1], true);
if (target != null)
{
if (!target.getWorld().getName().equals("world"))
@ -224,7 +222,7 @@ public class EventModule extends Module
return;
}
}
UtilPlayer.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + "."));
UtilPlayerBase.message(player, F.main("Game", "You teleported to " + F.name(target.getName()) + "."));
player.teleport(target);
}
}
@ -246,7 +244,7 @@ public class EventModule extends Module
//Permission
if (!getPlugin().getData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
UtilPlayerBase.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
event.setCancelled(true);
}
}
@ -276,10 +274,10 @@ public class EventModule extends Module
player.setFlySpeed(speed);
UtilPlayer.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + "."));
UtilPlayerBase.message(player, F.main("Game", "Fly Speed set to " + F.elem("" + speed) + "."));
} catch (Exception e)
{
UtilPlayer.message(player, F.main("Game", "Invalid Speed Input."));
UtilPlayerBase.message(player, F.main("Game", "Invalid Speed Input."));
}
}

View File

@ -14,7 +14,8 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Crypt
{
@ -42,10 +43,10 @@ public class Crypt
{
if(isDestroyed()) return false;
Integer lastTime = _damageCooldown.get(mob);
if(lastTime != null && lastTime > UtilTime.getServerTick()) return false;
if(lastTime != null && lastTime > MinecraftServer.currentTick) return false;
_health -= damage;
_damageCooldown.put(mob, UtilTime.getServerTick() + cooldown);
_damageCooldown.put(mob, MinecraftServer.currentTick + cooldown);
updateState(damage);

View File

@ -21,6 +21,7 @@
<module>Mineplex.Cache</module>
<module>Mineplex.Core</module>
<module>Mineplex.Core.Common</module>
<module>Mineplex.Core.Common.Base</module>
<module>Mineplex.Database</module>
<module>Mineplex.DDoSProtectionSwitcher</module>
<module>Mineplex.EnjinTranslator</module>
@ -36,7 +37,7 @@
<module>Mineplex.ServerData</module>
<module>Mineplex.ServerMonitor</module>
<module>Mineplex.StaffServer</module>
<module>Mineplex.Votifier</module>
<module>Mineplex.Votifier</module>
<module>Nautilus.Game.Arcade</module>
<module>Nautilus.Game.Arcade.UHC.WorldGen</module>
@ -51,10 +52,20 @@
<id>mineplex</id>
<url>http://dev.mineplex.com:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<id>spigotmc-public</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@ -68,7 +79,7 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<groupId>com.vexsoftware</groupId>
<artifactId>votifier</artifactId>
<version>1.9</version>
<scope>provided</scope>
@ -133,6 +144,12 @@
<version>3.5.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.mineplex</groupId>
<artifactId>spigot</artifactId>