mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 18:24:43 +02:00
Optimizations and a purge fix
This commit is contained in:
@ -19,6 +19,7 @@ import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
||||
import org.spongepowered.api.service.ban.BanService;
|
||||
import org.spongepowered.api.text.chat.ChatTypes;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
@ -94,7 +95,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
if (!world.equals(location.getWorld())) {
|
||||
this.player.transferToWorld(location.getWorld(), new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
} else {
|
||||
org.spongepowered.api.world.Location current = this.player.getLocation();
|
||||
org.spongepowered.api.world.Location<World> current = this.player.getLocation();
|
||||
current = current.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
this.player.setLocation(current);
|
||||
}
|
||||
|
@ -5,12 +5,6 @@ import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
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;
|
||||
@ -18,18 +12,25 @@ import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@Override
|
||||
public CommandResult process(final CommandSource cmd, final String string) throws CommandException {
|
||||
public CommandResult process(CommandSource cmd, String string) throws CommandException {
|
||||
TaskManager.runTask(() -> {
|
||||
final String id = cmd.getIdentifier();
|
||||
String id = cmd.getIdentifier();
|
||||
PlotPlayer pp;
|
||||
try {
|
||||
final UUID uuid = UUID.fromString(id);
|
||||
final Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||
UUID uuid = UUID.fromString(id);
|
||||
Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||
pp = SpongeUtil.getPlayer(player);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
pp = ConsolePlayer.getConsole();
|
||||
}
|
||||
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));
|
||||
@ -38,11 +39,11 @@ public class SpongeCommand implements CommandCallable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(final CommandSource source, final String s) throws CommandException {
|
||||
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
|
||||
if (!(source instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
final PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
||||
PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
||||
String[] args = s.split(" ");
|
||||
if (args.length == 0) {
|
||||
return Collections.singletonList(MainCommand.getInstance().toString());
|
||||
@ -55,26 +56,26 @@ public class SpongeCommand implements CommandCallable {
|
||||
for (Object o : objects) {
|
||||
result.add(o.toString());
|
||||
}
|
||||
return result.size() == 0 ? null : result;
|
||||
return result.isEmpty() ? null : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission(final CommandSource cmd) {
|
||||
public boolean testPermission(CommandSource cmd) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Text> getShortDescription(final CommandSource cmd) {
|
||||
public Optional<? extends Text> getShortDescription(CommandSource cmd) {
|
||||
return Optional.of(Text.of("Shows plot help"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Text> getHelp(final CommandSource cmd) {
|
||||
public Optional<? extends Text> getHelp(CommandSource cmd) {
|
||||
return Optional.of(Text.of("/plot"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(final CommandSource cmd) {
|
||||
public Text getUsage(CommandSource cmd) {
|
||||
return Text.of("/plot <command>");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user