2014-06-15 02:12:08 +02:00
|
|
|
package mineplex.mapparser;
|
|
|
|
|
|
|
|
import java.io.File;
|
2014-08-16 22:50:33 +02:00
|
|
|
import java.util.ArrayList;
|
2014-07-09 00:13:30 +02:00
|
|
|
import java.util.HashMap;
|
2014-10-15 22:04:44 +02:00
|
|
|
import java.util.HashSet;
|
2014-08-16 22:50:33 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
2014-06-15 02:12:08 +02:00
|
|
|
|
2014-09-09 02:52:51 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2014-07-09 02:33:22 +02:00
|
|
|
import org.bukkit.ChatColor;
|
2014-07-05 08:04:46 +02:00
|
|
|
import org.bukkit.GameMode;
|
2014-06-15 02:12:08 +02:00
|
|
|
import org.bukkit.Location;
|
2014-07-09 02:33:22 +02:00
|
|
|
import org.bukkit.Material;
|
2014-06-26 05:53:28 +02:00
|
|
|
import org.bukkit.World;
|
2014-07-05 08:04:46 +02:00
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
2014-06-15 02:12:08 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
2014-08-15 07:28:50 +02:00
|
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
|
|
|
import org.bukkit.event.block.BlockFadeEvent;
|
|
|
|
import org.bukkit.event.block.BlockSpreadEvent;
|
|
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
2014-07-05 08:04:46 +02:00
|
|
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
2014-07-09 02:33:22 +02:00
|
|
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
2014-06-15 02:12:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
2014-07-09 02:33:22 +02:00
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
2014-07-08 01:23:55 +02:00
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
2014-07-05 08:04:46 +02:00
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
2014-07-09 02:33:22 +02:00
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
2014-09-09 02:52:51 +02:00
|
|
|
import org.bukkit.plugin.Plugin;
|
2014-06-15 02:12:08 +02:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2014-08-17 03:17:21 +02:00
|
|
|
import mineplex.core.common.util.C;
|
2014-10-15 22:04:44 +02:00
|
|
|
import mineplex.core.common.util.Callback;
|
2014-08-17 03:17:21 +02:00
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.MapUtil;
|
|
|
|
import mineplex.core.common.util.UtilInv;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-10-15 22:04:44 +02:00
|
|
|
import mineplex.mapparser.command.AdminCommand;
|
2014-08-17 03:17:21 +02:00
|
|
|
import mineplex.mapparser.command.AuthorCommand;
|
|
|
|
import mineplex.mapparser.command.BaseCommand;
|
|
|
|
import mineplex.mapparser.command.CopyCommand;
|
|
|
|
import mineplex.mapparser.command.CopySchematicsCommand;
|
|
|
|
import mineplex.mapparser.command.CreateCommand;
|
|
|
|
import mineplex.mapparser.command.DeleteCommand;
|
|
|
|
import mineplex.mapparser.command.GameTypeCommand;
|
|
|
|
import mineplex.mapparser.command.HubCommand;
|
|
|
|
import mineplex.mapparser.command.ListCommand;
|
|
|
|
import mineplex.mapparser.command.MapCommand;
|
|
|
|
import mineplex.mapparser.command.NameCommand;
|
|
|
|
import mineplex.mapparser.command.ParseCommand;
|
|
|
|
import mineplex.mapparser.command.RenameCommand;
|
|
|
|
import mineplex.mapparser.command.SaveCommand;
|
|
|
|
import mineplex.mapparser.command.WorldsCommand;
|
|
|
|
|
2014-06-15 02:12:08 +02:00
|
|
|
public class MapParser extends JavaPlugin implements Listener
|
|
|
|
{
|
2014-06-26 05:53:28 +02:00
|
|
|
private WorldManager _worldManager;
|
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
private Parse _curParse = null;
|
2014-07-09 00:13:30 +02:00
|
|
|
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
|
2014-10-15 22:04:44 +02:00
|
|
|
private HashSet<String> _mapsBeingZipped = new HashSet<String>();
|
2014-08-16 22:50:33 +02:00
|
|
|
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
|
2014-08-16 23:01:00 +02:00
|
|
|
private Location _spawnLocation;
|
2014-07-09 00:13:30 +02:00
|
|
|
|
2014-06-15 02:12:08 +02:00
|
|
|
@Override
|
|
|
|
public void onEnable()
|
|
|
|
{
|
2014-06-26 05:53:28 +02:00
|
|
|
_worldManager = new WorldManager(this);
|
|
|
|
|
|
|
|
getServer().getPluginManager().registerEvents(this, this);
|
2014-07-08 01:23:55 +02:00
|
|
|
|
|
|
|
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
|
2014-08-16 23:01:00 +02:00
|
|
|
_spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0);
|
2014-07-08 01:23:55 +02:00
|
|
|
|
|
|
|
//Updates
|
|
|
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
|
2014-08-16 22:50:33 +02:00
|
|
|
|
|
|
|
_commands.add(new AuthorCommand(this));
|
2014-08-20 03:02:12 +02:00
|
|
|
_commands.add(new AdminCommand(this));
|
2014-08-16 22:50:33 +02:00
|
|
|
_commands.add(new CopySchematicsCommand(this));
|
|
|
|
_commands.add(new CreateCommand(this));
|
|
|
|
_commands.add(new DeleteCommand(this));
|
|
|
|
_commands.add(new GameTypeCommand(this));
|
|
|
|
_commands.add(new HubCommand(this));
|
|
|
|
_commands.add(new ListCommand(this));
|
|
|
|
_commands.add(new MapCommand(this));
|
|
|
|
_commands.add(new NameCommand(this));
|
|
|
|
_commands.add(new ParseCommand(this));
|
|
|
|
_commands.add(new RenameCommand(this));
|
|
|
|
_commands.add(new SaveCommand(this));
|
|
|
|
_commands.add(new WorldsCommand(this));
|
2014-08-17 03:17:21 +02:00
|
|
|
_commands.add(new CopyCommand(this));
|
2014-06-15 02:12:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-07-08 01:23:55 +02:00
|
|
|
public void PlayerJoin(PlayerJoinEvent event)
|
2014-06-15 02:12:08 +02:00
|
|
|
{
|
2014-07-05 08:04:46 +02:00
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
2014-08-16 23:01:00 +02:00
|
|
|
player.teleport(getSpawnLocation());
|
2014-07-08 01:23:55 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
ResetInventory(event.getPlayer());
|
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
DisplayHelp(player);
|
2014-09-09 02:52:51 +02:00
|
|
|
|
|
|
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
|
|
|
player.addAttachment(plugin, "worldedit.*", true);
|
2014-07-08 01:23:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void DisplayHelp(Player player)
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
|
2014-08-16 22:50:33 +02:00
|
|
|
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
|
2014-07-08 01:23:55 +02:00
|
|
|
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
|
2014-07-09 02:33:22 +02:00
|
|
|
UtilPlayer.message(player, " ");
|
|
|
|
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));
|
|
|
|
UtilPlayer.message(player, F.value("/author <name>", "Set author for current map"));
|
2014-08-16 22:50:33 +02:00
|
|
|
UtilPlayer.message(player, F.value("/gametype <type>", "Set gametype for current map"));
|
2014-07-09 03:08:37 +02:00
|
|
|
UtilPlayer.message(player, " ");
|
2014-08-20 03:02:12 +02:00
|
|
|
UtilPlayer.message(player, F.value("/admin <name>", "Toggle admin for player on map"));
|
|
|
|
UtilPlayer.message(player, " ");
|
|
|
|
UtilPlayer.message(player, F.value("/create <name> [gametype]", "Creates a new map"));
|
|
|
|
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
|
|
|
|
UtilPlayer.message(player, F.value("/copy <name> <copy name>", "Copies an existing map"));
|
|
|
|
UtilPlayer.message(player, " ");
|
|
|
|
UtilPlayer.message(player, F.value("/list", "List maps"));
|
|
|
|
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
|
|
|
|
UtilPlayer.message(player, " ");
|
2014-07-09 03:08:37 +02:00
|
|
|
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
|
2014-07-09 02:33:22 +02:00
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Command(PlayerCommandPreprocessEvent event)
|
2014-10-15 22:04:44 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
String[] parts = event.getMessage().split(" ");
|
|
|
|
String commandLabel = parts[0].substring(1);
|
|
|
|
String[] args = new String[parts.length - 1];
|
|
|
|
System.arraycopy(parts, 1, args, 0, parts.length - 1);
|
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
if (_curParse != null)
|
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
|
2014-07-08 01:23:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event.getMessage().toLowerCase().startsWith("/help"))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
DisplayHelp(player);
|
2014-06-26 05:53:28 +02:00
|
|
|
}
|
2014-07-09 02:33:22 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
for (BaseCommand command : _commands)
|
2014-07-08 04:04:44 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
for (String alias : command.getAliases())
|
2014-07-08 21:18:43 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
if (alias.equalsIgnoreCase(commandLabel))
|
2014-07-09 02:33:22 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
if (!command.execute(player, commandLabel, args))
|
|
|
|
{
|
2014-08-17 03:17:21 +02:00
|
|
|
UtilPlayer.message(player, F.main("Parser", "Invalid Input."));
|
|
|
|
UtilPlayer.message(player, F.elem(command.getUsage()));
|
2014-08-16 22:50:33 +02:00
|
|
|
}
|
2014-07-08 04:04:44 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
event.setCancelled(true);
|
2014-07-08 01:23:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-08 01:23:55 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
public void sendValidGameTypes(Player player)
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, F.main("Parser", "Valid Game Types;"));
|
2014-07-08 01:23:55 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
String gameTypes = "";
|
2014-06-26 21:09:29 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
for (GameType game : GameType.values())
|
2014-07-09 02:33:22 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
gameTypes += game.toString() + " ";
|
2014-06-15 02:12:08 +02:00
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
|
|
|
player.sendMessage(gameTypes);
|
2014-07-08 01:23:55 +02:00
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
@EventHandler
|
|
|
|
public void ParseUpdate(TickEvent event)
|
|
|
|
{
|
|
|
|
if (_curParse == null)
|
2014-06-15 02:12:08 +02:00
|
|
|
return;
|
2014-07-08 01:23:55 +02:00
|
|
|
|
|
|
|
if (_curParse.Update())
|
2014-06-15 02:12:08 +02:00
|
|
|
{
|
2014-07-08 21:40:28 +02:00
|
|
|
Announce("Parse Completed!");
|
2014-07-08 21:18:43 +02:00
|
|
|
|
2014-07-08 21:40:28 +02:00
|
|
|
Announce("Cleaning and Creating ZIP...");
|
2014-07-08 01:23:55 +02:00
|
|
|
|
2014-07-08 21:40:28 +02:00
|
|
|
try
|
|
|
|
{
|
2014-07-09 00:13:30 +02:00
|
|
|
_worldManager.finalizeParsedWorld(_curParse.getWorld());
|
2014-07-08 21:40:28 +02:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Announce("Creating ZIP Failed! Please Try Again!");
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
_curParse = null;
|
2014-06-15 02:12:08 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-05 08:04:46 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void DisableCreatures(EntitySpawnEvent event)
|
|
|
|
{
|
|
|
|
if (event.getEntityType() == EntityType.DROPPED_ITEM || event.getEntity() instanceof LivingEntity)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
2014-08-15 07:28:50 +02:00
|
|
|
@EventHandler
|
|
|
|
public void DisableBurn(BlockBurnEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void DisableFire(BlockSpreadEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void DisableFade(BlockFadeEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void DisableDecay(LeavesDecayEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
2014-07-05 08:04:46 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Updates(PlayerMoveEvent event)
|
|
|
|
{
|
|
|
|
for (World world : this.getServer().getWorlds())
|
2014-08-06 03:07:49 +02:00
|
|
|
{
|
2014-10-15 07:57:25 +02:00
|
|
|
if (world.getName().toLowerCase().contains("halloween"))
|
|
|
|
world.setTime(16000);
|
|
|
|
else
|
|
|
|
world.setTime(8000);
|
2014-08-06 03:07:49 +02:00
|
|
|
world.setStorm(false);
|
|
|
|
}
|
|
|
|
|
2014-07-05 08:04:46 +02:00
|
|
|
|
|
|
|
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
|
|
event.getPlayer().setGameMode(GameMode.CREATIVE);
|
|
|
|
}
|
2014-07-08 01:23:55 +02:00
|
|
|
|
2014-07-08 04:04:44 +02:00
|
|
|
@EventHandler
|
|
|
|
public void SaveUnloadWorlds(TickEvent event)
|
|
|
|
{
|
2014-10-15 22:04:44 +02:00
|
|
|
for (final World world : getServer().getWorlds())
|
2014-07-08 04:04:44 +02:00
|
|
|
{
|
|
|
|
if (world.getName().equalsIgnoreCase("world"))
|
|
|
|
continue;
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-08 21:18:43 +02:00
|
|
|
if (world.getName().startsWith("parse_"))
|
|
|
|
continue;
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
if (!world.getName().startsWith("map"))
|
2014-07-08 21:18:43 +02:00
|
|
|
continue;
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-08 04:04:44 +02:00
|
|
|
if (world.getPlayers().isEmpty())
|
|
|
|
{
|
2014-08-17 03:17:21 +02:00
|
|
|
Announce("Saving & Closing World: " + F.elem(world.getName()));
|
2014-07-08 04:04:44 +02:00
|
|
|
MapUtil.UnloadWorld(this, world, true);
|
2014-10-15 22:04:44 +02:00
|
|
|
|
|
|
|
_mapsBeingZipped.add(world.getName());
|
|
|
|
System.out.println("Starting backup of " + world);
|
|
|
|
BackupTask backupTask = new BackupTask(this, world.getName(), new Callback<Boolean>()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void run(Boolean data)
|
|
|
|
{
|
|
|
|
System.out.println("Finished backup of " + world);
|
|
|
|
_mapsBeingZipped.remove(world.getName());
|
|
|
|
}
|
|
|
|
});
|
2014-07-08 04:04:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 22:04:44 +02:00
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
public void Announce(String msg)
|
|
|
|
{
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
player.sendMessage(C.cGold + msg);
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-08-24 08:45:47 +02:00
|
|
|
System.out.println("[Announce] " + msg);
|
2014-07-08 01:23:55 +02:00
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-08-16 22:50:33 +02:00
|
|
|
public boolean DoesMapExist(String mapName, GameType gameType)
|
2014-07-08 01:23:55 +02:00
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
return DoesMapExist(getWorldString(mapName, gameType));
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean DoesMapExist(String worldName)
|
|
|
|
{
|
|
|
|
File file = new File(worldName);
|
|
|
|
|
|
|
|
if (file.exists() && file.isDirectory())
|
|
|
|
return true;
|
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
|
|
|
public String getShortWorldName(String worldName)
|
|
|
|
{
|
|
|
|
int lastIndexOfSeperator = worldName.lastIndexOf('/');
|
|
|
|
|
|
|
|
if (lastIndexOfSeperator != -1)
|
|
|
|
return worldName.substring(lastIndexOfSeperator + 1);
|
|
|
|
|
|
|
|
return worldName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public World GetMapWorld(String mapName, GameType gameType)
|
|
|
|
{
|
|
|
|
return GetMapWorld(getWorldString(mapName, gameType));
|
|
|
|
}
|
|
|
|
|
|
|
|
public World GetMapWorld(String worldName)
|
2014-07-08 01:23:55 +02:00
|
|
|
{
|
|
|
|
for (World world : this.getServer().getWorlds())
|
|
|
|
{
|
2014-08-16 22:50:33 +02:00
|
|
|
if (world.getName().equals(worldName))
|
2014-07-08 01:23:55 +02:00
|
|
|
return world;
|
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
2014-07-08 01:23:55 +02:00
|
|
|
return null;
|
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
2014-08-17 03:17:21 +02:00
|
|
|
public String getWorldString(String mapName, GameType type)
|
2014-08-16 22:50:33 +02:00
|
|
|
{
|
2014-08-17 03:17:21 +02:00
|
|
|
return "map" + "/" + type.GetName() + "/" + mapName;
|
2014-08-16 22:50:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getMapsByName(String name)
|
|
|
|
{
|
|
|
|
name = name.toLowerCase();
|
|
|
|
|
|
|
|
List<String> maps = new LinkedList<String>();
|
|
|
|
boolean matchesExact = false;
|
|
|
|
|
|
|
|
for (GameType type : GameType.values())
|
|
|
|
{
|
|
|
|
ChatColor color = ChatColor.YELLOW;
|
|
|
|
|
|
|
|
File mapsFolder = new File("map" + File.separator + type.GetName());
|
|
|
|
if (!mapsFolder.exists())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (File file : mapsFolder.listFiles())
|
|
|
|
{
|
|
|
|
if (!file.isDirectory())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!file.getName().toLowerCase().contains(name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (file.getName().equalsIgnoreCase(name))
|
|
|
|
matchesExact = true;
|
|
|
|
|
|
|
|
maps.add(getWorldString(file.getName(), type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (matchesExact)
|
|
|
|
{
|
|
|
|
Iterator<String> it = maps.iterator();
|
|
|
|
while (it.hasNext())
|
|
|
|
{
|
|
|
|
String mapString = it.next();
|
|
|
|
|
|
|
|
if (!mapString.toLowerCase().endsWith(name))
|
|
|
|
{
|
|
|
|
it.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return maps;
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 00:13:30 +02:00
|
|
|
public MapData GetData(String mapName)
|
|
|
|
{
|
|
|
|
if (_mapData.containsKey(mapName))
|
|
|
|
return _mapData.get(mapName);
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 00:13:30 +02:00
|
|
|
MapData data = new MapData(mapName);
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 00:13:30 +02:00
|
|
|
_mapData.put(mapName, data);
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 00:13:30 +02:00
|
|
|
return data;
|
|
|
|
}
|
2014-08-16 23:01:00 +02:00
|
|
|
|
|
|
|
public Location getSpawnLocation()
|
|
|
|
{
|
|
|
|
return _spawnLocation;
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
public void ResetInventory(Player player)
|
|
|
|
{
|
2014-08-20 03:02:12 +02:00
|
|
|
UtilInv.Clear(player);
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
|
|
|
player.getInventory().addItem(new ItemStack(Material.STONE_SPADE));
|
|
|
|
player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
|
|
|
|
player.getInventory().addItem(new ItemStack(Material.STONE_AXE));
|
2014-08-20 02:39:41 +02:00
|
|
|
player.getInventory().addItem(new ItemStack(Material.WOOD_AXE));
|
2014-07-09 02:33:22 +02:00
|
|
|
}
|
2014-08-16 22:50:33 +02:00
|
|
|
|
|
|
|
public WorldManager getWorldManager()
|
|
|
|
{
|
|
|
|
return _worldManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCurrentParse(Parse parse)
|
|
|
|
{
|
|
|
|
_curParse = parse;
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Chat(AsyncPlayerChatEvent event)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
2014-08-16 22:50:33 +02:00
|
|
|
|
|
|
|
String world = C.cDGreen + C.Bold + getShortWorldName(event.getPlayer().getWorld().getName());
|
|
|
|
|
|
|
|
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
String name = C.cYellow + event.getPlayer().getName();
|
2014-08-20 03:02:12 +02:00
|
|
|
if (GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
2014-07-09 02:33:22 +02:00
|
|
|
name = C.cGreen + event.getPlayer().getName();
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
String grayName = C.cBlue + event.getPlayer().getName();
|
|
|
|
String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName();
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (player.getWorld().equals(event.getPlayer().getWorld()))
|
|
|
|
{
|
|
|
|
player.sendMessage(world + ChatColor.RESET + " " + name + ChatColor.RESET + " " + event.getMessage());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.sendMessage(grayWorld + ChatColor.RESET + " " + grayName + ChatColor.RESET + " " + C.cGray + event.getMessage());
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
System.out.println(world + ChatColor.RESET + " " + name + ChatColor.RESET + " " + event.getMessage());
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
@EventHandler
|
|
|
|
public void InteractCancel(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
//Permission
|
2014-08-20 03:02:12 +02:00
|
|
|
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
2014-07-09 02:33:22 +02:00
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
@EventHandler
|
|
|
|
public void WorldeditCancel(PlayerCommandPreprocessEvent event)
|
|
|
|
{
|
|
|
|
if (event.getMessage().startsWith("//"))
|
|
|
|
{
|
|
|
|
//Permission
|
2014-08-20 03:02:12 +02:00
|
|
|
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
2014-07-09 02:33:22 +02:00
|
|
|
{
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-15 22:04:44 +02:00
|
|
|
|
|
|
|
public HashSet<String> getMapsBeingZipped()
|
|
|
|
{
|
|
|
|
return _mapsBeingZipped;
|
|
|
|
}
|
2014-10-17 00:51:32 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Join(PlayerJoinEvent event)
|
|
|
|
{
|
|
|
|
event.setJoinMessage(F.sys("Player Join", event.getPlayer().getName()));
|
|
|
|
}
|
2014-10-15 07:57:25 +02:00
|
|
|
|
2014-07-09 02:33:22 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Join(PlayerQuitEvent event)
|
|
|
|
{
|
|
|
|
event.setQuitMessage(F.sys("Player Quit", event.getPlayer().getName()));
|
|
|
|
}
|
2014-06-15 02:12:08 +02:00
|
|
|
}
|