Parser changes
This commit is contained in:
parent
94e5eb03da
commit
2ffcfb7737
@ -19,13 +19,13 @@ public class MapData
|
||||
public String MapName = "null";
|
||||
public String MapCreator = "null";
|
||||
|
||||
public HashSet<String> BuildList;
|
||||
public HashSet<String> AdminList;
|
||||
|
||||
public MapData(String mapFolder)
|
||||
{
|
||||
MapFolder = mapFolder;
|
||||
|
||||
BuildList = new HashSet<String>();
|
||||
AdminList = new HashSet<String>();
|
||||
|
||||
if ((new File(MapFolder + File.separator + "Map.dat")).exists())
|
||||
Read();
|
||||
@ -66,10 +66,10 @@ public class MapData
|
||||
{
|
||||
GameType = GameType.valueOf(tokens[1] == null ? "Null" : tokens[1]);
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("BUILD_LIST"))
|
||||
else if (tokens[0].equalsIgnoreCase("ADMIN_LIST"))
|
||||
{
|
||||
for (String cur : tokens[1].split(","))
|
||||
BuildList.add(cur);
|
||||
AdminList.add(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,12 +96,12 @@ public class MapData
|
||||
out.write("\n");
|
||||
out.write("GAME_TYPE:"+GameType);
|
||||
|
||||
String buildList = "";
|
||||
for (String cur : BuildList)
|
||||
buildList += cur + ",";
|
||||
String adminList = "";
|
||||
for (String cur : AdminList)
|
||||
adminList += cur + ",";
|
||||
|
||||
out.write("\n");
|
||||
out.write("BUILD_LIST:"+buildList);
|
||||
out.write("ADMIN_LIST:"+adminList);
|
||||
|
||||
out.close();
|
||||
}
|
||||
@ -111,9 +111,9 @@ public class MapData
|
||||
}
|
||||
}
|
||||
|
||||
public boolean CanBuild(Player player)
|
||||
public boolean HasAccess(Player player)
|
||||
{
|
||||
return BuildList.contains(player.getName()) || player.isOp();
|
||||
return AdminList.contains(player.getName()) || player.isOp();
|
||||
}
|
||||
|
||||
public boolean CanJoin(Player player)
|
||||
|
@ -39,7 +39,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.mapparser.command.AuthorCommand;
|
||||
import mineplex.mapparser.command.BaseCommand;
|
||||
import mineplex.mapparser.command.BuildCommand;
|
||||
import mineplex.mapparser.command.AdminCommand;
|
||||
import mineplex.mapparser.command.CopyCommand;
|
||||
import mineplex.mapparser.command.CopySchematicsCommand;
|
||||
import mineplex.mapparser.command.CreateCommand;
|
||||
@ -77,7 +77,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
|
||||
|
||||
_commands.add(new AuthorCommand(this));
|
||||
_commands.add(new BuildCommand(this));
|
||||
_commands.add(new AdminCommand(this));
|
||||
_commands.add(new CopySchematicsCommand(this));
|
||||
_commands.add(new CreateCommand(this));
|
||||
_commands.add(new DeleteCommand(this));
|
||||
@ -117,19 +117,19 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
|
||||
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
|
||||
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("/map <name> [gametype]", "Teleport to a map"));
|
||||
UtilPlayer.message(player, F.value("/list", "List maps"));
|
||||
UtilPlayer.message(player, F.value("/parse", "Parse your current map!"));
|
||||
UtilPlayer.message(player, " ");
|
||||
UtilPlayer.message(player, F.value("/join <name>", "Toggle join for player on map"));
|
||||
UtilPlayer.message(player, F.value("/build <name>", "Toggle build for player on map"));
|
||||
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"));
|
||||
UtilPlayer.message(player, F.value("/gametype <type>", "Set gametype for current map"));
|
||||
UtilPlayer.message(player, " ");
|
||||
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, " ");
|
||||
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
|
||||
|
||||
}
|
||||
@ -404,7 +404,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
public void ResetInventory(Player player)
|
||||
{
|
||||
UtilInv.Clear(player);
|
||||
UtilInv.Clear(player);
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_SPADE));
|
||||
@ -433,7 +433,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
|
||||
String name = C.cYellow + event.getPlayer().getName();
|
||||
if (GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
if (GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
||||
name = C.cGreen + event.getPlayer().getName();
|
||||
|
||||
String grayName = C.cBlue + event.getPlayer().getName();
|
||||
@ -459,7 +459,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
public void InteractCancel(PlayerInteractEvent event)
|
||||
{
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -471,7 +471,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
if (event.getMessage().startsWith("//"))
|
||||
{
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).HasAccess(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
|
||||
event.setCancelled(true);
|
||||
|
@ -41,7 +41,7 @@ public class AuthorCommand extends BaseCommand
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!getPlugin().GetData(world.getName()).CanBuild(player))
|
||||
if (!getPlugin().GetData(world.getName()).HasAccess(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
|
@ -1,68 +0,0 @@
|
||||
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.MapData;
|
||||
import mineplex.mapparser.MapParser;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/16/2014.
|
||||
*/
|
||||
public class BuildCommand extends BaseCommand
|
||||
{
|
||||
public BuildCommand(MapParser plugin)
|
||||
{
|
||||
super(plugin, "build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String alias, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
message(player, "Invalid Input. " + F.elem("/build <Name>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
|
||||
if (world.getName().equals("world"))
|
||||
{
|
||||
message(player, "Cannot change Build-List for Lobby.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!getPlugin().GetData(world.getName()).CanBuild(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = UtilPlayer.searchOnline(player, args[0], true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
MapData data = getPlugin().GetData(world.getName());
|
||||
|
||||
if (data.BuildList.contains(other.getName()))
|
||||
{
|
||||
data.BuildList.remove(other.getName());
|
||||
data.Write();
|
||||
|
||||
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(false) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.BuildList.add(other.getName());
|
||||
data.Write();
|
||||
|
||||
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(true) + ")");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class CreateCommand extends BaseCommand
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
message(player, "Invalid Input. " + F.elem("/create <MapName>"));
|
||||
message(player, "Invalid Input. " + F.elem("/create <MapName> <GameType>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public class CreateCommand extends BaseCommand
|
||||
|
||||
//Give Access
|
||||
MapData mapData = getPlugin().GetData(worldName);
|
||||
mapData.BuildList.add(player.getName());
|
||||
mapData.AdminList.add(player.getName());
|
||||
mapData.GameType = gameType;
|
||||
mapData.Write();
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class DeleteCommand extends BaseCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getPlugin().GetData(worldName).CanBuild(player))
|
||||
if (!getPlugin().GetData(worldName).HasAccess(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
|
@ -41,7 +41,7 @@ public class GameTypeCommand extends BaseCommand
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!getPlugin().GetData(world.getName()).CanBuild(player))
|
||||
if (!getPlugin().GetData(world.getName()).HasAccess(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
|
@ -43,7 +43,7 @@ public class NameCommand extends BaseCommand
|
||||
mapName = mapName.trim();
|
||||
|
||||
//Permission
|
||||
if (!getPlugin().GetData(world.getName()).CanBuild(player))
|
||||
if (!getPlugin().GetData(world.getName()).HasAccess(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
|
@ -1,12 +1,10 @@
|
||||
package mineplex.mapparser.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.mapparser.MapData;
|
||||
import mineplex.mapparser.MapParser;
|
||||
import mineplex.mapparser.Parse;
|
||||
@ -24,6 +22,12 @@ public class ParseCommand extends BaseCommand
|
||||
@Override
|
||||
public boolean execute(Player player, String alias, String[] args)
|
||||
{
|
||||
if (!player.isOp())
|
||||
{
|
||||
message(player, "Only OPs can parse maps!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Location parseLoc = player.getLocation();
|
||||
|
||||
World world = parseLoc.getWorld();
|
||||
|
@ -52,7 +52,7 @@ public class SaveCommand extends BaseCommand
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
if (!getPlugin().GetData(worldName).CanBuild(player))
|
||||
if (!getPlugin().GetData(worldName).HasAccess(player))
|
||||
{
|
||||
message(player, "You do not have Build-Access on this Map.");
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user