mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
more fixes.
This commit is contained in:
parent
ed3003a2f6
commit
33acc95d92
@ -143,6 +143,7 @@ public class Schematic extends SubCommand {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (counter>=plots.length) {
|
if (counter>=plots.length) {
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!");
|
PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!");
|
||||||
|
running = false;
|
||||||
Bukkit.getScheduler().cancelTask(task);
|
Bukkit.getScheduler().cancelTask(task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,8 +179,12 @@ public class Schematic extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId i;
|
if (running) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&cTask is already running.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final String world;
|
final String world;
|
||||||
|
final Plot p2;
|
||||||
if (plr!=null) {
|
if (plr!=null) {
|
||||||
if(!PlayerFunctions.isInPlot(plr)) {
|
if(!PlayerFunctions.isInPlot(plr)) {
|
||||||
sendMessage(plr, C.NOT_IN_PLOT);
|
sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
@ -190,7 +195,7 @@ public class Schematic extends SubCommand {
|
|||||||
sendMessage(plr, C.NO_PLOT_PERMS);
|
sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
i = myplot.id;
|
p2 = myplot;
|
||||||
world = plr.getWorld().getName();
|
world = plr.getWorld().getName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -198,12 +203,12 @@ public class Schematic extends SubCommand {
|
|||||||
try {
|
try {
|
||||||
world = args[0];
|
world = args[0];
|
||||||
String[] split = args[2].split(";");
|
String[] split = args[2].split(";");
|
||||||
i = new PlotId(Integer.parseInt(split[0]),Integer.parseInt(split[1]));
|
PlotId i = new PlotId(Integer.parseInt(split[0]),Integer.parseInt(split[1]));
|
||||||
if (PlotMain.getPlots(world)==null || PlotMain.getPlots(world).get(i) == null) {
|
if (PlotMain.getPlots(world)==null || PlotMain.getPlots(world).get(i) == null) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
p2 = PlotMain.getPlots(world).get(i);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||||
@ -216,25 +221,47 @@ public class Schematic extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||||
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
|
this.plots = new Plot[] {p2} ;
|
||||||
@Override
|
this.running = true;
|
||||||
public void run() {
|
this.counter = 0;
|
||||||
CompoundTag schematic = SchematicHandler.getCompoundTag(Bukkit.getWorld(world), i);
|
|
||||||
if (schematic==null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, "&cInvalid plot");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
boolean result = SchematicHandler.save(schematic, Settings.Web.PATH+"/"+i.x+","+i.y+","+world+".schematic");
|
|
||||||
|
|
||||||
if (!result) {
|
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin2, new Runnable() {
|
||||||
PlayerFunctions.sendMessage(plr, "&cFailed to save schematic");
|
@Override
|
||||||
return;
|
public void run() {
|
||||||
}
|
if (counter>=plots.length) {
|
||||||
PlayerFunctions.sendMessage(plr, "&aSuccessfully saved schematic!");
|
PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &aFinished!");
|
||||||
}
|
running = false;
|
||||||
});
|
Bukkit.getScheduler().cancelTask(task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Plot plot = plots[counter];
|
||||||
|
final CompoundTag sch = SchematicHandler.getCompoundTag(Bukkit.getWorld(world), plot.id);
|
||||||
|
if (sch==null) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c"+plot.id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
counter++;
|
||||||
|
PlayerFunctions.sendMessage(plr, "&6ID: "+plot.id);
|
||||||
|
boolean result = SchematicHandler.save(sch, Settings.Web.PATH+"/"+plot.id.x+","+plot.id.y+","+worldname+".schematic");
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c"+plot.id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlayerFunctions.sendMessage(plr, "&7 - &aExport success: "+plot.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}, 20, 60);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||||
|
Loading…
Reference in New Issue
Block a user