Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-10-17 13:20:09 +11:00
commit 5fb4f3324d
13 changed files with 352 additions and 57 deletions

View File

@ -0,0 +1,73 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
public class PacketPlayOutChat
extends Packet
{
private IChatBaseComponent a;
private boolean b;
private byte _chatType = 0;
public PacketPlayOutChat()
{
this.b = true;
}
public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent)
{
this(ichatbasecomponent, true);
}
public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, boolean flag)
{
this.b = true;
this.a = ichatbasecomponent;
this.b = flag;
}
public PacketPlayOutChat(String text)
{
this(ChatSerializer.a(text));
}
public void a(PacketDataSerializer packetdataserializer)
throws IOException
{
this.a = ChatSerializer.a(packetdataserializer.c(32767));
}
public void b(PacketDataSerializer packetdataserializer)
throws IOException
{
packetdataserializer.a(ChatSerializer.a(this.a));
if (packetdataserializer.version >= 16) {
packetdataserializer.writeByte(_chatType);
}
}
public void setChatType(byte chatType)
{
_chatType = chatType;
}
public void a(PacketPlayOutListener packetplayoutlistener)
{
packetplayoutlistener.a(this);
}
public String b()
{
return String.format("message='%s'", new Object[] { this.a });
}
public boolean d()
{
return this.b;
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayOutListener)packetlistener);
}
}

Binary file not shown.

View File

@ -1,7 +1,11 @@
package mineplex.core.common.jsonchat; package mineplex.core.common.jsonchat;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
public class JsonMessage public class JsonMessage
@ -63,4 +67,53 @@ public class JsonMessage
{ {
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + player.getName() + " " + toString()); UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + player.getName() + " " + toString());
} }
/**
* Send a message to players using the new 1.8 message types
*
* @param messageType Message type to send
* @param players Players to send to
*/
public void send(MessageType messageType, Player... players)
{
send(messageType, false, players);
}
/**
* Send a message to players using the new 1.8 message types
*
* @param messageType Message type to send
* @param defaultToChat Only applies to MessageType.ABOVE_HOTBAR. If true, it will send this to chat for 1.7 clients
* @param players Players to send to
*/
public void send(MessageType messageType, boolean defaultToChat, Player... players)
{
PacketPlayOutChat chatPacket = new PacketPlayOutChat(ChatSerializer.a(toString()));
chatPacket.setChatType(messageType.getId());
for (Player player : players)
{
if (defaultToChat || messageType != MessageType.ABOVE_HOTBAR || UtilPlayer.is1_8(player))
((CraftPlayer) player).getHandle().playerConnection.sendPacket(chatPacket);
}
}
public static enum MessageType
{
CHAT_BOX((byte) 0), // Inside Chat Box
SYSTEM_MESSAGE((byte) 1), // Inside Chat Box - This is used for the client to identify difference between chat message and server messages
ABOVE_HOTBAR((byte) 2); // Shows above hotbar
private byte _id;
MessageType(byte id)
{
_id = id;
}
public byte getId()
{
return _id;
}
}
} }

View File

@ -0,0 +1,51 @@
package mineplex.core.donation;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class CoinCommand extends CommandBase<DonationManager>
{
public CoinCommand(DonationManager plugin)
{
super(plugin, Rank.ADMIN, "coin");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Coin", "Missing Args"));
return;
}
//Try Online
final Player target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
return;
//Give Coins to Target
try
{
final int coins = Integer.parseInt(args[1]);
Plugin.RewardCoins(new Callback<Boolean>()
{
public void run(Boolean completed)
{
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(target.getName()) + "."));
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
}
}, caller.getName(), target.getName(), target.getUniqueId(), coins);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount"));
}
}
}

View File

