This commit is contained in:
Telesphoreo 2020-08-23 21:38:56 -05:00
commit 26ea64a316
19 changed files with 119 additions and 73 deletions

View file

@ -6,7 +6,7 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
</parent>
<artifactId>EssentialsX</artifactId>
@ -75,13 +75,13 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>BaseProviders</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSReflectionProvider</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
@ -93,7 +93,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>PaperProvider</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
<exclusions>
<exclusion>
<groupId>com.destroystokyo.paper</groupId>
@ -105,7 +105,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>1_8Provider</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>

View file

@ -179,8 +179,13 @@ public class AsyncTeleport implements IAsyncTeleport {
}
}
teleportee.setLastLocation();
PaperLib.getChunkAtAsync(target.getLocation()).thenAccept(chunk -> {
Location loc = target.getLocation();
final Location targetLoc = target.getLocation();
if (ess.getSettings().isTeleportSafetyEnabled() && LocationUtil.isBlockOutsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX(), targetLoc.getBlockZ())) {
targetLoc.setX(LocationUtil.getXInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockX()));
targetLoc.setZ(LocationUtil.getZInsideWorldBorder(targetLoc.getWorld(), targetLoc.getBlockZ()));
}
PaperLib.getChunkAtAsync(targetLoc).thenAccept(chunk -> {
Location loc = targetLoc;
if (LocationUtil.isBlockUnsafeForUser(teleportee, chunk.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {

View file

@ -367,6 +367,13 @@ public class MetaItemStack {
} else {
throw new Exception(tl("invalidPotionMeta", split[1]));
}
} else if (split[0].equalsIgnoreCase("amplifier") || (allowShortName && split[0].equalsIgnoreCase("a"))) {
if (NumberUtil.isInt(split[1])) {
validPotionPower = true;
power = Integer.parseInt(split[1]);
} else {
throw new Exception(tl("invalidPotionMeta", split[1]));
}
} else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d"))) {
if (NumberUtil.isInt(split[1])) {
validPotionDuration = true;

View file

@ -59,7 +59,7 @@ public class PlayerList {
}
// Build the basic player list, divided by groups.
public static Map<String, List<User>> getPlayerLists(final IEssentials ess, final User sender, final boolean showHidden) {
public static Map<String, List<User>> getPlayerLists(final IEssentials ess, final IUser sender, final boolean showHidden) {
final Map<String, List<User>> playerList = new HashMap<>();
for (User onlineUser : ess.getOnlineUsers()) {
if ((sender == null && !showHidden && onlineUser.isHidden()) || (sender != null && !showHidden && !sender.getBase().canSee(onlineUser.getBase()))) {

View file

@ -34,7 +34,7 @@ public class Commandbigtree extends EssentialsCommand {
}
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
if (!user.getWorld().getBlockAt(loc).isPassable()) {
if (loc.getBlock().getType().isSolid()) {
throw new Exception(tl("bigTreeFailure"));
}
final boolean success = user.getWorld().generateTree(loc, tree);

View file

@ -120,7 +120,7 @@ public class Commandlist extends EssentialsCommand {
@Override
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
if (args.length == 1) {
return getGroups();
return new ArrayList<>(PlayerList.getPlayerLists(ess, sender.getUser(ess), true).keySet());
} else {
return Collections.emptyList();
}

View file

@ -87,7 +87,7 @@ public class Commandpotion extends EssentialsCommand {
}
return options;
} else if (args.length == 2 && args[0].startsWith("effect:")) {
return Lists.newArrayList("power:1", "power:2", "power:3", "power:4");
return Lists.newArrayList("power:1", "power:2", "power:3", "power:4", "amplifier:0", "amplifier:1", "amplifier:2", "amplifier:3");
} else if (args.length == 3 && args[0].startsWith("effect:")) {
List<String> options = Lists.newArrayList();
for (String duration : COMMON_DURATIONS) {

View file

@ -64,6 +64,10 @@ public class Commandtime extends EssentialsCommand {
// Start updating world times, we have what we need
User user = ess.getUser(sender.getPlayer());
if (!user.isAuthorized("essentials.time.set")) {
throw new Exception(tl("timeSetPermission"));
}
for (World world : worlds) {
if (!canUpdateWorld(user, world)) {
throw new Exception(tl("timeSetWorldPermission", user.getWorld().getName()));

View file

@ -43,7 +43,7 @@ public class Commandtree extends EssentialsCommand {
}
final Location loc = LocationUtil.getTarget(user.getBase()).add(0, 1, 0);
if (!user.getWorld().getBlockAt(loc).isPassable()) {
if (loc.getBlock().getType().isSolid()) {
throw new Exception(tl("treeFailure"));
}

View file

@ -1,17 +1,19 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.*;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IEssentialsModule;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import net.ess3.api.IEssentials;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
@ -33,16 +35,11 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
protected transient IEssentials ess;
protected transient IEssentialsModule module;
protected static final Logger logger = Logger.getLogger("Essentials");
protected static final TFMHandler tfmHandler = new TFMHandler();
protected EssentialsCommand(final String name) {
this.name = name;
}
public static TFMHandler getTFMHandler() {
return tfmHandler;
}
@Override
public void setEssentials(final IEssentials ess) {
this.ess = ess;
@ -283,14 +280,6 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
return players;
}
/**
* Returns a list of all online groups.
*/
protected List<String> getGroups() {
// TODO: A better way to do this
return new ArrayList<>(PlayerList.getPlayerLists(ess, null, true).keySet());
}
/**
* Gets a list of tab-completable items that start with the given name.
* Due to the number of items, this may not return the entire list.

View file

@ -17,8 +17,15 @@ import static com.earth2me.essentials.I18n.tl;
public class LocationUtil {
// Water types used for TRANSPARENT_MATERIALS and is-water-safe config option
private static final Set<Material> WATER_TYPES =
EnumUtil.getAllMatching(Material.class, "WATER", "FLOWING_WATER");
private static final Set<Material> WATER_TYPES = EnumUtil.getAllMatching(Material.class,
"FLOWING_WATER", "WATER");
// Types checked by isBlockDamaging
private static final Set<Material> DAMAGING_TYPES = EnumUtil.getAllMatching(Material.class,
"CACTUS", "CAMPFIRE", "FIRE", "MAGMA_BLOCK", "SOUL_CAMPFIRE", "SOUL_FIRE", "SWEET_BERRY_BUSH", "WITHER_ROSE");
private static final Set<Material> LAVA_TYPES = EnumUtil.getAllMatching(Material.class,
"FLOWING_LAVA", "LAVA", "STATIONARY_LAVA");
private static final Material PORTAL = EnumUtil.getMaterial("NETHER_PORTAL", "PORTAL");
// The player can stand inside these materials
private static final Set<Material> HOLLOW_MATERIALS = new HashSet<>();
@ -92,6 +99,38 @@ public class LocationUtil {
return y > world.getMaxHeight() || HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType());
}
public static boolean isBlockOutsideWorldBorder(final World world, final int x, final int z) {
final Location center = world.getWorldBorder().getCenter();
final int radius = (int) world.getWorldBorder().getSize() / 2;
final int x1 = center.getBlockX() - radius, x2 = center.getBlockX() + radius;
final int z1 = center.getBlockZ() - radius, z2 = center.getBlockZ() + radius;
return x < x1 || x > x2 || z < z1 || z > z2;
}
public static int getXInsideWorldBorder(final World world, final int x) {
final Location center = world.getWorldBorder().getCenter();
final int radius = (int) world.getWorldBorder().getSize() / 2;
final int x1 = center.getBlockX() - radius, x2 = center.getBlockX() + radius;
if (x < x1) {
return x1;
} else if (x > x2) {
return x2;
}
return x;
}
public static int getZInsideWorldBorder(final World world, final int z) {
final Location center = world.getWorldBorder().getCenter();
final int radius = (int) world.getWorldBorder().getSize() / 2;
final int z1 = center.getBlockZ() - radius, z2 = center.getBlockZ() + radius;
if (z < z1) {
return z1;
} else if (z > z2) {
return z2;
}
return z;
}
public static boolean isBlockUnsafeForUser(final IUser user, final World world, final int x, final int y, final int z) {
if (user.getBase().isOnline() && world.equals(user.getBase().getWorld()) && (user.getBase().getGameMode() == GameMode.CREATIVE || user.getBase().getGameMode() == GameMode.SPECTATOR || user.isGodModeEnabled()) && user.getBase().getAllowFlight()) {
return false;
@ -100,7 +139,10 @@ public class LocationUtil {
if (isBlockDamaging(world, x, y, z)) {
return true;
}
return isBlockAboveAir(world, x, y, z);
if (isBlockAboveAir(world, x, y, z)) {
return true;
}
return isBlockOutsideWorldBorder(world, x, z);
}
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z) {
@ -108,31 +150,19 @@ public class LocationUtil {
}
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z) {
final Block below = world.getBlockAt(x, y - 1, z);
final Material block = world.getBlockAt(x, y, z).getType();
final Material below = world.getBlockAt(x, y - 1, z).getType();
final Material above = world.getBlockAt(x, y + 1, z).getType();
switch (below.getType()) {
case LAVA:
case FIRE:
return true;
}
if (MaterialUtil.isBed(below.getType())) {
if (DAMAGING_TYPES.contains(below) || LAVA_TYPES.contains(below) || MaterialUtil.isBed(below)) {
return true;
}
try {
if (below.getType() == Material.valueOf("FLOWING_LAVA")) {
return true;
}
} catch (Exception ignored) {} // 1.13 LAVA uses Levelled
Material PORTAL = EnumUtil.getMaterial("NETHER_PORTAL", "PORTAL");
if (world.getBlockAt(x, y, z).getType() == PORTAL) {
if (block == PORTAL) {
return true;
}
return (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y, z).getType())) || (!HOLLOW_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType()));
return !HOLLOW_MATERIALS.contains(block) || !HOLLOW_MATERIALS.contains(above);
}
// Not needed if using getSafeDestination(loc)
@ -175,6 +205,10 @@ public class LocationUtil {
int x = loc.getBlockX();
int y = (int) Math.round(loc.getY());
int z = loc.getBlockZ();
if (isBlockOutsideWorldBorder(world, x, z)) {
x = getXInsideWorldBorder(world, x);
z = getZInsideWorldBorder(world, z);
}
final int origX = x;
final int origY = y;
final int origZ = z;

View file

@ -789,6 +789,7 @@ chat:
# Chat formatting can be done in two ways, you can either define a standard format for all chat.
# Or you can give a group specific chat format, to give some extra variation.
# For more information of chat formatting, check out the wiki: http://wiki.ess3.net/wiki/Chat_Formatting
# Note: Using the {PREFIX} and {SUFFIX} placeholders along with {DISPLAYNAME} may cause double prefixes/suffixes to be shown in chat unless add-prefix-suffix is uncommented and set to false.
format: '<{DISPLAYNAME}> {MESSAGE}'
#format: '&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}'

View file

@ -6,7 +6,7 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
</parent>
<artifactId>EssentialsXSpawn</artifactId>

View file

@ -1,4 +1,4 @@
[![EssentialsX](https://i.imgur.com/CP4SZpB.png)](https://essentialsx.cf)
[![EssentialsX](https://i.imgur.com/CP4SZpB.png)](https://essentialsx.net)
[<img alt="Jenkins" src="https://img.shields.io/badge/-Download_from_Jenkins-D24939.svg?logo=jenkins&style=flat-square&logoColor=white" height=32>](http://ci.ender.zone/job/EssentialsX/)
@ -14,9 +14,9 @@ The official upstream repository for the original Essentials project is at https
Why use EssentialsX?
--------
--------------------
EssentialsX is an unofficial continuation of Essentials, updated to support modern Minecraft and Spigot versions. It provides several performance enhancements and fixes that are currently not available in Essentials and Spigot-Essentials. [For more details, see the wiki.](https://essentialsx.github.io/#/Improvements)
EssentialsX is an unofficial continuation of Essentials, updated to support modern Minecraft and Spigot versions. It provides several performance enhancements and fixes that are currently not available in Essentials and Spigot-Essentials. [For more details, see the wiki.](https://essentialsx.net/wiki/Improvements.html)
EssentialsX is almost a completely drop-in replacement for Essentials. However, it has different requirements:
@ -47,11 +47,13 @@ mvn clean install
Each module's jar can be found in `target/` inside each module's directory.
Using EssentialsX in your plugin
--------------------------------
Do you want to integrate with EssentialsX in your plugin? EssentialsX is available on the **ender.zone Maven repository** at https://ci.ender.zone/plugin/repository/everything/, and the EssentialsX artifact is `net.ess3:EssentialsX:2.18.1`.
More information at the [wiki](https://github.com/EssentialsX/Essentials/wiki/Common-Issues#how-do-i-add-essentialsx-as-a-dependency).
Do you want to integrate with EssentialsX in your plugin? EssentialsX is available on the **ender.zone Maven repository** at https://ci.ender.zone/plugin/repository/everything/.
To depend on EssentialsX 2.18.1, you should use the artifact `net.ess3:EssentialsX:2.18.1`. You can find more information at the [wiki](https://essentialsx.net/wiki/Common-Issues.html#how-do-i-add-essentialsx-as-a-dependency).
Contributing
@ -59,12 +61,16 @@ Contributing
Want to help improve EssentialsX? There are numerous ways you can contribute to the project.
If you'd like to make a financial contribution to the project, you can join our [Patreon](https://www.patreon.com/essentialsx/).
If you can't make a donation, don't worry! There's lots of other ways to contribute:
If you'd like to make a financial contribution to the project, you can join our [Patreon](https://www.patreon.com/essentialsx/),
or to make a one-off donation you can visit our [Ko-fi page](https://ko-fi.com/essentialsx). If you can't make a
donation, don't worry! There's lots of other ways to contribute:
* Do you run a server? Take a look at our ["help wanted" issues](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22),
where you can find issues that need extra testing and investigation. You can also join the [MOSS Discord community](https://discord.gg/casfFyh)
and provide support to others.
* Do you run a server? Take a look at our ["help wanted"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22)
and ["bug: unconfirmed"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22bug%3A+unconfirmed%22)
issues, where you can find issues that need extra testing and investigation.
* Do you speak multiple languages? If so, we always welcome contributions to our [Crowdin project](https://crowdin.com/project/essentialsx-official).
* If you're a developer, you could look through our ["open to PR" issues](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22status%3A+open+to+PR%22).
We're always happy to receive bug fixes and feature additions as pull requests.
* Do you enjoy helping others? If so, why not contribute to the [EssentialsX documentation](https://github.com/EssentialsX/wiki)?
You can also join the [MOSS Discord community](https://discord.gg/casfFyh) and provide direct community support to
other EssentialsX users.
* If you're a developer, you could look through our ["open to PR"](https://github.com/EssentialsX/Essentials/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22status%3A+open+to+PR%22)
issues. We're always happy to receive bug fixes and feature additions as pull requests.

View file

@ -5,7 +5,7 @@
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
<packaging>pom</packaging>
@ -251,7 +251,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- The plugins' release version -->
<release.version>2.18.0</release.version>
<release.version>2.18.1</release.version>
<!-- The plugins' build number -->
<build.version>${git.closest.tag.commit.count}</build.version>

View file

@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.18.0</version>
<version>2.18.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -16,7 +16,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSReflectionProvider</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
</dependency>
</dependencies>
</project>

View file

@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.18.0</version>
<version>2.18.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View file

@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.18.0</version>
<version>2.18.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -16,7 +16,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>BaseProviders</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>

View file

@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.18.0</version>
<version>2.18.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -23,7 +23,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>BaseProviders</artifactId>
<version>2.18.0</version>
<version>2.18.1</version>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>