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