@ -2,6 +2,11 @@ package mineplex.core.donation;
import java.util.UUID; import java.util.UUID;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.account.event.ClientWebResponseEvent;
@ -14,11 +19,6 @@ import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
public class DonationManager extends MiniPlugin public class DonationManager extends MiniPlugin
{ {
private DonationRepository _repository; private DonationRepository _repository;
@ -42,6 +42,7 @@ public class DonationManager extends MiniPlugin
public void AddCommands() public void AddCommands()
{ {
AddCommand(new GemCommand(this)); AddCommand(new GemCommand(this));
AddCommand(new CoinCommand(this));
} }
@EventHandler @EventHandler

View File

@ -29,8 +29,8 @@ public class Npc
public void setEntity(LivingEntity entity) public void setEntity(LivingEntity entity)
{ {
if (entity != null) if (_entity != null)
getNpcManager()._npcMap.remove(entity.getUniqueId()); getNpcManager()._npcMap.remove(_entity.getUniqueId());
_entity = entity; _entity = entity;

View File

@ -173,8 +173,7 @@ public class NpcManager extends MiniPlugin
public boolean isDetachedNpc(LivingEntity entity) public boolean isDetachedNpc(LivingEntity entity)
{ {
// Npc's name starts with ChatColor.RESET but it's missing from _npcMap return !isNpc(entity) && entity.getCustomName() != null && entity.getCustomName().startsWith(ChatColor.RESET.toString());
return !isNpc(entity) && entity.isCustomNameVisible() && (entity.getCustomName() == null || entity.getCustomName().startsWith(ChatColor.RESET.toString()));
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@ -302,16 +301,13 @@ public class NpcManager extends MiniPlugin
LivingEntity entity = (LivingEntity) _creature.SpawnEntity(npc.getLocation(), EntityType.valueOf(npc.getDatabaseRecord().getEntityType())); LivingEntity entity = (LivingEntity) _creature.SpawnEntity(npc.getLocation(), EntityType.valueOf(npc.getDatabaseRecord().getEntityType()));
entity.setCustomNameVisible(true); entity.setCustomNameVisible(true);
if (npc.getDatabaseRecord().getName() != null) String name = npc.getDatabaseRecord().getName() == null ? "" : npc.getDatabaseRecord().getName();
{ for (ChatColor color : ChatColor.values())
String name = npc.getDatabaseRecord().getName(); name = name.replace("(" + color.name().toLowerCase() + ")", color.toString());
for (ChatColor color : ChatColor.values())
name = name.replace("(" + color.name().toLowerCase() + ")", color.toString());
name = ChatColor.translateAlternateColorCodes('&', name); name = ChatColor.translateAlternateColorCodes('&', name);
entity.setCustomName(ChatColor.RESET + name); entity.setCustomName(ChatColor.RESET + name);
}
entity.setCanPickupItems(false); entity.setCanPickupItems(false);
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);
@ -521,6 +517,9 @@ public class NpcManager extends MiniPlugin
if (event.getType() != UpdateType.SEC) if (event.getType() != UpdateType.SEC)
return; return;
if (Bukkit.getOnlinePlayers().isEmpty())
return;
for (World world : Bukkit.getWorlds()) for (World world : Bukkit.getWorlds())
{ {
for (LivingEntity livingEntity : world.getEntitiesByClass(LivingEntity.class)) for (LivingEntity livingEntity : world.getEntitiesByClass(LivingEntity.class))

View File

@ -1,13 +1,13 @@
package mineplex.core.shop.item; package mineplex.core.shop.item;
import mineplex.core.common.util.UtilInv;
import net.minecraft.server.v1_7_R4.NBTTagList;
import net.minecraft.server.v1_7_R4.NBTTagString;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.NBTTagList;
import net.minecraft.server.v1_7_R4.NBTTagString;
import mineplex.core.common.util.UtilInv;
public class ShopItem extends CraftItemStack public class ShopItem extends CraftItemStack
{ {
@ -27,7 +27,8 @@ public class ShopItem extends CraftItemStack
_displayItem = displayItem; _displayItem = displayItem;
_deliveryAmount = deliveryAmount; _deliveryAmount = deliveryAmount;
getHandle().tag = ((CraftItemStack)itemStack).getHandle().tag; CraftItemStack craftItem = CraftItemStack.asCraftCopy(itemStack);
getHandle().tag = craftItem.getHandle().tag;
UpdateVisual(true); UpdateVisual(true);
getHandle().tag.set("AttributeModifiers", new NBTTagList()); getHandle().tag.set("AttributeModifiers", new NBTTagList());

View File

@ -8,7 +8,6 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.ServerListPingEvent;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
@ -240,7 +239,10 @@ public class NewsManager extends MiniPlugin
{ {
_newsIndex = (_newsIndex + 1)%_news.length; _newsIndex = (_newsIndex + 1)%_news.length;
_newsTime = System.currentTimeMillis(); _newsTime = System.currentTimeMillis();
}
// JsonMessage jsonMessage = new JsonMessage(_news[_newsIndex]);
// jsonMessage.send(JsonMessage.MessageType.ABOVE_HOTBAR, UtilServer.getPlayers());
}
if (_newsIndex >= _news.length) if (_newsIndex >= _news.length)
{ {
// Resets newsIndex if outside of bounds of news array after RefreshNews but before UtilTime.elapsed above // Resets newsIndex if outside of bounds of news array after RefreshNews but before UtilTime.elapsed above

View File

@ -88,7 +88,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
ChatColor.RESET + C.cGreen + timeLeft + " Remaining...", ChatColor.RESET + C.cGreen + timeLeft + " Remaining...",
ChatColor.RESET + "", ChatColor.RESET + "",
ChatColor.RESET + C.cYellow + "Free players must wait a " + (beta ? "long" : "short") + " time", ChatColor.RESET + C.cYellow + "Free players must wait a " + (beta ? "long" : "short") + " time",
ChatColor.RESET + C.cYellow + "to help lighten the load on our " + (beta ? "Beta" : "") + " servers.", ChatColor.RESET + C.cYellow + "to help lighten the load on our" + (beta ? " Beta" : "") + " servers.",
ChatColor.RESET + "", ChatColor.RESET + "",
ChatColor.RESET + C.cAqua + "Ultra and Hero players have", ChatColor.RESET + C.cAqua + "Ultra and Hero players have",
ChatColor.RESET + C.cAqua + "instant access to our servers!", ChatColor.RESET + C.cAqua + "instant access to our servers!",

View File

@ -0,0 +1,90 @@
package mineplex.mapparser;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.ZipUtil;
/**
* Created by shaun on 14-09-23.
*/
public class BackupTask implements Runnable
{
private final String _worldName;
private final Callback<Boolean> _callback;
private final JavaPlugin _plugin;
public BackupTask(JavaPlugin plugin, String worldName, Callback<Boolean> callback)
{
_plugin = plugin;
_worldName = worldName;
_callback = callback;
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this);
}
@Override
public void run()
{
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
List<String> fileList = new ArrayList<String>();
List<String> folderList = new ArrayList<String>();
String dest = "backup" + _worldName.substring(3) + "/" + format.format(date) + ".zip";
File srcFile = new File(_worldName);
// Create backup folder if it doesnt already exist
File folder = new File(dest.substring(0, dest.lastIndexOf('/')));
if (!folder.exists())
folder.mkdirs();
// Get all files to backup
for (File file : srcFile.listFiles())
{
if (file.isFile())
fileList.add(_worldName + File.separator + file.getName());
else if (file.isDirectory())
folderList.add(_worldName + File.separator + file.getName());
}
// Delete old folders if more than 20 backups exist
if (folder.listFiles().length > 20)
{
File[] files = folder.listFiles();
File oldestFile = files[0];
for (int i = 1; i < files.length; i++)
{
File file = files[i];
if (file.getName().endsWith(".zip") && file.lastModified() < oldestFile.lastModified())
{
oldestFile = file;
}
}
System.out.println("Deleting oldest file: " + oldestFile.getName());
oldestFile.delete();
}
ZipUtil.ZipFolders(srcFile.getAbsolutePath(), dest, folderList, fileList);
if (_callback != null)
{
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
{
@Override
public void run()
{
_callback.run(true);
}
});
}
}
}

View File

@ -3,6 +3,7 @@ package mineplex.mapparser;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -30,19 +31,19 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.mapparser.command.AdminCommand;
import mineplex.mapparser.command.AuthorCommand; import mineplex.mapparser.command.AuthorCommand;
import mineplex.mapparser.command.BaseCommand; import mineplex.mapparser.command.BaseCommand;
import mineplex.mapparser.command.AdminCommand;
import mineplex.mapparser.command.CopyCommand; import mineplex.mapparser.command.CopyCommand;
import mineplex.mapparser.command.CopySchematicsCommand; import mineplex.mapparser.command.CopySchematicsCommand;
import mineplex.mapparser.command.CreateCommand; import mineplex.mapparser.command.CreateCommand;
@ -60,22 +61,23 @@ import mineplex.mapparser.command.WorldsCommand;
public class MapParser extends JavaPlugin implements Listener public class MapParser extends JavaPlugin implements Listener
{ {
private WorldManager _worldManager; private WorldManager _worldManager;
private Parse _curParse = null; private Parse _curParse = null;
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>(); private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
private HashSet<String> _mapsBeingZipped = new HashSet<String>();
private List<BaseCommand> _commands = new ArrayList<BaseCommand>(); private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
private Location _spawnLocation; private Location _spawnLocation;
@Override @Override
public void onEnable() public void onEnable()
{ {
_worldManager = new WorldManager(this); _worldManager = new WorldManager(this);
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(this, this);
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0); getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
_spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0); _spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0);
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
@ -99,24 +101,24 @@ public class MapParser extends JavaPlugin implements Listener
@Override @Override
public void onDisable() public void onDisable()
{ {
} }
@EventHandler @EventHandler
public void PlayerJoin(PlayerJoinEvent event) public void PlayerJoin(PlayerJoinEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
player.teleport(getSpawnLocation()); player.teleport(getSpawnLocation());
ResetInventory(event.getPlayer()); ResetInventory(event.getPlayer());
DisplayHelp(player); DisplayHelp(player);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
player.addAttachment(plugin, "worldedit.*", true); player.addAttachment(plugin, "worldedit.*", true);
} }
public void DisplayHelp(Player player) public void DisplayHelp(Player player)
{ {
UtilPlayer.message(player, F.main("Parser", "Listing Commands;")); UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
@ -137,12 +139,12 @@ public class MapParser extends JavaPlugin implements Listener
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map")); UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
UtilPlayer.message(player, " "); UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps"); UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
} }
@EventHandler @EventHandler
public void Command(PlayerCommandPreprocessEvent event) public void Command(PlayerCommandPreprocessEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
String[] parts = event.getMessage().split(" "); String[] parts = event.getMessage().split(" ");
@ -158,7 +160,7 @@ public class MapParser extends JavaPlugin implements Listener
if (event.getMessage().toLowerCase().startsWith("/help")) if (event.getMessage().toLowerCase().startsWith("/help"))
{ {
event.setCancelled(true); event.setCancelled(true);
DisplayHelp(player); DisplayHelp(player);
} }
@ -200,13 +202,13 @@ public class MapParser extends JavaPlugin implements Listener
{ {
if (_curParse == null) if (_curParse == null)
return; return;
if (_curParse.Update()) if (_curParse.Update())
{ {
Announce("Parse Completed!"); Announce("Parse Completed!");
Announce("Cleaning and Creating ZIP..."); Announce("Cleaning and Creating ZIP...");
try try
{ {
_worldManager.finalizeParsedWorld(_curParse.getWorld()); _worldManager.finalizeParsedWorld(_curParse.getWorld());
@ -216,42 +218,42 @@ public class MapParser extends JavaPlugin implements Listener
Announce("Creating ZIP Failed! Please Try Again!"); Announce("Creating ZIP Failed! Please Try Again!");
e.printStackTrace(); e.printStackTrace();
} }
_curParse = null; _curParse = null;
} }
} }
@EventHandler @EventHandler
public void DisableCreatures(EntitySpawnEvent event) public void DisableCreatures(EntitySpawnEvent event)
{ {
if (event.getEntityType() == EntityType.DROPPED_ITEM || event.getEntity() instanceof LivingEntity) if (event.getEntityType() == EntityType.DROPPED_ITEM || event.getEntity() instanceof LivingEntity)
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void DisableBurn(BlockBurnEvent event) public void DisableBurn(BlockBurnEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void DisableFire(BlockSpreadEvent event) public void DisableFire(BlockSpreadEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void DisableFade(BlockFadeEvent event) public void DisableFade(BlockFadeEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void DisableDecay(LeavesDecayEvent event) public void DisableDecay(LeavesDecayEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void Updates(PlayerMoveEvent event) public void Updates(PlayerMoveEvent event)
{ {
@ -263,16 +265,16 @@ public class MapParser extends JavaPlugin implements Listener
world.setTime(8000); world.setTime(8000);
world.setStorm(false); world.setStorm(false);
} }
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
event.getPlayer().setGameMode(GameMode.CREATIVE); event.getPlayer().setGameMode(GameMode.CREATIVE);
} }
@EventHandler @EventHandler
public void SaveUnloadWorlds(TickEvent event) public void SaveUnloadWorlds(TickEvent event)
{ {
for (World world : getServer().getWorlds()) for (final World world : getServer().getWorlds())
{ {
if (world.getName().equalsIgnoreCase("world")) if (world.getName().equalsIgnoreCase("world"))
continue; continue;
@ -287,6 +289,18 @@ public class MapParser extends JavaPlugin implements Listener
{ {
Announce("Saving & Closing World: " + F.elem(world.getName())); Announce("Saving & Closing World: " + F.elem(world.getName()));
MapUtil.UnloadWorld(this, world, true); MapUtil.UnloadWorld(this, world, true);
_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());
}
});
} }
} }
} }
@ -488,6 +502,11 @@ public class MapParser extends JavaPlugin implements Listener
} }
} }
public HashSet<String> getMapsBeingZipped()
{
return _mapsBeingZipped;
}
@EventHandler @EventHandler
public void Join(PlayerJoinEvent event) public void Join(PlayerJoinEvent event)
{ {

View File

@ -72,6 +72,12 @@ public class MapCommand extends BaseCommand
worldName = getPlugin().getWorldString(args[0], gameType); worldName = getPlugin().getWorldString(args[0], gameType);
} }
if (getPlugin().getMapsBeingZipped().contains(worldName))
{
message(player, "That map is being backed up now. Try again soon");
return true;
}
World world = getPlugin().GetMapWorld(worldName); World world = getPlugin().GetMapWorld(worldName);
if (world == null) if (world == null)
{ {