mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Small changes
This commit is contained in:
parent
5b8f6e466a
commit
539ad9f05c
@ -699,7 +699,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
+ " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
|
||||
+ "Bukkit");
|
||||
} else {
|
||||
PlotSquared.log(Captions.PREFIX + " &6" + getPluginName() + " is using online UUIDs");
|
||||
PlotSquared.log(Captions.PREFIX + " " + getPluginName() + " is using online UUIDs");
|
||||
}
|
||||
if (Settings.UUID.USE_SQLUUIDHANDLER) {
|
||||
return new SQLUUIDHandler(wrapper);
|
||||
|
@ -123,8 +123,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
|
||||
if (insertionData != null) {
|
||||
json.name("insertion").value(insertionData);
|
||||
}
|
||||
if (translationReplacements.size() > 0 && text != null && TextualComponent
|
||||
.isTranslatableText(text)) {
|
||||
if (translationReplacements.size() > 0 && TextualComponent.isTranslatableText(text)) {
|
||||
json.name("with").beginArray();
|
||||
for (JsonRepresentedObject obj : translationReplacements) {
|
||||
obj.writeJson(json);
|
||||
|
@ -6,8 +6,12 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -41,14 +45,12 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
*
|
||||
* @param player Bukkit player instance
|
||||
*/
|
||||
public BukkitPlayer(@Nonnull final Player player) {
|
||||
Preconditions.checkNotNull(player, "Bukkit player instance cannot be null");
|
||||
public BukkitPlayer(@NotNull final Player player) {
|
||||
this.player = player;
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
|
||||
public BukkitPlayer(@Nonnull final Player player, final boolean offline) {
|
||||
Preconditions.checkNotNull(player, "Bukkit player instance cannot be null");
|
||||
public BukkitPlayer(@NotNull final Player player, final boolean offline) {
|
||||
this.player = player;
|
||||
this.offline = offline;
|
||||
super.populatePersistentMetaMap();
|
||||
@ -70,8 +72,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return this.player.getLastPlayed();
|
||||
}
|
||||
|
||||
@Override public boolean canTeleport(@Nonnull final Location loc) {
|
||||
Preconditions.checkNotNull(loc, "Bukkit location cannot be null");
|
||||
@Override public boolean canTeleport(@NotNull final Location loc) {
|
||||
final org.bukkit.Location to = BukkitUtil.getLocation(loc);
|
||||
final org.bukkit.Location from = player.getLocation();
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||
@ -89,9 +90,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
private void callEvent(final Event event) {
|
||||
Preconditions.checkNotNull(event, "Event cannot be null");
|
||||
|
||||
private void callEvent(@NotNull final Event event) {
|
||||
final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
for (final RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals(PlotSquared.imp().getPluginName())) {
|
||||
@ -215,8 +214,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return BukkitUtil.getLocationFull(this.player);
|
||||
}
|
||||
|
||||
@Override public void setWeather(@Nonnull final PlotWeather weather) {
|
||||
Preconditions.checkNotNull(weather, "Specified weather cannot be null");
|
||||
@Override public void setWeather(@NotNull final PlotWeather weather) {
|
||||
switch (weather) {
|
||||
case CLEAR:
|
||||
this.player.setPlayerWeather(WeatherType.CLEAR);
|
||||
@ -246,8 +244,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void setGameMode(@Nonnull final PlotGameMode gameMode) {
|
||||
Preconditions.checkNotNull(gameMode, "Specified gamemode cannot be null");
|
||||
@Override public void setGameMode(@NotNull final PlotGameMode gameMode) {
|
||||
switch (gameMode) {
|
||||
case ADVENTURE:
|
||||
this.player.setGameMode(GameMode.ADVENTURE);
|
||||
@ -281,9 +278,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
this.player.setAllowFlight(fly);
|
||||
}
|
||||
|
||||
@Override public void playMusic(@Nonnull final Location location, @Nonnull final PlotBlock id) {
|
||||
Preconditions.checkNotNull(location, "Specified location cannot be null");
|
||||
Preconditions.checkNotNull(id, "Specified block cannot be null");
|
||||
@Override public void playMusic(@NotNull final Location location, @NotNull final PlotBlock id) {
|
||||
if (PlotBlock.isEverything(id) || id.isAir()) {
|
||||
// Let's just stop all the discs because why not?
|
||||
for (final Sound sound : Arrays.stream(Sound.values())
|
||||
|
@ -673,8 +673,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
//todo optimize maxY
|
||||
void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX, int offsetZ) {
|
||||
maxY = Math.min(255, maxY);
|
||||
BaseBlock[] ids;
|
||||
ids = new BaseBlock[maxY + 1];
|
||||
BaseBlock[] ids = new BaseBlock[maxY + 1];
|
||||
for (short y = 0; y <= maxY; y++) {
|
||||
BaseBlock block = world.getFullBlock(BlockVector3.at(x, y, z));
|
||||
ids[y] = block;
|
||||
|
@ -1,22 +1,11 @@
|
||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
@ -26,6 +15,9 @@ import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java
|
||||
* Original License:
|
||||
@ -773,7 +765,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
|
||||
PlotBlock plotBlock;
|
||||
if (Material.matchMaterial(workingString) != null) {
|
||||
return PlotBlock.get(workingString);
|
||||
} else if (NEW_STRING_TO_LEGACY_PLOT_BLOCK.keySet().contains(workingString.toLowerCase())) {
|
||||
} else if (NEW_STRING_TO_LEGACY_PLOT_BLOCK.containsKey(workingString.toLowerCase())) {
|
||||
return PlotBlock.get(workingString);
|
||||
} else if ((plotBlock = fromLegacyToString(idDataPair)) != null) {
|
||||
return plotBlock;
|
||||
|
@ -5,14 +5,22 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,7 +29,12 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
|
||||
|
||||
@ -215,7 +228,11 @@ import java.util.*;
|
||||
|
||||
public static List<Entity> getEntities(@NonNull final String worldName) {
|
||||
World world = getWorld(worldName);
|
||||
return world != null ? world.getEntities() : new ArrayList<Entity>();
|
||||
if (world != null) {
|
||||
return world.getEntities();
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getLocation(@NonNull final Entity entity) {
|
||||
@ -270,19 +287,17 @@ import java.util.*;
|
||||
int air = 1;
|
||||
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
||||
Block block = bukkitWorld.getBlockAt(x, y, z);
|
||||
if (block != null) {
|
||||
Material type = block.getType();
|
||||
if (type.isSolid()) {
|
||||
if (air > 1) {
|
||||
return y;
|
||||
}
|
||||
air = 0;
|
||||
} else {
|
||||
if (block.isLiquid()) {
|
||||
return y;
|
||||
}
|
||||
air++;
|
||||
Material type = block.getType();
|
||||
if (type.isSolid()) {
|
||||
if (air > 1) {
|
||||
return y;
|
||||
}
|
||||
air = 0;
|
||||
} else {
|
||||
if (block.isLiquid()) {
|
||||
return y;
|
||||
}
|
||||
air++;
|
||||
}
|
||||
}
|
||||
return bukkitWorld.getMaxHeight() - 1;
|
||||
@ -291,11 +306,9 @@ import java.util.*;
|
||||
@Override @Nullable public String[] getSign(@NonNull final Location location) {
|
||||
Block block = getWorld(location.getWorld())
|
||||
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||
if (block != null) {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
return sign.getLines();
|
||||
}
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
return sign.getLines();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -377,9 +390,6 @@ import java.util.*;
|
||||
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
|
||||
final World world = getWorld(worldName);
|
||||
final Block block = world.getBlockAt(items.x, items.y, items.z);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
final BlockState state = block.getState();
|
||||
if (state instanceof InventoryHolder) {
|
||||
InventoryHolder holder = (InventoryHolder) state;
|
||||
@ -457,9 +467,6 @@ import java.util.*;
|
||||
@Override public PlotBlock getBlock(@NonNull final Location location) {
|
||||
final World world = getWorld(location.getWorld());
|
||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||
if (block == null) {
|
||||
return StringPlotBlock.EVERYTHING;
|
||||
}
|
||||
return PlotBlock.get(block.getType().name());
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
world = worlds.get(0).getName();
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
PlotSquared.debug(Captions.PREFIX + "&6Starting player data caching for: " + world);
|
||||
PlotSquared.debug(Captions.PREFIX + "Starting player data caching for: " + world);
|
||||
File uuidFile = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (uuidFile.exists()) {
|
||||
try {
|
||||
@ -83,7 +83,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<>());
|
||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PlotSquared.debug("&aFast mode UUID caching enabled!");
|
||||
PlotSquared.debug("Fast mode UUID caching enabled!");
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new DatFileFilter());
|
||||
boolean check = all.isEmpty();
|
||||
|
@ -249,11 +249,11 @@ public abstract class Command {
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1")
|
||||
.command(baseCommand + " " + (0 + 2)).text(Captions.CLICKABLE.s()).color("$2")
|
||||
.command(baseCommand + " " + 2).text(Captions.CLICKABLE.s()).color("$2")
|
||||
.send(player);
|
||||
return;
|
||||
}
|
||||
if (page == totalPages && totalPages != 0) { // Back
|
||||
if (totalPages != 0) { // Back
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ")
|
||||
.color("$3").text("->").color("$3").text(Captions.CLICKABLE.s()).color("$2")
|
||||
.send(player);
|
||||
@ -387,7 +387,7 @@ public abstract class Command {
|
||||
String[] split = usage[i].split("\\|| |\\>|\\<|\\[|\\]|\\{|\\}|\\_|\\/");
|
||||
for (String aSplit : split) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(arg, aSplit)) {
|
||||
if (arg.equalsIgnoreCase(aSplit)) {
|
||||
count += 5 - i + require;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class Help extends Command {
|
||||
|
||||
CommandCategory catEnum = null;
|
||||
if (cat != null) {
|
||||
if (!StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||
if (!"all".equalsIgnoreCase(cat)) {
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
|
||||
catEnum = c;
|
||||
|
@ -16,7 +16,6 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
@ -348,12 +347,7 @@ public class ListCmd extends SubCommand {
|
||||
public void displayPlots(final PlotPlayer player, List<Plot> plots, int pageSize, int page,
|
||||
PlotArea area, String[] args, boolean sort) {
|
||||
// Header
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().isBasePlot()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
plots.removeIf(plot -> !plot.isBasePlot());
|
||||
if (sort) {
|
||||
plots = PlotSquared.get().sortPlots(plots, SortType.CREATION_DATE, area);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class FlatRandomCollection<T> extends RandomCollection<T> {
|
||||
super(weights, random);
|
||||
int max = 0;
|
||||
int[] counts = new int[weights.size()];
|
||||
Double[] weightDoubles = weights.values().toArray(new Double[weights.size()]);
|
||||
Double[] weightDoubles = weights.values().toArray(new Double[0]);
|
||||
for (int i = 0; i < weightDoubles.length; i++) {
|
||||
int weight = (int) (weightDoubles[i] * 100);
|
||||
counts[i] = weight;
|
||||
|
@ -500,7 +500,7 @@ public class MainUtil {
|
||||
}
|
||||
for (Plot p : plots) {
|
||||
String name = p.getAlias();
|
||||
if (!name.isEmpty() && StringMan.isEqualIgnoreCase(name, arg)) {
|
||||
if (!name.isEmpty() && name.equalsIgnoreCase(arg)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,15 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class StringMan {
|
||||
|
||||
@ -145,12 +152,7 @@ public class StringMan {
|
||||
|
||||
public static String joinOrdered(Collection<?> collection, String delimiter) {
|
||||
Object[] array = collection.toArray();
|
||||
Arrays.sort(array, new Comparator<Object>() {
|
||||
@Override public int compare(Object a, Object b) {
|
||||
return a.hashCode() - b.hashCode();
|
||||
}
|
||||
|
||||
});
|
||||
Arrays.sort(array, Comparator.comparingInt(Object::hashCode));
|
||||
return join(array, delimiter);
|
||||
}
|
||||
|
||||
@ -186,8 +188,8 @@ public class StringMan {
|
||||
n = m;
|
||||
m = t.length();
|
||||
}
|
||||
int p[] = new int[n + 1];
|
||||
int d[] = new int[n + 1];
|
||||
int[] p = new int[n + 1];
|
||||
int[] d = new int[n + 1];
|
||||
int i;
|
||||
for (i = 0; i <= n; i++) {
|
||||
p[i] = i;
|
||||
@ -235,9 +237,9 @@ public class StringMan {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualIgnoreCaseToAny(String a, String... args) {
|
||||
public static boolean isEqualIgnoreCaseToAny(@NotNull String a, String... args) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(a, arg)) {
|
||||
if (a.equalsIgnoreCase(arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ public abstract class UUIDHandlerImplementation {
|
||||
protected UUIDWrapper uuidWrapper;
|
||||
private boolean cached = false;
|
||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<>());
|
||||
// private BiMap<UUID, StringWrapper> nameMap = uuidMap.inverse();
|
||||
|
||||
public UUIDHandlerImplementation(UUIDWrapper wrapper) {
|
||||
this.uuidWrapper = wrapper;
|
||||
|
Loading…
Reference in New Issue
Block a user