mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Update sponge port
This commit is contained in:
parent
056f77a3ba
commit
46d3dc609e
6 changed files with 44 additions and 63 deletions
|
@ -21,8 +21,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel,
|
||||
String[] args) {
|
||||
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel, String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
||||
}
|
||||
|
|
|
@ -1465,13 +1465,16 @@ public class PS {
|
|||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
log(C.PREFIX + "&3 - " + areaId);
|
||||
String[] split = areaId.split("([^\\-]+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)");
|
||||
if (split.length != 3) {
|
||||
int i1 = areaId.indexOf("-");
|
||||
int i2 = areaId.indexOf(";");
|
||||
if (i1 == -1 || i2 == -1) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||
}
|
||||
String name = split[0];
|
||||
PlotId pos1 = PlotId.fromString(split[1]);
|
||||
PlotId pos2 = PlotId.fromString(split[2]);
|
||||
String name = areaId.substring(0, i1);
|
||||
String rest = areaId.substring(i1 + 1);
|
||||
int i3 = rest.indexOf("-", i2);
|
||||
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
|
||||
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
|
||||
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<x1;z1>-<x2;z2>`");
|
||||
}
|
||||
|
|
|
@ -174,6 +174,9 @@ public class Trim extends SubCommand {
|
|||
public void run(Set<ChunkLoc> viable, final Set<ChunkLoc> nonViable) {
|
||||
Runnable regenTask;
|
||||
if (regen) {
|
||||
PS.log("Starting regen task:");
|
||||
PS.log(" - This is a VERY slow command");
|
||||
PS.log(" - It will say `Trim done!` when complete");
|
||||
regenTask = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -80,9 +80,10 @@ import java.util.UUID;
|
|||
* Created by robin on 01/11/2014
|
||||
*/
|
||||
|
||||
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.1")
|
||||
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.2")
|
||||
public class SpongeMain implements IPlotMain {
|
||||
public static SpongeMain THIS;
|
||||
public PluginContainer plugin;
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
@ -130,6 +131,7 @@ public class SpongeMain implements IPlotMain {
|
|||
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
log("PlotSquared: Server init");
|
||||
THIS = this;
|
||||
THIS.plugin = this.game.getPluginManager().fromInstance(this).get();
|
||||
new PS(this, "Sponge");
|
||||
this.server = this.game.getServer();
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify());
|
||||
|
@ -304,7 +306,7 @@ public class SpongeMain implements IPlotMain {
|
|||
@Override
|
||||
public void startMetrics() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this.game, (PluginContainer) this);
|
||||
Metrics metrics = new Metrics(this.game, plugin);
|
||||
metrics.start();
|
||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -3,11 +3,14 @@ package com.plotsquared.sponge.util;
|
|||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.spongepowered.api.command.CommandCallable;
|
||||
import org.spongepowered.api.command.CommandException;
|
||||
import org.spongepowered.api.command.CommandResult;
|
||||
|
@ -15,67 +18,44 @@ import org.spongepowered.api.command.CommandSource;
|
|||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@Override
|
||||
public CommandResult process(final CommandSource cmd, final String string) throws CommandException {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String id = cmd.getIdentifier();
|
||||
PlotPlayer pp;
|
||||
try {
|
||||
final UUID uuid = UUID.fromString(id);
|
||||
final Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||
pp = SpongeUtil.getPlayer(player);
|
||||
} catch (final Exception e) {
|
||||
pp = ConsolePlayer.getConsole();
|
||||
}
|
||||
MainCommand.onCommand(pp, cmd.getName(), string.isEmpty() ? new String[]{} : string.split(" "));
|
||||
TaskManager.runTask(() -> {
|
||||
final String id = cmd.getIdentifier();
|
||||
PlotPlayer pp;
|
||||
try {
|
||||
final UUID uuid = UUID.fromString(id);
|
||||
final Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||
pp = SpongeUtil.getPlayer(player);
|
||||
} catch (final Exception e) {
|
||||
pp = ConsolePlayer.getConsole();
|
||||
}
|
||||
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));
|
||||
});
|
||||
return CommandResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(final CommandSource source, final String string) throws CommandException {
|
||||
public List<String> getSuggestions(final CommandSource source, final String s) throws CommandException {
|
||||
if (!(source instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
final PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
||||
String[] split = string.split(" ");
|
||||
if (split.length < 1) {
|
||||
return Collections.singletonList("plots");
|
||||
String[] args = s.split(" ");
|
||||
if (args.length == 0) {
|
||||
return Collections.singletonList(MainCommand.getInstance().toString());
|
||||
}
|
||||
if (split.length > 1) {
|
||||
return Collections.emptyList();
|
||||
Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" "));
|
||||
if (objects == null) {
|
||||
return null;
|
||||
}
|
||||
final Set<String> tabOptions = new HashSet<>();
|
||||
final String arg = split[0].toLowerCase();
|
||||
ArrayList<String> labels = new ArrayList<>();
|
||||
for (final Command cmd : MainCommand.getInstance().getCommands()) {
|
||||
final String label = cmd.toS();
|
||||
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||
aliases.add(label);
|
||||
for (String alias : aliases) {
|
||||
labels.add(alias);
|
||||
if (alias.startsWith(arg)) {
|
||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
tabOptions.add(label);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Object o : objects) {
|
||||
result.add(o.toString());
|
||||
}
|
||||
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||
tabOptions.add(best);
|
||||
if (!tabOptions.isEmpty()) {
|
||||
return new ArrayList<>(tabOptions);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +70,7 @@ public class SpongeCommand implements CommandCallable {
|
|||
|
||||
@Override
|
||||
public Optional<? extends Text> getHelp(final CommandSource cmd) {
|
||||
return Optional.of(Text.of("/plot help"));
|
||||
return Optional.of(Text.of("/plot"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,12 +64,6 @@ public class SpongeEconHandler extends EconHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermission(String world, String player, String perm, boolean value) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("TODO/WIP/NOT IMPLEMENTED!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String world, String player, String perm) {
|
||||
SpongePlayer obj = (SpongePlayer) UUIDHandler.getPlayer(player);
|
||||
|
|
Loading…
Reference in a new issue