mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Small changes
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user