3 Commits
Author SHA1 Message Date
KennyTV 09be08aa77 Remove the rest of wrapping (since this branch now only suppors 1.8) 2019-09-02 18:06:56 +02:00
KennyTV e33fc4802d 1.6.1 Release
* Add option to enable the advanced for the clipboard selection as well
* Removed 1.9+ support from this branch - one should use the proper (master) version for that
(This branch does not contain support for particles that need extra data)
2019-09-02 17:43:45 +02:00
KennyTV f22e9cd668 Update README 2019-08-29 23:29:45 +02:00
45 changed files with 662 additions and 1496 deletions

No files matched your search

+5 -6
View File
@@ -3,16 +3,15 @@
[![Twitter](https://img.shields.io/twitter/follow/KennyTVN.svg?label=Twitter)](https://twitter.com/KennyTVN)
Sassy Minecraft plugin to show your current WorldEdit selection by displaying particles (which can be greatly customized in the plugin's config).
Compared to other server plugins with similar functionality, it aims at a higher performance and lesser memory impact by having a quite simplistic approach to calculating vectors.
It aims at a higher performance and lesser memory impact by having a quite simplistic approach to calculating vectors.
You can read up on everything else and see examples on the [**Spigot page**](https://www.spigotmc.org/resources/worldeditsui.60726/).
## Legacy support
This branch supports Minecraft versions from 1.9 upwards.
If you want a jar that supports 1.8.4-1.8.9 as well, see the `1.8-support` branch / the [**last release to contain a 1.8 build**](https://github.com/KennyTV/WorldEditSUI/releases/tag/1.6.1).
## Compiling
You need the Spigot server version 1.8.8-R0.1-SNAPSHOT installed (i.e. BuildTools/compiled source) to be able to compile the project.
See the `master` branch to compile the project without it (done by simply dropping 1.8 support).
Use Maven to compile the project (`mvn clean package`).
## Licence
This project is licensed under the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0).
This project is licensed under the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0).
@@ -5,18 +5,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat</artifactId>
<version>1.7</version>
<artifactId>nms-compat</artifactId>
<version>1.6.1</version>
</parent>
<artifactId>we-compat-common</artifactId>
<dependencies>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>nms-compat-common</artifactId>
</project>
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* WorldEditCUI - https://git.io/wecui
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,25 +16,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
package eu.kennytv.worldeditsui.compat.nms;
import com.sk89q.worldedit.regions.Region;
import org.bukkit.entity.Player;
public final class ProtectedRegionWrapper {
public abstract class AbstractParticleHelper implements IParticleHelper {
private final Region region;
private final SelectionType selectionType;
/**
* Only players with this permission can see another player's particles.
*/
private String permission;
public ProtectedRegionWrapper(final Region region, final SelectionType selectionType) {
this.region = region;
this.selectionType = selectionType;
protected boolean canSeeOtherParticles(final Player player) {
return permission == null || player.hasPermission(permission);
}
public Region getRegion() {
return region;
}
public SelectionType getSelectionType() {
return selectionType;
@Override
public void setPermission(final String permission) {
this.permission = permission;
}
}
@@ -0,0 +1,39 @@
/*
* WorldEditCUI - https://git.io/wecui
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.nms;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public interface IParticleHelper {
void playEffect(ViaParticle particle, Location location, float offX, float offY, float offZ, float speed, int amount, int radius, Player player);
default void playEffect(final ViaParticle particle, final Location location, final float speed, final int amount, final int radius, final Player player) {
playEffect(particle, location, 0, 0, 0, speed, amount, radius, player);
}
void playEffectToAll(ViaParticle particle, ViaParticle othersParticle, Location location, float offX, float offY, float offZ, float speed, int amount, int radius, Player origin);
default void playEffectToAll(final ViaParticle particle, final ViaParticle othersParticle, final Location location, final float speed, final int amount, final int radius, final Player origin) {
playEffectToAll(particle, othersParticle, location, 0, 0, 0, speed, amount, radius, origin);
}
void setPermission(String permission);
}
@@ -0,0 +1,104 @@
/*
* WorldEditCUI - https://git.io/wecui
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.nms;
import java.util.HashMap;
import java.util.Map;
public enum ViaParticle {
EXPLOSION_NORMAL,
EXPLOSION_LARGE,
EXPLOSION_HUGE,
FIREWORKS_SPARK,
WATER_BUBBLE,
WATER_SPLASH,
WATER_WAKE,
SUSPENDED,
SUSPENDED_DEPTH,
CRIT,
CRIT_MAGIC,
SMOKE_NORMAL,
SMOKE_LARGE,
SPELL,
SPELL_INSTANT,
SPELL_MOB,
SPELL_MOB_AMBIENT,
SPELL_WITCH,
DRIP_WATER,
DRIP_LAVA,
VILLAGER_ANGRY,
VILLAGER_HAPPY,
TOWN_AURA,
NOTE,
PORTAL,
ENCHANTMENT_TABLE,
FLAME,
LAVA,
FOOTSTEP,
CLOUD,
@Deprecated REDSTONE,
SNOWBALL,
SNOW_SHOVEL,
SLIME,
HEART,
BARRIER,
@Deprecated ITEM_CRACK,
@Deprecated BLOCK_CRACK,
@Deprecated BLOCK_DUST,
WATER_DROP,
ITEM_TAKE,
MOB_APPEARANCE,
// 1.9
DRAGON_BREATH,
END_ROD,
DAMAGE_INDICATOR,
SWEEP_ATTACK,
@Deprecated FALLING_DUST,
TOTEM,
SPIT,
// 1.13
SQUID_INK,
BUBBLE_POP,
CURRENT_DOWN,
BUBBLE_COLUMN_UP,
NAUTILUS,
DOLPHIN,
// 1.14
SNEEZE,
CAMPFIRE_COSY_SMOKE,
CAMPFIRE_SIGNAL_SMOKE,
COMPOSTER,
FLASH,
FALLING_LAVA,
LANDING_LAVA,
FALLING_WATER;
private static final Map<String, ViaParticle> BY_NAME = new HashMap<>();
static {
for (final ViaParticle particle : ViaParticle.values()) {
BY_NAME.put(particle.name(), particle);
}
}
public static ViaParticle getByName(final String name) {
return BY_NAME.get(name.toUpperCase());
}
}
+4 -5
View File
@@ -6,15 +6,14 @@
<parent>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>worldedit-sui-parent</artifactId>
<version>1.7</version>
<version>1.6.1</version>
</parent>
<packaging>pom</packaging>
<artifactId>we-compat</artifactId>
<artifactId>nms-compat</artifactId>
<modules>
<module>we-compat-common</module>
<module>we6-compat</module>
<module>we7-compat</module>
<module>nms-compat-common</module>
<module>v1_8_R3-compat</module>
</modules>
</project>
@@ -5,29 +5,23 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat</artifactId>
<version>1.7</version>
<artifactId>nms-compat</artifactId>
<version>1.6.1</version>
</parent>
<artifactId>we6-compat</artifactId>
<artifactId>v1_8_R3-compat</artifactId>
<dependencies>
<dependency>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat-common</artifactId>
<artifactId>nms-compat-common</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.1.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -0,0 +1,65 @@
/*
* WorldEditCUI - https://git.io/wecui
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.nms.v1_8_R3;
import eu.kennytv.worldeditsui.compat.nms.AbstractParticleHelper;
import eu.kennytv.worldeditsui.compat.nms.ViaParticle;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public final class ParticleHelper extends AbstractParticleHelper {
@Override
public void playEffect(final ViaParticle particle, final Location location, final float offX, final float offY, final float offZ, final float speed, final int amount, final int radius, final Player player) {
if (!location.getWorld().equals(player.getWorld())) return;
final int radiusSquared = radius * radius;
if (player.getLocation().distanceSquared(location) > radiusSquared) return;
final CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().playerConnection.sendPacket(createPacket(particle, location, offX, offY, offZ, speed, amount));
}
@Override
public void playEffectToAll(final ViaParticle particle, final ViaParticle othersParticle, final Location location, final float offX, final float offY, final float offZ, final float speed, final int amount, final int radius, final Player origin) {
final PacketPlayOutWorldParticles packet = createPacket(particle, location, offX, offY, offZ, speed, amount);
final PacketPlayOutWorldParticles othersPacket = particle == othersParticle ? packet : createPacket(othersParticle, location, offX, offY, offZ, speed, amount);
final int radiusSquared = radius * radius;
for (final Player player : Bukkit.getOnlinePlayers()) {
if (!location.getWorld().equals(player.getWorld())
|| player.getLocation().distanceSquared(location) > radiusSquared) continue;
final boolean originalPlayer = player.getUniqueId().equals(origin.getUniqueId());
if (!originalPlayer && !canSeeOtherParticles(player)) continue;
final CraftPlayer craftPlayer = (CraftPlayer) player;
craftPlayer.getHandle().playerConnection.sendPacket(originalPlayer ? packet : othersPacket);
}
}
private PacketPlayOutWorldParticles createPacket(final ViaParticle particle, final Location location, final float offX, final float offY, final float offZ, final float speed, final int amount) {
return new PacketPlayOutWorldParticles(EnumParticle.a(particle.ordinal()), true,
(float) location.getX(), (float) location.getY(), (float) location.getZ(),
offX, offY, offZ, speed, amount, (int[]) null);
}
}
+10 -16
View File
@@ -7,11 +7,11 @@
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>worldedit-sui-parent</artifactId>
<packaging>pom</packaging>
<version>1.7</version>
<version>1.6.1</version>
<modules>
<module>worldedit-sui</module>
<module>we-compat</module>
<module>nms-compat</module>
</modules>
<properties>
@@ -22,27 +22,21 @@
</properties>
<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>enginehub-repo</id>
<url>https://maven.sk89q.com/artifactory/repo/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -53,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
@@ -1,32 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
import org.bukkit.World;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
public interface ProtectedRegionHelper {
@Nullable
ProtectedRegionWrapper getRegion(World world, String regionName);
Set<String> getRegionNames(World world);
}
@@ -1,55 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.Material;
public interface RegionHelper {
SimpleVector getRadius(EllipsoidRegion region);
SimpleVector getRadius(EllipsoidRegion region, double offX, double offY, double offZ);
SimpleVector getRadius(CylinderRegion region, double offX, double offZ);
SimpleVector getCenter(Region region);
SimpleVector getCenter(Region region, double offX, double offY, double offZ);
SimpleVector getMinimumPoint(Region region);
SimpleVector getMaximumPoint(Region region);
SimpleVector getOrigin(Clipboard clipboard);
Region transformAndReShift(ClipboardHolder holder, Region region);
Region shift(Region region, double x, double y, double z);
Material getWand(WorldEditPlugin plugin);
Simple2DVector[] getPoints(Polygonal2DRegion region);
}
@@ -1,51 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
import org.bukkit.util.NumberConversions;
public final class Simple2DVector {
private final double x;
private final double z;
public Simple2DVector(final double x, final double z) {
this.x = x;
this.z = z;
}
public double getX() {
return x;
}
public double getZ() {
return z;
}
public double length() {
return Math.sqrt(lengthSquared());
}
public double lengthSquared() {
return NumberConversions.square(this.x) + NumberConversions.square(this.z);
}
public Simple2DVector subtract(final Simple2DVector vector) {
return new Simple2DVector(this.x - vector.x, this.z - vector.z);
}
}
@@ -1,64 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
public final class SimpleVector {
private final double x;
private final double y;
private final double z;
public SimpleVector(final double x, final double y, final double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final SimpleVector that = (SimpleVector) o;
return this.x == that.x && this.y == that.y && this.z == that.z;
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(x);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}
@@ -1,68 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.we6;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldguard.bukkit.RegionContainer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionType;
import eu.kennytv.worldeditsui.compat.ProtectedRegionHelper;
import eu.kennytv.worldeditsui.compat.ProtectedRegionWrapper;
import eu.kennytv.worldeditsui.compat.SelectionType;
import org.bukkit.World;
import java.util.Collections;
import java.util.Set;
public final class ProtectedRegionHelper6 implements ProtectedRegionHelper {
private final RegionContainer regionContainer = WorldGuardPlugin.inst().getRegionContainer();
@Override
public ProtectedRegionWrapper getRegion(final World world, final String regionName) {
final RegionManager regionManager = regionContainer.get(world);
if (regionManager == null) return null;
final ProtectedRegion region = regionManager.getRegion(regionName);
final RegionType type = region.getType();
final com.sk89q.worldedit.world.World worldWrapper = new BukkitWorld(world);
switch (type) {
case CUBOID:
return new ProtectedRegionWrapper(new CuboidRegion(worldWrapper, region.getMinimumPoint(), region.getMaximumPoint()), SelectionType.CUBOID);
case POLYGON:
return new ProtectedRegionWrapper(new Polygonal2DRegion(worldWrapper, region.getPoints(),
(int) region.getMinimumPoint().getY(), (int) region.getMaximumPoint().getY()), SelectionType.POLYGON);
case GLOBAL:
default:
return null;
}
}
@Override
public Set<String> getRegionNames(final World world) {
final RegionManager regionManager = regionContainer.get(world);
if (regionManager == null) return Collections.emptySet();
return regionManager.getRegions().keySet();
}
}
@@ -1,124 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.we6;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.*;
import com.sk89q.worldedit.session.ClipboardHolder;
import eu.kennytv.worldeditsui.compat.RegionHelper;
import eu.kennytv.worldeditsui.compat.Simple2DVector;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public final class RegionHelper6 implements RegionHelper {
@Override
public SimpleVector getRadius(final EllipsoidRegion region) {
final Vector radius = region.getRadius();
return new SimpleVector(radius.getX(), radius.getY(), radius.getZ());
}
@Override
public SimpleVector getRadius(final EllipsoidRegion region, final double offX, final double offY, final double offZ) {
final Vector radius = region.getRadius();
return new SimpleVector(radius.getX() + offX, radius.getY() + offY, radius.getZ() + offZ);
}
@Override
public SimpleVector getRadius(final CylinderRegion region, final double offX, final double offZ) {
final Vector2D radius = region.getRadius();
return new SimpleVector(radius.getX() + offX, region.getHeight(), radius.getZ() + offZ);
}
@Override
public SimpleVector getCenter(final Region region) {
final Vector center = region.getCenter();
return new SimpleVector(center.getX(), center.getY(), center.getZ());
}
@Override
public SimpleVector getCenter(final Region region, final double offX, final double offY, final double offZ) {
final Vector center = region.getCenter();
return new SimpleVector(center.getX() + offX, center.getY() + offY, center.getZ() + offZ);
}
@Override
public SimpleVector getMinimumPoint(final Region region) {
final Vector minimum = region.getMinimumPoint();
return new SimpleVector(minimum.getX(), minimum.getY(), minimum.getZ());
}
@Override
public SimpleVector getMaximumPoint(final Region region) {
final Vector maximum = region.getMaximumPoint();
return new SimpleVector(maximum.getX(), maximum.getY(), maximum.getZ());
}
@Override
public SimpleVector getOrigin(final Clipboard clipboard) {
final Vector origin = clipboard.getOrigin();
return new SimpleVector(origin.getX(), origin.getY(), origin.getZ());
}
@Override
public Region transformAndReShift(final ClipboardHolder holder, final Region region) {
final Transform transform = holder.getTransform();
final Vector origin = holder.getClipboard().getOrigin();
final Vector oldMin = region.getMinimumPoint();
final Vector oldMax = region.getMaximumPoint();
final Vector offset = oldMin.subtract(origin);
final Vector min = origin.add(transform.apply(offset));
final Vector max = min.add(transform.apply(oldMax.subtract(oldMin)));
return new CuboidRegion(region.getWorld(), min, max);
}
@Override
public Region shift(final Region region, final double x, final double y, final double z) {
try {
region.shift(new Vector(x, y, z));
} catch (final RegionOperationException ignored) {
}
return region;
}
@Override
public Material getWand(final WorldEditPlugin plugin) {
return new ItemStack(plugin.getLocalConfiguration().wandItem).getType();
}
@Override
public Simple2DVector[] getPoints(final Polygonal2DRegion region) {
final List<BlockVector2D> originalVectors = region.polygonize(-1);
final Simple2DVector[] vectors = new Simple2DVector[originalVectors.size()];
int i = 0;
for (final BlockVector2D vector : originalVectors) {
vectors[i++] = new Simple2DVector(vector.getX(), vector.getZ());
}
return vectors;
}
}
-34
View File
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat</artifactId>
<version>1.7</version>
</parent>
<artifactId>we7-compat</artifactId>
<dependencies>
<dependency>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat-common</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,68 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.we7;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionType;
import eu.kennytv.worldeditsui.compat.ProtectedRegionHelper;
import eu.kennytv.worldeditsui.compat.ProtectedRegionWrapper;
import eu.kennytv.worldeditsui.compat.SelectionType;
import org.bukkit.World;
import java.util.Collections;
import java.util.Set;
public final class ProtectedRegionHelper7 implements ProtectedRegionHelper {
private final RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
@Override
public ProtectedRegionWrapper getRegion(final World world, final String regionName) {
final BukkitWorld worldWrapper = new BukkitWorld(world);
final RegionManager regionManager = regionContainer.get(worldWrapper);
if (regionManager == null) return null;
final ProtectedRegion region = regionManager.getRegion(regionName);
final RegionType type = region.getType();
switch (type) {
case CUBOID:
return new ProtectedRegionWrapper(new CuboidRegion(worldWrapper, region.getMinimumPoint(), region.getMaximumPoint()), SelectionType.CUBOID);
case POLYGON:
return new ProtectedRegionWrapper(new Polygonal2DRegion(worldWrapper, region.getPoints(),
region.getMinimumPoint().getY(), region.getMaximumPoint().getY()), SelectionType.POLYGON);
case GLOBAL:
default:
return null;
}
}
@Override
public Set<String> getRegionNames(final World world) {
final RegionManager regionManager = regionContainer.get(new BukkitWorld(world));
if (regionManager == null) return Collections.emptySet();
return regionManager.getRegions().keySet();
}
}
@@ -1,124 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat.we7;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.*;
import com.sk89q.worldedit.session.ClipboardHolder;
import eu.kennytv.worldeditsui.compat.RegionHelper;
import eu.kennytv.worldeditsui.compat.Simple2DVector;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import org.bukkit.Material;
import java.util.List;
public final class RegionHelper7 implements RegionHelper {
@Override
public SimpleVector getRadius(final EllipsoidRegion region) {
final Vector3 radius = region.getRadius();
return new SimpleVector(radius.getX(), radius.getY(), radius.getZ());
}
@Override
public SimpleVector getRadius(final EllipsoidRegion region, final double offX, final double offY, final double offZ) {
final Vector3 radius = region.getRadius();
return new SimpleVector(radius.getX() + offX, radius.getY() + offY, radius.getZ() + offZ);
}
@Override
public SimpleVector getRadius(final CylinderRegion region, final double offX, final double offZ) {
final Vector2 radius = region.getRadius();
return new SimpleVector(radius.getX() + offX, region.getHeight(), radius.getZ() + offZ);
}
@Override
public SimpleVector getCenter(final Region region) {
final Vector3 center = region.getCenter();
return new SimpleVector(center.getX(), center.getY(), center.getZ());
}
@Override
public SimpleVector getCenter(final Region region, final double offX, final double offY, final double offZ) {
final Vector3 center = region.getCenter();
return new SimpleVector(center.getX() + offX, center.getY() + offY, center.getZ() + offZ);
}
@Override
public SimpleVector getMinimumPoint(final Region region) {
final BlockVector3 minimum = region.getMinimumPoint();
return new SimpleVector(minimum.getX(), minimum.getY(), minimum.getZ());
}
@Override
public SimpleVector getMaximumPoint(final Region region) {
final BlockVector3 maximum = region.getMaximumPoint();
return new SimpleVector(maximum.getX(), maximum.getY(), maximum.getZ());
}
@Override
public SimpleVector getOrigin(final Clipboard clipboard) {
final BlockVector3 origin = clipboard.getOrigin();
return new SimpleVector(origin.getX(), origin.getY(), origin.getZ());
}
@Override
public Region transformAndReShift(final ClipboardHolder holder, final Region region) {
final Transform transform = holder.getTransform();
final BlockVector3 origin = holder.getClipboard().getOrigin();
final BlockVector3 oldMin = region.getMinimumPoint();
final BlockVector3 oldMax = region.getMaximumPoint();
final BlockVector3 offset = oldMin.subtract(origin);
final BlockVector3 min = origin.add(transform.apply(offset.toVector3()).toBlockPoint());
final BlockVector3 max = min.add(transform.apply(oldMax.subtract(oldMin).toVector3()).toBlockPoint());
return new CuboidRegion(region.getWorld(), min, max);
}
@Override
public Region shift(final Region region, final double x, final double y, final double z) {
final Region clone = region.clone();
try {
clone.shift(BlockVector3.at(x, y, z));
} catch (final RegionOperationException ignored) {
}
return clone;
}
@Override
public Material getWand(final WorldEditPlugin plugin) {
return Material.getMaterial(plugin.getLocalConfiguration().wandItem.toUpperCase().replace("MINECRAFT:", ""));
}
@Override
public Simple2DVector[] getPoints(final Polygonal2DRegion region) {
final List<BlockVector2> originalVectors = region.polygonize(-1);
final Simple2DVector[] vectors = new Simple2DVector[originalVectors.size()];
int i = 0;
for (final BlockVector2 vector : originalVectors) {
vectors[i++] = new Simple2DVector(vector.getX(), vector.getZ());
}
return vectors;
}
}
+4 -16
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>worldedit-sui-parent</artifactId>
<version>1.7</version>
<version>1.6.1</version>
</parent>
<artifactId>worldedit-sui</artifactId>
@@ -15,33 +15,21 @@
<dependencies>
<dependency>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we-compat-common</artifactId>
<artifactId>nms-compat-common</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we6-compat</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>eu.kennytv.worldeditsui</groupId>
<artifactId>we7-compat</artifactId>
<artifactId>v1_8_R3-compat</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.1.0-SNAPSHOT</version>
<version>6.1.4-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,21 +18,12 @@
package eu.kennytv.worldeditsui;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.util.ParticleData;
import eu.kennytv.worldeditsui.compat.nms.ViaParticle;
import org.bukkit.ChatColor;
import org.bukkit.Particle;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -52,7 +43,6 @@ public final class Settings {
private int particleSendInterval;
private int particleViewDistance;
private long expiresAfterMillis;
private int maxPing;
private boolean cacheLocations;
private boolean expiryEnabled;
private boolean expireMessage;
@@ -61,14 +51,12 @@ public final class Settings {
private boolean persistentToggles;
private boolean showByDefault;
private boolean showClipboardByDefault;
private ParticleData particle;
private ParticleData clipboardParticle;
private ParticleData othersParticle;
private ParticleData othersClipboardParticle;
private ParticleData wgRegionParticle;
private ViaParticle particle;
private ViaParticle clipboardParticle;
private ViaParticle othersParticle;
private ViaParticle othersClipboardParticle;
private GridSettings advancedGrid;
private GridSettings advancedClipboardGrid;
private GridSettings advancedWGRegionGrid;
Settings(final WorldEditSUIPlugin plugin) {
this.plugin = plugin;
@@ -82,19 +70,8 @@ public final class Settings {
final YamlConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml"));
wandItem = config.getString("wand", "").toUpperCase().replace("MINECRAFT:", "");
particle = loadParticle(config, "particle", Particle.FLAME);
clipboardParticle = loadParticle(config, "clipboard-particle", Particle.VILLAGER_HAPPY);
wgRegionParticle = loadParticle(config, "wg-region-particle", Particle.VILLAGER_HAPPY);
try {
maxPing = Math.max(config.getInt("max-ping"), 0);
Player.Spigot.class.getDeclaredMethod("getPing");
} catch (final NoSuchMethodException ignored) {
if (maxPing != 0) {
plugin.getLogger().warning("The max-ping option only works on servers running Paper!");
maxPing = 0;
}
}
particle = loadParticle(config, "particle", ViaParticle.FLAME);
clipboardParticle = loadParticle(config, "clipboard-particle", ViaParticle.VILLAGER_HAPPY);
final ConfigurationSection sendToAllSection = config.getConfigurationSection("send-particles-to-all");
sendParticlesToAll = sendToAllSection.getBoolean("enabled");
@@ -102,9 +79,9 @@ public final class Settings {
if (otherParticlesPermission.isEmpty() || otherParticlesPermission.equalsIgnoreCase("none")) {
otherParticlesPermission = null;
}
othersParticle = loadParticle(sendToAllSection, "others-particle", Particle.FLAME);
othersClipboardParticle = loadParticle(sendToAllSection, "others-clipboard-particle", Particle.VILLAGER_HAPPY);
plugin.getParticleHelper().setPermission(otherParticlesPermission);
othersParticle = loadParticle(sendToAllSection, "others-particle", ViaParticle.FLAME);
othersClipboardParticle = loadParticle(sendToAllSection, "others-clipboard-particle", ViaParticle.VILLAGER_HAPPY);
particlesPerBlock = config.getInt("particles-per-block", 4);
if (particlesPerBlock < 0.5 || particlesPerBlock > 5) {
@@ -123,10 +100,6 @@ public final class Settings {
advancedClipboardGrid = clipboardGridSection != null && clipboardGridSection.getBoolean("enabled", false) ?
new GridSettings(plugin, clipboardGridSection) : null;
final ConfigurationSection wgRegionGridSection = config.getConfigurationSection("advanced-wg-region-grid");
advancedWGRegionGrid = wgRegionGridSection != null && wgRegionGridSection.getBoolean("enabled", false) ?
new GridSettings(plugin, wgRegionGridSection) : null;
particleSendInterval = config.getInt("particle-send-interval", 12);
if (particleSendInterval < 5 || particleSendInterval > 200) {
plugin.getLogger().warning("The particle-send-interval has to be set between 5 and 200!");
@@ -200,26 +173,19 @@ public final class Settings {
}
}
private ParticleData loadParticle(final ConfigurationSection section, final String s, final Particle defaultParticle) {
private ViaParticle loadParticle(final ConfigurationSection section, final String s, final ViaParticle defaultParticle) {
final String particleName = section.getString(s, defaultParticle.name()).toUpperCase().replace("MINECRAFT:", "");
final Particle particle;
try {
particle = Particle.valueOf(particleName);
} catch (final Exception e) {
final ViaParticle particle = ViaParticle.getByName(particleName);
if (particle == null) {
plugin.getLogger().warning("Unknown particle for " + s + ": " + particleName.toUpperCase());
plugin.getLogger().warning("Switched to default particle: " + defaultParticle);
return new ParticleData(defaultParticle, null);
return defaultParticle;
}
try {
final Object data = ParticleData.getExtraData(particle, section.getConfigurationSection(s + "-data"));
return new ParticleData(particle, data);
} catch (final Exception e) {
plugin.getLogger().warning("Error loading particle data of " + particleName + " - Missing data? You may read up on how to correctly set its data at the bottom of the plugin's Spigot page.");
plugin.getLogger().warning("Falling back to default particle: " + defaultParticle);
e.printStackTrace();
return new ParticleData(particle, null);
if (particle == ViaParticle.BLOCK_CRACK || particle == ViaParticle.BLOCK_DUST || particle == ViaParticle.ITEM_CRACK
|| particle == ViaParticle.REDSTONE || particle == ViaParticle.FALLING_DUST) {
plugin.getLogger().warning("This particle needs custom data, which isn't yet implemented in the plugin -> This particle might not work correctly!");
}
return particle;
}
public void saveData() {
@@ -244,10 +210,8 @@ public final class Settings {
plugin.getLogger().warning("The language file is missing the following string: " + path);
return "empty";
}
if (s.contains("%prefix%")) {
if (s.contains("%prefix%"))
s = s.replace("%prefix%", language.getString("prefix", ""));
}
return ChatColor.translateAlternateColorCodes('&', s);
}
@@ -255,40 +219,45 @@ public final class Settings {
return permission;
}
// getter is unused since the perm is directly given to the particle helper class
public String getOtherParticlesPermission() {
return otherParticlesPermission;
}
@Nullable
public GridSettings getGridSettings(final DrawedType drawedType) {
switch (drawedType) {
case SELECTED:
return advancedGrid;
case CLIPBOARD:
return advancedClipboardGrid;
case WG_REGION:
return advancedWGRegionGrid;
default:
throw new IllegalArgumentException();
}
public boolean hasAdvancedGrid() {
return advancedGrid != null;
}
public boolean hasAdvancedGrid(final DrawedType drawedType) {
return getGridSettings(drawedType) != null;
public boolean hasAdvancedGrid(final boolean clipboardSelection) {
return clipboardSelection ? advancedClipboardGrid != null : advancedGrid != null;
}
/**
* @see #hasAdvancedGrid(DrawedType)
* @see #hasAdvancedGrid()
*/
public double getParticleGridSpace(final DrawedType drawedType) {
return getGridSettings(drawedType).getParticleGridSpace();
public double getParticleGridSpace() {
return advancedGrid.getParticleGridSpace();
}
/**
* @see #hasAdvancedGrid(DrawedType)
* @see #hasAdvancedGrid(boolean)
*/
public int getParticlesPerGridBlock(final DrawedType drawedType) {
return getGridSettings(drawedType).getParticlesPerGridBlock();
public double getParticleGridSpace(final boolean clipboardSelection) {
return clipboardSelection ? advancedClipboardGrid.getParticleGridSpace() : advancedGrid.getParticleGridSpace();
}
/**
* @see #hasAdvancedGrid()
*/
public int getParticlesPerGridBlock() {
return advancedGrid.getParticlesPerGridBlock();
}
/**
* @see #hasAdvancedGrid(boolean)
*/
public int getParticlesPerGridBlock(final boolean clipboardSelection) {
return clipboardSelection ? advancedClipboardGrid.getParticlesPerGridBlock() : advancedGrid.getParticlesPerGridBlock();
}
public double getParticleSpace() {
@@ -311,10 +280,6 @@ public final class Settings {
return expiresAfterMillis;
}
public int getMaxPing() {
return maxPing;
}
public boolean isExpiryEnabled() {
return expiryEnabled;
}
@@ -327,8 +292,8 @@ public final class Settings {
return updateChecks;
}
public boolean sendParticlesToAll(final DrawedType drawedType) {
return sendParticlesToAll && (drawedType == DrawedType.SELECTED || drawedType == DrawedType.CLIPBOARD);
public boolean sendParticlesToAll() {
return sendParticlesToAll;
}
public boolean hasPersistentToggles() {
@@ -347,27 +312,20 @@ public final class Settings {
return cacheLocations;
}
public ParticleData getParticle(final DrawedType drawedType) {
switch (drawedType) {
default:
case SELECTED:
return particle;
case CLIPBOARD:
return clipboardParticle;
case WG_REGION:
return wgRegionParticle;
}
public ViaParticle getParticle() {
return particle;
}
public ParticleData getOthersParticle(final DrawedType drawedType) {
switch (drawedType) {
case SELECTED:
return othersParticle;
case CLIPBOARD:
return othersClipboardParticle;
default:
throw new IllegalArgumentException();
}
public ViaParticle getClipboardParticle() {
return clipboardParticle;
}
public ViaParticle getOthersParticle() {
return othersParticle;
}
public ViaParticle getOthersClipboardParticle() {
return othersClipboardParticle;
}
public String getWandItem() {
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,25 +21,18 @@ package eu.kennytv.worldeditsui;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import eu.kennytv.worldeditsui.command.WESUICommand;
import eu.kennytv.worldeditsui.compat.ProtectedRegionHelper;
import eu.kennytv.worldeditsui.compat.ProtectedRegionWrapper;
import eu.kennytv.worldeditsui.compat.RegionHelper;
import eu.kennytv.worldeditsui.compat.SelectionType;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.compat.we6.ProtectedRegionHelper6;
import eu.kennytv.worldeditsui.compat.we6.RegionHelper6;
import eu.kennytv.worldeditsui.compat.we7.ProtectedRegionHelper7;
import eu.kennytv.worldeditsui.compat.we7.RegionHelper7;
import eu.kennytv.worldeditsui.compat.nms.IParticleHelper;
import eu.kennytv.worldeditsui.drawer.DrawManager;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.listener.PlayerJoinListener;
import eu.kennytv.worldeditsui.listener.PlayerQuitListener;
import eu.kennytv.worldeditsui.listener.WESelectionListener;
@@ -47,14 +40,13 @@ import eu.kennytv.worldeditsui.metrics.MetricsLite;
import eu.kennytv.worldeditsui.user.SelectionCache;
import eu.kennytv.worldeditsui.user.User;
import eu.kennytv.worldeditsui.user.UserManager;
import eu.kennytv.worldeditsui.util.ParticleHelper;
import eu.kennytv.worldeditsui.util.RegionHelper;
import eu.kennytv.worldeditsui.util.SelectionType;
import eu.kennytv.worldeditsui.util.Version;
import org.bukkit.Location;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -68,8 +60,7 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
private static final String PREFIX = "§8[§eWorldEditSUI§8] ";
private RegionHelper regionHelper;
private ProtectedRegionHelper protectedRegionHelper;
private ParticleHelper particleHelper;
private IParticleHelper particleHelper;
private UserManager userManager;
private Settings settings;
private DrawManager drawManager;
@@ -78,41 +69,40 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
private Version newestVersion;
private int expiryTask = -1;
private int persistentTogglesTask = -1;
private boolean worldGuardEnabled;
@Override
public void onEnable() {
version = new Version(getDescription().getVersion());
printEnableMessage();
try {
Class.forName("org.bukkit.Particle");
} catch (final ClassNotFoundException e) {
getLogger().severe("This plugin only supports Minecraft versions from 1.9 upwards.");
getServer().getPluginManager().disablePlugin(this);
return;
}
regionHelper = new RegionHelper();
boolean isWorldEdit7 = true;
try {
Class.forName("com.sk89q.worldedit.math.Vector2");
} catch (final ClassNotFoundException e) {
isWorldEdit7 = false;
Class.forName("net.minecraft.server.v1_8_R3.EnumParticle");
particleHelper = new eu.kennytv.worldeditsui.compat.nms.v1_8_R3.ParticleHelper();
} catch (ClassNotFoundException ex) {
try {
Class.forName("org.bukkit.Particle");
getLogger().severe("This version of the plugin only supports Minecraft versions from 1.8.4-1.8.9.");
getLogger().severe("If you want 1.9+ support, use the version provided on the plugin's Spigot page (or the default version found on the GitHub Releases page).");
getServer().getPluginManager().disablePlugin(this);
return;
} catch (final ClassNotFoundException e) {
// If you want to support lower versions than 1.8(.4), feel free to add a new ParticleHelperModule ¯\_(ツ)_/¯
getLogger().severe("Sorry - this plugin only supports Minecraft versions from 1.8.4-1.8.9.");
getLogger().severe("If you want to support versions lower than 1.8.4, feel free to ask me on the support Discord guild or to pr support yourself.");
getLogger().severe("If you want 1.9+ support, use the version provided on the plugin's Spigot page (or the default version found on the GitHub Releases page).");
getServer().getPluginManager().disablePlugin(this);
return;
}
}
regionHelper = isWorldEdit7 ? new RegionHelper7() : new RegionHelper6();
particleHelper = new ParticleHelper(settings);
settings = new Settings(this);
userManager = new UserManager(settings);
drawManager = new DrawManager(this);
final PluginManager pm = getServer().getPluginManager();
worldEditPlugin = ((WorldEditPlugin) pm.getPlugin("WorldEdit"));
worldGuardEnabled = pm.isPluginEnabled("WorldGuard");
if (worldGuardEnabled) {
protectedRegionHelper = isWorldEdit7 ? new ProtectedRegionHelper7() : new ProtectedRegionHelper6();
}
// Imagine someone using the server reload command 👀
getServer().getOnlinePlayers().forEach(p -> userManager.createUser(p));
@@ -120,10 +110,7 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
pm.registerEvents(new PlayerJoinListener(this), this);
pm.registerEvents(new PlayerQuitListener(userManager), this);
pm.registerEvents(new WESelectionListener(this), this);
final PluginCommand command = getCommand("worldeditsui");
command.setExecutor(new WESUICommand(this));
command.setPermissionMessage(settings.getMessage("noPermission"));
getCommand("worldeditsui").setExecutor(new WESUICommand(this));
// Start tasks
getServer().getScheduler().runTaskTimerAsynchronously(this, this::updateSelections, settings.getParticleSendInterval(), settings.getParticleSendInterval());
@@ -134,8 +121,6 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
@Override
public void onDisable() {
if (settings == null) return; // if instantly disabled
settings.saveData();
getServer().getOnlinePlayers().forEach(player -> userManager.deleteUser(player));
}
@@ -175,20 +160,15 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
// Start tasks if not already running, or cancel them if one is running but now disabled in the config
if (expiryTask == -1 && settings.isExpiryEnabled()) {
expiryTask = getServer().getScheduler().runTaskTimer(this, () -> {
for (final User user : userManager.getUsers().values()) {
if (user.getExpireTimestamp() == 0) continue;
if (user.getExpireTimestamp() > System.currentTimeMillis()) continue;
user.setExpireTimestamp(0);
if (settings.hasExpireMessage()) {
getServer().getPlayer(user.getUuid()).sendMessage(settings.getMessage("idled"));
userManager.getExpireTimestamps().entrySet().removeIf(entry -> {
final boolean remove = entry.getValue() < System.currentTimeMillis();
if (remove && settings.hasExpireMessage()) {
getServer().getPlayer(entry.getKey()).sendMessage(settings.getMessage("idled"));
}
}
return remove;
});
}, 20, 20).getTaskId();
} else if (expiryTask != -1 && !settings.isExpiryEnabled()) {
for (final User user : userManager.getUsers().values()) {
user.setExpireTimestamp(-1);
}
getServer().getScheduler().cancelTask(expiryTask);
expiryTask = -1;
}
@@ -208,38 +188,32 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
final User user = userManager.getUser(player);
if (user == null) continue;
// Check for sending restrictions
if (!user.isSelectionShown() && !user.isClipboardShown()) continue;
if (settings.isExpiryEnabled() && user.getExpireTimestamp() == 0)
if (settings.isExpiryEnabled() && !userManager.getExpireTimestamps().containsKey(player.getUniqueId()))
continue;
if (settings.getPermission() != null && !player.hasPermission(settings.getPermission())) continue;
if (settings.getMaxPing() != 0 && player.spigot().getPing() > settings.getMaxPing()) continue;
final LocalSession session = worldEditPlugin.getSession(player);
final RegionSelector selector = session.getRegionSelector(new BukkitWorld(player.getWorld()));
// Selected WorldGuard region
final ProtectedRegionWrapper selectedWGRegion = user.getSelectedWGRegion();
if (selectedWGRegion != null) {
drawSelection(player, user, selectedWGRegion.getRegion(), selectedWGRegion.getSelectionType(), DrawedType.WG_REGION);
}
// Clipboard
if (user.isClipboardShown()) {
try {
final ClipboardHolder holder = session.getClipboard();
final Clipboard clipboard = holder.getClipboard();
final Location location = player.getLocation();
final SimpleVector origin = regionHelper.getOrigin(clipboard);
final Vector origin = clipboard.getOrigin();
// Transform the clipboard if necessary
final Transform transform = holder.getTransform();
final Region region = transform.isIdentity() ? clipboard.getRegion() : regionHelper.transformAndReShift(holder, clipboard.getRegion());
// Shift the transformed region relative to the player
final Region shiftedRegion = regionHelper.shift(region,
location.getBlockX() - origin.getX(), location.getBlockY() - origin.getY(), location.getBlockZ() - origin.getZ());
drawManager.getDrawer(SelectionType.CUBOID).draw(player, shiftedRegion, DrawedType.CLIPBOARD);
try {
region.shift(new Vector(location.getBlockX() - origin.getX(), location.getBlockY() - origin.getY(), location.getBlockZ() - origin.getZ()));
} catch (final RegionOperationException ignored) {
}
drawManager.getDrawer(SelectionType.CUBOID).draw(player, region, true);
} catch (final EmptyClipboardException ignored) {
// Ignore if there's no clipboard
}
@@ -253,44 +227,46 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
} catch (final IncompleteRegionException ignored) {
// Clear cache if present
if (settings.cacheLocations()) {
user.clearCache(DrawedType.SELECTED);
final SelectionCache cache = user.getSelectionCache();
if (cache != null) {
cache.getVectors().clear();
user.setSelectionCache(null);
}
}
continue;
}
final SelectionType selectionType = SelectionType.fromKey(selector.getTypeName());
if (selectionType != null) {
drawSelection(player, user, region, selectionType, DrawedType.SELECTED);
}
if (selectionType != null)
drawSelection(player, user, region, selectionType);
}
}
}
private void drawSelection(final Player player, final User user, final Region region, final SelectionType selectionType, final DrawedType drawedType) {
private void drawSelection(final Player player, final User user, final Region region, final SelectionType selectionType) {
if (settings.cacheLocations()) {
final SimpleVector minimumPoint = regionHelper.getMinimumPoint(region);
final SimpleVector maximumPoint = regionHelper.getMaximumPoint(region);
SelectionCache cache = user.getSelectionCache(drawedType);
final Vector minimumPoint = region.getMinimumPoint();
final Vector maximumPoint = region.getMaximumPoint();
SelectionCache cache = user.getSelectionCache();
if (cache != null) {
if (selectionType == cache.getSelectionType()
&& cache.getMinimum().equals(minimumPoint) && cache.getMaximum().equals(maximumPoint)) {
final Location location = new Location(player.getWorld(), 0, 0, 0);
for (final SimpleVector vector : cache.getVectors()) {
for (final Vector vector : cache.getVectors()) {
location.setX(vector.getX());
location.setY(vector.getY());
location.setZ(vector.getZ());
if (settings.sendParticlesToAll(drawedType)) {
particleHelper.playEffectToAll(settings.getParticle(drawedType), settings.getOthersParticle(drawedType),
location, settings.getParticleViewDistance(), player);
if (settings.sendParticlesToAll()) {
particleHelper.playEffectToAll(settings.getParticle(), settings.getOthersParticle(), location, 0, 1, settings.getParticleViewDistance(), player);
} else {
particleHelper.playEffect(settings.getParticle(drawedType), location, settings.getParticleViewDistance(), player);
particleHelper.playEffect(settings.getParticle(), location, 0, 1, settings.getParticleViewDistance(), player);
}
}
return;
}
} else {
cache = new SelectionCache();
user.setSelectionCache(drawedType, cache);
user.setSelectionCache(cache);
}
// If there's a new region, reset the cache and recalculate vectors
@@ -300,18 +276,13 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
cache.getVectors().clear();
}
// Current selection
drawManager.getDrawer(selectionType).draw(player, region, drawedType);
drawManager.getDrawer(selectionType).draw(player, region);
}
public WorldEditPlugin getWorldEditPlugin() {
return worldEditPlugin;
}
public DrawManager getDrawManager() {
return drawManager;
}
public UserManager getUserManager() {
return userManager;
}
@@ -336,16 +307,7 @@ public final class WorldEditSUIPlugin extends JavaPlugin {
return regionHelper;
}
@Nullable
public ProtectedRegionHelper getProtectedRegionHelper() {
return protectedRegionHelper;
}
public ParticleHelper getParticleHelper() {
public IParticleHelper getParticleHelper() {
return particleHelper;
}
public boolean isWorldGuardEnabled() {
return worldGuardEnabled;
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,21 +20,17 @@ package eu.kennytv.worldeditsui.command;
import eu.kennytv.worldeditsui.Settings;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.ProtectedRegionWrapper;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.user.SelectionCache;
import eu.kennytv.worldeditsui.user.User;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public final class WESUICommand implements CommandExecutor, TabCompleter {
@@ -47,95 +43,55 @@ public final class WESUICommand implements CommandExecutor, TabCompleter {
}
@Override
public boolean onCommand(@NotNull final CommandSender sender, @NotNull final Command cmd, @NotNull final String s, @NotNull final String[] args) {
public boolean onCommand(final CommandSender sender, final Command cmd, final String s, final String[] args) {
if (checkPermission(sender, "command")) return true;
if (args.length == 1) {
final String arg = args[0].toLowerCase();
switch (arg) {
case "toggle": {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.toggle")) return true;
if (args[0].equalsIgnoreCase("toggle")) {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.toggle")) return true;
final Player player = (Player) sender;
final User user = plugin.getUserManager().getUser(player);
if (user.isSelectionShown()) {
player.sendMessage(getMessage("particlesHidden"));
user.setSelectionShown(false);
user.clearCaches();
} else {
player.sendMessage(getMessage("particlesShown"));
user.setSelectionShown(true);
}
final Player player = (Player) sender;
final User user = plugin.getUserManager().getUser(player);
if (user.isSelectionShown()) {
player.sendMessage(getMessage("particlesHidden"));
user.setSelectionShown(false);
if (settings.hasPersistentToggles()) {
settings.setUserData("selection." + player.getUniqueId(), user.isSelectionShown());
final SelectionCache cache = user.getSelectionCache();
if (cache != null) {
cache.getVectors().clear();
user.setSelectionCache(null);
}
break;
} else {
player.sendMessage(getMessage("particlesShown"));
user.setSelectionShown(true);
}
case "toggleclipboard": {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.toggleclipboard")) return true;
final Player player = (Player) sender;
final User user = plugin.getUserManager().getUser(player);
player.sendMessage(user.isClipboardShown() ? getMessage("clipboardHidden") : getMessage("clipboardShown"));
user.setClipboardShown(!user.isClipboardShown());
if (settings.hasPersistentToggles()) {
settings.setUserData("clipboard." + player.getUniqueId(), user.isClipboardShown());
}
break;
if (settings.hasPersistentToggles()) {
settings.setUserData("selection." + player.getUniqueId(), user.isSelectionShown());
}
case "reload":
if (checkPermission(sender, "command.reload")) return true;
} else if (args[0].equalsIgnoreCase("toggleclipboard")) {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.toggleclipboard")) return true;
settings.loadSettings();
settings.loadLanguageFile();
// Empty cache to recalculate positions
plugin.getUserManager().getUsers().values().forEach(User::clearCaches);
plugin.checkTasks();
sender.sendMessage(getMessage("reload"));
// Reset Bukkit's no perm message for the command
plugin.getCommand("worldeditsui").setPermissionMessage(settings.getMessage("noPermission"));
break;
case "showregion": {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.showregion")) return true;
final Player player = (Player) sender;
final User user = plugin.getUserManager().getUser(player);
if (user.getSelectedWGRegion() == null) {
sendHelp(sender);
return true;
}
user.setSelectedWGRegion(null);
user.clearCache(DrawedType.WG_REGION);
user.setExpireTimestamp(System.currentTimeMillis() + plugin.getSettings().getExpiresAfterMillis());
sender.sendMessage(getMessage("regionCleared"));
break;
final Player player = (Player) sender;
final User user = plugin.getUserManager().getUser(player);
player.sendMessage(user.isClipboardShown() ? getMessage("clipboardHidden") : getMessage("clipboardShown"));
user.setClipboardShown(!user.isClipboardShown());
if (settings.hasPersistentToggles()) {
settings.setUserData("clipboard." + player.getUniqueId(), user.isClipboardShown());
}
default:
sendHelp(sender);
break;
}
} else if (args.length == 2 && args[0].equalsIgnoreCase("showregion")) {
if (!(sender instanceof Player)) return true;
if (checkPermission(sender, "command.showregion")) return true;
if (!plugin.isWorldGuardEnabled()) {
sender.sendMessage(getMessage("WGNotEnabled"));
return true;
}
} else if (args[0].equalsIgnoreCase("reload")) {
if (checkPermission(sender, "command.reload")) return true;
final Player player = (Player) sender;
final ProtectedRegionWrapper region = plugin.getProtectedRegionHelper().getRegion(player.getWorld(), args[1]);
if (region == null) {
sender.sendMessage(getMessage("regionNotFound"));
return true;
}
final User user = plugin.getUserManager().getUser(player);
user.clearCache(DrawedType.WG_REGION);
user.setSelectedWGRegion(region);
player.sendMessage(getMessage("regionDisplayed"));
final boolean cache = settings.cacheLocations();
settings.loadSettings();
settings.loadLanguageFile();
// Empty cache to recalculate positions
plugin.getUserManager().getUsers().values().forEach(user -> user.setSelectionCache(null));
plugin.checkTasks();
sender.sendMessage(getMessage("reload"));
} else
sendHelp(sender);
} else
sendHelp(sender);
return true;
@@ -150,8 +106,6 @@ public final class WESUICommand implements CommandExecutor, TabCompleter {
sender.sendMessage(getMessage("helpToggle"));
if (sender.hasPermission("wesui.command.toggleclipboard"))
sender.sendMessage(getMessage("helpToggleClipboard"));
if (plugin.isWorldGuardEnabled() && sender.hasPermission("wesui.command.showregion"))
sender.sendMessage(getMessage("helpShowRegion"));
sender.sendMessage("§8× §eVersion " + plugin.getVersion() + " §7by §bKennyTV");
sender.sendMessage(getMessage("helpHeader"));
sender.sendMessage("");
@@ -166,33 +120,21 @@ public final class WESUICommand implements CommandExecutor, TabCompleter {
}
@Override
public List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final Command cmd, @NotNull final String s, @NotNull final String[] args) {
if (!sender.hasPermission("wesui.command")) return Collections.emptyList();
if (args.length == 1) {
final String arg = args[0].toLowerCase();
final List<String> list = new ArrayList<>();
checkString(sender, arg, "reload", list);
checkString(sender, arg, "toggle", list);
checkString(sender, arg, "toggleclipboard", list);
if (plugin.isWorldGuardEnabled()) {
checkString(sender, arg, "showregion", list);
}
return list;
} else if (args.length == 2) {
if (sender instanceof Player && plugin.isWorldGuardEnabled()
&& args[0].equalsIgnoreCase("showregion") && sender.hasPermission("wesui.showregion")) {
final Set<String> regionNames = plugin.getProtectedRegionHelper().getRegionNames(((Player) sender).getWorld());
return StringUtil.copyPartialMatches(args[1], regionNames, new ArrayList<>());
}
}
return Collections.emptyList();
public List<String> onTabComplete(final CommandSender sender, final Command cmd, final String s, final String[] args) {
if (args.length != 1 || !sender.hasPermission("wesui.command")) return Collections.emptyList();
final String arg = args[0].toLowerCase();
final List<String> list = new ArrayList<>();
checkString(sender, arg, "reload", list);
checkString(sender, arg, "toggle", list);
checkString(sender, arg, "toggleclipboard", list);
return list;
}
private void checkString(final CommandSender sender, final String s, final String command, final List<String> list) {
if (!s.isEmpty() && !command.startsWith(s)) return;
if (sender.hasPermission("wesui.command." + command)) {
if (sender.hasPermission("wesui.command." + command))
list.add(command);
}
}
private String getMessage(final String path) {
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,10 +18,9 @@
package eu.kennytv.worldeditsui.drawer;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.Region;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.drawer.base.DrawerBase;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -34,11 +33,16 @@ public final class CuboidDrawer extends DrawerBase {
}
@Override
public void draw(final Player player, final Region region, final DrawedType drawedType) {
public void draw(final Player player, final Region region) {
this.draw(player, region, false);
}
@Override
public void draw(final Player player, final Region region, final boolean copySelection) {
final double width = region.getWidth();
final double length = region.getLength();
final double height = region.getHeight();
final SimpleVector minimumVector = plugin.getRegionHelper().getMinimumPoint(region);
final Vector minimumVector = region.getMinimumPoint();
final Location minimumPoint = new Location(player.getWorld(), minimumVector.getX(), minimumVector.getY(), minimumVector.getZ());
final double maxTicksX = width * settings.getParticlesPerBlock() - 1;
@@ -49,50 +53,49 @@ public final class CuboidDrawer extends DrawerBase {
int gridSpaceX = 0;
int gridSpaceZ = 0;
int topGridSpace = 0;
if (settings.hasAdvancedGrid(drawedType)) {
if (settings.hasAdvancedGrid(copySelection)) {
gridSpaceX = settings.getParticlesPerBlock() * ((int) ((width * height) / AREA_FACTOR) + 1);
gridSpaceZ = settings.getParticlesPerBlock() * ((int) ((length * height) / AREA_FACTOR) + 1);
topGridSpace = settings.getParticlesPerBlock() * ((int) ((width * length) / AREA_FACTOR) + 1);
maxGridTicks = height * settings.getParticlesPerGridBlock(drawedType) - 1;
maxTopGridTicksX = length * settings.getParticlesPerGridBlock(drawedType) - 1;
maxTopGridTicksZ = width * settings.getParticlesPerGridBlock(drawedType) - 1;
maxGridTicks = height * settings.getParticlesPerGridBlock(copySelection) - 1;
maxTopGridTicksX = length * settings.getParticlesPerGridBlock(copySelection) - 1;
maxTopGridTicksZ = width * settings.getParticlesPerGridBlock(copySelection) - 1;
}
drawLines(player, minimumPoint.clone(), gridSpaceX, topGridSpace, maxTicksX, maxGridTicks, maxTopGridTicksX, height, true, drawedType);
drawLines(player, minimumPoint.clone().add(0, 0, length), gridSpaceX, 0, maxTicksX, maxGridTicks, 0, height, true, drawedType);
drawLines(player, minimumPoint.clone(), gridSpaceZ, topGridSpace, maxTicksZ, maxGridTicks, maxTopGridTicksZ, height, false, drawedType);
drawLines(player, minimumPoint.clone().add(width, 0, 0), gridSpaceZ, 0, maxTicksZ, maxGridTicks, 0, height, false, drawedType);
drawPillarsAndGrid(player, minimumPoint, gridSpaceX, gridSpaceZ, height, width, length, drawedType);
drawLines(player, minimumPoint.clone(), gridSpaceX, topGridSpace, maxTicksX, maxGridTicks, maxTopGridTicksX, height, true, copySelection);
drawLines(player, minimumPoint.clone().add(0, 0, length), gridSpaceX, 0, maxTicksX, maxGridTicks, 0, height, true, copySelection);
drawLines(player, minimumPoint.clone(), gridSpaceZ, topGridSpace, maxTicksZ, maxGridTicks, maxTopGridTicksZ, height, false, copySelection);
drawLines(player, minimumPoint.clone().add(width, 0, 0), gridSpaceZ, 0, maxTicksZ, maxGridTicks, 0, height, false, copySelection);
drawPillarsAndGrid(player, minimumPoint, gridSpaceX, gridSpaceZ, height, width, length, copySelection);
}
private void drawLines(final Player player, final Location location, final int gridSpace, final int topGridSpace,
final double maxTicks, final double maxGridTicks, final double maxTopGridTicks,
final double height, final boolean x, final DrawedType drawedType) {
final double height, final boolean x, final boolean copySelection) {
// Lower row (with vertical grid)
final double oldX = location.getX();
final double oldZ = location.getZ();
int blocks = 0;
for (int i = 0; i < maxTicks; i++) {
if (settings.hasAdvancedGrid(drawedType)) {
if (settings.hasAdvancedGrid(copySelection)) {
if (blocks % gridSpace == 0 && i != 0) {
final Location clone = location.clone();
for (double j = 0; j < maxGridTicks; j++) {
clone.add(0, settings.getParticleGridSpace(drawedType), 0);
playEffect(clone, player, drawedType);
clone.add(0, settings.getParticleGridSpace(copySelection), 0);
playEffect(clone, player, copySelection);
}
}
if (topGridSpace != 0 && blocks % topGridSpace == 0 && i != 0) {
tickGrid(player, location, maxTopGridTicks, x, drawedType);
tickGrid(player, location, maxTopGridTicks, x, copySelection);
}
blocks++;
}
if (x) {
if (x)
location.add(settings.getParticleSpace(), 0, 0);
} else {
else
location.add(0, 0, settings.getParticleSpace());
}
playEffect(location, player, drawedType);
playEffect(location, player, copySelection);
}
// Upper row
@@ -101,72 +104,70 @@ public final class CuboidDrawer extends DrawerBase {
location.setY(location.getY() + height);
blocks = 0;
for (double i = 0; i < maxTicks; i++) {
if (settings.hasAdvancedGrid(drawedType) && topGridSpace != 0 && blocks++ % topGridSpace == 0 && i != 0) {
tickGrid(player, location, maxTopGridTicks, x, drawedType);
if (settings.hasAdvancedGrid(copySelection) && topGridSpace != 0 && blocks++ % topGridSpace == 0 && i != 0) {
tickGrid(player, location, maxTopGridTicks, x, copySelection);
}
if (x) {
if (x)
location.add(settings.getParticleSpace(), 0, 0);
} else {
else
location.add(0, 0, settings.getParticleSpace());
}
playEffect(location, player, drawedType);
playEffect(location, player, copySelection);
}
}
private void tickGrid(final Player player, final Location location, final double maxTopGridTicks, final boolean x, final DrawedType drawedType) {
private void tickGrid(final Player player, final Location location, final double maxTopGridTicks, final boolean x, final boolean copySelection) {
final Location clone = location.clone();
for (double j = 0; j < maxTopGridTicks; j++) {
if (x)
clone.add(0, 0, settings.getParticleGridSpace(drawedType));
clone.add(0, 0, settings.getParticleGridSpace(copySelection));
else
clone.add(settings.getParticleGridSpace(drawedType), 0, 0);
playEffect(clone, player, drawedType);
clone.add(settings.getParticleGridSpace(copySelection), 0, 0);
playEffect(clone, player, copySelection);
}
}
private void drawPillarsAndGrid(final Player player, final Location minimum, final int gridSpaceX, final int gridSpaceZ,
final double height, final double width, final double length, final DrawedType drawedType) {
final boolean advancedGridEnabled = settings.hasAdvancedGrid(drawedType);
final double height, final double width, final double length, final boolean copySelection) {
final boolean advancedGridEnabled = settings.hasAdvancedGrid(copySelection);
final double x = minimum.getX();
final double y = minimum.getY();
final double z = minimum.getZ();
final double gridSpace = advancedGridEnabled ? settings.getParticleGridSpace(drawedType) : 0;
final double gridSpace = advancedGridEnabled ? settings.getParticleGridSpace(copySelection) : 0;
final double maxTicks = height * settings.getParticlesPerBlock();
final double maxGridTicksX = advancedGridEnabled ? width * settings.getParticlesPerGridBlock(drawedType) - 1 : 0;
final double maxGridTicksZ = advancedGridEnabled ? length * settings.getParticlesPerGridBlock(drawedType) - 1 : 0;
setGrid(player, minimum, gridSpaceX, maxTicks, maxGridTicksX, gridSpace, 0, drawedType);
final double maxGridTicksX = advancedGridEnabled ? width * settings.getParticlesPerGridBlock(copySelection) - 1 : 0;
final double maxGridTicksZ = advancedGridEnabled ? length * settings.getParticlesPerGridBlock(copySelection) - 1 : 0;
setGrid(player, minimum, gridSpaceX, maxTicks, maxGridTicksX, gridSpace, 0, copySelection);
minimum.setX(x + width);
minimum.setY(y);
minimum.setZ(z + length);
setGrid(player, minimum, gridSpaceX, maxTicks, maxGridTicksX, -gridSpace, 0, drawedType);
setGrid(player, minimum, gridSpaceX, maxTicks, maxGridTicksX, -gridSpace, 0, copySelection);
minimum.setX(x + width);
minimum.setY(y);
minimum.setZ(z);
setGrid(player, minimum, gridSpaceZ, maxTicks, maxGridTicksZ, 0, gridSpace, drawedType);
setGrid(player, minimum, gridSpaceZ, maxTicks, maxGridTicksZ, 0, gridSpace, copySelection);
minimum.setX(x);
minimum.setY(y);
minimum.setZ(z + length);
setGrid(player, minimum, gridSpaceZ, maxTicks, maxGridTicksZ, 0, -gridSpace, drawedType);
setGrid(player, minimum, gridSpaceZ, maxTicks, maxGridTicksZ, 0, -gridSpace, copySelection);
}
private void setGrid(final Player player, final Location location, final int gridSpace, final double maxTicks, final double maxGridTicks,
final double xAddition, final double zAddition, final DrawedType drawedType) {
private void setGrid(final Player player, final Location location, final int gridSpace, final double maxTicks, final double maxGridTicks, final double xAddition, final double zAddition, final boolean copySelection) {
int blocks = 0;
for (int i = 0; i < maxTicks; i++) {
// Horizontal grid
if (settings.hasAdvancedGrid(drawedType) && blocks++ % gridSpace == 0 && i != 0) {
if (settings.hasAdvancedGrid(copySelection) && blocks++ % gridSpace == 0 && i != 0) {
final Location clone = location.clone();
for (double j = 0; j < maxGridTicks; j++) {
clone.add(xAddition, 0, zAddition);
playEffect(clone, player, drawedType);
playEffect(clone, player, copySelection);
}
}
// Pillar
location.add(0, settings.getParticleSpace(), 0);
playEffect(location, player, drawedType);
playEffect(location, player, copySelection);
}
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,12 +18,12 @@
package eu.kennytv.worldeditsui.drawer;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.drawer.base.DrawerBase;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -35,8 +35,10 @@ public final class CylinderDrawer extends DrawerBase {
}
@Override
public void draw(final Player player, final Region region, final DrawedType drawedType) {
final SimpleVector radius = plugin.getRegionHelper().getRadius((CylinderRegion) region, 1.3, 1.3);
public void draw(final Player player, final Region region) {
final CylinderRegion cylinder = (CylinderRegion) region;
final Vector2D radius2D = cylinder.getRadius();
final Vector radius = new Vector(radius2D.getX() + 1.3, cylinder.getHeight(), radius2D.getZ() + 1.3);
final int width = (int) radius.getX();
final int length = (int) radius.getZ();
final int height = (int) radius.getY();
@@ -44,7 +46,8 @@ public final class CylinderDrawer extends DrawerBase {
final int bottom = ((FlatRegion) region).getMinimumY();
final int top = ((FlatRegion) region).getMaximumY() + 1;
final SimpleVector center = plugin.getRegionHelper().getCenter(region, 0.5, 0, 0.5);
Vector center = region.getCenter();
center = new Vector(center.getX() + 0.5, center.getY(), center.getZ() + 0.5);
final Location location = new Location(player.getWorld(), center.getX(), bottom, center.getZ());
final double wideGrid = Math.PI / (settings.getParticlesPerBlock() * max * 2);
final int heightSpace = (int) (settings.getParticleSpace() * height);
@@ -52,68 +55,46 @@ public final class CylinderDrawer extends DrawerBase {
location.setY(top);
drawCurves(player, width, length, 1, location, wideGrid, heightSpace == 0 ? 1 : heightSpace);
if (settings.hasAdvancedGrid(drawedType)) {
if (settings.hasAdvancedGrid()) {
location.setY(bottom);
final double wideInterval = Math.PI / (settings.getParticlesPerGridBlock(drawedType) * max / 10D);
drawCurves(player, width, length, height * settings.getParticlesPerGridBlock(drawedType), location, wideInterval, settings.getParticleGridSpace(drawedType));
drawGrid(player, drawedType, width, length, top, location, true);
drawGrid(player, drawedType, length, width, top, location, false);
final double wideInterval = Math.PI / (settings.getParticlesPerGridBlock() * max / 10D);
drawCurves(player, width, length, height * settings.getParticlesPerGridBlock(), location, wideInterval, settings.getParticleGridSpace());
drawGrid(player, width, length, top, location, true);
drawGrid(player, length, width, top, location, false);
}
}
private void drawGrid(final Player player, final DrawedType drawedType, final int width, final int length, final int top, final Location location, final boolean xAxis) {
private void drawGrid(final Player player, final int width, final int length, final int top, final Location location, final boolean xAxis) {
final double x = location.getX();
final double z = location.getZ();
final double bottom = location.getY();
final int gap = settings.getParticlesPerBlock() * (((width * length) / AREA_FACTOR) + 1);
final int ticks = 2 * (width - 1) / gap;
if (xAxis) {
location.setX(location.getX() - width);
} else {
location.setZ(location.getZ() - width);
}
if (xAxis) location.setX(location.getX() - width);
else location.setZ(location.getZ() - width);
for (int i = 0; i < ticks; i++) {
if (xAxis) {
location.setX(location.getX() + gap);
} else {
location.setZ(location.getZ() + gap);
}
if (xAxis) location.setX(location.getX() + gap);
else location.setZ(location.getZ() + gap);
final double delta = Math.abs(xAxis ? location.getX() - x : location.getZ() - z);
// Thanks to a beautiful buddy of mine that took an our of his life to come up with this formula by himself, even though it's on Wikipedia 👀
final double radius = ((double) length / width) * Math.sqrt((width * width) - (delta * delta));
final int gridTicks = (int) (radius * settings.getParticlesPerGridBlock(drawedType) * 2);
if (xAxis) {
location.setZ(location.getZ() - radius);
} else {
location.setX(location.getX() - radius);
}
final int gridTicks = (int) (radius * settings.getParticlesPerGridBlock() * 2);
if (xAxis) location.setZ(location.getZ() - radius);
else location.setX(location.getX() - radius);
for (int j = 0; j < gridTicks; j++) {
if (xAxis) {
location.setZ(location.getZ() + settings.getParticleGridSpace(drawedType));
} else {
location.setX(location.getX() + settings.getParticleGridSpace(drawedType));
}
if (xAxis) location.setZ(location.getZ() + settings.getParticleGridSpace());
else location.setX(location.getX() + settings.getParticleGridSpace());
playEffect(location, player);
location.setY(top);
playEffect(location, player);
location.setY(bottom);
}
if (xAxis) {
location.setZ(z);
} else {
location.setX(x);
}
}
if (xAxis) {
location.setX(x);
} else {
location.setZ(z);
if (xAxis) location.setZ(z);
else location.setX(x);
}
if (xAxis) location.setX(x);
else location.setZ(z);
}
private void drawCurves(final Player player, final int width, final int length, final int ticks, final Location location, final double wideGrid, final double heightSpace) {
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
package eu.kennytv.worldeditsui.drawer;
import eu.kennytv.worldeditsui.compat.SelectionType;
import eu.kennytv.worldeditsui.util.SelectionType;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.drawer.base.Drawer;
@@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.Map;
public final class DrawManager {
private final Map<SelectionType, Drawer> drawers = new HashMap<>();
public DrawManager(final WorldEditSUIPlugin plugin) {
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,11 +18,10 @@
package eu.kennytv.worldeditsui.drawer;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.Region;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.drawer.base.DrawerBase;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -34,22 +33,25 @@ public final class EllipsoidDrawer extends DrawerBase {
}
@Override
public void draw(final Player player, final Region region, final DrawedType drawedType) {
final SimpleVector radius = plugin.getRegionHelper().getRadius((EllipsoidRegion) region, 1.5, 1.4, 1.5);
public void draw(final Player player, final Region region) {
final EllipsoidRegion ellipsoid = (EllipsoidRegion) region;
Vector radius = ellipsoid.getRadius();
radius = new Vector(radius.getX() + 1.5, radius.getY() + 1.4, radius.getZ() + 1.5);
final int width = (int) radius.getX();
final int length = (int) radius.getZ();
final int height = (int) radius.getY();
final int max = Math.max(length, width);
final SimpleVector center = plugin.getRegionHelper().getCenter(region, 0.5, 0.5, 0.5);
Vector center = region.getCenter();
center = new Vector(center.getX() + 0.5, center.getY() + 0.5, center.getZ() + 0.5);
final Location location = new Location(player.getWorld(), center.getX(), center.getY(), center.getZ());
final double heightInterval = Math.PI / (settings.getParticlesPerBlock() * height);
final double wideInterval = Math.PI / (settings.getParticlesPerBlock() * max / 10D);
showGrid(player, width, length, height, location, wideInterval, heightInterval);
if (settings.hasAdvancedGrid(drawedType)) {
final double heightGrid = Math.PI / (settings.getParticlesPerGridBlock(drawedType) * height);
final double wideGrid = Math.PI / (settings.getParticlesPerGridBlock(drawedType) * max / 5D);
if (settings.hasAdvancedGrid()) {
final double heightGrid = Math.PI / (settings.getParticlesPerGridBlock() * height);
final double wideGrid = Math.PI / (settings.getParticlesPerGridBlock() * max / 5D);
showGrid(player, width, length, height, location, heightGrid, wideGrid);
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,12 +18,12 @@
package eu.kennytv.worldeditsui.drawer;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.Simple2DVector;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import eu.kennytv.worldeditsui.drawer.base.DrawerBase;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -35,17 +35,17 @@ public final class PolygonalDrawer extends DrawerBase {
}
@Override
public void draw(final Player player, final Region region, final DrawedType drawedType) {
public void draw(final Player player, final Region region) {
final Polygonal2DRegion polyRegion = (Polygonal2DRegion) region;
final Simple2DVector[] points = plugin.getRegionHelper().getPoints(polyRegion);
Simple2DVector last = points[0];
final BlockVector2D[] points = plugin.getRegionHelper().getPoints(polyRegion);
BlockVector2D last = points[0];
final int bottom = ((FlatRegion) region).getMinimumY();
final Location location = new Location(player.getWorld(), last.getX(), bottom, last.getZ());
final int height = region.getHeight();
final int top = bottom + height;
final int upwardsTicks = height * settings.getParticlesPerBlock();
boolean skip = true;
for (final Simple2DVector point : points) {
for (final BlockVector2D point : points) {
if (skip) {
skip = false;
continue;
@@ -60,7 +60,7 @@ public final class PolygonalDrawer extends DrawerBase {
connect(points[0].subtract(points[points.length - 1]), bottom, top, upwardsTicks, location, player);
}
private void connect(final Simple2DVector vector, final int bottom, final int top, final int upwardsTicks, final Location location, final Player player) {
private void connect(final Vector2D vector, final int bottom, final int top, final int upwardsTicks, final Location location, final Player player) {
final double length = vector.length();
final double factor = length * settings.getParticlesPerBlock();
final double x = vector.getX() / factor;
@@ -1,26 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.drawer.base;
public enum DrawedType {
SELECTED,
CLIPBOARD,
WG_REGION
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,21 +20,11 @@ package eu.kennytv.worldeditsui.drawer.base;
import com.sk89q.worldedit.regions.Region;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
public interface Drawer {
/**
* Recreates the given with particles.
* If the given player object is null, the particles
* will be sent to all players nearby.
*
* @param player player to send the particles to, may be null when sent to all players
* @param region region to be displayed with particles
* @param drawedType drawed type
*/
void draw(@Nullable Player player, Region region, DrawedType drawedType);
/**
* Recreates the given with particles.
* If the given player object is null, the particles
@@ -43,7 +33,21 @@ public interface Drawer {
* @param player player to send the particles to, may be null when sent to all players
* @param region region to be displayed with particles
*/
default void draw(@Nullable final Player player, final Region region) {
draw(player, region, DrawedType.SELECTED);
void draw(@Nullable Player player, Region region);
/**
* Recreates the given with particles.
* If the given player object is null, the particles
* will be sent to all players nearby.
*
* @param player player to send the particles to, may be null when sent to all players
* @param region region to be displayed with particles
* @param copySelection if the region is a copied region
* @see #draw(Player, Region)
* @deprecated only implemented by the CuboidDrawer
*/
@Deprecated
default void draw(@Nullable final Player player, final Region region, final boolean copySelection) {
this.draw(player, region);
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,12 +18,11 @@
package eu.kennytv.worldeditsui.drawer.base;
import com.sk89q.worldedit.Vector;
import eu.kennytv.worldeditsui.Settings;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.user.SelectionCache;
import eu.kennytv.worldeditsui.compat.nms.ViaParticle;
import eu.kennytv.worldeditsui.user.User;
import eu.kennytv.worldeditsui.util.ParticleData;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -39,24 +38,22 @@ public abstract class DrawerBase implements Drawer {
}
protected void playEffect(final Location location, final Player player) {
playEffect(location, player, DrawedType.SELECTED);
playEffect(location, player, false);
}
protected void playEffect(final Location location, final Player player, final DrawedType drawedType) {
if (settings.cacheLocations() && drawedType != DrawedType.CLIPBOARD) {
protected void playEffect(final Location location, final Player player, final boolean copySelection) {
if (settings.cacheLocations() && !copySelection) {
final User user = plugin.getUserManager().getUser(player);
if (user == null) return;
final SelectionCache cache = user.getSelectionCache(drawedType);
cache.getVectors().add(new SimpleVector(location.getX(), location.getY(), location.getZ()));
user.getSelectionCache().getVectors().add(new Vector(location.getX(), location.getY(), location.getZ()));
}
final ParticleData particle = settings.getParticle(drawedType);
if (settings.sendParticlesToAll(drawedType)) {
final ParticleData othersParticle = settings.getOthersParticle(drawedType);
plugin.getParticleHelper().playEffectToAll(particle, othersParticle, location, settings.getParticleViewDistance(), player);
final ViaParticle particle = copySelection ? settings.getClipboardParticle() : settings.getParticle();
if (settings.sendParticlesToAll()) {
final ViaParticle othersParticle = copySelection ? settings.getOthersClipboardParticle() : settings.getOthersParticle();
plugin.getParticleHelper().playEffectToAll(particle, othersParticle, location, 0, 1, settings.getParticleViewDistance(), player);
} else {
plugin.getParticleHelper().playEffect(particle, location, settings.getParticleViewDistance(), player);
plugin.getParticleHelper().playEffect(particle, location, 0, 1, settings.getParticleViewDistance(), player);
}
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,10 +19,6 @@
package eu.kennytv.worldeditsui.listener;
import eu.kennytv.worldeditsui.WorldEditSUIPlugin;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -56,19 +52,7 @@ public final class PlayerJoinListener implements Listener {
player.sendMessage(plugin.getPrefix() + "§cThere is a newer version available: §aVersion " + plugin.getNewestVersion() + "§c, you're on §a" + plugin.getDescription().getVersion());
notified.add(player.getUniqueId());
try {
final TextComponent tc1 = new TextComponent(TextComponent.fromLegacyText(plugin.getPrefix()));
final TextComponent tc2 = new TextComponent(TextComponent.fromLegacyText("§cDownload it at: §6https://www.spigotmc.org/resources/worldeditsui.60726/"));
final TextComponent click = new TextComponent(TextComponent.fromLegacyText(" §7§l§o(CLICK ME)"));
click.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org/resources/worldeditsui.60726/"));
click.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aDownload the latest version").create()));
tc1.addExtra(tc2);
tc1.addExtra(click);
player.spigot().sendMessage(tc1);
} catch (final Exception e) {
player.sendMessage(plugin.getPrefix() + "§cDownload it at: §6https://www.spigotmc.org/resources/worldeditsui.60726/");
}
player.sendMessage(plugin.getPrefix() + "§cDownload it at: §6https://www.spigotmc.org/resources/worldeditsui.60726/");
});
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Set;
import java.util.UUID;
public final class WESelectionListener implements Listener {
@@ -52,7 +51,7 @@ public final class WESelectionListener implements Listener {
if (plugin.getSettings().getWandItem().isEmpty()) {
plugin.getLogger().info("If you have set another item than the wooden axe as the WE wand, please write it into the WESUI config, for example:");
plugin.getLogger().info("wand: WOODEN_SWORD");
wand = Material.getMaterial("WOODEN_AXE");
wand = Material.WOOD_AXE;
return;
}
@@ -79,8 +78,7 @@ public final class WESelectionListener implements Listener {
final String type = item.getType().name();
if (!type.endsWith("_AXE") || !type.contains("WOOD")) return;
}
plugin.getUserManager().getUser(player).setExpireTimestamp(System.currentTimeMillis() + plugin.getSettings().getExpiresAfterMillis());
plugin.getUserManager().getExpireTimestamps().put(player.getUniqueId(), System.currentTimeMillis() + plugin.getSettings().getExpiresAfterMillis());
}
@Subscribe
@@ -91,13 +89,10 @@ public final class WESelectionListener implements Listener {
while (!arguments.isEmpty() && arguments.charAt(0) == '/') {
arguments = arguments.substring(1);
}
if (arguments.isEmpty()) return;
final String command = arguments.split(" ", 2)[0].toLowerCase();
if (weCommands.stream().noneMatch(command::equals)) return;
final UUID uuid = event.getActor().getUniqueId();
plugin.getUserManager().getUser(uuid).setExpireTimestamp(System.currentTimeMillis() + plugin.getSettings().getExpiresAfterMillis());
plugin.getUserManager().getExpireTimestamps().put(event.getActor().getUniqueId(), System.currentTimeMillis() + plugin.getSettings().getExpiresAfterMillis());
}
}
@@ -29,7 +29,6 @@ import java.util.zip.GZIPOutputStream;
public final class MetricsLite {
public static final int B_STATS_VERSION = 1;
private static final int PLUGIN_ID = 5444;
private static final String URL = "https://bStats.org/submitData/bukkit";
private final boolean enabled;
private static boolean logFailedRequests;
@@ -114,7 +113,6 @@ public final class MetricsLite {
final String pluginVersion = plugin.getDescription().getVersion();
data.addProperty("pluginName", pluginName);
data.addProperty("id", PLUGIN_ID);
data.addProperty("pluginVersion", pluginVersion);
data.add("customCharts", new JsonArray());
@@ -223,18 +221,21 @@ public final class MetricsLite {
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
connection.setDoOutput(true);
try (final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
outputStream.write(compressedData);
}
final DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.write(compressedData);
outputStream.flush();
outputStream.close();
if (logResponseStatusText) {
final InputStream inputStream = connection.getInputStream();
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
final StringBuilder builder = new StringBuilder();
try (final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
String line;
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
bufferedReader.close();
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
} else {
connection.getInputStream().close();
@@ -246,9 +247,9 @@ public final class MetricsLite {
return null;
}
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try (final GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
gzip.write(str.getBytes(StandardCharsets.UTF_8));
}
final GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
gzip.write(str.getBytes(StandardCharsets.UTF_8));
gzip.close();
return outputStream.toByteArray();
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,20 +18,20 @@
package eu.kennytv.worldeditsui.user;
import eu.kennytv.worldeditsui.compat.SimpleVector;
import eu.kennytv.worldeditsui.compat.SelectionType;
import com.sk89q.worldedit.Vector;
import eu.kennytv.worldeditsui.util.SelectionType;
import java.util.ArrayList;
import java.util.List;
public final class SelectionCache {
private final List<SimpleVector> vectors = new ArrayList<>();
private final List<Vector> vectors = new ArrayList<>();
private SelectionType selectionType = SelectionType.NONE;
private SimpleVector minimum;
private SimpleVector maximum;
private Vector minimum;
private Vector maximum;
public List<SimpleVector> getVectors() {
public List<Vector> getVectors() {
return vectors;
}
@@ -43,19 +43,19 @@ public final class SelectionCache {
this.selectionType = selectionType;
}
public SimpleVector getMinimum() {
public Vector getMinimum() {
return minimum;
}
public void setMinimum(final SimpleVector minimum) {
public void setMinimum(final Vector minimum) {
this.minimum = minimum;
}
public SimpleVector getMaximum() {
public Vector getMaximum() {
return maximum;
}
public void setMaximum(final SimpleVector maximum) {
public void setMaximum(final Vector maximum) {
this.maximum = maximum;
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,32 +18,17 @@
package eu.kennytv.worldeditsui.user;
import eu.kennytv.worldeditsui.compat.ProtectedRegionWrapper;
import eu.kennytv.worldeditsui.drawer.base.DrawedType;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public final class User {
private final UUID uuid;
private SelectionCache selectionCache;
private SelectionCache selectedWGRegionCache;
private ProtectedRegionWrapper selectedWGRegion;
private boolean selectionShown;
private boolean clipboardShown;
private long expireTimestamp = -1;
User(final UUID uuid, final boolean selectionShown, final boolean clipboardShown) {
this.uuid = uuid;
User(final boolean selectionShown, final boolean clipboardShown) {
this.selectionShown = selectionShown;
this.clipboardShown = clipboardShown;
}
public UUID getUuid() {
return uuid;
}
public boolean isSelectionShown() {
return selectionShown;
}
@@ -60,72 +45,11 @@ public final class User {
this.clipboardShown = clipboardShown;
}
/**
* @return time at which the selection will expire, 0 if no longer shown, -1 if disabled
*/
public long getExpireTimestamp() {
return expireTimestamp;
}
public void setExpireTimestamp(final long expireTimestamp) {
this.expireTimestamp = expireTimestamp;
}
@Nullable
public SelectionCache getSelectionCache() {
return selectionCache;
}
@Nullable
public SelectionCache getSelectionCache(final DrawedType drawedType) {
switch (drawedType) {
case SELECTED:
return selectionCache;
case WG_REGION:
return selectedWGRegionCache;
default:
throw new IllegalArgumentException("Only allowed types are SELECTED and WG_REGION");
}
}
public void setSelectionCache(final DrawedType drawedType, @Nullable final SelectionCache selectionCache) {
switch (drawedType) {
case SELECTED:
this.selectionCache = selectionCache;
break;
case WG_REGION:
this.selectedWGRegionCache = selectionCache;
break;
default:
throw new IllegalArgumentException("Only allowed types are SELECTED and WG_REGION");
}
}
@Nullable
public ProtectedRegionWrapper getSelectedWGRegion() {
return selectedWGRegion;
}
public void setSelectedWGRegion(@Nullable final ProtectedRegionWrapper selectedWGRegion) {
this.selectedWGRegion = selectedWGRegion;
}
public void clearCaches() {
if (selectionCache != null) {
selectionCache.getVectors().clear();
selectionCache = null;
}
if (selectedWGRegionCache != null) {
selectedWGRegionCache.getVectors().clear();
selectedWGRegionCache = null;
}
}
public void clearCache(final DrawedType drawedType) {
final SelectionCache oldCache = getSelectionCache(drawedType);
if (oldCache != null) {
oldCache.getVectors().clear();
setSelectionCache(drawedType, null);
}
public void setSelectionCache(final SelectionCache selectionCache) {
this.selectionCache = selectionCache;
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,16 +28,13 @@ import java.util.UUID;
public final class UserManager {
private final Map<UUID, User> users = new HashMap<>();
private final Map<UUID, Long> expireTimestamps = new HashMap<>();
private final Settings settings;
public UserManager(final Settings settings) {
this.settings = settings;
}
public User getUser(final UUID uuid) {
return users.get(uuid);
}
public User getUser(final Player player) {
return users.get(player.getUniqueId());
}
@@ -53,15 +50,22 @@ public final class UserManager {
selection = settings.showByDefault();
clipboard = settings.showClipboardByDefault();
}
users.put(player.getUniqueId(), new User(player.getUniqueId(), selection, clipboard));
users.put(player.getUniqueId(), new User(selection, clipboard));
}
public void deleteUser(final Player player) {
final User removedUser = users.remove(player.getUniqueId());
removedUser.clearCaches();
expireTimestamps.remove(player.getUniqueId());
final User remove = users.remove(player.getUniqueId());
final SelectionCache cache = remove.getSelectionCache();
if (cache != null)
cache.getVectors().clear();
}
public Map<UUID, User> getUsers() {
return users;
}
public Map<UUID, Long> getExpireTimestamps() {
return expireTimestamps;
}
}
@@ -1,79 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.util;
import com.google.common.base.Preconditions;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.Nullable;
public final class ParticleData {
private final Particle particle;
private final Object data;
public ParticleData(final Particle particle, @Nullable final Object data) {
this.particle = particle;
this.data = data;
}
public Particle getParticle() {
return particle;
}
@Nullable
public Object getData() {
return data;
}
//TODO proper error handling/warnings
public static Object getExtraData(final Particle particle, final ConfigurationSection section) throws Exception {
final Class<?> dataType = particle.getDataType();
if (dataType == null || dataType == Void.class) return null;
Preconditions.checkArgument(section != null, "The data section is missing!");
final String name = dataType.getSimpleName();
// they might exist, they might not ¯\_(ツ)_/¯
// also it's only executed when (re)loading the config, so I think I might just get away with this method (prolly not worth doing extra modules for this)
if (name.equals("DustOptions")) {
final float size = (float) section.getDouble("size");
final Color color = section.contains("rgb") ? Color.fromRGB(section.getInt("rgb"))
: Color.fromRGB(section.getInt("r"), section.getInt("g"), section.getInt("b"));
return new Particle.DustOptions(color, size);
} else if (name.equals("BlockData")) {
final Material material = Material.getMaterial(section.getString("material"));
Preconditions.checkArgument(material.isBlock(), "This particle requires a block material for its data.");
return material.createBlockData();
} else if (dataType == ItemStack.class) {
return new ItemStack(Material.getMaterial(section.getString("material")));
} else if (name.equals("MaterialData")) { // use the name in case of its removal
return new MaterialData(Material.getMaterial(section.getString("material")), (byte) section.getInt("data"));
} else if (dataType == Color.class) {
return section.contains("rgb") ? Color.fromRGB(section.getInt("rgb"))
: Color.fromRGB(section.getInt("r"), section.getInt("g"), section.getInt("b"));
}
throw new IllegalArgumentException("The datatype " + name + " is not yet supported by the plugin - please report this error!");
}
}
@@ -1,68 +0,0 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.util;
import eu.kennytv.worldeditsui.Settings;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public final class ParticleHelper {
private final Settings settings;
public ParticleHelper(final Settings settings) {
this.settings = settings;
}
public void playEffect(final ParticleData particle, final Location location, final int radius, final Player player) {
playEffect(particle, location, 0, 0, 0, radius, player);
}
public void playEffect(final ParticleData particle, final Location location, final float offX, final float offY, final float offZ, final int radius, final Player player) {
if (!location.getWorld().equals(player.getWorld())) return;
final int radiusSquared = radius * radius;
if (player.getLocation().distanceSquared(location) > radiusSquared) return;
player.spawnParticle(particle.getParticle(), location, 1, offX, offY, offZ, 0, particle.getData());
}
public void playEffectToAll(final ParticleData particle, final ParticleData othersParticle, final Location location, final int radius, final Player origin) {
playEffectToAll(particle, othersParticle, location, 0, 0, 0, radius, origin);
}
public void playEffectToAll(final ParticleData particle, final ParticleData othersParticle, final Location location, final float offX, final float offY, final float offZ, final int radius, final Player origin) {
final int radiusSquared = radius * radius;
for (final Player player : Bukkit.getOnlinePlayers()) {
if (!location.getWorld().equals(player.getWorld())
|| player.getLocation().distanceSquared(location) > radiusSquared) continue;
final boolean originalPlayer = player.getUniqueId().equals(origin.getUniqueId());
if (!originalPlayer && !canSeeOtherParticles(player)) continue;
final ParticleData toSend = originalPlayer ? particle : othersParticle;
player.spawnParticle(toSend.getParticle(), location, 1, offX, offY, offZ, 0, toSend.getData());
}
}
private boolean canSeeOtherParticles(final Player player) {
return settings.getOtherParticlesPermission() == null || player.hasPermission(settings.getOtherParticlesPermission());
}
}
@@ -0,0 +1,58 @@
/*
* WorldEditCUI - https://git.io/wecui
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.util;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public final class RegionHelper {
private static final BlockVector2D[] A = new BlockVector2D[0];
public Region transformAndReShift(final ClipboardHolder holder, final Region region) {
final Transform transform = holder.getTransform();
final Vector origin = holder.getClipboard().getOrigin();
final Vector oldMin = region.getMinimumPoint();
final Vector oldMax = region.getMaximumPoint();
final Vector offset = oldMin.subtract(origin);
final Vector min = origin.add(transform.apply(offset));
final Vector max = min.add(transform.apply(oldMax.subtract(oldMin)));
return new CuboidRegion(region.getWorld(), min, max);
}
public Material getWand(final WorldEditPlugin plugin) {
return new ItemStack(plugin.getLocalConfiguration().wandItem).getType();
}
public BlockVector2D[] getPoints(final Polygonal2DRegion region) {
final List<BlockVector2D> originalVectors = region.polygonize(-1);
return originalVectors.toArray(A);
}
}
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.kennytv.worldeditsui.compat;
package eu.kennytv.worldeditsui.util;
import java.util.HashMap;
import java.util.Map;
@@ -1,6 +1,6 @@
/*
* WorldEditSUI - https://git.io/wesui
* Copyright (C) 2018-2020 KennyTV (https://github.com/KennyTV)
* Copyright (C) 2018 KennyTV (https://github.com/KennyTV)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,8 +18,6 @@
package eu.kennytv.worldeditsui.util;
import org.jetbrains.annotations.NotNull;
public final class Version implements Comparable<Version> {
private final int[] parts;
@@ -55,7 +53,7 @@ public final class Version implements Comparable<Version> {
* @return 0 if they are the same, 1 if this instance is newer, -1 if older
*/
@Override
public int compareTo(@NotNull final Version version) {
public int compareTo(final Version version) {
if (version == null || version.toString() == null) return 0;
final int max = Math.max(this.parts.length, version.parts.length);
for (int i = 0; i < max; i++) {
@@ -9,15 +9,10 @@ cache-calculated-positions: true
# A list of all particles can be found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Particle.html
# Just note that newly introduced particles obviously won't work in older versions.
# Shown for the selection you currently have.
#
# If you want to use a particle that requires extra data (REDSTONE, FALLING_DUST, BLOCK_DUST, BLOCK_CRACK, ITEM_CRACK),
# you can read up on how to do that at the bottom of the plugin's Spigot page.
particle: FLAME
# Shown for the clipboard (after using WorldEdit's //copy command).
# Can be enabled with the '/wesui toggleclipboard' command.
clipboard-particle: VILLAGER_HAPPY
# Shown for the WG region view (when using '/wesui showregion <region>').
wg-region-particle: VILLAGER_HAPPY
# How many particles should be displayed for every block of length.
# The recommended amount is between 2 and 4. Can be set from 1 to 5.
@@ -28,10 +23,6 @@ particles-per-block: 3
# For reference: 20 Minecraft ticks are equivalent to 1 second -> 10 ticks are 0.5 seconds -> 1 tick is 0.05 seconds.
particle-send-interval: 12
# Max ping a player can have before particles are no longer sent - this option only works on Paper servers.
# Set this to -1 to disable.
max-ping: 150
advanced-grid:
# If enabled, the selection will not only be displayed by the outline,
# but also with a grid between the outlines (the bigger the selection, the bigger the grid).
@@ -47,12 +38,6 @@ advanced-clipboard-grid:
enabled: false
particles-per-block: 2
advanced-wg-region-grid:
# You can also enable the grid for the WG region view by using the '/wesui showregion <region>' command.
# Same as advanced-grid settings, but for the WorldGuard regions.
enabled: false
particles-per-block: 2
particle-expiry:
# If enabled and a selection isn't changed for the given amount of seconds, particles will stop being sent for it
enabled: false
@@ -7,13 +7,8 @@ clipboardShown: "%prefix% &aParticles of your clipboard are now shown!"
clipboardHidden: "%prefix% &cParticles of your clipboard are now hidden!"
reload: "%prefix% &aReloaded config and language file!"
idled: "%prefix% &7The selection particles are no longer displayed. Update your selection to display them again."
WGNotEnabled: "%prefix% &cThis command requires WorldGuard to be present."
regionNotFound: "%prefix% &cThere is no region with that name!"
regionDisplayed: "%prefix% &aThe selected region will now be displayed. Use &e/wesui showregion &ato turn it off again."
regionCleared: "%prefix% &7The WG region is no longer displayed."
helpHeader: "&8===========[ &eWorldEditSUI &8]==========="
helpReload: "&6/wesui reload &7(Reloads the config file)"
helpToggle: "&6/wesui toggle &7(Toggles the visibility of your selection-particles)"
helpToggleClipboard: "&6/wesui toggleclipboard &7(Toggles the visibility of your clipboard-particles)"
helpShowRegion: "&6/wesui showgregion <WG region> §7(Outlines the given WorldGuard region)"
+1 -3
View File
@@ -3,12 +3,10 @@ version: ${project.version}
main: eu.kennytv.worldeditsui.WorldEditSUIPlugin
authors: [KennyTV]
depend: [WorldEdit]
softdepend: [WorldGuard]
website: https://www.spigotmc.org/resources/worldeditsui.60726/
api-version: 1.13
commands:
worldeditsui:
description: WorldEditSUI main command.
aliases: [wesui]
permission: wesui.command
aliases: [wesui, wecui] # keep wecui alias for legacy reasons