mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Minor code tweaks
This commit is contained in:
parent
7760631751
commit
07b6942690
@ -171,7 +171,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
getLogger().info("-------- PlotSquared Update Check --------");
|
getLogger().info("-------- PlotSquared Update Check --------");
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
getLogger().severe(String
|
getLogger().severe(String
|
||||||
.format("Could not check for update. Reason: %s",
|
.format("Could not check for updates. Reason: %s",
|
||||||
throwable.getMessage()));
|
throwable.getMessage()));
|
||||||
} else {
|
} else {
|
||||||
if (updateDescription == null) {
|
if (updateDescription == null) {
|
||||||
@ -180,8 +180,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
} else {
|
} else {
|
||||||
getLogger()
|
getLogger()
|
||||||
.info("There appears to be a PlotSquared update available!");
|
.info("There appears to be a PlotSquared update available!");
|
||||||
getLogger().info(String.format("You are running version %s,"
|
getLogger().info(String.format(
|
||||||
+ " the newest available version is %s",
|
"You are running version %s, the newest available version is %s",
|
||||||
getPluginVersionString(), updateDescription.getVersion()));
|
getPluginVersionString(), updateDescription.getVersion()));
|
||||||
getLogger().info(
|
getLogger().info(
|
||||||
String.format("Update URL: %s", updateDescription.getUrl()));
|
String.format("Update URL: %s", updateDescription.getUrl()));
|
||||||
@ -540,6 +540,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
case PUFFERFISH:
|
case PUFFERFISH:
|
||||||
case PHANTOM:
|
case PHANTOM:
|
||||||
case ILLUSIONER:
|
case ILLUSIONER:
|
||||||
|
case CAT:
|
||||||
|
case PANDA:
|
||||||
|
case FOX:
|
||||||
|
case PILLAGER:
|
||||||
|
case TRADER_LLAMA:
|
||||||
|
case WANDERING_TRADER:
|
||||||
|
case RAVAGER:
|
||||||
|
//case BEE:
|
||||||
default: {
|
default: {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
|
@ -73,7 +73,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
return this.platformGenerator;
|
return this.platformGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||||
try {
|
try {
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
@ -117,7 +119,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
return toAdd;
|
return toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @NotNull
|
@Override
|
||||||
|
@NotNull
|
||||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
|
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
|
||||||
@NotNull BiomeGrid biome) {
|
@NotNull BiomeGrid biome) {
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ import java.util.regex.Pattern;
|
|||||||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
||||||
if (flag.isPresent() && !Permissions
|
if (flag.isPresent() && !Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||||
List<String> blocked_cmds = flag.get();
|
List<String> blockedCommands = flag.get();
|
||||||
String part = parts[0];
|
String part = parts[0];
|
||||||
if (parts[0].contains(":")) {
|
if (parts[0].contains(":")) {
|
||||||
part = parts[0].split(":")[1];
|
part = parts[0].split(":")[1];
|
||||||
@ -674,7 +674,7 @@ import java.util.regex.Pattern;
|
|||||||
if (!s1.equals(part)) {
|
if (!s1.equals(part)) {
|
||||||
msg = msg.replace(s1, part);
|
msg = msg.replace(s1, part);
|
||||||
}
|
}
|
||||||
for (String s : blocked_cmds) {
|
for (String s : blockedCommands) {
|
||||||
Pattern pattern;
|
Pattern pattern;
|
||||||
if (!RegExUtil.compiledPatterns.containsKey(s)) {
|
if (!RegExUtil.compiledPatterns.containsKey(s)) {
|
||||||
RegExUtil.compiledPatterns.put(s, pattern = Pattern.compile(s));
|
RegExUtil.compiledPatterns.put(s, pattern = Pattern.compile(s));
|
||||||
@ -745,8 +745,8 @@ import java.util.regex.Pattern;
|
|||||||
.text(" --------").color("$2").send(pp);
|
.text(" --------").color("$2").send(pp);
|
||||||
new PlotMessage("There appears to be a PlotSquared update available!")
|
new PlotMessage("There appears to be a PlotSquared update available!")
|
||||||
.color("$1").send(pp);
|
.color("$1").send(pp);
|
||||||
new PlotMessage(String.format("You are running version %s,"
|
new PlotMessage(String.format(
|
||||||
+ " the newest available version is %s",
|
"You are running version %s, the newest available version is %s",
|
||||||
bukkitMain.getPluginVersionString(),
|
bukkitMain.getPluginVersionString(),
|
||||||
updateDescription.getVersion())).color("$1").send(pp);
|
updateDescription.getVersion())).color("$1").send(pp);
|
||||||
new PlotMessage("Update URL").color("$1").text(": ").color("$2")
|
new PlotMessage("Update URL").color("$1").text(": ").color("$2")
|
||||||
@ -1340,12 +1340,6 @@ import java.util.regex.Pattern;
|
|||||||
if (Flags.ICE_FORM.isFalse(plot)) {
|
if (Flags.ICE_FORM.isFalse(plot)) {
|
||||||
event.setCancelled(true);
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Block> blocks = event.getBlocks();
|
for (Block block1 : event.getBlocks()) {
|
||||||
for (Block block1 : blocks) {
|
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
.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());
|
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
/*
|
/*
|
||||||
* plot -> the base plot of the merged area
|
* plot → the base plot of the merged area
|
||||||
* origin -> the plot where the event gets called
|
* 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())) {
|
if (!Objects.equals(plot, origin) && (!plot.isMerged() && !origin.isMerged())) {
|
||||||
event.getBlocks().remove(i);
|
event.getBlocks().remove(i);
|
||||||
}
|
}
|
||||||
@ -2025,6 +2018,18 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
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)) {
|
if (!EventUtil.manager.checkPlayerBlockEvent(pp, eventType, location, blocktype1, true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Event.Result.DENY);
|
event.setUseInteractedBlock(Event.Result.DENY);
|
||||||
@ -2372,6 +2377,11 @@ import java.util.regex.Pattern;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player p = event.getPlayer();
|
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);
|
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
|
@ -2,6 +2,4 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
|
|||||||
|
|
||||||
public class BukkitVersion {
|
public class BukkitVersion {
|
||||||
public static int[] v1_13_2 = {1, 13, 2};
|
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.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||||
@ -21,7 +22,7 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
|||||||
|
|
||||||
@Override public UUID getUUID(OfflinePlayer player) {
|
@Override public UUID getUUID(OfflinePlayer player) {
|
||||||
return UUID.nameUUIDFromBytes(
|
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) {
|
@Override public UUID getUUID(String name) {
|
||||||
|
@ -52,8 +52,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (PreparedStatement stmt = getConnection().prepareStatement(
|
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();
|
stmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -237,7 +236,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SQLUUIDHandlerException extends RuntimeException {
|
private static class SQLUUIDHandlerException extends RuntimeException {
|
||||||
|
|
||||||
SQLUUIDHandlerException(String s, Throwable c) {
|
SQLUUIDHandlerException(String s, Throwable c) {
|
||||||
super("SQLUUIDHandler caused an exception: " + s, 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) {
|
private void addBlock(@NonNull final BlockState block, double chance) {
|
||||||
if (chance == -1) chance = 1;
|
if (chance == -1) chance = 1;
|
||||||
String prefix = input.length() == 0 ? "" : ",";
|
String prefix = input.length() == 0 ? "" : ",";
|
||||||
input.append(prefix).append(chance + "%" + prefix);
|
input.append(prefix).append(chance).append("%").append(prefix);
|
||||||
this.compiled = false;
|
this.compiled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ public final class BlockBucket implements ConfigurationSerializable {
|
|||||||
return ImmutableMap.of("blocks", this.toString());
|
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 min;
|
||||||
private final int max;
|
private final int max;
|
||||||
|
@ -105,6 +105,10 @@ public class Location implements Cloneable, Comparable<Location> {
|
|||||||
return area != null && area.getPlotAbs(this) == null;
|
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() {
|
public boolean isUnownedPlotArea() {
|
||||||
PlotArea area = getPlotArea();
|
PlotArea area = getPlotArea();
|
||||||
return area != null && area.getOwnedPlotAbs(this) == null;
|
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.
|
* the whole world if none exists.
|
||||||
*
|
*
|
||||||
* @return CuboidRegion
|
* @return CuboidRegion
|
||||||
@ -627,7 +627,7 @@ public abstract class PlotArea {
|
|||||||
this.meta.put(key, value);
|
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);
|
final Object v = getMeta(key);
|
||||||
return v == null ? def : (T) v;
|
return v == null ? def : (T) v;
|
||||||
}
|
}
|
||||||
@ -637,7 +637,8 @@ public abstract class PlotArea {
|
|||||||
* <br>
|
* <br>
|
||||||
* For persistent metadata use the flag system
|
* 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) {
|
if (this.meta != null) {
|
||||||
return this.meta.get(key);
|
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.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
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) {
|
Location location, BlockType blockType, boolean notifyPerms) {
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
assert area != null;
|
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.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||||||
public final BlockState[][][] result;
|
public final BlockState[][][] result;
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int length;
|
private final int length;
|
||||||
private final int area;
|
@Deprecated private final int area;
|
||||||
private final BlockVector3 bot;
|
private final BlockVector3 bot;
|
||||||
private final BlockVector3 top;
|
private final BlockVector3 top;
|
||||||
|
|
||||||
@ -70,7 +71,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||||||
return true;
|
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];
|
BlockState[][] blocksY = result[y];
|
||||||
if (blocksY != null) {
|
if (blocksY != null) {
|
||||||
BlockState[] blocksYZ = blocksY[z];
|
BlockState[] blocksYZ = blocksY[z];
|
||||||
@ -81,7 +84,9 @@ public class ChunkBlockQueue extends ScopedLocalBlockQueue {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getWorld() {
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public String getWorld() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user