mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Minor fixes
This commit is contained in:
parent
5978c9c3c0
commit
c97544d083
@ -197,7 +197,7 @@ public class MainCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
// Clear perm caching //
|
||||
player.deleteMeta("perm");
|
||||
// Optional command scope //
|
||||
@ -223,6 +223,37 @@ public class MainCommand extends Command {
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
if (args.length >= 2 && args[0].charAt(0) == '-') {
|
||||
switch (args[0].substring(1)) {
|
||||
case "f":
|
||||
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
|
||||
@Override
|
||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (success != null) {
|
||||
success.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
break;
|
||||
default:
|
||||
C.INVALID_COMMAND_FLAG.send(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
super.execute(player, args, confirm, whenDone);
|
||||
|
@ -452,6 +452,10 @@ public enum C {
|
||||
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
|
||||
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
|
||||
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
|
||||
/*
|
||||
* Command flag
|
||||
*/
|
||||
INVALID_COMMAND_FLAG("$2Invalid command flag: %s0", "Errors"),
|
||||
/*
|
||||
* Unknown Error
|
||||
*/
|
||||
|
@ -3,7 +3,6 @@ package com.plotsquared.nukkit.util;
|
||||
import cn.nukkit.level.Level;
|
||||
import cn.nukkit.level.generator.Generator;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
@ -12,7 +11,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.nukkit.NukkitMain;
|
||||
import com.plotsquared.nukkit.generator.NukkitPlotGenerator;
|
||||
import java.io.File;
|
||||
import com.plotsquared.nukkit.util.block.NukkitHybridGen;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
@ -25,6 +24,7 @@ public class NukkitSetupUtils extends SetupUtils {
|
||||
|
||||
public NukkitSetupUtils(NukkitMain plugin) {
|
||||
this.plugin = plugin;
|
||||
Generator.addGenerator(NukkitHybridGen.class, "PlotSquared", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,14 +119,16 @@ public class NukkitSetupUtils extends SetupUtils {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("world", object.world);
|
||||
map.put("plot-generator", PS.get().IMP.getDefaultGenerator());
|
||||
if (!plugin.getServer().generateLevel(object.world, object.world.hashCode(), NukkitPlotGenerator.class, map)) {
|
||||
if (!plugin.getServer().generateLevel(object.world, object.world.hashCode(), NukkitHybridGen.class, map)) {
|
||||
plugin.getServer().loadLevel(object.world);
|
||||
}
|
||||
try {
|
||||
File nukkitFile = new File("nukkit.yml");
|
||||
YamlConfiguration nukkitYml = YamlConfiguration.loadConfiguration(nukkitFile);
|
||||
nukkitYml.set("worlds." + object.world + ".generator", object.setupGenerator);
|
||||
nukkitYml.save(nukkitFile);
|
||||
// File nukkitFile = new File("nukkit.yml");
|
||||
// YamlConfiguration nukkitYml = YamlConfiguration.loadConfiguration(nukkitFile);
|
||||
// if (!nukkitYml.contains("worlds." + object.world + ".generator")) {
|
||||
// nukkitYml.set("worlds." + object.world + ".generator", object.setupGenerator);
|
||||
// nukkitYml.save(nukkitFile);
|
||||
// }
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -138,17 +140,6 @@ public class NukkitSetupUtils extends SetupUtils {
|
||||
return object.world;
|
||||
}
|
||||
|
||||
public void setGenerator(String world, String generator) {
|
||||
File file = new File("nukkit.yml").getAbsoluteFile();
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
yml.set("worlds." + world + ".generator", generator);
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
|
@ -2,7 +2,6 @@ package com.plotsquared.nukkit.util.block;
|
||||
|
||||
import cn.nukkit.level.Level;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.plotsquared.nukkit.NukkitMain;
|
||||
import com.plotsquared.nukkit.generator.NukkitPlotGenerator;
|
||||
import java.util.Map;
|
||||
|
Loading…
Reference in New Issue
Block a user