mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Minor code tweaks
This commit is contained in:
parent
7760631751
commit
07b6942690
12 changed files with 160 additions and 130 deletions
|
@ -171,7 +171,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
getLogger().info("-------- PlotSquared Update Check --------");
|
||||
if (throwable != null) {
|
||||
getLogger().severe(String
|
||||
.format("Could not check for update. Reason: %s",
|
||||
.format("Could not check for updates. Reason: %s",
|
||||
throwable.getMessage()));
|
||||
} else {
|
||||
if (updateDescription == null) {
|
||||
|
@ -180,8 +180,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
} else {
|
||||
getLogger()
|
||||
.info("There appears to be a PlotSquared update available!");
|
||||
getLogger().info(String.format("You are running version %s,"
|
||||
+ " the newest available version is %s",
|
||||
getLogger().info(String.format(
|
||||
"You are running version %s, the newest available version is %s",
|
||||
getPluginVersionString(), updateDescription.getVersion()));
|
||||
getLogger().info(
|
||||
String.format("Update URL: %s", updateDescription.getUrl()));
|
||||
|
@ -540,6 +540,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
case PUFFERFISH:
|
||||
case PHANTOM:
|
||||
case ILLUSIONER:
|
||||
case CAT:
|
||||
case PANDA:
|
||||
case FOX:
|
||||
case PILLAGER:
|
||||
case TRADER_LLAMA:
|
||||
case WANDERING_TRADER:
|
||||
case RAVAGER:
|
||||
//case BEE:
|
||||
default: {
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
Location location = entity.getLocation();
|
||||
|
|
|
@ -73,7 +73,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||
return this.platformGenerator;
|
||||
}
|
||||
|
||||
@Override @NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||
@Override
|
||||
@NotNull
|
||||
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||
try {
|
||||
if (!this.loaded) {
|
||||
String name = world.getName();
|
||||
|
@ -117,7 +119,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||
return toAdd;
|
||||
}
|
||||
|
||||
@Override @NotNull
|
||||
@Override
|
||||
@NotNull
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
|
||||
@NotNull BiomeGrid biome) {
|
||||
|
||||
|
|
|
@ -640,7 +640,7 @@ import java.util.regex.Pattern;
|
|||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
||||
if (flag.isPresent() && !Permissions
|
||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
List<String> blocked_cmds = flag.get();
|
||||
List<String> blockedCommands = flag.get();
|
||||
String part = parts[0];
|
||||
if (parts[0].contains(":")) {
|
||||
part = parts[0].split(":")[1];
|
||||
|
@ -674,7 +674,7 @@ import java.util.regex.Pattern;
|
|||
if (!s1.equals(part)) {
|
||||
msg = msg.replace(s1, part);
|
||||
}
|
||||
for (String s : blocked_cmds) {
|
||||
for (String s : blockedCommands) {
|
||||
Pattern pattern;
|
||||
if (!RegExUtil.compiledPatterns.containsKey(s)) {
|
||||
RegExUtil.compiledPatterns.put(s, pattern = Pattern.compile(s));
|
||||
|
@ -745,8 +745,8 @@ import java.util.regex.Pattern;
|
|||
.text(" --------").color("$2").send(pp);
|
||||
new PlotMessage("There appears to be a PlotSquared update available!")
|
||||
.color("$1").send(pp);
|
||||
new PlotMessage(String.format("You are running version %s,"
|
||||
+ " the newest available version is %s",
|
||||
new PlotMessage(String.format(
|
||||
"You are running version %s, the newest available version is %s",
|
||||
bukkitMain.getPluginVersionString(),
|
||||
updateDescription.getVersion())).color("$1").send(pp);
|
||||
new PlotMessage("Update URL").color("$1").text(": ").color("$2")
|
||||
|
@ -1340,12 +1340,6 @@ import java.util.regex.Pattern;
|
|||
if (Flags.ICE_FORM.isFalse(plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
case STONE:
|
||||
case OBSIDIAN:
|
||||
case COBBLESTONE:
|
||||
// TODO event ?
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1491,8 +1485,7 @@ import java.util.regex.Pattern;
|
|||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
List<Block> blocks = event.getBlocks();
|
||||
for (Block block1 : blocks) {
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||
|
@ -1650,11 +1643,11 @@ import java.util.regex.Pattern;
|
|||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
/*
|
||||
* plot -> the base plot of the merged area
|
||||
* origin -> the plot where the event gets called
|
||||
* plot → the base plot of the merged area
|
||||
* origin → the plot where the event gets called
|
||||
*/
|
||||
|
||||
// Are plot and origin not the same AND are both plots merged
|
||||
// Are plot and origin different AND are both plots merged
|
||||
if (!Objects.equals(plot, origin) && (!plot.isMerged() && !origin.isMerged())) {
|
||||
event.getBlocks().remove(i);
|
||||
}
|
||||
|
@ -2025,6 +2018,18 @@ import java.util.regex.Pattern;
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (eventType == null) {
|
||||
PlotSquared.log("Please report this to PlotSquared Developers: ");
|
||||
PlotSquared.log("Action: " + event.getAction().toString());
|
||||
PlotSquared.log("HasItem: " + event.hasItem());
|
||||
PlotSquared.log("HasBlock: " + event.hasBlock());
|
||||
PlotSquared.log("getItem: " + (event.hasItem() ? Objects.requireNonNull(event.getItem())
|
||||
.toString() : "null"));
|
||||
PlotSquared.log("getBlockFace: " + (event.getBlockFace() != null ? event.getBlockFace().toString() : "null"));
|
||||
PlotSquared.log("isBlockInHand: " + (event.isBlockInHand()));
|
||||
PlotSquared.log("getClickedBlock: " + (event.getClickedBlock() != null ? event.getClickedBlock().toString() : "null"));
|
||||
return;
|
||||
}
|
||||
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
|
@ -2372,6 +2377,11 @@ import java.util.regex.Pattern;
|
|||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
if (p != null) {
|
||||
PlotSquared.debug("PlotSquared does not support HangingPlaceEvent for non-players.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
|
|
|
@ -2,6 +2,4 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
|||
|
||||
public class BukkitVersion {
|
||||
public static int[] v1_13_2 = {1, 13, 2};
|
||||
public static int[] v1_13_1 = {1, 13, 1};
|
||||
public static int[] v1_13_0 = {1, 13, 0};
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.google.common.base.Charsets;
|
|||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
|
@ -21,7 +22,7 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
|||
|
||||
@Override public UUID getUUID(OfflinePlayer player) {
|
||||
return UUID.nameUUIDFromBytes(
|
||||
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
("OfflinePlayer:" + Objects.requireNonNull(player.getName()).toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override public UUID getUUID(String name) {
|
||||
|
|
|
@ -52,8 +52,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||
}
|
||||
|
||||
try (PreparedStatement stmt = getConnection().prepareStatement(
|
||||
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)"
|
||||
+ ')')) {
|
||||
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username))")) {
|
||||
stmt.execute();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -237,7 +236,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||
return false;
|
||||
}
|
||||
|
||||
private class SQLUUIDHandlerException extends RuntimeException {
|
||||
private static class SQLUUIDHandlerException extends RuntimeException {
|
||||
|
||||
SQLUUIDHandlerException(String s, Throwable c) {
|
||||
super("SQLUUIDHandler caused an exception: " + s, c);
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class BlockBucket implements ConfigurationSerializable {
|
|||
private void addBlock(@NonNull final BlockState block, double chance) {
|
||||
if (chance == -1) chance = 1;
|
||||
String prefix = input.length() == 0 ? "" : ",";
|
||||
input.append(prefix).append(chance + "%" + prefix);
|
||||
input.append(prefix).append(chance).append("%").append(prefix);
|
||||
this.compiled = false;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ public final class BlockBucket implements ConfigurationSerializable {
|
|||
return ImmutableMap.of("blocks", this.toString());
|
||||
}
|
||||
|
||||
@Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range {
|
||||
@Getter @EqualsAndHashCode @RequiredArgsConstructor private static final class Range {
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
|
|
@ -105,6 +105,10 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||
return area != null && area.getPlotAbs(this) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if anyone owns a plot at the current location.
|
||||
* @return true if the location is a road, not a plot area, or if the plot is unclaimed.
|
||||
*/
|
||||
public boolean isUnownedPlotArea() {
|
||||
PlotArea area = getPlotArea();
|
||||
return area != null && area.getOwnedPlotAbs(this) == null;
|
||||
|
|
|
@ -117,7 +117,7 @@ public abstract class PlotArea {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the region for this PlotArea or a CuboidRegion encompassing
|
||||
* Returns the region for this PlotArea, or a CuboidRegion encompassing
|
||||
* the whole world if none exists.
|
||||
*
|
||||
* @return CuboidRegion
|
||||
|
@ -627,7 +627,7 @@ public abstract class PlotArea {
|
|||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@NotNull public <T> T getMeta(@Nullable final String key, @NotNull final T def) {
|
||||
@NotNull public <T> T getMeta(@NotNull final String key, @NotNull final T def) {
|
||||
final Object v = getMeta(key);
|
||||
return v == null ? def : (T) v;
|
||||
}
|
||||
|
@ -637,7 +637,8 @@ public abstract class PlotArea {
|
|||
* <br>
|
||||
* For persistent metadata use the flag system
|
||||
*/
|
||||
@Nullable public Object getMeta(@NotNull final String key) {
|
||||
@Nullable
|
||||
public Object getMeta(@NotNull final String key) {
|
||||
if (this.meta != null) {
|
||||
return this.meta.get(key);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAre
|
|||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -100,7 +101,7 @@ public abstract class EventUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer player, PlayerBlockEventType type,
|
||||
public boolean checkPlayerBlockEvent(PlotPlayer player, @NotNull PlayerBlockEventType type,
|
||||
Location location, BlockType blockType, boolean notifyPerms) {
|
||||
PlotArea area = location.getPlotArea();
|
||||
assert area != null;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -14,7 +15,7 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||
public final BlockState[][][] result;
|
||||
private final int width;
|
||||
private final int length;
|
||||
private final int area;
|
||||
@Deprecated private final int area;
|
||||
private final BlockVector3 bot;
|
||||
private final BlockVector3 top;
|
||||
|
||||
|
@ -70,7 +71,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override public BlockState getBlock(int x, int y, int z) {
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
BlockState[][] blocksY = result[y];
|
||||
if (blocksY != null) {
|
||||
BlockState[] blocksYZ = blocksY[z];
|
||||
|
@ -81,7 +84,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override public String getWorld() {
|
||||
@Override
|
||||
@Nullable
|
||||
public String getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue