mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
IT COMPILES!
This commit is contained in:
parent
973c18623f
commit
8efc78e1c9
@ -25,20 +25,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.player;
|
package com.plotsquared.bukkit.player;
|
||||||
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player manager providing {@link BukkitPlayer Bukkit players}
|
* Player manager providing {@link BukkitPlayer Bukkit players}
|
||||||
*/
|
*/
|
||||||
public class BukkitPlayerManager extends PlayerManager {
|
public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, BukkitOfflinePlayer> {
|
||||||
|
|
||||||
@Override @NotNull public PlotPlayer createPlayer(@NotNull final UUID uuid) {
|
@Override @NotNull public BukkitPlayer createPlayer(@NotNull final UUID uuid) {
|
||||||
final Player player = Bukkit.getPlayer(uuid);
|
final Player player = Bukkit.getPlayer(uuid);
|
||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
throw new NoSuchPlayerException(uuid);
|
throw new NoSuchPlayerException(uuid);
|
||||||
@ -46,4 +46,15 @@ public class BukkitPlayerManager extends PlayerManager {
|
|||||||
return new BukkitPlayer(player);
|
return new BukkitPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
|
||||||
|
if (uuid == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override public BukkitOfflinePlayer getOfflinePlayer(@NotNull final String username) {
|
||||||
|
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(username));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2020 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.bukkit.util.uuid;
|
|
||||||
|
|
||||||
import com.plotsquared.bukkit.player.BukkitOfflinePlayer;
|
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
|
||||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
|
||||||
import com.plotsquared.core.util.uuid.UUIDWrapper;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class DefaultUUIDWrapper extends UUIDWrapper {
|
|
||||||
|
|
||||||
@NotNull @Override public UUID getUUID(PlotPlayer player) {
|
|
||||||
return ((BukkitPlayer) player).player.getUniqueId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public UUID getUUID(OfflinePlotPlayer player) {
|
|
||||||
return player.getUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
|
||||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public UUID getUUID(String name) {
|
|
||||||
return Bukkit.getOfflinePlayer(name).getUniqueId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
|
|
||||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
|
||||||
return Arrays.stream(ops).map(BukkitOfflinePlayer::new).toArray(BukkitOfflinePlayer[]::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
|
|
||||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(name));
|
|
||||||
}
|
|
||||||
}
|
|
@ -286,6 +286,6 @@ public interface IPlotMain extends ILogger {
|
|||||||
*
|
*
|
||||||
* @return Player manager
|
* @return Player manager
|
||||||
*/
|
*/
|
||||||
@NotNull PlayerManager getPlayerManager();
|
@NotNull PlayerManager<?, ?> getPlayerManager();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class PlayerBackupProfile implements BackupProfile {
|
|||||||
}
|
}
|
||||||
final List<Plot> plots = Collections.singletonList(plot);
|
final List<Plot> plots = Collections.singletonList(plot);
|
||||||
final boolean result = SchematicHandler.manager.exportAll(plots, getBackupDirectory().toFile(),
|
final boolean result = SchematicHandler.manager.exportAll(plots, getBackupDirectory().toFile(),
|
||||||
"%world%-%id%-%owner%-" + System.currentTimeMillis(), () ->
|
"%world%-%id%-" + System.currentTimeMillis(), () ->
|
||||||
future.complete(new Backup(this, System.currentTimeMillis(), null)));
|
future.complete(new Backup(this, System.currentTimeMillis(), null)));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
future.completeExceptionally(new RuntimeException("Failed to complete the backup"));
|
future.completeExceptionally(new RuntimeException("Failed to complete the backup"));
|
||||||
|
@ -37,7 +37,6 @@ import com.plotsquared.core.util.EconHandler;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -82,10 +81,10 @@ public class Buy extends Command {
|
|||||||
// Success
|
// Success
|
||||||
confirm.run(this, () -> {
|
confirm.run(this, () -> {
|
||||||
Captions.REMOVED_BALANCE.send(player, price);
|
Captions.REMOVED_BALANCE.send(player, price);
|
||||||
EconHandler.manager
|
|
||||||
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.getOwnerAbs()),
|
EconHandler.manager.depositMoney(PlotSquared.imp().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
|
||||||
price);
|
|
||||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.getOwnerAbs());
|
PlotPlayer owner = PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import com.plotsquared.core.events.Result;
|
|||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
@ -59,7 +58,6 @@ import com.plotsquared.core.util.task.RunnableVal;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
@ -71,13 +69,10 @@ import javax.script.SimpleScriptContext;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@CommandDeclaration(command = "debugexec",
|
@CommandDeclaration(command = "debugexec",
|
||||||
@ -172,7 +167,6 @@ public class DebugExec extends SubCommand {
|
|||||||
this.scope.put("SetupUtils", SetupUtils.manager);
|
this.scope.put("SetupUtils", SetupUtils.manager);
|
||||||
this.scope.put("EventUtil", PlotSquared.get().getEventDispatcher());
|
this.scope.put("EventUtil", PlotSquared.get().getEventDispatcher());
|
||||||
this.scope.put("EconHandler", EconHandler.manager);
|
this.scope.put("EconHandler", EconHandler.manager);
|
||||||
this.scope.put("UUIDHandler", UUIDHandler.implementation);
|
|
||||||
this.scope.put("DBFunc", DBFunc.dbManager);
|
this.scope.put("DBFunc", DBFunc.dbManager);
|
||||||
this.scope.put("HybridUtils", HybridUtils.manager);
|
this.scope.put("HybridUtils", HybridUtils.manager);
|
||||||
this.scope.put("IMP", PlotSquared.get().IMP);
|
this.scope.put("IMP", PlotSquared.get().IMP);
|
||||||
@ -301,27 +295,6 @@ public class DebugExec extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
return MainUtil.sendMessage(player, "Plot expiry task already started");
|
return MainUtil.sendMessage(player, "Plot expiry task already started");
|
||||||
}
|
}
|
||||||
case "seen":
|
|
||||||
if (args.length != 2) {
|
|
||||||
return MainUtil.sendMessage(player, "Use /plot debugexec seen <player>");
|
|
||||||
}
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
|
||||||
if (uuid == null) {
|
|
||||||
return MainUtil.sendMessage(player, "Player not found: " + args[1]);
|
|
||||||
}
|
|
||||||
OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
|
|
||||||
if (op == null || op.getLastPlayed() == 0) {
|
|
||||||
return MainUtil
|
|
||||||
.sendMessage(player, "Player hasn't connected before: " + args[1]);
|
|
||||||
}
|
|
||||||
Timestamp stamp = new Timestamp(op.getLastPlayed());
|
|
||||||
Date date = new Date(stamp.getTime());
|
|
||||||
MainUtil.sendMessage(player, "PLAYER: " + args[1]);
|
|
||||||
MainUtil.sendMessage(player, "UUID: " + uuid);
|
|
||||||
MainUtil.sendMessage(player, "Object: " + date.toGMTString());
|
|
||||||
MainUtil.sendMessage(player, "GMT: " + date.toGMTString());
|
|
||||||
MainUtil.sendMessage(player, "Local: " + date.toLocaleString());
|
|
||||||
return true;
|
|
||||||
case "h":
|
case "h":
|
||||||
case "he":
|
case "he":
|
||||||
case "?":
|
case "?":
|
||||||
|
@ -35,7 +35,6 @@ import com.plotsquared.core.util.MainUtil;
|
|||||||
import com.plotsquared.core.util.PremiumVerification;
|
import com.plotsquared.core.util.PremiumVerification;
|
||||||
import com.plotsquared.core.util.net.IncendoPaster;
|
import com.plotsquared.core.util.net.IncendoPaster;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -90,7 +89,7 @@ public class DebugPaste extends SubCommand {
|
|||||||
b.append("# Server Information\n");
|
b.append("# Server Information\n");
|
||||||
b.append("Server Version: ").append(PlotSquared.get().IMP.getServerImplementation())
|
b.append("Server Version: ").append(PlotSquared.get().IMP.getServerImplementation())
|
||||||
.append("\n");
|
.append("\n");
|
||||||
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';')
|
b.append("online_mode: ").append(!Settings.UUID.OFFLINE).append(';')
|
||||||
.append(!Settings.UUID.OFFLINE).append('\n');
|
.append(!Settings.UUID.OFFLINE).append('\n');
|
||||||
b.append("Plugins:");
|
b.append("Plugins:");
|
||||||
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
|
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
@ -35,10 +36,10 @@ import com.plotsquared.core.util.Permissions;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
@CommandDeclaration(command = "grant",
|
@CommandDeclaration(command = "grant",
|
||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
@ -69,17 +70,15 @@ public class Grant extends Command {
|
|||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
final UUID uuid;
|
MainUtil.getUUIDsFromString(args[1], (uuids, throwable) -> {
|
||||||
if (args.length == 2) {
|
if (throwable instanceof TimeoutException) {
|
||||||
uuid = UUIDHandler.getUUIDFromString(args[1]);
|
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
|
||||||
|
} else if (throwable != null || uuids.size() != 1) {
|
||||||
|
MainUtil.sendMessage(player, Captions.INVALID_PLAYER);
|
||||||
} else {
|
} else {
|
||||||
uuid = player.getUUID();
|
final UUID uuid = uuids.toArray(new UUID[0])[0];
|
||||||
}
|
MainUtil.getPersistentMeta(uuid,
|
||||||
if (uuid == null) {
|
"grantedPlots", new RunnableVal<byte[]>() {
|
||||||
Captions.INVALID_PLAYER.send(player, args[1]);
|
|
||||||
return CompletableFuture.completedFuture(false);
|
|
||||||
}
|
|
||||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
|
||||||
@Override public void run(byte[] array) {
|
@Override public void run(byte[] array) {
|
||||||
if (arg0.equals("check")) { // check
|
if (arg0.equals("check")) { // check
|
||||||
int granted;
|
int granted;
|
||||||
@ -99,7 +98,8 @@ public class Grant extends Command {
|
|||||||
boolean replace = array != null;
|
boolean replace = array != null;
|
||||||
String key = "grantedPlots";
|
String key = "grantedPlots";
|
||||||
byte[] rawData = Ints.toByteArray(amount);
|
byte[] rawData = Ints.toByteArray(amount);
|
||||||
PlotPlayer online = UUIDHandler.getPlayer(uuid);
|
|
||||||
|
PlotPlayer online = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||||
if (online != null) {
|
if (online != null) {
|
||||||
online.setPersistentMeta(key, rawData);
|
online.setPersistentMeta(key, rawData);
|
||||||
} else {
|
} else {
|
||||||
@ -108,6 +108,8 @@ public class Grant extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
}
|
}
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
|
@ -34,11 +34,11 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
@CommandDeclaration(command = "kick",
|
@CommandDeclaration(command = "kick",
|
||||||
aliases = "k",
|
aliases = "k",
|
||||||
@ -64,11 +64,13 @@ public class Kick extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
|
||||||
if (uuids.isEmpty()) {
|
MainUtil.getUUIDsFromString(args[0], (uuids, throwable) -> {
|
||||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
if (throwable instanceof TimeoutException) {
|
||||||
return false;
|
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
|
||||||
}
|
} else if (throwable != null || uuids.isEmpty()) {
|
||||||
|
MainUtil.sendMessage(player, Captions.INVALID_PLAYER);
|
||||||
|
} else {
|
||||||
Set<PlotPlayer> players = new HashSet<>();
|
Set<PlotPlayer> players = new HashSet<>();
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
if (uuid == DBFunc.EVERYONE) {
|
if (uuid == DBFunc.EVERYONE) {
|
||||||
@ -81,7 +83,7 @@ public class Kick extends SubCommand {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
PlotPlayer pp = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||||
if (pp != null) {
|
if (pp != null) {
|
||||||
players.add(pp);
|
players.add(pp);
|
||||||
}
|
}
|
||||||
@ -89,16 +91,16 @@ public class Kick extends SubCommand {
|
|||||||
players.remove(player); // Don't ever kick the calling player
|
players.remove(player); // Don't ever kick the calling player
|
||||||
if (players.isEmpty()) {
|
if (players.isEmpty()) {
|
||||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
for (PlotPlayer player2 : players) {
|
for (PlotPlayer player2 : players) {
|
||||||
if (!plot.equals(player2.getCurrentPlot())) {
|
if (!plot.equals(player2.getCurrentPlot())) {
|
||||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(player2, Captions.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
if (Permissions.hasPermission(player2, Captions.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||||
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||||
Captions.YOU_GOT_KICKED.send(player2);
|
Captions.YOU_GOT_KICKED.send(player2);
|
||||||
@ -115,6 +117,9 @@ public class Kick extends SubCommand {
|
|||||||
player2.plotkick(spawn);
|
player2.plotkick(spawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ public class MainCommand extends Command {
|
|||||||
new DebugPaste();
|
new DebugPaste();
|
||||||
new Unlink();
|
new Unlink();
|
||||||
new Kick();
|
new Kick();
|
||||||
new DebugClaimTest();
|
|
||||||
new Inbox();
|
new Inbox();
|
||||||
new Comment();
|
new Comment();
|
||||||
new DatabaseCommand();
|
new DatabaseCommand();
|
||||||
|
@ -40,7 +40,6 @@ import com.plotsquared.core.util.Expression;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ public class Merge extends SubCommand {
|
|||||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
for (final UUID owner : uuids) {
|
for (final UUID owner : uuids) {
|
||||||
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
final PlotPlayer accepter = PlotSquared.imp().getPlayerManager().getPlayerIfExists(owner);
|
||||||
if (!force && accepter == null) {
|
if (!force && accepter == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -222,7 +221,7 @@ public class Merge extends SubCommand {
|
|||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
MainUtil.sendMessage(accepter, Captions.MERGE_ACCEPTED);
|
MainUtil.sendMessage(accepter, Captions.MERGE_ACCEPTED);
|
||||||
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
||||||
PlotPlayer plotPlayer = UUIDHandler.getPlayer(player.getUUID());
|
PlotPlayer plotPlayer = PlotSquared.imp().getPlayerManager().getPlayerIfExists(player.getUUID());
|
||||||
if (plotPlayer == null) {
|
if (plotPlayer == null) {
|
||||||
sendMessage(accepter, Captions.MERGE_NOT_VALID);
|
sendMessage(accepter, Captions.MERGE_NOT_VALID);
|
||||||
return;
|
return;
|
||||||
|
@ -36,10 +36,11 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setowner",
|
@CommandDeclaration(command = "setowner",
|
||||||
permission = "plots.set.owner",
|
permission = "plots.set.owner",
|
||||||
@ -57,26 +58,19 @@ public class Owner extends SetCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<Plot> plots = plot.getConnectedPlots();
|
Set<Plot> plots = plot.getConnectedPlots();
|
||||||
UUID uuid = null;
|
|
||||||
if (value.length() == 36) {
|
final Consumer<UUID> uuidConsumer = uuid -> {
|
||||||
try {
|
|
||||||
uuid = UUID.fromString(value);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uuid = UUIDHandler.getUUID(value, null);
|
|
||||||
}
|
|
||||||
if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null")
|
if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null")
|
||||||
&& !value.equalsIgnoreCase("-")) {
|
&& !value.equalsIgnoreCase("-")) {
|
||||||
Captions.INVALID_PLAYER.send(player, value);
|
Captions.INVALID_PLAYER.send(player, value);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
|
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid,
|
.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid,
|
||||||
plot.hasOwner());
|
plot.hasOwner());
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
uuid = event.getNewOwner();
|
uuid = event.getNewOwner();
|
||||||
boolean force = event.getEventResult() == Result.FORCE;
|
boolean force = event.getEventResult() == Result.FORCE;
|
||||||
@ -84,13 +78,13 @@ public class Owner extends SetCommand {
|
|||||||
if (!force && !Permissions
|
if (!force && !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.getTranslated(),
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.getTranslated(),
|
||||||
true)) {
|
true)) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
PlotUnlinkEvent unlinkEvent = PlotSquared.get().getEventDispatcher()
|
PlotUnlinkEvent unlinkEvent = PlotSquared.get().getEventDispatcher()
|
||||||
.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER);
|
.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER);
|
||||||
if (unlinkEvent.getEventResult() == Result.DENY) {
|
if (unlinkEvent.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change");
|
sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
plot.unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
|
plot.unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad());
|
||||||
Set<Plot> connected = plot.getConnectedPlots();
|
Set<Plot> connected = plot.getConnectedPlots();
|
||||||
@ -99,18 +93,18 @@ public class Owner extends SetCommand {
|
|||||||
current.removeSign();
|
current.removeSign();
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
final PlotPlayer other = PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid);
|
||||||
if (plot.isOwner(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!force && !Permissions
|
if (!force && !Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
Captions.INVALID_PLAYER_OFFLINE.send(player, value);
|
Captions.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
int size = plots.size();
|
int size = plots.size();
|
||||||
int currentPlots = (Settings.Limit.GLOBAL ?
|
int currentPlots = (Settings.Limit.GLOBAL ?
|
||||||
@ -118,11 +112,11 @@ public class Owner extends SetCommand {
|
|||||||
other.getPlotCount(plot.getWorldName())) + size;
|
other.getPlotCount(plot.getWorldName())) + size;
|
||||||
if (currentPlots > other.getAllowedPlots()) {
|
if (currentPlots > other.getAllowedPlots()) {
|
||||||
sendMessage(player, Captions.CANT_TRANSFER_MORE_PLOTS);
|
sendMessage(player, Captions.CANT_TRANSFER_MORE_PLOTS);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String finalName = UUIDHandler.getName(uuid);
|
|
||||||
final UUID finalUUID = uuid;
|
final UUID finalUUID = uuid;
|
||||||
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(uuid, (finalName, throwable) -> {
|
||||||
final boolean removeDenied = plot.isDenied(finalUUID);
|
final boolean removeDenied = plot.isDenied(finalUUID);
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
if (plot.setOwner(finalUUID, player)) {
|
if (plot.setOwner(finalUUID, player)) {
|
||||||
@ -143,6 +137,25 @@ public class Owner extends SetCommand {
|
|||||||
} else {
|
} else {
|
||||||
TaskManager.runTask(run);
|
TaskManager.runTask(run);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (value.length() == 36) {
|
||||||
|
try {
|
||||||
|
uuidConsumer.accept(UUID.fromString(value));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(value, (uuid, throwable) -> {
|
||||||
|
if (throwable instanceof TimeoutException) {
|
||||||
|
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
|
||||||
|
} else if (throwable != null) {
|
||||||
|
MainUtil.sendMessage(player, Captions.INVALID_PLAYER);
|
||||||
|
} else {
|
||||||
|
uuidConsumer.accept(uuid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -65,7 +64,6 @@ public class Purge extends SubCommand {
|
|||||||
PlotId id = null;
|
PlotId id = null;
|
||||||
UUID owner = null;
|
UUID owner = null;
|
||||||
UUID added = null;
|
UUID added = null;
|
||||||
boolean unknown = false;
|
|
||||||
boolean clear = false;
|
boolean clear = false;
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
String[] split = arg.split(":");
|
String[] split = arg.split(":");
|
||||||
@ -97,7 +95,7 @@ public class Purge extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
case "owner":
|
case "owner":
|
||||||
case "o":
|
case "o":
|
||||||
owner = UUIDHandler.getUUID(split[1], null);
|
owner = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(split[1], Settings.UUID.BLOCKING_TIMEOUT);
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
Captions.INVALID_PLAYER.send(player, split[1]);
|
Captions.INVALID_PLAYER.send(player, split[1]);
|
||||||
return false;
|
return false;
|
||||||
@ -105,17 +103,12 @@ public class Purge extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
case "shared":
|
case "shared":
|
||||||
case "s":
|
case "s":
|
||||||
added = UUIDHandler.getUUID(split[1], null);
|
added = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(split[1], Settings.UUID.BLOCKING_TIMEOUT);
|
||||||
if (added == null) {
|
if (added == null) {
|
||||||
Captions.INVALID_PLAYER.send(player, split[1]);
|
Captions.INVALID_PLAYER.send(player, split[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "unknown":
|
|
||||||
case "?":
|
|
||||||
case "u":
|
|
||||||
unknown = Boolean.parseBoolean(split[1]);
|
|
||||||
break;
|
|
||||||
case "clear":
|
case "clear":
|
||||||
case "c":
|
case "c":
|
||||||
case "delete":
|
case "delete":
|
||||||
@ -145,9 +138,6 @@ public class Purge extends SubCommand {
|
|||||||
if (added != null && !plot.isAdded(added)) {
|
if (added != null && !plot.isAdded(added)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
toDelete.addAll(plot.getConnectedPlots());
|
toDelete.addAll(plot.getConnectedPlots());
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().plots_tmp != null) {
|
if (PlotSquared.get().plots_tmp != null) {
|
||||||
@ -168,9 +158,6 @@ public class Purge extends SubCommand {
|
|||||||
if (added != null && !plot.isAdded(added)) {
|
if (added != null && !plot.isAdded(added)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
toDelete.add(plot);
|
toDelete.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (isMerged()) {
|
if (isMerged()) {
|
||||||
Set<Plot> plots = getConnectedPlots();
|
Set<Plot> plots = getConnectedPlots();
|
||||||
Plot[] array = plots.toArray(new Plot[plots.size()]);
|
Plot[] array = plots.toArray(new Plot[0]);
|
||||||
ImmutableSet.Builder<UUID> owners = ImmutableSet.builder();
|
ImmutableSet.Builder<UUID> owners = ImmutableSet.builder();
|
||||||
UUID last = this.getOwner();
|
UUID last = this.getOwner();
|
||||||
owners.add(this.getOwner());
|
owners.add(this.getOwner());
|
||||||
@ -1711,7 +1711,8 @@ public class Plot {
|
|||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(this.getOwnerAbs(), this::setSign);
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(this.getOwnerAbs(), (username, sign) ->
|
||||||
|
this.setSign(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ package com.plotsquared.core.plot.expiration;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||||
import com.plotsquared.core.events.PlotUnlinkEvent;
|
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||||
@ -48,7 +47,6 @@ import com.plotsquared.core.util.StringMan;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -411,13 +409,13 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (UUID helper : plot.getTrusted()) {
|
for (UUID helper : plot.getTrusted()) {
|
||||||
PlotPlayer player = UUIDHandler.getPlayer(helper);
|
PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (UUID helper : plot.getMembers()) {
|
for (UUID helper : plot.getMembers()) {
|
||||||
PlotPlayer player = UUIDHandler.getPlayer(helper);
|
PlotPlayer player = PlotSquared.imp().getPlayerManager().getPlayerIfExists(helper);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
||||||
}
|
}
|
||||||
@ -433,26 +431,19 @@ public class ExpireManager {
|
|||||||
.getString(plots));
|
.getString(plots));
|
||||||
PlotSquared.debug("$4 - Area: " + plot.getArea());
|
PlotSquared.debug("$4 - Area: " + plot.getArea());
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
PlotSquared.debug("$4 - Owner: " + UUIDHandler.getName(plot.getOwner()));
|
PlotSquared.debug("$4 - Owner: " + plot.getOwner());
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.debug("$4 - Owner: Unowned");
|
PlotSquared.debug("$4 - Owner: Unowned");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAge(UUID uuid) {
|
public long getAge(UUID uuid) {
|
||||||
if (UUIDHandler.getPlayer(uuid) != null) {
|
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(uuid) != null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
String name = UUIDHandler.getName(uuid);
|
|
||||||
if (name != null) {
|
|
||||||
Long last = this.dates_cache.get(uuid);
|
Long last = this.dates_cache.get(uuid);
|
||||||
if (last == null) {
|
if (last == null) {
|
||||||
OfflinePlotPlayer opp;
|
OfflinePlotPlayer opp = PlotSquared.imp().getPlayerManager().getOfflinePlayer(uuid);
|
||||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
|
||||||
opp = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
|
|
||||||
} else {
|
|
||||||
opp = UUIDHandler.getUUIDWrapper().getOfflinePlayer(name);
|
|
||||||
}
|
|
||||||
if (opp != null && (last = opp.getLastPlayed()) != 0) {
|
if (opp != null && (last = opp.getLastPlayed()) != 0) {
|
||||||
this.dates_cache.put(uuid, last);
|
this.dates_cache.put(uuid, last);
|
||||||
} else {
|
} else {
|
||||||
@ -464,25 +455,10 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
return System.currentTimeMillis() - last;
|
return System.currentTimeMillis() - last;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getAccountAge(Plot plot) {
|
|
||||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
|
||||||
|| UUIDHandler.getPlayer(plot.getOwner()) != null || plot.getRunning() > 0) {
|
|
||||||
return Long.MAX_VALUE;
|
|
||||||
}
|
|
||||||
long max = 0;
|
|
||||||
for (UUID owner : plot.getOwners()) {
|
|
||||||
long age = getAccountAge(owner);
|
|
||||||
max = Math.max(age, max);
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getAge(Plot plot) {
|
public long getAge(Plot plot) {
|
||||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
||||||
|| UUIDHandler.getPlayer(plot.getOwner()) != null || plot.getRunning() > 0) {
|
|| PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwner()) != null || plot.getRunning() > 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.queue;
|
package com.plotsquared.core.queue;
|
||||||
|
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.PatternUtil;
|
import com.plotsquared.core.util.PatternUtil;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -43,8 +43,6 @@ import lombok.Setter;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class LocalBlockQueue {
|
public abstract class LocalBlockQueue {
|
||||||
|
|
||||||
@Getter @Setter private boolean forceSync = false;
|
@Getter @Setter private boolean forceSync = false;
|
||||||
@ -124,8 +122,8 @@ public abstract class LocalBlockQueue {
|
|||||||
regenChunk(x, z);
|
regenChunk(x, z);
|
||||||
fixChunkLighting(x, z);
|
fixChunkLighting(x, z);
|
||||||
BlockVector2 loc = BlockVector2.at(x, z);
|
BlockVector2 loc = BlockVector2.at(x, z);
|
||||||
for (Map.Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
|
||||||
PlotPlayer pp = entry.getValue();
|
for (final PlotPlayer pp : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
||||||
Location pLoc = pp.getLocation();
|
Location pLoc = pp.getLocation();
|
||||||
if (!StringMan.isEqual(getWorld(), pLoc.getWorld()) || !pLoc.getBlockVector2()
|
if (!StringMan.isEqual(getWorld(), pLoc.getWorld()) || !pLoc.getBlockVector2()
|
||||||
.equals(loc)) {
|
.equals(loc)) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
|
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -38,9 +39,9 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Manages player instances
|
* Manages player instances
|
||||||
*/
|
*/
|
||||||
public abstract class PlayerManager {
|
public abstract class PlayerManager<P extends PlotPlayer, O extends OfflinePlotPlayer> {
|
||||||
|
|
||||||
private final Map<UUID, PlotPlayer> playerMap = new HashMap<>();
|
private final Map<UUID, P> playerMap = new HashMap<>();
|
||||||
private final Object playerLock = new Object();
|
private final Object playerLock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,15 +61,15 @@ public abstract class PlayerManager {
|
|||||||
* @param uuid Player UUID
|
* @param uuid Player UUID
|
||||||
* @return Player, or null
|
* @return Player, or null
|
||||||
*/
|
*/
|
||||||
@Nullable public PlotPlayer getPlayerIfExists(@Nullable final UUID uuid) {
|
@Nullable public P getPlayerIfExists(@Nullable final UUID uuid) {
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.playerMap.get(uuid);
|
return this.playerMap.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable public PlotPlayer getPlayerIfExists(@Nullable final String name) {
|
@Nullable public P getPlayerIfExists(@Nullable final String name) {
|
||||||
for (final PlotPlayer plotPlayer : this.playerMap.values()) {
|
for (final P plotPlayer : this.playerMap.values()) {
|
||||||
if (plotPlayer.getName().equalsIgnoreCase(name)) {
|
if (plotPlayer.getName().equalsIgnoreCase(name)) {
|
||||||
return plotPlayer;
|
return plotPlayer;
|
||||||
}
|
}
|
||||||
@ -86,9 +87,9 @@ public abstract class PlayerManager {
|
|||||||
* @param uuid Player UUID
|
* @param uuid Player UUID
|
||||||
* @return Player object
|
* @return Player object
|
||||||
*/
|
*/
|
||||||
@NotNull public PlotPlayer getPlayer(@NotNull final UUID uuid) {
|
@NotNull public P getPlayer(@NotNull final UUID uuid) {
|
||||||
synchronized (playerLock) {
|
synchronized (playerLock) {
|
||||||
PlotPlayer player = this.playerMap.get(uuid);
|
P player = this.playerMap.get(uuid);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
player = createPlayer(uuid);
|
player = createPlayer(uuid);
|
||||||
this.playerMap.put(uuid, player);
|
this.playerMap.put(uuid, player);
|
||||||
@ -97,14 +98,30 @@ public abstract class PlayerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull protected abstract PlotPlayer createPlayer(@NotNull final UUID uuid);
|
@NotNull protected abstract P createPlayer(@NotNull final UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an an offline player object from the player's UUID
|
||||||
|
*
|
||||||
|
* @param uuid Player UUID
|
||||||
|
* @return Offline player object
|
||||||
|
*/
|
||||||
|
@Nullable public abstract O getOfflinePlayer(@Nullable final UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an offline player object from the player's username
|
||||||
|
*
|
||||||
|
* @param username Player name
|
||||||
|
* @return Offline player object
|
||||||
|
*/
|
||||||
|
@Nullable public abstract O getOfflinePlayer(@NotNull final String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all online players
|
* Get all online players
|
||||||
*
|
*
|
||||||
* @return Unmodifiable collection of players
|
* @return Unmodifiable collection of players
|
||||||
*/
|
*/
|
||||||
public Collection<PlotPlayer> getPlayers() {
|
public Collection<P> getPlayers() {
|
||||||
return Collections.unmodifiableCollection(this.playerMap.values());
|
return Collections.unmodifiableCollection(this.playerMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import com.plotsquared.core.plot.schematic.Schematic;
|
|||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
import com.sk89q.jnbt.NBTOutputStream;
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
@ -104,16 +103,24 @@ public abstract class SchematicHandler {
|
|||||||
Iterator<Plot> i = plots.iterator();
|
Iterator<Plot> i = plots.iterator();
|
||||||
final Plot plot = i.next();
|
final Plot plot = i.next();
|
||||||
i.remove();
|
i.remove();
|
||||||
String owner = UUIDHandler.getName(plot.getOwnerAbs());
|
|
||||||
if (owner == null) {
|
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwnerAbs(), (username, throwable) -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
final String owner;
|
||||||
|
if (plot.hasOwner()) {
|
||||||
|
owner = plot.getOwnerAbs().toString();
|
||||||
|
} else {
|
||||||
owner = "unknown";
|
owner = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
if (namingScheme == null) {
|
if (namingScheme == null) {
|
||||||
name =
|
name =
|
||||||
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
|
plot.getId().x + ";" + plot.getId().y + ',' + plot.getArea() + ',' + owner;
|
||||||
} else {
|
} else {
|
||||||
name = namingScheme.replaceAll("%owner%", owner)
|
name = namingScheme
|
||||||
.replaceAll("%id%", plot.getId().toString())
|
.replaceAll("%id%", plot.getId().toString())
|
||||||
.replaceAll("%idx%", plot.getId().x + "")
|
.replaceAll("%idx%", plot.getId().x + "")
|
||||||
.replaceAll("%idy%", plot.getId().y + "")
|
.replaceAll("%idy%", plot.getId().y + "")
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* _____ _ _ _____ _
|
|
||||||
* | __ \| | | | / ____| | |
|
|
||||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
||||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
||||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
||||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
||||||
* | |
|
|
||||||
* |_|
|
|
||||||
* PlotSquared plot management system for Minecraft
|
|
||||||
* Copyright (C) 2020 IntellectualSites
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.core.plot.util;
|
|
||||||
|
|
||||||
import com.plotsquared.core.database.AbstractDBTest;
|
|
||||||
import com.plotsquared.core.database.DBFunc;
|
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
|
||||||
import com.plotsquared.core.util.uuid.OfflinePlayerService;
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UUIDHandlerImplementationTest extends UUIDHandlerImplementation {
|
|
||||||
|
|
||||||
public UUIDHandlerImplementationTest(OfflinePlayerService wrapper) {
|
|
||||||
super(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before public void setUp() throws Exception {
|
|
||||||
DBFunc.dbManager = new AbstractDBTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void fetchUUID(String name, RunnableVal<UUID> ifFetch) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user