Compare commits

..
51 Commits
Author SHA1 Message Date
md678685 f57557b43a Bump version to 2.16.1 2019-03-01 22:45:25 +00:00
md678685 0711fd6f9e Add #version line to allow automatic items.json updates 2019-03-01 12:04:08 +00:00
md678685 b5ecbd1739 Remove Vault repo
Fixes Travis builds and slow builds - Maven pauses while trying to reach the repo and so Travis assumes that the build has failed.
2019-03-01 11:41:29 +00:00
md678685 dda5e4e333 Merge pull request #2402 from Techno3600/patch-1
Pull Request for #2282
2019-03-01 11:32:46 +00:00
md678685 dde4a36df0 Economy API: Attempt to find users by UUID if username not present (#2432)
Attempt to find user by UUID if username not present. Fixes (maybe) #2400.

https://github.com/EssentialsX/Essentials/issues/2400#issuecomment-466043896
2019-02-22 18:10:36 +00:00
triagonal 31b98fb9f3 allow console to use color codes when sending mail (#2435) @triagonal 2019-02-22 14:34:56 +00:00
kashike 289d34d96c Relocate PaperLib in EssentialsXSpawn too
fixes #2433
2019-02-22 09:58:02 +00:00
md678685 eafd110ed0 Update items.json
Add spawner aliases that end in "spawner".
2019-02-20 14:50:43 +00:00
md678685 e72644abf4 Update items.json
* Add mooshroom spawners
* Add new aliases for red sandstone, sandstone, stone and prismarine variants
2019-02-20 14:42:22 +00:00
md678685 b267103274 Remove getMap(short) method from FakeServer 2019-02-20 12:45:37 +00:00
DoNotSpamPls 3856a690eb Use PaperLib to load chunks and teleport players async (#2409)
* Remove outdated permission plugin handlers, minor test fixes

* Re-add PermissionEX handler

* Use PaperLib to load chunks async whenever possible

* Revert "Use PaperLib to load chunks async whenever possible"

This reverts commit db4df6f3cf.

* Use PaperLib to load chunks and teleport players async

* Resolve some PR issues

* Update PaperLib, return teleport causes

* Remove useless PaperLib usage in LocationUtil

* Fix FakeServer spacing
2019-02-20 12:25:05 +00:00
md678685 f214696664 Check Protect/AntiBuild config materials against Material enum (#2431) 2019-02-20 12:24:30 +00:00
md678685 9e73c29b40 Fix creating and using kits on legacy versions (#2428)
* Attempt to look up legacy items in Material enum
* Use name method when serializing ItemStacks
* Make name uppercase before looking up in Material enum
2019-02-20 12:24:07 +00:00
md678685 aca83bd462 Switch Vault dependency to VaultAPI (#2430)
* Switch Vault dependency to VaultAPI
* Remove direct Vault class usage from VaultEco
2019-02-20 11:28:20 +00:00
md678685 189d6a23c6 Add README section about depending on EssX 2019-02-19 21:58:43 +00:00
md678685 441f88deea Implement missing FakeServer methods 2019-02-17 19:01:47 +00:00
Wiz_Techno 6d6666dace Pull Request for #2282
"Obsolete entries in items.csv should be removed"
2019-01-31 23:14:21 -05:00
Rafał Pokrywka fb779533e6 Replace nbsp with a space when formatting messages (#2394) @ravkr 2019-01-27 12:15:03 +00:00
DoNotSpamPls 7325113a8c Remove outdated permission plugin handlers, minor test fixes (#2367) @DoNotSpamPls
* Remove outdated permission plugin handlers, minor test fixes

* Re-add PermissionEX handler

* Use PaperLib to load chunks async whenever possible

* Revert "Use PaperLib to load chunks async whenever possible"

This reverts commit db4df6f3cf.
2019-01-27 12:14:16 +00:00
Glare Masters 827217823e Add the ability to make spectator gamemode signs (#2386) @darbyjack
Fixes #2383.
2019-01-20 10:14:20 +00:00
md678685 060dfc69f4 Update items.json
Fixed regression of unspawnable items not being marked as such, impacting the alias generation process. This fix also retains the ability to specify non-item blocks in the EssentialsX Protect material lists.
2019-01-12 22:07:03 +00:00
md678685 b831713737 Check whether item is spawnable in FlatItemDb 2019-01-12 21:43:36 +00:00
md678685 7da90b3a6b Load item spawn blacklist after item DB
Partially resolves #2360.
2019-01-12 21:43:36 +00:00
md678685 32540c23ab Add IItemDb#isReady to check if item database is available 2019-01-12 21:43:36 +00:00
md678685 d24b0616f8 Hide ServerListPingEvent exceptions thrown by CB's LegacyPingHandler (#2378)
Fixes #2327.
2019-01-12 17:19:11 +00:00
md678685 9aef2ef883 Update items.json
Add several new aliases. Closes #2348.
2019-01-09 15:10:38 +00:00
md678685 727d473319 Fix Enchantments on 1.12.2 and lower 2019-01-09 14:23:55 +00:00
md678685 8225e51867 Fix XMPP metrics reporting
The XMPP config was being reported as valid when it wasn't valid.
2019-01-09 13:57:18 +00:00
md678685 1ba6c2a596 Properly fix language mappings 2019-01-08 22:19:16 +00:00
md678685 60a166aeb0 Fix language mapping in Crowdin config 2019-01-08 21:45:46 +00:00
md678685 65c2155bca Update Crowdin config
Map most locales to the existing locale files.
2019-01-08 21:36:16 +00:00
md678685 6031c01584 Update Crowdin config
Fix file placement and map locale codes to existing translations
2019-01-08 21:21:35 +00:00
md678685 da8e8c8a25 Update Crowdin config
Crowdin should only use `messages.properties` as the "source" and this file will get copied to all the other language files like `messages_de.properties` for the German translation, `messages_ro.properties` for the Romanian translation etc.
2019-01-08 21:14:56 +00:00
Trent Hensler 70a750a32d Update Crowdin configuration file 2019-01-08 12:48:25 -08:00
md678685 7c63324504 Fix allow-old-id-signs allowing creation of signs with IDs 2019-01-07 22:38:13 +00:00
md678685 dd41b10522 attempt to fix Essentials overriding Skulls (#2356) @kennyrkun 2019-01-05 18:48:33 +00:00
triagonal 7948e764d4 disallow setting bed homes in non-overworld dimensions (#2335) @triagonal 2019-01-05 18:43:27 +00:00
DoNotSpamPls 82ede4530a Lots of little fixes in the Essentials modules (#2337) @DoNotSpamPls
Look at changed files for the changes
2019-01-05 18:42:09 +00:00
md678685 e8ab2db8e8 Improve ServerListPingEvent warning handling 2019-01-05 18:12:04 +00:00
md678685 8882e0214c Add bStats metrics for each EssentialsX module (#2333)
Does what it says on the tin.
2019-01-05 17:48:44 +00:00
md678685 4adb669cdd Add support for spawners with entities on 1.13+ 2019-01-05 17:35:29 +00:00
md678685 7e1d258dd3 Cache BukkitVersion in getServerBukkitVersion 2019-01-05 16:29:11 +00:00
md678685 417fe29e21 Remove duplicated item IDs in messages 2019-01-05 16:28:53 +00:00
md678685 bd8ef2a25d Only show available warps in tab complete
Fixes #2353 by only displaying warps where the player has the permission `essentials.warps.<warp>`.
2019-01-05 15:45:34 +00:00
md678685 fd01b75c33 Wrap UnsafeValues.fromLegacy() in try/catch for older versions
Should address #2352.
2019-01-05 15:27:07 +00:00
md678685 1388755d2a Wrap Enchantment.getByKey in try/catch for older versions
Should address #2351.
2019-01-05 15:17:58 +00:00
md678685 97cc3d0066 Update items.json
* Fix wrong harming potion mapping (fixes #2349)
* Add mob spawner aliases (not complete, related to #2347)
* Closes #2348:
  - Fix log aliases mistakenly pointing to stripped logs
  - Fix sandstone alias
  - Add shorter concrete powder aliases
2019-01-05 15:04:59 +00:00
md678685 694cf7a79e Revert 1.13 API hacks in LegacyItemDb
Earlier changes broke the items.csv database on older versions - this should now be fixed.
2019-01-04 15:01:18 +00:00
md678685 da89efb79f Make VersionUtil not explode when patch is not present 2019-01-03 22:16:14 +00:00
md678685 04ec013407 Update README to reflect 1.13 support 2019-01-03 21:25:48 +00:00
md678685 023cf6a1aa Merge pull request #2278 from EssentialsX/1.13
Full 1.13 support + 2.16.0 release
2019-01-03 20:56:14 +00:00
112 changed files with 3873 additions and 2216 deletions

No files matched your search

+18 -54
View File
@@ -1,54 +1,18 @@
.DS_Store
/BuildAll/nbproject/private/
/EssentialsProtect/nbproject/private/
/EssentialsChat/nbproject/private/
/EssentialsGroupBridge/nbproject/private/
/EssentialsGeoIP/nbproject/private/
/EssentialsSpawn/nbproject/private/
/EssentialsXMPP/nbproject/private/
/BuildAll/build/
/EssentialsGroupBridge/dist/
/EssentialsGroupBridge/build/
/EssentialsGeoIP/dist/
/EssentialsGeoIP/build/
/BuildAll/dist/
/EssentialsChat/build/
/EssentialsChat/dist/
/EssentialsSpawn/build/
/EssentialsSpawn/dist/
/EssentialsXMPP/dist/
/EssentialsXMPP/build/
/EssentialsProtect/dist/
/EssentialsProtect/build/
/EssentialsPermissionsCommands/nbproject/private/
/EssentialsPermissionsCommands/build/
/EssentialsPermissionsCommands/dist/
/Essentials/nbproject/private/
/Essentials/dist/
/Essentials/build/
/YamlAnnotations/
/EssentialsUpdate/nbproject/private/
/EssentialsRelease/
/EssentialsUpdate/dist/
/EssentialsUpdate/build/
/WebPush/apikey.php
/WebPush/nbproject/private
/EssentialsAntiBuild/nbproject/private/
/EssentialsAntiBuild/dist/
/EssentialsAntiBuild/build/
/jars
/out
.idea/
.buildtools/
*.iml
*.classpath
*.project
*.settings/
target/
dependency-reduced-pom.xml
/Essentials/config.yml
/Essentials/kits.yml
/Essentials/userdata/testplayer1.yml
/Essentials/usermap.csv
/Essentials/userdata
/EssentialsGroupManager/target/
# IDE files
*.classpath
*.project
*.settings/
.idea/
*.iml
.DS_Store
# Essentials files
/Essentials/userdata
/Essentials/config.yml
/Essentials/kits.yml
/Essentials/userdata/testplayer1.yml
/Essentials/usermap.csv
# Build files
target/
jars/
+27 -31
View File
@@ -6,25 +6,18 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsX</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsX-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.0</version>
<configuration>
<showDeprecation>false</showDeprecation>
</configuration>
@@ -32,7 +25,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
@@ -41,6 +34,15 @@
</goals>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>com.earth2me.essentials.paperlib</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
@@ -48,26 +50,32 @@
<dependencies>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.5.6</version>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>UpdatedMetaProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>1_8_R1Provider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -79,7 +87,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>1_8_R2Provider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@@ -91,32 +99,20 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>LegacyProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>ReflectionProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>FlattenedProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
</repositories>
</project>
@@ -1,7 +1,5 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.NumberUtil;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
@@ -15,6 +13,7 @@ import java.util.Set;
public class Enchantments {
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
private static boolean isFlat;
static {
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
@@ -231,10 +230,23 @@ public class Enchantments {
ALIASENCHANTMENTS.put("channel", channelling);
}
} catch (IllegalArgumentException ignored) {}
try {
Class<?> namespacedKeyClass = Class.forName("org.bukkit.NamespacedKey");
Class<?> enchantmentClass = Class.forName("org.bukkit.enchantments.Enchantment");
enchantmentClass.getDeclaredMethod("getByKey", namespacedKeyClass);
isFlat = true;
} catch (ClassNotFoundException | NoSuchMethodException e) {
isFlat = false;
}
}
public static Enchantment getByName(String name) {
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
Enchantment enchantment = null;
if (isFlat) { // 1.13+ only
enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
}
if (enchantment == null) {
enchantment = Enchantment.getByName(name.toUpperCase());
}
@@ -196,27 +196,34 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
execTimer.mark("Upgrade");
confList = new ArrayList<>();
settings = new Settings(this);
confList.add(settings);
execTimer.mark("Settings");
userMap = new UserMap(this);
confList.add(userMap);
execTimer.mark("Init(Usermap)");
kits = new Kits(this);
confList.add(kits);
upgrade.convertKits();
execTimer.mark("Kits");
upgrade.afterSettings();
execTimer.mark("Upgrade2");
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
execTimer.mark("Init(Spawn/Warp)");
worth = new Worth(this.getDataFolder());
confList.add(worth);
itemDb = getItemDbFromConfig();
confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)");
jails = new Jails(this);
confList.add(jails);
execTimer.mark("Init(Jails)");
@@ -241,6 +248,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
), "potion meta").getProvider();
execTimer.mark("Init(Providers)");
reload();
// The item spawn blacklist is loaded with all other settings, before the item
// DB, but it depends on the item DB, so we need to reload it again here:
((Settings) settings)._lateLoadItemSpawnBlacklist();
} catch (YAMLException exception) {
if (pm.getPlugin("EssentialsUpdate") != null) {
LOGGER.log(Level.SEVERE, tl("essentialsHelp2"));
@@ -7,6 +7,7 @@ import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.MaterialUtil;
import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import org.bukkit.BanEntry;
@@ -14,6 +15,7 @@ import org.bukkit.BanList;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
@@ -601,7 +603,7 @@ public class EssentialsPlayerListener implements Listener {
case RIGHT_CLICK_BLOCK:
if (!event.isCancelled() && MaterialUtil.isBed(event.getClickedBlock().getType()) && ess.getSettings().getUpdateBedAtDaytime()) {
User player = ess.getUser(event.getPlayer());
if (player.isAuthorized("essentials.sethome.bed")) {
if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
}
@@ -641,7 +643,7 @@ public class EssentialsPlayerListener implements Listener {
while (LocationUtil.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ())) {
loc.setY(loc.getY() + 1d);
}
user.getBase().teleport(loc, TeleportCause.PLUGIN);
PaperLib.teleportAsync(user.getBase(), loc, TeleportCause.PLUGIN);
}
}
ess.scheduleSyncDelayedTask(new DelayedClickJumpTask());
@@ -727,6 +729,7 @@ public class EssentialsPlayerListener implements Listener {
} else if (clickedInventory != null && clickedInventory.getType() == InventoryType.PLAYER) {
if (ess.getSettings().isDirectHatAllowed() && event.getClick() == ClickType.LEFT && event.getSlot() == 39
&& event.getCursor().getType() != Material.AIR && event.getCursor().getType().getMaxDurability() == 0
&& !MaterialUtil.isSkull(event.getCursor().getType())
&& ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat")) {
event.setCancelled(true);
final PlayerInventory inv = (PlayerInventory) clickedInventory;
@@ -10,12 +10,17 @@ import org.bukkit.event.server.ServerListPingEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
public class EssentialsServerListener implements Listener {
private static List<String> ignoredSLPECallers = Arrays.asList(
".LegacyPingHandler.channelRead(" // CB responding to pings from pre-Netty clients
);
private final transient IEssentials ess;
private boolean unsupportedLogged = false;
private boolean npeWarned = false;
@@ -31,13 +36,13 @@ public class EssentialsServerListener implements Listener {
setSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "setSampleText", List.class);
getSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "getSampleText");
if (setSampleText != null && getSampleText != null) {
ess.getLogger().info("Using Paper 1.12+ ServerListPingEvent methods");
ess.getLogger().info("ServerListPingEvent: Paper 1.12.2 setSampleText API");
isPaperSample = true;
return;
}
}
ess.getLogger().info("Using Spigot 1.7.10+ ServerListPingEvent iterator");
ess.getLogger().info("ServerListPingEvent: Spigot iterator API");
isPaperSample = false;
}
@@ -46,22 +51,16 @@ public class EssentialsServerListener implements Listener {
if (isPaperSample) {
try {
List<String> playerNames = (List<String>) getSampleText.invoke(event, null);
Iterator<String> iterator = playerNames.iterator();
while (iterator.hasNext()) {
String player = iterator.next();
if (ess.getUser(player).isVanished()) {
iterator.remove();
}
}
playerNames.removeIf(player -> ess.getUser(player).isVanished());
setSampleText.invoke(event, playerNames);
} catch (IllegalAccessException | InvocationTargetException | ClassCastException e) {
if (!unsupportedLogged) {
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
ess.getLogger().log(Level.WARNING, "Unable to hide players from server list ping "
+ "using Paper 1.12+ method!", e);
+ "using Paper 1.12 method!", e);
unsupportedLogged = true;
}
} catch (NullPointerException e) {
if (!npeWarned) {
if (!npeWarned && shouldWarnSLPECaller(e)) {
npeWarned = true;
Exception ex = new Exception("A plugin has fired a ServerListPingEvent "
+ "without implementing Paper's methods. Point the author to https://git.io/v7Xzl.");
@@ -79,12 +78,38 @@ public class EssentialsServerListener implements Listener {
}
}
} catch (UnsupportedOperationException e) {
if (!unsupportedLogged) {
ess.getLogger().warning("Current server implementation does not support "
+ "hiding players from server list ping. Update or contact the maintainers.");
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
ess.getLogger().log(Level.WARNING, "Could not hide vanished players while handling " + event.getClass().getName(), e);
unsupportedLogged = true;
}
}
}
}
/**
* Should we warn about this SLPE caller, or should we silently ignore it?
* This checks against the ignoredSLPECallers strings, and if it matches one of those, we
* return false.
*
* @param throwable A throwable caught by a catch block
* @return Whether or not to send a warning about this particular caller
*/
private boolean shouldWarnSLPECaller(Throwable throwable) {
final int maxStackDepth = 20; // Limit the depth when searching through the stack trace
int depth = 0;
for (StackTraceElement element : throwable.getStackTrace()) {
depth++;
if (depth > maxStackDepth) {
break;
}
for (String ignoredString : ignoredSLPECallers) {
if (element.toString().contains(ignoredString)) {
return false; // We know about this error and should ignore it, so don't warn
}
}
}
return true; // We don't know for certain that we can ignore this, so warn just to be safe
}
}
@@ -93,7 +93,7 @@ public class I18n implements net.ess3.api.II18n {
}
messageFormatCache.put(format, messageFormat);
}
return messageFormat.format(objects);
return messageFormat.format(objects).replace(' ', ' '); // replace nbsp with a space
}
public void updateLocale(final String loc) {
@@ -1,10 +1,12 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IItemDb;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.Signs;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.EnumUtil;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil;
@@ -541,7 +543,11 @@ public class Settings implements net.ess3.api.ISettings {
allowOldIdSigns = _allowOldIdSigns();
}
private List<Material> itemSpawnBl = new ArrayList<Material>();
void _lateLoadItemSpawnBlacklist() {
itemSpawnBl = _getItemSpawnBlacklist();
}
private List<Material> itemSpawnBl = new ArrayList<>();
@Override
public List<Material> itemSpawnBlacklist() {
@@ -550,7 +556,8 @@ public class Settings implements net.ess3.api.ISettings {
private List<Material> _getItemSpawnBlacklist() {
final List<Material> epItemSpwn = new ArrayList<>();
if (ess.getItemDb() == null) {
final IItemDb itemDb = ess.getItemDb();
if (itemDb == null || !itemDb.isReady()) {
logger.log(Level.FINE, "Skipping item spawn blacklist read; item DB not yet loaded.");
return epItemSpwn;
}
@@ -560,7 +567,7 @@ public class Settings implements net.ess3.api.ISettings {
continue;
}
try {
final ItemStack iStack = ess.getItemDb().get(itemName);
final ItemStack iStack = itemDb.get(itemName);
epItemSpwn.add(iStack.getType());
} catch (Exception ex) {
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"), ex);
@@ -685,12 +692,20 @@ public class Settings implements net.ess3.api.ISettings {
if (itemName.isEmpty()) {
continue;
}
ItemStack itemStack;
try {
itemStack = ess.getItemDb().get(itemName);
list.add(itemStack.getType());
} catch (Exception ex) {
Material mat = EnumUtil.getMaterial(itemName.toUpperCase());
if (mat == null) {
try {
ItemStack itemStack = ess.getItemDb().get(itemName);
mat = itemStack.getType();
} catch (Exception ignored) {}
}
if (mat == null) {
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, configName));
} else {
list.add(mat);
}
}
return list;
@@ -2,7 +2,9 @@ package com.earth2me.essentials;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import net.ess3.api.ITeleport;
import net.ess3.api.IUser;
import net.ess3.api.events.UserWarpEvent;
import org.bukkit.Bukkit;
@@ -18,7 +20,7 @@ import java.util.GregorianCalendar;
import static com.earth2me.essentials.I18n.tl;
public class Teleport implements net.ess3.api.ITeleport {
public class Teleport implements ITeleport {
private final IUser teleportOwner;
private final IEssentials ess;
private TimedTeleport timedTeleport;
@@ -49,7 +51,7 @@ public class Teleport implements net.ess3.api.ITeleport {
final long earliestLong = earliestTime.getTimeInMillis();
// When was the last teleportPlayer used?
final Long lastTime = teleportOwner.getLastTeleportTimestamp();
final long lastTime = teleportOwner.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis()) {
// This is to make sure time didn't get messed up on last teleportPlayer use.
@@ -124,21 +126,21 @@ public class Teleport implements net.ess3.api.ITeleport {
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
if (ess.getSettings().isTeleportSafetyEnabled()) {
if (ess.getSettings().isForceDisableTeleportSafety()) {
teleportee.getBase().teleport(loc, cause);
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
teleportee.getBase().teleport(LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
}
} else {
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
} else {
if (ess.getSettings().isForceDisableTeleportSafety()) {
teleportee.getBase().teleport(loc, cause);
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
} else {
if (ess.getSettings().isTeleportToCenterLocation()) {
loc = LocationUtil.getRoundedDestination(loc);
}
teleportee.getBase().teleport(loc, cause);
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
}
}
}
@@ -231,7 +233,7 @@ public class Teleport implements net.ess3.api.ITeleport {
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
}
protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
final Player player = teleportee.getBase();
Location bed = player.getBedSpawnLocation();
if (bed != null) {
@@ -16,9 +16,9 @@ public class TimedTeleport implements Runnable {
private final IEssentials ess;
private final Teleport teleport;
private final UUID timer_teleportee;
private int timer_task = -1;
private final long timer_started; // time this task was initiated
private final long timer_delay; // how long to delay the teleportPlayer
private int timer_task;
private final long timer_started; // time this task was initiated
private final long timer_delay; // how long to delay the teleportPlayer
private double timer_health;
// note that I initially stored a clone of the location for reference, but...
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
@@ -32,8 +32,7 @@ public class TimedTeleport implements Runnable {
private final Trade timer_chargeFor;
private final TeleportCause timer_cause;
public TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
this.teleportOwner = user;
this.ess = ess;
this.teleport = teleport;
@@ -111,8 +110,7 @@ public class TimedTeleport implements Runnable {
if (timer_chargeFor != null) {
timer_chargeFor.charge(teleportOwner);
}
} catch (Exception ex) {
}
} catch (Exception ignored) {}
} catch (Exception ex) {
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
@@ -124,7 +122,7 @@ public class TimedTeleport implements Runnable {
}
//If we need to cancelTimer a pending teleportPlayer call this method
public void cancelTimer(boolean notifyUser) {
void cancelTimer(boolean notifyUser) {
if (timer_task == -1) {
return;
}
@@ -8,6 +8,7 @@ import com.earth2me.essentials.utils.StringUtil;
import com.google.common.base.Charsets;
import net.ess3.api.IEssentials;
import net.ess3.api.MaxMoneyException;
import org.bukkit.entity.Player;
import java.io.File;
import java.math.BigDecimal;
@@ -18,7 +19,7 @@ import java.util.logging.Logger;
/**
* Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod
* You should use Vault instead of directly using this class.
*/
public class Economy {
public Economy() {
@@ -64,7 +65,24 @@ public class Economy {
if (name == null) {
throw new RuntimeException("Economy username cannot be null");
}
return ess.getUser(name);
User user = ess.getUser(name);
if (user == null) {
/*
Attempt lookup using UUID - this prevents balance resets when accessing economy
via Vault during player join.
See: https://github.com/EssentialsX/Essentials/issues/2400
*/
Player player = ess.getServer().getPlayerExact(name);
if (player != null) {
user = ess.getUser(player.getUniqueId());
if (user != null) {
logger.info(String.format("[Economy] Found player %s by UUID %s but not by their actual name - they may have changed their username", name, player.getUniqueId().toString()));
}
}
}
return user;
}
/**
@@ -153,4 +153,11 @@ public interface IItemDb {
default Material getFromLegacy(final int id, final byte damage) {
return MaterialUtil.convertFromLegacy(id, damage);
}
/**
* Check whether the item database is loaded and ready for use.
*
* @return Whether items have finished loading
*/
boolean isReady();
}
@@ -33,10 +33,16 @@ public class Commanditemdb extends EssentialsCommand {
itemStack = ess.getItemDb().get(args[0]);
}
sender.sendMessage(tl("itemType", itemStack.getType().toString()));
String itemId = "none";
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01)) {
final String itemId = itemStack.getType().getId() + ":" + itemStack.getDurability();
itemId = itemStack.getType().getId() + ":" + itemStack.getDurability();
}
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemId));
// Don't send IDs twice
if (!tl("itemType").contains("{1}") && !itemId.equals("none")) {
sender.sendMessage(tl("itemId", itemId));
}
@@ -105,11 +105,11 @@ public class Commandmail extends EssentialsCommand {
if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[1]));
}
u.addMail(tl("mailFormat", "Server", getFinalArg(args, 2)));
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 2))));
sender.sendMessage(tl("mailSent"));
return;
} else if (args.length >= 2 && "sendall".equalsIgnoreCase(args[0])) {
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", getFinalArg(args, 1))));
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1)))));
sender.sendMessage(tl("mailSent"));
return;
} else if (args.length >= 2) {
@@ -118,7 +118,7 @@ public class Commandmail extends EssentialsCommand {
if (u == null) {
throw new Exception(tl("playerNeverOnServer", args[0]));
}
u.addMail(tl("mailFormat", "Server", getFinalArg(args, 1)));
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
sender.sendMessage(tl("mailSent"));
return;
}
@@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import static com.earth2me.essentials.I18n.tl;
@@ -64,17 +64,8 @@ public class Commandwarp extends EssentialsCommand {
//TODO: Use one of the new text classes, like /help ?
private void warpList(final CommandSource sender, final String[] args, final IUser user) throws Exception {
final IWarps warps = ess.getWarps();
final List<String> warpNameList = new ArrayList<>(warps.getList());
final List<String> warpNameList = getAvailableWarpsFor(user);
if (user != null) {
final Iterator<String> iterator = warpNameList.iterator();
while (iterator.hasNext()) {
final String warpName = iterator.next();
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warps." + warpName)) {
iterator.remove();
}
}
}
if (warpNameList.isEmpty()) {
throw new Exception(tl("noWarpsDefined"));
}
@@ -112,10 +103,20 @@ public class Commandwarp extends EssentialsCommand {
owner.getTeleport().warp(user, name, charge, TeleportCause.COMMAND);
}
private List<String> getAvailableWarpsFor(final IUser user) {
if (ess.getSettings().getPerWarpPermission() && user != null) {
return ess.getWarps().getList().stream()
.filter(warpName -> user.isAuthorized("essentials.warps." + warpName))
.collect(Collectors.toList());
}
return new ArrayList<>(ess.getWarps().getList());
}
@Override
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
if (args.length == 1 && user.isAuthorized("essentials.warp.list")) {
return new ArrayList<>(ess.getWarps().getList());
return getAvailableWarpsFor(user);
} else if (args.length == 2 && (user.isAuthorized("essentials.warp.otherplayers") || user.isAuthorized("essentials.warp.others"))) {
//TODO: Remove 'otherplayers' permission.
return getPlayers(server, user);
@@ -27,6 +27,8 @@ import static com.earth2me.essentials.I18n.tl;
public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
protected boolean ready = false;
@Override
public List<ItemStack> getMatching(User user, String[] args) throws Exception {
List<ItemStack> is = new ArrayList<>();
@@ -62,7 +64,7 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
@Override
public String serialize(ItemStack is) {
String mat = is.getType().name();
String mat = name(is);
if (VersionUtil.getServerBukkitVersion().isLowerThanOrEqualTo(VersionUtil.v1_12_2_R01) && is.getData().getData() != 0) {
mat = mat + ":" + is.getData().getData();
}
@@ -224,4 +226,9 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
return sb.toString().trim().replaceAll("§", "&");
}
@Override
public boolean isReady() {
return ready;
}
}
@@ -8,11 +8,11 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.ess3.api.IEssentials;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.Repairable;
import org.bukkit.potion.PotionData;
import java.util.*;
@@ -24,10 +24,8 @@ import static com.earth2me.essentials.I18n.tl;
public class FlatItemDb extends AbstractItemDb {
protected static final Logger LOGGER = Logger.getLogger("Essentials");
private final transient IEssentials ess;
private static Gson gson = new Gson();
private final transient IEssentials ess;
// Maps primary name to ItemData
private final transient Map<String, ItemData> items = new HashMap<>();
@@ -57,13 +55,16 @@ public class FlatItemDb extends AbstractItemDb {
this.reset();
String json = file.getLines().stream()
.filter(line -> !line.startsWith("#"))
.collect(Collectors.joining());
.filter(line -> !line.startsWith("#"))
.collect(Collectors.joining());
this.loadJSON(String.join("\n", json));
ready = true;
}
private void reset() {
ready = false;
items.clear();
itemAliases.clear();
allAliases.clear();
@@ -108,12 +109,14 @@ public class FlatItemDb extends AbstractItemDb {
throw new Exception(tl("unknownItemName", id));
}
PotionData potionData = data.getPotionData();
Material material = data.getMaterial();
if (!material.isItem()) throw new Exception(tl("unableToSpawnItem", id));
ItemStack stack = new ItemStack(material);
stack.setAmount(material.getMaxStackSize());
PotionData potionData = data.getPotionData();
ItemMeta meta = stack.getItemMeta();
if (potionData != null && meta instanceof PotionMeta) {
@@ -130,6 +133,13 @@ public class FlatItemDb extends AbstractItemDb {
stack.setItemMeta(meta);
// The spawner provider will update the meta again, so we need to call it after
// setItemMeta to prevent a race condition
EntityType entity = data.getEntity();
if (entity != null && material.toString().contains("SPAWNER")) {
ess.getSpawnerProvider().setEntityType(stack, entity);
}
return stack;
}
@@ -161,14 +171,7 @@ public class FlatItemDb extends AbstractItemDb {
@Override
public String name(ItemStack item) {
Material type = item.getType();
PotionData potion = null;
if (MaterialUtil.isPotion(type) && item.getItemMeta() instanceof PotionMeta) {
potion = ((PotionMeta) item.getItemMeta()).getBasePotionData();
}
ItemData data = new ItemData(type, potion);
ItemData data = lookup(item);
for (Map.Entry<String, ItemData> entry : items.entrySet()) {
if (entry.getValue().equals(data)) {
@@ -185,20 +188,44 @@ public class FlatItemDb extends AbstractItemDb {
throw new UnsupportedOperationException("Legacy IDs aren't supported on this version.");
}
public ItemData lookup(ItemStack item) {
Material type = item.getType();
if (MaterialUtil.isPotion(type) && item.getItemMeta() instanceof PotionMeta) {
PotionData potion = ((PotionMeta) item.getItemMeta()).getBasePotionData();
return new ItemData(type, potion);
} else if (type.toString().contains("SPAWNER")) {
EntityType entity = ess.getSpawnerProvider().getEntityType(item);
return new ItemData(type, entity);
} else {
return new ItemData(type);
}
}
@Override
public Collection<String> listNames() {
return Collections.unmodifiableSet(allAliases);
}
public static class ItemData {
private Material material;
private PotionData potionData;
private final Material material;
private PotionData potionData = null;
private EntityType entity = null;
public ItemData(Material material) {
this.material = material;
}
public ItemData(Material material, PotionData potionData) {
this.material = material;
this.potionData = potionData;
}
public ItemData(Material material, EntityType entity) {
this.material = material;
this.entity = entity;
}
@Override
public int hashCode() {
return (31 * material.hashCode()) ^ potionData.hashCode();
@@ -213,7 +240,7 @@ public class FlatItemDb extends AbstractItemDb {
return false;
}
ItemData that = (ItemData) o;
return this.material == that.getMaterial() && potionDataEquals(that);
return this.material == that.getMaterial() && potionDataEquals(that) && entityEquals(that);
}
public Material getMaterial() {
@@ -224,6 +251,10 @@ public class FlatItemDb extends AbstractItemDb {
return this.potionData;
}
public EntityType getEntity() {
return this.entity;
}
private boolean potionDataEquals(ItemData o) {
if (this.potionData == null && o.getPotionData() == null) {
return true;
@@ -233,5 +264,15 @@ public class FlatItemDb extends AbstractItemDb {
return false;
}
}
private boolean entityEquals(ItemData o) {
if (this.entity == null && o.getEntity() == null) { // neither have an entity
return true;
} else if (this.entity != null && o.getEntity() != null) { // both have an entity; check if it's the same one
return this.entity.equals(o.getEntity());
} else { // one has an entity but the other doesn't, so they can't be equal
return false;
}
}
}
}
@@ -44,6 +44,7 @@ public class LegacyItemDb extends AbstractItemDb {
return;
}
ready = false;
durabilities.clear();
items.clear();
names.clear();
@@ -90,18 +91,13 @@ public class LegacyItemDb extends AbstractItemDb {
continue;
}
Material material = Material.matchMaterial(itemName);
if (material == null) {
LOGGER.warning(String.format("Failed to find material for %s", itemName));
continue;
}
durabilities.put(itemName, data);
items.put(itemName, numeric);
if (nbt != null) {
nbtData.put(itemName, nbt);
}
ItemData itemData = new ItemData(material, numeric, data);
ItemData itemData = new ItemData(numeric, data);
if (names.containsKey(itemData)) {
List<String> nameList = names.get(itemData);
nameList.add(itemName);
@@ -120,6 +116,8 @@ public class LegacyItemDb extends AbstractItemDb {
}
LOGGER.info(String.format("Loaded %s items from items.csv.", listNames().size()));
ready = true;
}
@Override
@@ -152,6 +150,13 @@ public class LegacyItemDb extends AbstractItemDb {
}
}
if (itemid < 1) {
Material matFromName = EnumUtil.getMaterial(itemname.toUpperCase());
if (matFromName != null) {
itemid = matFromName.getId();
}
}
if (itemid < 1) {
throw new Exception(tl("unknownItemName", itemname));
}
@@ -161,7 +166,7 @@ public class LegacyItemDb extends AbstractItemDb {
throw new Exception(tl("unknownItemId", itemid));
}
Material mat = data.getMaterial();
Material mat = getFromLegacy(itemid, (byte) metaData);
ItemStack retval = new ItemStack(mat);
if (nbtData.containsKey(itemname)) {
String nbt = nbtData.get(itemname);
@@ -198,10 +203,10 @@ public class LegacyItemDb extends AbstractItemDb {
@Override
public List<String> nameList(ItemStack item) {
ItemData itemData = new ItemData(item.getType(), item.getDurability());
ItemData itemData = new ItemData(item.getType().getId(), item.getDurability());
List<String> nameList = names.get(itemData);
if (nameList == null) {
itemData = new ItemData(item.getType(), (short) 0);
itemData = new ItemData(item.getType().getId(), (short) 0);
nameList = names.get(itemData);
if (nameList == null) {
return null;
@@ -213,10 +218,10 @@ public class LegacyItemDb extends AbstractItemDb {
@Override
public String name(ItemStack item) {
ItemData itemData = new ItemData(item.getType(), item.getDurability());
ItemData itemData = new ItemData(item.getType().getId(), item.getDurability());
String name = primaryName.get(itemData);
if (name == null) {
itemData = new ItemData(item.getType(), (short) 0);
itemData = new ItemData(item.getType().getId(), (short) 0);
name = primaryName.get(itemData);
if (name == null) {
return null;
@@ -225,16 +230,6 @@ public class LegacyItemDb extends AbstractItemDb {
return name;
}
@Override
public Material getFromLegacy(final int id, final byte damage) {
ItemData data = this.legacyIds.get(id);
if (data == null) {
return null;
}
return data.getMaterial();
}
@Override
public int getLegacyId(Material material) throws Exception {
for(Map.Entry<String, Integer> entry : items.entrySet()) {
@@ -252,29 +247,16 @@ public class LegacyItemDb extends AbstractItemDb {
}
static class ItemData {
final private Material material;
private int legacyId;
private int itemNo;
final private short itemData;
ItemData(Material material, short itemData) {
this.material = material;
ItemData(final int itemNo, final short itemData) {
this.itemNo = itemNo;
this.itemData = itemData;
}
@Deprecated
ItemData(Material material, final int legacyId, final short itemData) {
this.material = material;
this.legacyId = legacyId;
this.itemData = itemData;
}
public Material getMaterial() {
return material;
}
@Deprecated
public int getItemNo() {
return legacyId;
return itemNo;
}
public short getItemData() {
@@ -283,7 +265,7 @@ public class LegacyItemDb extends AbstractItemDb {
@Override
public int hashCode() {
return (31 * material.hashCode()) ^ itemData;
return (31 * itemNo) ^ itemData;
}
@Override
@@ -295,7 +277,7 @@ public class LegacyItemDb extends AbstractItemDb {
return false;
}
ItemData pairo = (ItemData) o;
return this.material == pairo.getMaterial() && this.itemData == pairo.getItemData();
return this.itemNo == pairo.getItemNo() && this.itemData == pairo.getItemData();
}
}
@@ -2,7 +2,6 @@ package com.earth2me.essentials.messaging;
import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.IUser;
import com.earth2me.essentials.User;
@@ -189,7 +189,7 @@ public class Metrics {
public JSONObject getPluginData() {
JSONObject data = new JSONObject();
String pluginName = "EssentialsX";
String pluginName = plugin.getDescription().getName().replace("Essentials", "EssentialsX");
String pluginVersion = plugin.getDescription().getVersion();
data.put("pluginName", pluginName); // Append the name of the plugin
@@ -13,7 +13,7 @@ public class PermissionsHandler implements IPermissionsHandler {
private transient IPermissionsHandler handler = null;
private transient String defaultGroup = "default";
private final transient Essentials ess;
private transient boolean useSuperperms = false;
private transient boolean useSuperperms;
private Class<?> lastHandler = null;
@@ -92,10 +92,7 @@ public class PermissionsHandler implements IPermissionsHandler {
public void checkPermissions() {
// load and assign a handler
List<Class<? extends SuperpermsHandler>> providerClazz = Arrays.asList(
BPermissions2Handler.class,
PermissionsExHandler.class,
PrivilegesHandler.class,
SimplyPermsHandler.class,
GenericVaultHandler.class,
SuperpermsHandler.class
);
@@ -158,7 +155,4 @@ public class PermissionsHandler implements IPermissionsHandler {
}
}
private void checkPermLag(long start) {
checkPermLag(start, "not defined");
}
}
@@ -13,7 +13,7 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
protected static Permission perms = null;
protected static Chat chat = null;
public boolean setupProviders() {
private boolean setupProviders() {
try {
Class.forName("net.milkbowl.vault.permission.Permission");
Class.forName("net.milkbowl.vault.chat.Chat");
@@ -65,7 +65,7 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
}
}
protected boolean canLoad() {
boolean canLoad() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) return false;
try {
return setupProviders();
@@ -1,17 +0,0 @@
package com.earth2me.essentials.perm.impl;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class BPermissions2Handler extends AbstractVaultHandler {
@Override
public boolean canBuild(final Player base, final String group) {
return hasPermission(base, "bPermissions.build");
}
@Override
public boolean tryProvider() {
return super.canLoad() && Bukkit.getPluginManager().getPlugin("bPermissions") != null;
}
}
@@ -1,16 +0,0 @@
package com.earth2me.essentials.perm.impl;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class PrivilegesHandler extends AbstractVaultHandler {
@Override
public boolean canBuild(Player base, String group) {
return hasPermission(base, "privileges.build");
}
@Override
public boolean tryProvider() {
return super.canLoad() && Bukkit.getPluginManager().getPlugin("Privileges") != null;
}
}
@@ -1,16 +0,0 @@
package com.earth2me.essentials.perm.impl;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class SimplyPermsHandler extends AbstractVaultHandler {
@Override
public boolean canBuild(Player base, String group) {
return hasPermission(base, "permissions.allow.build");
}
@Override
public boolean tryProvider() {
return super.canLoad() && Bukkit.getPluginManager().getPlugin("SimplyPerms") != null;
}
}
@@ -5,10 +5,10 @@ import org.bukkit.plugin.Plugin;
/**
* Interface to be implemented by a payment method.
* Copyright (C) 2011
* AOL license <http://aol.nexua.org>
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright Copyright (C) 2011
* @license AOL license <http://aol.nexua.org>
*/
public interface Method {
/**
@@ -22,7 +22,7 @@ import java.util.Set;
* preferred: "iConomy"
* </pre></blockquote>
*
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun) @copyright: Copyright (C) 2011 @license: AOL license
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun) @copyright: Copyright (C) 2011 @license: AOL license
* <http://aol.nexua.org>
*/
public class Methods {
@@ -30,9 +30,9 @@ public class Methods {
private static boolean self = false;
private static Method Method = null;
private static String preferred = "";
private static final Set<Method> Methods = new HashSet<Method>();
private static final Set<String> Dependencies = new HashSet<String>();
private static final Set<Method> Attachables = new HashSet<Method>();
private static final Set<Method> Methods = new HashSet<>();
private static final Set<String> Dependencies = new HashSet<>();
private static final Set<Method> Attachables = new HashSet<>();
static {
_init();
@@ -79,7 +79,7 @@ public class Methods {
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
*
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #setMethod(PluginManager)
*/
public static Set<String> getDependencies() {
return Dependencies;
@@ -114,8 +114,8 @@ public class Methods {
*
* @return <code>boolean</code>
*
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
* @see #setMethod(PluginManager)
* @see #checkDisabled(Plugin)
*/
public static boolean hasMethod() {
return (Method != null);
@@ -124,7 +124,7 @@ public class Methods {
/**
* Checks Plugin Class against a multitude of checks to verify it's usability as a payment method.
*
* @param <code>PluginManager</code> the plugin manager for the server
* @param manager the plugin manager for the server
*
* @return <code>boolean</code> True on success, False on failure.
*/
@@ -140,7 +140,7 @@ public class Methods {
int count = 0;
boolean match = false;
Plugin plugin = null;
Plugin plugin;
for (String name : getDependencies()) {
if (hasMethod()) {
@@ -1,18 +1,17 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
public class VaultEco implements Method {
private Vault vault;
private Plugin vault;
private Economy economy;
@Override
public Vault getPlugin() {
public Plugin getPlugin() {
return this.vault;
}
@@ -108,17 +107,15 @@ public class VaultEco implements Method {
public boolean isCompatible(Plugin plugin) {
try {
RegisteredServiceProvider<Economy> ecoPlugin = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
return plugin instanceof Vault && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
} catch (LinkageError e) {
return false;
} catch (Exception e) {
return plugin.getName().equals("Vault") && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
} catch (LinkageError | Exception e) {
return false;
}
}
@Override
public void setPlugin(Plugin plugin) {
this.vault = (Vault) plugin;
this.vault = plugin;
RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
this.economy = economyProvider.getProvider();
@@ -130,7 +127,7 @@ public class VaultEco implements Method {
private final String name;
private final Economy economy;
public VaultAccount(String name, Economy economy) {
VaultAccount(String name, Economy economy) {
this.name = name;
this.economy = economy;
}
@@ -297,12 +297,16 @@ public class EssentialsSign {
}
protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex, final User player, final IEssentials ess) throws SignException {
return getTrade(sign, amountIndex, itemIndex, player, false, ess);
}
protected final Trade getTrade(final ISign sign, final int amountIndex, final int itemIndex, final User player, final boolean allowId, final IEssentials ess) throws SignException {
final String itemType = getSignText(sign, itemIndex);
if (itemType.equalsIgnoreCase("exp") || itemType.equalsIgnoreCase("xp")) {
final int amount = getIntegerPositive(getSignText(sign, amountIndex));
return new Trade(amount, ess);
}
final ItemStack item = getItemStack(itemType, 1, true, ess);
final ItemStack item = getItemStack(itemType, 1, allowId, ess);
final int amount = Math.min(getIntegerPositive(getSignText(sign, amountIndex)), item.getType().getMaxStackSize() * player.getBase().getInventory().getSize());
if (item.getType() == Material.AIR || amount < 1) {
throw new SignException(tl("moreThanZero"));
@@ -402,6 +406,10 @@ public class EssentialsSign {
}
protected final Trade getTrade(final ISign sign, final int index, final int decrement, final IEssentials ess) throws SignException {
return getTrade(sign, index, decrement, false, ess);
}
protected final Trade getTrade(final ISign sign, final int index, final int decrement, final boolean allowId, final IEssentials ess) throws SignException {
final String line = getSignText(sign, index);
if (line.isEmpty()) {
return new Trade(signName.toLowerCase(Locale.ENGLISH) + "sign", ess);
@@ -424,7 +432,7 @@ public class EssentialsSign {
sign.setLine(index, quantity + " exp");
return new Trade(quantity, ess);
} else {
final ItemStack stack = getItemStack(item, quantity, true, ess);
final ItemStack stack = getItemStack(item, quantity, allowId, ess);
sign.setLine(index, quantity + " " + item);
return new Trade(stack, ess);
}
@@ -54,6 +54,8 @@ public class SignGameMode extends EssentialsSign {
player.setGameMode(GameMode.CREATIVE);
} else if (mode.contains("advent") || mode.equalsIgnoreCase("2")) {
player.setGameMode(GameMode.ADVENTURE);
} else if (mode.contains("spec") || mode.equalsIgnoreCase("3")) {
player.setGameMode(GameMode.SPECTATOR);
} else {
throw new SignException(tl("invalidSignLine", 2));
}
@@ -26,8 +26,8 @@ public class SignTrade extends EssentialsSign {
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException {
validateTrade(sign, 1, false, ess);
validateTrade(sign, 2, true, ess);
final Trade trade = getTrade(sign, 2, AmountType.ROUNDED, true, ess);
final Trade charge = getTrade(sign, 1, AmountType.ROUNDED, false, ess);
final Trade trade = getTrade(sign, 2, AmountType.ROUNDED, true, true, ess);
final Trade charge = getTrade(sign, 1, AmountType.ROUNDED, false, true, ess);
if (trade.getType() == charge.getType() && (trade.getType() != TradeType.ITEM || trade.getItemStack().isSimilar(charge.getItemStack()))) {
throw new SignException("You cannot trade for the same item type.");
}
@@ -44,7 +44,7 @@ public class SignTrade extends EssentialsSign {
final Trade store = rechargeSign(sign, ess, player);
Trade stored;
try {
stored = getTrade(sign, 1, AmountType.TOTAL, true, ess);
stored = getTrade(sign, 1, AmountType.TOTAL, true, true, ess);
subtractAmount(sign, 1, stored, ess);
Map<Integer, ItemStack> withdraw = stored.pay(player, OverflowType.RETURN);
@@ -62,8 +62,8 @@ public class SignTrade extends EssentialsSign {
}
Trade.log("Sign", "Trade", "Deposit", username, store, username, null, sign.getBlock().getLocation(), ess);
} else {
final Trade charge = getTrade(sign, 1, AmountType.COST, false, ess);
final Trade trade = getTrade(sign, 2, AmountType.COST, true, ess);
final Trade charge = getTrade(sign, 1, AmountType.COST, false, true, ess);
final Trade trade = getTrade(sign, 2, AmountType.COST, true, true, ess);
charge.isAffordableFor(player);
addAmount(sign, 1, charge, ess);
subtractAmount(sign, 2, trade, ess);
@@ -80,7 +80,7 @@ public class SignTrade extends EssentialsSign {
}
private Trade rechargeSign(final ISign sign, final IEssentials ess, final User player) throws SignException, ChargeException {
final Trade trade = getTrade(sign, 2, AmountType.COST, false, ess);
final Trade trade = getTrade(sign, 2, AmountType.COST, false, true, ess);
if (trade.getItemStack() != null && player.getBase().getItemInHand() != null && trade.getItemStack().getType() == player.getBase().getItemInHand().getType() && trade.getItemStack().getDurability() == player.getBase().getItemInHand().getDurability() && trade.getItemStack().getEnchantments().equals(player.getBase().getItemInHand().getEnchantments())) {
int amount = player.getBase().getItemInHand().getAmount();
amount -= amount % trade.getItemStack().getAmount();
@@ -106,8 +106,8 @@ public class SignTrade extends EssentialsSign {
if (canBreak) {
try {
final Trade stored1 = getTrade(sign, 1, AmountType.TOTAL, false, ess);
final Trade stored2 = getTrade(sign, 2, AmountType.TOTAL, false, ess);
final Trade stored1 = getTrade(sign, 1, AmountType.TOTAL, false, true, ess);
final Trade stored2 = getTrade(sign, 2, AmountType.TOTAL, false, true, ess);
if (!canCollect) {
Trade.log("Sign", "Trade", "Destroy", signOwner, stored2, username, stored1, sign.getBlock().getLocation(), ess);
@@ -206,6 +206,10 @@ public class SignTrade extends EssentialsSign {
}
protected final Trade getTrade(final ISign sign, final int index, final AmountType amountType, final boolean notEmpty, final IEssentials ess) throws SignException {
return getTrade(sign, index, amountType, notEmpty, false, ess);
}
protected final Trade getTrade(final ISign sign, final int index, final AmountType amountType, final boolean notEmpty, final boolean allowId, final IEssentials ess) throws SignException {
final String line = sign.getLine(index).trim();
if (line.isEmpty()) {
throw new SignException("Empty line");
@@ -237,7 +241,7 @@ public class SignTrade extends EssentialsSign {
return new Trade((amountType == AmountType.COST ? stackamount : amount), ess);
} else {
final int stackamount = getIntegerPositive(split[0]);
final ItemStack item = getItemStack(split[1], stackamount, true, ess);
final ItemStack item = getItemStack(split[1], stackamount, allowId, ess);
int amount = getInteger(split[2]);
if (amountType == AmountType.ROUNDED) {
amount -= amount % stackamount;
@@ -12,7 +12,7 @@ public class EnumUtil {
/**
* Returns the field matching the first provided enum name that exists within the given
* enum class.
* enum class. If no field is found, this method returns null.
*
* @param enumClass The class to search through
* @param names The names of the fields to search for
@@ -17,7 +17,7 @@ import static com.earth2me.essentials.I18n.tl;
public class LocationUtil {
// The player can stand inside these materials
public static final Set<Material> HOLLOW_MATERIALS = new HashSet<>();
private static final Set<Material> HOLLOW_MATERIALS = new HashSet<>();
private static final Set<Material> TRANSPARENT_MATERIALS = new HashSet<>();
static {
@@ -32,8 +32,7 @@ public class LocationUtil {
TRANSPARENT_MATERIALS.add(Material.WATER);
try {
TRANSPARENT_MATERIALS.add(Material.valueOf("FLOWING_WATER"));
} catch (Exception ignored) { // 1.13 WATER uses Levelled
}
} catch (Exception ignored) {} // 1.13 WATER uses Levelled
}
public static final int RADIUS = 3;
@@ -49,7 +48,7 @@ public class LocationUtil {
public int y;
public int z;
public Vector3D(int x, int y, int z) {
Vector3D(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
@@ -57,7 +56,7 @@ public class LocationUtil {
}
static {
List<Vector3D> pos = new ArrayList<Vector3D>();
List<Vector3D> pos = new ArrayList<>();
for (int x = -RADIUS; x <= RADIUS; x++) {
for (int y = -RADIUS; y <= RADIUS; y++) {
for (int z = -RADIUS; z <= RADIUS; z++) {
@@ -65,30 +64,22 @@ public class LocationUtil {
}
}
}
Collections.sort(pos, new Comparator<Vector3D>() {
@Override
public int compare(Vector3D a, Vector3D b) {
return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
}
});
pos.sort(Comparator.comparingInt(a -> (a.x * a.x + a.y * a.y + a.z * a.z)));
VOLUME = pos.toArray(new Vector3D[0]);
}
@SuppressWarnings("deprecation")
public static Location getTarget(final LivingEntity entity) throws Exception {
Block block = null;
try {
block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300);
} catch (NoSuchMethodError e) {
// failing now :(
}
} catch (NoSuchMethodError ignored) {} // failing now :(
if (block == null) {
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) {
public static boolean isBlockAboveAir(final World world, final int x, final int y, final int z) {
return y > world.getMaxHeight() || HOLLOW_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType());
}
@@ -124,8 +115,7 @@ public class LocationUtil {
if (below.getType() == Material.valueOf("FLOWING_LAVA")) {
return true;
}
} catch (Exception ignored) { // 1.13 LAVA uses Levelled
}
} catch (Exception ignored) {} // 1.13 LAVA uses Levelled
Material PORTAL = EnumUtil.getMaterial("NETHER_PORTAL", "PORTAL");
@@ -159,7 +149,6 @@ public class LocationUtil {
user.getBase().setFlying(true);
}
// ess can be null if old deprecated method is calling it.
System.out.println((ess == null) + " " + ess.getSettings().isTeleportToCenterLocation());
if (ess == null || ess.getSettings().isTeleportToCenterLocation()) {
return getRoundedDestination(loc);
} else {
@@ -103,11 +103,16 @@ public class MaterialUtil {
}
public static Material convertFromLegacy(int id, byte damage) {
return EnumSet.allOf(Material.class).stream()
.filter(material -> material.getId() == id)
.findFirst()
.map(material -> Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage)))
.orElse(null);
for (Material material : EnumSet.allOf(Material.class)) {
if (material.getId() == id) {
try {
return Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage));
} catch (NoSuchMethodError error) {
return material;
}
}
}
return null;
}
public static DyeColor getColorOf(Material material) {
@@ -23,8 +23,13 @@ public class VersionUtil {
private static final Set<BukkitVersion> supportedVersions = ImmutableSet.of(v1_8_8_R01, v1_9_4_R01, v1_10_2_R01, v1_11_2_R01, v1_12_2_R01, v1_13_2_R01);
private static BukkitVersion serverVersion = null;
public static BukkitVersion getServerBukkitVersion() {
return BukkitVersion.fromString(Bukkit.getServer().getBukkitVersion());
if (serverVersion == null) {
serverVersion = BukkitVersion.fromString(Bukkit.getServer().getBukkitVersion());
}
return serverVersion;
}
public static boolean isServerSupported() {
@@ -49,7 +54,16 @@ public class VersionUtil {
matcher = VERSION_PATTERN.matcher(v1_13_2_R01.toString());
Preconditions.checkArgument(matcher.matches(), string + " is not in valid version format. e.g. 1.8.8-R0.1");
}
return new BukkitVersion(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)), Integer.parseInt(matcher.group(3)), Double.parseDouble(matcher.group(4)));
return from(matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(4));
}
private static BukkitVersion from(String major, String minor, String patch, String revision) {
if (patch.isEmpty()) patch = "0";
return new BukkitVersion(Integer.parseInt(major),
Integer.parseInt(minor),
Integer.parseInt(patch),
Double.parseDouble(revision));
}
private BukkitVersion(int major, int minor, int patch, double revision) {
-3
View File
@@ -1901,9 +1901,6 @@ plantren,91,0
glowpumpkin,91,0
gpumpkin,91,0
lpumpkin,91,0
lockedchest,95,0
lockchest,95,0
jokechest,95,0
whiteglass,95,0
whitesglass,95,0
whitestainedglass,95,0
1 #version: ${full.version}
1901 glowpumpkin,91,0
1902 gpumpkin,91,0
1903 lpumpkin,91,0
lockedchest,95,0
lockchest,95,0
jokechest,95,0
1904 whiteglass,95,0
1905 whitesglass,95,0
1906 whitestainedglass,95,0
+2874 -826
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -545,7 +545,7 @@ typeTpacancel=\u00a76To cancel this request, type \u00a7c/tpacancel\u00a76.
typeTpaccept=\u00a76To teleport, type \u00a7c/tpaccept\u00a76.
typeTpdeny=\u00a76To deny this request, type \u00a7c/tpdeny\u00a76.
typeWorldName=\u00a76You can also type the name of a specific world.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74; this is not a spawnable item.
unableToSpawnMob=\u00a74Unable to spawn mob.
unignorePlayer=\u00a76You are not ignoring player\u00a7c {0} \u00a76anymore.
unknownItemId=\u00a74Unknown item id\:\u00a7r {0}\u00a74.
+1 -1
View File
@@ -224,7 +224,7 @@ itemsNotConverted=\u00a74Du hast keine Items, die in Bl\u00f6cke konvertiert wer
itemSold=\u00a7aVerkauft f\u00fcr \u00a7c{0}\u00a7a ({1} {2} Einheiten je {3})
itemSoldConsole=\u00a7a{0} $averkauft {1} f\u00fcr \u00a7a{2} \u00a7a({3} Einheiten je {4})
itemSpawn=\u00a76Du gibst dir\u00a7c {0}\u00a76x\u00a7c {1}
itemType=\u00a76Gegenstand\:\u00a7c {0} \u00a76-\u00a7c {1}
itemType=\u00a76Gegenstand\:\u00a7c {0} \u00a76
jailAlreadyIncarcerated=\u00a74Spieler ist bereits im Gef\u00e4ngnis\:\u00a7c {0}
jailList=\u00a76Jails\:\u00a7r {0}
jailMessage=\u00a74Du hast ein Verbrechen begangen, also musst du deine Zeit absitzen.
+1 -1
View File
@@ -545,7 +545,7 @@ typeTpacancel=\u00a76To cancel this request, type \u00a7c/tpacancel\u00a76.
typeTpaccept=\u00a76To teleport, type \u00a7c/tpaccept\u00a76.
typeTpdeny=\u00a76To deny this request, type \u00a7c/tpdeny\u00a76.
typeWorldName=\u00a76You can also type the name of a specific world.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74; this is not a spawnable item.
unableToSpawnMob=\u00a74Unable to spawn mob.
unignorePlayer=\u00a76You are not ignoring player\u00a7c {0} \u00a76anymore.
unknownItemId=\u00a74Unknown item id\:\u00a7r {0}\u00a74.
+2 -2
View File
@@ -224,7 +224,7 @@ itemsNotConverted=\u00a74You have no items that can be converted into blocks.
itemSold=\u00a7aSold for \u00a7c{0} \u00a7a({1} {2} at {3} each).
itemSoldConsole=\u00a7a{0} \u00a7asold {1} for \u00a7a{2} \u00a7a({3} items at {4} each).
itemSpawn=\u00a76Giving\u00a7c {0} \u00a76of\u00a7c {1}
itemType=\u00a76Item\:\u00a7c {0} \u00a76-\u00a7c {1}
itemType=\u00a76Item\:\u00a7c {0} \u00a76
jailAlreadyIncarcerated=\u00a74Person is already in jail\:\u00a7c {0}
jailList=\u00a76Jails\:\u00a7r {0}
jailMessage=\u00a74You do the crime, you do the time.
@@ -544,7 +544,7 @@ typeTpacancel=\u00a76To cancel this request, type \u00a7c/tpacancel\u00a76.
typeTpaccept=\u00a76To teleport, type \u00a7c/tpaccept\u00a76.
typeTpdeny=\u00a76To deny this request, type \u00a7c/tpdeny\u00a76.
typeWorldName=\u00a76You can also type the name of a specific world.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74; this is not a spawnable item.
unableToSpawnMob=\u00a74Unable to spawn mob.
unignorePlayer=\u00a76You are not ignoring player\u00a7c {0} \u00a76anymore.
unknownItemId=\u00a74Unknown item id\:\u00a7r {0}\u00a74.
+1 -1
View File
@@ -224,7 +224,7 @@ itemsNotConverted=\u00a74Sul pole esemeid, mida saaks plokkideks konverteerida.
itemSold=\u00a7aM\u00fc\u00fcdud hinnaga \u00a7c{0} \u00a7a({1} {2} hinnaga {3} t\u00fckk).
itemSoldConsole=\u00a7aM\u00e4ngija {0} \u00a7am\u00fc\u00fcs {1} hinnaga \u00a7a{2} \u00a7a({3} eset hinnaga {4} t\u00fckk).
itemSpawn=\u00a76Annan m\u00e4ngijale\u00a7c {0} {1}
itemType=\u00a76Ese\:\u00a7c {0} \u00a76-\u00a7c {1}
itemType=\u00a76Ese\:\u00a7c {0} \u00a76
jailAlreadyIncarcerated=\u00a74M\u00e4ngija on juba vanglas\:\u00a7c {0}
jailList=\u00a76Vanglad\:\u00a7r {0}
jailMessage=\u00a74Sooritasid kuriteo, istud oma aja \u00e4ra.
@@ -5,34 +5,33 @@ import com.earth2me.essentials.api.UserDoesNotExistException;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException;
import junit.framework.TestCase;
import net.ess3.api.Economy;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.InvalidDescriptionException;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
public class EconomyTest extends TestCase {
public class EconomyTest {
private final transient Essentials ess;
private static final String NPCNAME = "npc1";
private static final String PLAYERNAME = "testPlayer1";
private static final String PLAYERNAME2 = "testPlayer2";
private final FakeServer server;
public EconomyTest(final String testName) {
super(testName);
public EconomyTest() {
this.server = new FakeServer();
server.createWorld("testWorld", Environment.NORMAL);
ess = new Essentials(server);
try {
ess.setupForTesting(server);
} catch (InvalidDescriptionException ex) {
fail("InvalidDescriptionException");
Assert.fail("InvalidDescriptionException");
} catch (IOException ex) {
fail("IOException");
Assert.fail("IOException");
}
server.addPlayer(new OfflinePlayer(PLAYERNAME, ess.getServer()));
server.addPlayer(new OfflinePlayer(PLAYERNAME2, ess.getServer()));
@@ -42,66 +41,63 @@ public class EconomyTest extends TestCase {
@Test
public void testEconomy() {
// test NPC
assertFalse("NPC does not exists", Economy.playerExists(NPCNAME));
assertTrue("Create NPC", Economy.createNPC(NPCNAME));
assertTrue("NPC exists", Economy.playerExists(NPCNAME));
assertNotNull("NPC can be accessed", ess.getOfflineUser(NPCNAME));
Assert.assertFalse("NPC does not exists", Economy.playerExists(NPCNAME));
Assert.assertTrue("Create NPC", Economy.createNPC(NPCNAME));
Assert.assertTrue("NPC exists", Economy.playerExists(NPCNAME));
Assert.assertNotNull("NPC can be accessed", ess.getOfflineUser(NPCNAME));
try {
Economy.removeNPC(NPCNAME);
} catch (UserDoesNotExistException ex) {
fail(ex.getMessage());
Assert.fail(ex.getMessage());
}
assertFalse("NPC can be removed", Economy.playerExists(NPCNAME));
Assert.assertFalse("NPC can be removed", Economy.playerExists(NPCNAME));
//test Math
try {
assertTrue("Player exists", Economy.playerExists(PLAYERNAME));
Assert.assertTrue("Player exists", Economy.playerExists(PLAYERNAME));
Economy.resetBalance(PLAYERNAME);
assertEquals("Player has no money", 0.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Player has no money", 0.0, Economy.getMoney(PLAYERNAME), 0);
Economy.add(PLAYERNAME, 10.0);
assertEquals("Add money", 10.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Add money", 10.0, Economy.getMoney(PLAYERNAME),0);
Economy.subtract(PLAYERNAME, 5.0);
assertEquals("Subtract money", 5.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Subtract money", 5.0, Economy.getMoney(PLAYERNAME),0);
Economy.multiply(PLAYERNAME, 2.0);
assertEquals("Multiply money", 10.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Multiply money", 10.0, Economy.getMoney(PLAYERNAME),0);
Economy.divide(PLAYERNAME, 2.0);
assertEquals("Divide money", 5.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Divide money", 5.0, Economy.getMoney(PLAYERNAME),0);
Economy.setMoney(PLAYERNAME, 10.0);
assertEquals("Set money", 10.0, Economy.getMoney(PLAYERNAME));
} catch (NoLoanPermittedException ex) {
fail(ex.getMessage());
} catch (UserDoesNotExistException ex) {
fail(ex.getMessage());
Assert.assertEquals("Set money", 10.0, Economy.getMoney(PLAYERNAME),0);
} catch (NoLoanPermittedException | UserDoesNotExistException ex) {
Assert.fail(ex.getMessage());
}
//test Format
assertEquals("Format $1,000", "$1,000", Economy.format(1000.0));
assertEquals("Format $10", "$10", Economy.format(10.0));
assertEquals("Format $10.10", "$10.10", Economy.format(10.10));
assertEquals("Format $10.10", "$10.10", Economy.format(10.1000001));
assertEquals("Format $10.10", "$10.10", Economy.format(10.1099999));
Assert.assertEquals("Format $1,000", "$1,000", Economy.format(1000.0));
Assert.assertEquals("Format $10", "$10", Economy.format(10.0));
Assert.assertEquals("Format $10.10", "$10.10", Economy.format(10.10));
Assert.assertEquals("Format $10.10", "$10.10", Economy.format(10.1000001));
Assert.assertEquals("Format $10.10", "$10.10", Economy.format(10.1099999));
//test Exceptions
try {
assertTrue("Player exists", Economy.playerExists(PLAYERNAME));
Assert.assertTrue("Player exists", Economy.playerExists(PLAYERNAME));
Economy.resetBalance(PLAYERNAME);
assertEquals("Reset balance", 0.0, Economy.getMoney(PLAYERNAME));
Assert.assertEquals("Reset balance", 0.0, Economy.getMoney(PLAYERNAME),0);
Economy.subtract(PLAYERNAME, 5.0);
fail("Did not throw exception");
} catch (NoLoanPermittedException ex) {
Assert.fail("Did not throw exception");
} catch (NoLoanPermittedException ignored) {
} catch (UserDoesNotExistException ex) {
fail(ex.getMessage());
Assert.fail(ex.getMessage());
}
try {
Economy.resetBalance("UnknownPlayer");
fail("Did not throw exception");
Assert.fail("Did not throw exception");
} catch (NoLoanPermittedException ex) {
fail(ex.getMessage());
} catch (UserDoesNotExistException ex) {
}
Assert.fail(ex.getMessage());
} catch (UserDoesNotExistException ignored) {}
}
private void runCommand(String command, User user, String args) throws Exception {
@@ -116,8 +112,7 @@ public class EconomyTest extends TestCase {
.loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, user, command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
@@ -135,16 +130,16 @@ public class EconomyTest extends TestCase {
.loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, new CommandSource(sender), command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
public void testNegativePayCommand() throws Exception {
@Test
public void testNegativePayCommand() {
User user1 = ess.getUser(PLAYERNAME);
try {
runCommand("pay", user1, PLAYERNAME2 + " -123");
} catch (Exception e) {
assertEquals(I18n.tl("payMustBePositive"), e.getMessage());
Assert.assertEquals(I18n.tl("payMustBePositive"), e.getMessage());
}
}
}
@@ -39,7 +39,6 @@ import org.bukkit.util.CachedServerIcon;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
@@ -48,11 +47,11 @@ import java.util.logging.Logger;
public class FakeServer implements Server {
private List<Player> players = new ArrayList<Player>();
private final List<World> worlds = new ArrayList<World>();
PluginManager pluginManager = new FakePluginManager();
private List<Player> players = new ArrayList<>();
private final List<World> worlds = new ArrayList<>();
private PluginManager pluginManager = new FakePluginManager();
public FakeServer() {
FakeServer() {
if (Bukkit.getServer() == null) {
Bukkit.setServer(this);
}
@@ -139,7 +138,7 @@ public class FakeServer implements Server {
@Override
public List<Player> matchPlayer(String string) {
List<Player> matches = new ArrayList<Player>();
List<Player> matches = new ArrayList<>();
for (Player player : players) {
if (player.getName().substring(0, Math.min(player.getName().length(), string.length())).equalsIgnoreCase(string)) {
matches.add(player);
@@ -390,12 +389,12 @@ public class FakeServer implements Server {
throw new UnsupportedOperationException("Not supported yet.");
}
public void addPlayer(Player base1) {
void addPlayer(Player base1) {
players.add(base1);
pluginManager.callEvent(new PlayerJoinEvent(base1, null));
}
public OfflinePlayer createPlayer(String name) {
OfflinePlayer createPlayer(String name) {
OfflinePlayer player = new OfflinePlayer(name, this);
player.setLocation(new Location(worlds.get(0), 0, 0, 0, 0, 0));
return player;
@@ -445,6 +444,10 @@ public class FakeServer implements Server {
throw new UnsupportedOperationException("Not supported yet.");
}
public MapView getMap(int id) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getViewDistance() {
throw new UnsupportedOperationException("Not supported yet.");
@@ -460,11 +463,6 @@ public class FakeServer implements Server {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public MapView getMap(short s) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public MapView createMap(World world) {
throw new UnsupportedOperationException("Not supported yet.");
@@ -502,7 +500,12 @@ public class FakeServer implements Server {
@Override
public Player getPlayerExact(String string) {
throw new UnsupportedOperationException("Not supported yet.");
for (Player player : players) {
if (player.getName().equals(string)) {
return player;
}
}
return null;
}
@Override
@@ -589,14 +592,15 @@ public class FakeServer implements Server {
@Override
public UUID getUniqueId() {
if (string == "testPlayer1") {
return UUID.fromString("3c9ebe1a-9098-43fd-bc0c-a369b76817ba");
} else if (string == "testPlayer2") {
return UUID.fromString("2c9ebe1a-9098-43fd-bc0c-a369b76817ba");
} else if (string == "npc1") {
return null;
switch (string) {
case "testPlayer1":
return UUID.fromString("3c9ebe1a-9098-43fd-bc0c-a369b76817ba");
case "testPlayer2":
return UUID.fromString("2c9ebe1a-9098-43fd-bc0c-a369b76817ba");
case "npc1":
return null;
}
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
@@ -754,7 +758,7 @@ public class FakeServer implements Server {
}
@Override
public Set getOperators() {
public Set<org.bukkit.OfflinePlayer> getOperators() {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -919,12 +923,12 @@ public class FakeServer implements Server {
}
@Override
public CachedServerIcon loadServerIcon(File file) throws Exception {
public CachedServerIcon loadServerIcon(File file) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public CachedServerIcon loadServerIcon(BufferedImage bufferedImage) throws Exception {
public CachedServerIcon loadServerIcon(BufferedImage bufferedImage) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -969,6 +973,7 @@ public class FakeServer implements Server {
}
@Override
@SuppressWarnings("deprecation")
public UnsafeValues getUnsafe() {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -1049,8 +1054,12 @@ public class FakeServer implements Server {
throw new UnsupportedOperationException("Not supported yet.");
}
public <T extends Keyed> Iterable<Tag<T>> getTags(String registry, Class<T> clazz) {
throw new UnsupportedOperationException("Not supported yet.");
}
class FakePluginManager implements PluginManager {
ArrayList<RegisteredListener> listeners = new ArrayList<RegisteredListener>();
ArrayList<RegisteredListener> listeners = new ArrayList<>();
@Override
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException {
@@ -1078,7 +1087,7 @@ public class FakeServer implements Server {
}
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
public Plugin loadPlugin(File file) throws UnknownDependencyException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -1210,9 +1219,14 @@ public class FakeServer implements Server {
}
}
@Override
@Override
public LootTable getLootTable(NamespacedKey arg0) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@Override
public List<Entity> selectEntities(CommandSender sender, String selector) throws IllegalArgumentException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -49,8 +49,7 @@ public class MessagingTest {
.loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, user, command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
@@ -68,8 +67,7 @@ public class MessagingTest {
.loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, new CommandSource(sender), command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
@Test(expected = Exception.class) // I really don't like this, but see note below about console reply
@@ -1,19 +1,19 @@
package com.earth2me.essentials;
import junit.framework.TestCase;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.plugin.InvalidDescriptionException;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
public class StorageTest extends TestCase {
Essentials ess;
FakeServer server;
World world;
public class StorageTest {
private Essentials ess;
private FakeServer server;
private World world;
public StorageTest() {
server = new FakeServer();
@@ -22,9 +22,9 @@ public class StorageTest extends TestCase {
try {
ess.setupForTesting(server);
} catch (InvalidDescriptionException ex) {
fail("InvalidDescriptionException");
Assert.fail("InvalidDescriptionException");
} catch (IOException ex) {
fail("IOException");
Assert.fail("IOException");
}
}
@@ -39,8 +39,7 @@ public class ToggleTest extends TestCase {
cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, user, command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
@@ -53,8 +52,7 @@ public class ToggleTest extends TestCase {
cmd = (IEssentialsCommand) Essentials.class.getClassLoader().loadClass("com.earth2me.essentials.commands.Command" + command).newInstance();
cmd.setEssentials(ess);
cmd.run(server, new CommandSource(sender), command, null, args);
} catch (NoChargeException ex) {
}
} catch (NoChargeException ignored) {}
}
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.VersionUtil;
import junit.framework.TestCase;
import org.bukkit.World.Environment;
import org.bukkit.plugin.InvalidDescriptionException;
@@ -14,13 +15,11 @@ import java.util.Set;
public class UtilTest extends TestCase {
private final Essentials ess;
private final FakeServer server;
public UtilTest() {
server = new FakeServer();
FakeServer server = new FakeServer();
server.createWorld("testWorld", Environment.NORMAL);
ess = new Essentials(server);
Essentials ess = new Essentials(server);
try {
ess.setupForTesting(server);
} catch (InvalidDescriptionException ex) {
@@ -31,7 +30,7 @@ public class UtilTest extends TestCase {
}
public void testSafeLocation() {
Set<String> testSet = new HashSet<String>();
Set<String> testSet = new HashSet<>();
int count = 0;
int x, y, z, origX, origY, origZ;
x = y = z = origX = origY = origZ = 0;
@@ -62,132 +61,146 @@ public class UtilTest extends TestCase {
public void testFDDfuture() {
Calendar a, b;
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 1);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 1);
assertEquals("1 second", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 2);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 2);
assertEquals("2 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 0, 3);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 3);
assertEquals("3 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 1, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 1, 0);
assertEquals("1 minute", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 2, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 2, 0);
assertEquals("2 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 10, 3, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 3, 0);
assertEquals("3 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 11, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 11, 0, 0);
assertEquals("1 hour", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 12, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 12, 0, 0);
assertEquals("2 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 13, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 13, 0, 0);
assertEquals("3 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 2, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 2, 10, 0, 0);
assertEquals("1 day", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 3, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 3, 10, 0, 0);
assertEquals("2 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 4, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 4, 10, 0, 0);
assertEquals("3 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 2, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.MARCH, 1, 10, 0, 0);
assertEquals("1 month", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 3, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.APRIL, 1, 10, 0, 0);
assertEquals("2 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 4, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.MAY, 1, 10, 0, 0);
assertEquals("3 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2011, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2011, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("1 year", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2012, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2012, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("2 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2013, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2013, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("3 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2011, 4, 5, 23, 38, 12);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2011, Calendar.MAY, 5, 23, 38, 12);
assertEquals("1 year 3 months 4 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 9, 17, 23, 45, 45);
b = new GregorianCalendar(2015, 3, 7, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.OCTOBER, 17, 23, 45, 45);
b = new GregorianCalendar(2015, Calendar.APRIL, 7, 10, 0, 0);
assertEquals("4 years 5 months 20 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2011, 4, 31, 10, 0, 0);
b = new GregorianCalendar(2011, 4, 31, 10, 5, 0);
a = new GregorianCalendar(2011, Calendar.MAY, 31, 10, 0, 0);
b = new GregorianCalendar(2011, Calendar.MAY, 31, 10, 5, 0);
assertEquals("5 minutes", DateUtil.formatDateDiff(a, b));
}
public void testFDDpast() {
Calendar a, b;
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 59);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 59, 59);
assertEquals("1 second", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 58);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 59, 58);
assertEquals("2 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 57);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 59, 57);
assertEquals("3 seconds", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 59, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 59, 0);
assertEquals("1 minute", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 58, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 58, 0);
assertEquals("2 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 57, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 57, 0);
assertEquals("3 minutes", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 9, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 9, 0, 0);
assertEquals("1 hour", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 8, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 8, 0, 0);
assertEquals("2 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 1, 7, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 7, 0, 0);
assertEquals("3 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 4, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 5, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 4, 10, 0, 0);
assertEquals("1 day", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 3, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 5, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 3, 10, 0, 0);
assertEquals("2 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 5, 10, 0, 0);
b = new GregorianCalendar(2010, 1, 2, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 5, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.FEBRUARY, 2, 10, 0, 0);
assertEquals("3 days", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 4, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.JUNE, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.MAY, 1, 10, 0, 0);
assertEquals("1 month", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 3, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.JUNE, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.APRIL, 1, 10, 0, 0);
assertEquals("2 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 5, 1, 10, 0, 0);
b = new GregorianCalendar(2010, 2, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.JUNE, 1, 10, 0, 0);
b = new GregorianCalendar(2010, Calendar.MARCH, 1, 10, 0, 0);
assertEquals("3 months", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2009, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2009, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("1 year", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2008, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2008, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("2 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2007, 1, 1, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2007, Calendar.FEBRUARY, 1, 10, 0, 0);
assertEquals("3 years", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 1, 1, 10, 0, 0);
b = new GregorianCalendar(2009, 4, 5, 23, 38, 12);
a = new GregorianCalendar(2010, Calendar.FEBRUARY, 1, 10, 0, 0);
b = new GregorianCalendar(2009, Calendar.MAY, 5, 23, 38, 12);
assertEquals("8 months 26 days 10 hours", DateUtil.formatDateDiff(a, b));
a = new GregorianCalendar(2010, 9, 17, 23, 45, 45);
b = new GregorianCalendar(2000, 3, 7, 10, 0, 0);
a = new GregorianCalendar(2010, Calendar.OCTOBER, 17, 23, 45, 45);
b = new GregorianCalendar(2000, Calendar.APRIL, 7, 10, 0, 0);
assertEquals("10 years 6 months 10 days", DateUtil.formatDateDiff(a, b));
}
public void testVer() {
VersionUtil.BukkitVersion v;
v = VersionUtil.BukkitVersion.fromString("1.13.2-R0.1");
assertEquals(v.getMajor(), 1);
assertEquals(v.getMinor(), 13);
assertEquals(v.getPatch(), 2);
assertEquals(v.getRevision(), 0.1);
v = VersionUtil.BukkitVersion.fromString("1.9-R1.4");
assertEquals(v.getMajor(), 1);
assertEquals(v.getMinor(), 9);
assertEquals(v.getPatch(), 0);
assertEquals(v.getRevision(), 1.4);
}
}
+1 -8
View File
@@ -6,18 +6,11 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXAntiBuild</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXAntiBuild-${full.version}</finalName>
</build>
@@ -1,5 +1,6 @@
package com.earth2me.essentials.antibuild;
import com.earth2me.essentials.metrics.Metrics;
import org.bukkit.Material;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -14,6 +15,7 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
private final transient Map<AntiBuildConfig, Boolean> settingsBoolean = new EnumMap<>(AntiBuildConfig.class);
private final transient Map<AntiBuildConfig, List<Material>> settingsList = new EnumMap<>(AntiBuildConfig.class);
private transient EssentialsConnect ess = null;
private transient Metrics metrics = null;
@Override
public void onEnable() {
@@ -26,6 +28,10 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild {
final EssentialsAntiBuildListener blockListener = new EssentialsAntiBuildListener(this);
pm.registerEvents(blockListener, this);
if (metrics == null) {
metrics = new Metrics(this);
}
}
@Override
@@ -22,15 +22,18 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsAntiBuildListener implements Listener {
private static final Logger logger = Logger.getLogger("EssentialsAntiBuild");
final private transient IAntiBuild prot;
final private transient IEssentials ess;
public EssentialsAntiBuildListener(final IAntiBuild parent) {
EssentialsAntiBuildListener(final IAntiBuild parent) {
this.prot = parent;
this.ess = prot.getEssentialsConnect().getEssentials();
@@ -53,14 +56,14 @@ public class EssentialsAntiBuildListener implements Listener {
private boolean metaPermCheck(final User user, final String action, final Block block) {
if (block == null) {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "AntiBuild permission check failed, invalid block.");
logger.log(Level.INFO, "AntiBuild permission check failed, invalid block.");
}
return false;
}
return metaPermCheck(user, action, block.getType(), block.getData());
}
private boolean metaPermCheck(final User user, final String action, final Material material) {
public boolean metaPermCheck(final User user, final String action, final Material material) {
final String blockPerm = "essentials.build." + action + "." + material;
return user.isAuthorized(blockPerm);
}
@@ -74,7 +77,7 @@ public class EssentialsAntiBuildListener implements Listener {
return user.isAuthorized(dataPerm);
} else {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "DataValue perm on " + user.getName() + " is not directly set: " + dataPerm);
logger.log(Level.INFO, "DataValue perm on " + user.getName() + " is not directly set: " + dataPerm);
}
}
}
@@ -13,14 +13,14 @@ import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsConnect {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
class EssentialsConnect {
private static final Logger logger = Logger.getLogger("EssentialsAntiBuild");
private final transient IEssentials ess;
private final transient IAntiBuild protect;
public EssentialsConnect(Plugin essPlugin, Plugin essProtect) {
EssentialsConnect(Plugin essPlugin, Plugin essProtect) {
if (!essProtect.getDescription().getVersion().equals(essPlugin.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
logger.log(Level.WARNING, tl("versionMismatchAll"));
}
ess = (IEssentials) essPlugin;
protect = (IAntiBuild) essProtect;
@@ -29,17 +29,14 @@ public class EssentialsConnect {
ess.addReloadListener(pr);
}
public void onDisable() {
}
public IEssentials getEssentials() {
IEssentials getEssentials() {
return ess;
}
public void alert(final User user, final String item, final String type) {
void alert(final User user, final String item, final String type) {
final Location loc = user.getLocation();
final String warnMessage = tl("alertFormat", user.getName(), type, item, loc.getWorld().getName() + "," + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ());
LOGGER.log(Level.WARNING, warnMessage);
logger.log(Level.WARNING, warnMessage);
for (Player p : ess.getServer().getOnlinePlayers()) {
final User alertUser = ess.getUser(p);
if (alertUser.isAuthorized("essentials.protect.alerts")) {
@@ -48,7 +45,6 @@ public class EssentialsConnect {
}
}
private class AntiBuildReloader implements IConf {
@Override
public void reloadConfig() {
+1 -1
View File
@@ -6,5 +6,5 @@ version: ${full.version}
website: http://tiny.cc/EssentialsCommands
description: Provides build protection.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Iaccidentally]
api-version: 1.13
depend: [Essentials]
api-version: 1.13
+1 -8
View File
@@ -6,18 +6,11 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXChat</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXChat-${full.version}</finalName>
</build>
@@ -5,7 +5,7 @@ import com.earth2me.essentials.User;
import net.ess3.api.IEssentials;
public class ChatStore {
class ChatStore {
private final User user;
private final String type;
private final Trade charge;
@@ -17,27 +17,27 @@ public class ChatStore {
this.charge = new Trade(getLongType(), ess);
}
public User getUser() {
User getUser() {
return user;
}
public Trade getCharge() {
Trade getCharge() {
return charge;
}
public String getType() {
String getType() {
return type;
}
public final String getLongType() {
final String getLongType() {
return type.length() == 0 ? "chat" : "chat-" + type;
}
public long getRadius() {
long getRadius() {
return radius;
}
public void setRadius(long radius) {
void setRadius(long radius) {
this.radius = radius;
}
}
@@ -1,5 +1,6 @@
package com.earth2me.essentials.chat;
import com.earth2me.essentials.metrics.Metrics;
import net.ess3.api.IEssentials;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.PluginManager;
@@ -9,27 +10,27 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsChat extends JavaPlugin {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient Metrics metrics = null;
@Override
public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
final IEssentials ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
return;
}
final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<AsyncPlayerChatEvent, ChatStore>());
final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<>());
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore);
final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore);
@@ -38,5 +39,9 @@ public class EssentialsChat extends JavaPlugin {
pluginManager.registerEvents(playerListenerNormal, this);
pluginManager.registerEvents(playerListenerHighest, this);
if (metrics == null) {
metrics = new Metrics(this);
}
}
}
@@ -13,12 +13,12 @@ import java.util.logging.Logger;
public abstract class EssentialsChatPlayer implements Listener {
protected static final Logger logger = Logger.getLogger("Minecraft");
protected transient IEssentials ess;
protected final transient Server server;
protected final transient Map<AsyncPlayerChatEvent, ChatStore> chatStorage;
static final Logger logger = Logger.getLogger("EssentialsChat");
transient IEssentials ess;
final transient Server server;
private final transient Map<AsyncPlayerChatEvent, ChatStore> chatStorage;
public EssentialsChatPlayer(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayer(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
this.ess = ess;
this.server = server;
this.chatStorage = chatStorage;
@@ -26,11 +26,11 @@ public abstract class EssentialsChatPlayer implements Listener {
public abstract void onPlayerChat(final AsyncPlayerChatEvent event);
public boolean isAborted(final AsyncPlayerChatEvent event) {
boolean isAborted(final AsyncPlayerChatEvent event) {
return event.isCancelled();
}
public String getChatType(final String message) {
String getChatType(final String message) {
if (message.length() == 0) {
//Ignore empty chat events generated by plugins
return "";
@@ -46,23 +46,23 @@ public abstract class EssentialsChatPlayer implements Listener {
}
}
public ChatStore getChatStore(final AsyncPlayerChatEvent event) {
ChatStore getChatStore(final AsyncPlayerChatEvent event) {
return chatStorage.get(event);
}
public void setChatStore(final AsyncPlayerChatEvent event, final ChatStore chatStore) {
void setChatStore(final AsyncPlayerChatEvent event, final ChatStore chatStore) {
chatStorage.put(event, chatStore);
}
public ChatStore delChatStore(final AsyncPlayerChatEvent event) {
ChatStore delChatStore(final AsyncPlayerChatEvent event) {
return chatStorage.remove(event);
}
protected void charge(final User user, final Trade charge) throws ChargeException {
private void charge(final User user, final Trade charge) throws ChargeException {
charge.charge(user);
}
protected boolean charge(final AsyncPlayerChatEvent event, final ChatStore chatStore) {
boolean charge(final AsyncPlayerChatEvent event, final ChatStore chatStore) {
try {
charge(chatStore.getUser(), chatStore.getCharge());
} catch (ChargeException e) {
@@ -10,7 +10,7 @@ import java.util.Map;
public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer {
public EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerHighest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
super(server, ess, chatStorage);
}
@@ -22,9 +22,7 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer {
return;
}
/**
* This file should handle charging the user for the action before returning control back
*/
// This file should handle charging the user for the action before returning control back
charge(event, chatStore);
}
}
@@ -15,7 +15,7 @@ import java.util.Map;
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer {
public EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerLowest(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
super(server, ess, chatStorage);
}
@@ -36,9 +36,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer {
final ChatStore chatStore = new ChatStore(ess, user, getChatType(event.getMessage()));
setChatStore(event, chatStore);
/**
* This listener should apply the general chat formatting only...then return control back the event handler
*/
// This listener should apply the general chat formatting only...then return control back the event handler
event.setMessage(FormatUtil.formatMessage(user, "essentials.chat", event.getMessage()));
String group = user.getGroup();
String world = user.getWorld().getName();
@@ -18,7 +18,7 @@ import static com.earth2me.essentials.I18n.tl;
public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer {
public EssentialsChatPlayerListenerNormal(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
EssentialsChatPlayerListenerNormal(final Server server, final IEssentials ess, final Map<AsyncPlayerChatEvent, ChatStore> chatStorage) {
super(server, ess, chatStorage);
}
@@ -29,10 +29,7 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer {
return;
}
/**
* This file should handle detection of the local chat features... if local chat is enabled, we need to handle
* it here
*/
// This file should handle detection of the local chat features; if local chat is enabled, we need to handle it here
long radius = ess.getSettings().getChatRadius();
if (radius < 1) {
return;
@@ -66,13 +63,13 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer {
}
Set<Player> outList = event.getRecipients();
Set<Player> spyList = new HashSet<Player>();
Set<Player> spyList = new HashSet<>();
try {
outList.add(event.getPlayer());
} catch (UnsupportedOperationException ex) {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "Plugin triggered custom chat event, local chat handling aborted.", ex);
logger.log(Level.INFO, "Plugin triggered custom chat event, local chat handling aborted.", ex);
}
return;
}
+1 -1
View File
@@ -7,4 +7,4 @@ website: http://tiny.cc/EssentialsCommands
description: Provides chat control features for Essentials. Requires Permissions.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy, Iaccidentally]
depend: [Essentials]
#softdepend: [Factions]
api-version: 1.13
+21 -27
View File
@@ -6,43 +6,18 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXGeoIP</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>javatar</groupId>
<artifactId>javatar</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
<build>
<finalName>EssentialsXGeoIP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
@@ -52,6 +27,7 @@
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
@@ -65,4 +41,22 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>javatar</groupId>
<artifactId>javatar</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
</project>
@@ -1,5 +1,6 @@
package com.earth2me.essentials.geoip;
import com.earth2me.essentials.metrics.Metrics;
import net.ess3.api.IEssentials;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@@ -10,12 +11,8 @@ import static com.earth2me.essentials.I18n.tl;
public class EssentialsGeoIP extends JavaPlugin {
public EssentialsGeoIP() {
}
@Override
public void onDisable() {
}
private transient Metrics metrics = null;
@Override
public void onEnable() {
@@ -33,5 +30,10 @@ public class EssentialsGeoIP extends JavaPlugin {
getLogger().log(Level.INFO, "This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com/.");
if (metrics == null) {
metrics = new Metrics(this);
}
}
}
@@ -20,11 +20,10 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Date;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
import java.util.Arrays;
import java.util.List;
import com.ice.tar.TarInputStream;
import com.ice.tar.TarEntry;
@@ -32,14 +31,14 @@ import static com.earth2me.essentials.I18n.tl;
public class EssentialsGeoIPPlayerListener implements Listener, IConf {
DatabaseReader mmreader = null; // initialize maxmind geoip2 reader
private static final Logger logger = Logger.getLogger("Minecraft");
File databaseFile;
File dataFolder;
final EssentialsConf config;
private DatabaseReader mmreader = null; // initialize maxmind geoip2 reader
private static final Logger logger = Logger.getLogger("EssentialsGeoIP");
private File databaseFile;
private File dataFolder;
private final EssentialsConf config;
private final transient IEssentials ess;
public EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) {
EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) {
this.ess = ess;
this.dataFolder = dataFolder;
this.config = new EssentialsConf(new File(dataFolder, "config.yml"));
@@ -49,15 +48,10 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event) {
ess.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
delayedJoin(event.getPlayer());
}
});
ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer()));
}
public void delayedJoin(Player player) {
private void delayedJoin(Player player) {
User u = ess.getUser(player);
if (u.isAuthorized("essentials.geoip.hide") || player.getAddress() == null) {
return;
@@ -114,8 +108,8 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
// detect and update the old config.yml. migrate from legacy GeoIP to GeoIP2.
if (!config.isSet("enable-locale")) {
config.set("database.download-url", "http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz");
config.set("database.download-url-city", "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz");
config.set("database.download-url", "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz");
config.set("database.download-url-city", "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz");
config.set("database.update.enable", true);
config.set("database.update.by-every-x-days", 30);
config.set("enable-locale", true);
@@ -187,7 +181,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
String filename;
TarInputStream tarInputStream = new TarInputStream(input);
TarEntry entry;
while ((entry = (TarEntry) tarInputStream.getNextEntry()) != null) {
while ((entry = tarInputStream.getNextEntry()) != null) {
if (!entry.isDirectory()) {
filename = entry.getName();
if (filename.substring(filename.length() - 5).equalsIgnoreCase(".mmdb")) {
@@ -207,7 +201,6 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
input.close();
} catch (MalformedURLException ex) {
logger.log(Level.SEVERE, tl("geoIpUrlInvalid"), ex);
return;
} catch (IOException ex) {
logger.log(Level.SEVERE, tl("connectionFailed"), ex);
}
+2 -2
View File
@@ -2,9 +2,9 @@ database:
show-cities: false
download-if-missing: true
# Url for country
download-url: "http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz"
download-url: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz"
# Url for cities
download-url-city: "http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"
download-url-city: "https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz"
update:
enable: true
by-every-x-days: 30
+1
View File
@@ -7,3 +7,4 @@ website: http://tiny.cc/EssentialsCommands
description: Shows the country or city of a user on login and /whois.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, kjiang]
depend: [Essentials]
api-version: 1.13
+1 -8
View File
@@ -6,18 +6,11 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXProtect</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXProtect-${full.version}</finalName>
</build>
@@ -14,7 +14,7 @@ import org.bukkit.event.server.PluginEnableEvent;
public class EmergencyListener implements Listener {
EssentialsProtect plugin;
private EssentialsProtect plugin;
EmergencyListener(final EssentialsProtect essProtPlugin) {
plugin = essProtPlugin;
@@ -10,14 +10,14 @@ import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsConnect {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
class EssentialsConnect {
private static final Logger logger = Logger.getLogger("EssentialsProtect");
private final IEssentials ess;
private final IProtect protect;
public EssentialsConnect(Plugin essPlugin, Plugin essProtect) {
EssentialsConnect(Plugin essPlugin, Plugin essProtect) {
if (!essProtect.getDescription().getVersion().equals(essPlugin.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
logger.log(Level.WARNING, tl("versionMismatchAll"));
}
ess = (IEssentials) essPlugin;
protect = (IProtect) essProtect;
@@ -26,7 +26,7 @@ public class EssentialsConnect {
ess.addReloadListener(pr);
}
public IEssentials getEssentials() {
IEssentials getEssentials() {
return ess;
}
@@ -1,5 +1,6 @@
package com.earth2me.essentials.protect;
import com.earth2me.essentials.metrics.Metrics;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@@ -11,15 +12,14 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
public class EssentialsProtect extends JavaPlugin implements IProtect {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<>(ProtectConfig.class);
private final Map<ProtectConfig, String> settingsString = new EnumMap<>(ProtectConfig.class);
private final Map<ProtectConfig, List<Material>> settingsList = new EnumMap<>(ProtectConfig.class);
private EssentialsConnect ess = null;
private transient Metrics metrics = null;
private final EmergencyListener emListener = new EmergencyListener(this);
@@ -33,10 +33,14 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
}
initialize(pm, essPlugin);
if (metrics == null) {
metrics = new Metrics(this);
}
}
private void initialize(final PluginManager pm, final Plugin essPlugin) {
LOGGER.log(Level.INFO, "Continuing to enable Protect.");
getLogger().log(Level.INFO, "Continuing to enable Protect.");
ess = new EssentialsConnect(essPlugin, this);
final EssentialsProtectBlockListener blockListener = new EssentialsProtectBlockListener(this);
@@ -55,14 +59,14 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
for (Player player : getServer().getOnlinePlayers()) {
player.sendMessage("Essentials Protect is in emergency mode. Check your log for errors.");
}
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essentials Protect is in emergency mode now.");
getLogger().log(Level.SEVERE, "Essentials not installed or failed to load. Essentials Protect is in emergency mode now.");
}
void disableEmergencyMode() {
final PluginManager pm = this.getServer().getPluginManager();
final Plugin essPlugin = pm.getPlugin("Essentials");
if (essPlugin == null || !essPlugin.isEnabled()) {
LOGGER.log(Level.SEVERE, "Tried to disable emergency mode, but Essentials still isn't enabled!");
getLogger().log(Level.SEVERE, "Tried to disable emergency mode, but Essentials still isn't enabled!");
return;
}
@@ -71,7 +75,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect {
for (Player player : getServer().getOnlinePlayers()) {
player.sendMessage("Essentials Protect is no longer in emergency mode.");
}
LOGGER.log(Level.SEVERE, "Essentials was loaded late! Essentials Protect is no longer in emergency mode.");
getLogger().log(Level.SEVERE, "Essentials was loaded late! Essentials Protect is no longer in emergency mode.");
initialize(pm, essPlugin);
}
@@ -1,7 +1,7 @@
package com.earth2me.essentials.protect;
import com.earth2me.essentials.utils.EnumUtil;
import net.ess3.api.IEssentials;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -22,11 +22,9 @@ public class EssentialsProtectBlockListener implements Listener {
private static final Set<Material> LAVA_TYPES = EnumUtil.getAllMatching(Material.class, "LAVA", "STATIONARY_LAVA");
final private IProtect prot;
final private IEssentials ess;
public EssentialsProtectBlockListener(final IProtect parent) {
EssentialsProtectBlockListener(final IProtect parent) {
this.prot = parent;
this.ess = prot.getEssentialsConnect().getEssentials();
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -20,7 +20,7 @@ public class EssentialsProtectEntityListener implements Listener {
private final IProtect prot;
private final IEssentials ess;
public EssentialsProtectEntityListener(final IProtect prot) {
EssentialsProtectEntityListener(final IProtect prot) {
this.prot = prot;
this.ess = prot.getEssentialsConnect().getEssentials();
}
@@ -159,7 +159,7 @@ public class EssentialsProtectEntityListener implements Listener {
} else if (entity instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)) {
event.setCancelled(true);
} else if ((entity instanceof Fireball || entity instanceof SmallFireball) && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) {
} else if (entity instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) {
event.setCancelled(true);
} else if ((entity instanceof WitherSkull) && prot.getSettingBool(ProtectConfig.prevent_witherskull_explosion)) {
@@ -180,7 +180,7 @@ public class EssentialsProtectEntityListener implements Listener {
return;
}
final String creatureName = creature.toString().toLowerCase(Locale.ENGLISH);
if (creatureName == null || creatureName.isEmpty()) {
if (creatureName.isEmpty()) {
return;
}
if (ess.getSettings().getProtectPreventSpawn(creatureName)) {
@@ -194,7 +194,7 @@ public class EssentialsProtectEntityListener implements Listener {
return;
}
final User user = ess.getUser((Player) event.getTarget());
if ((event.getReason() == TargetReason.CLOSEST_PLAYER || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET || event.getReason() == TargetReason.RANDOM_TARGET || event.getReason() == TargetReason.DEFEND_VILLAGE || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET) && prot.getSettingBool(ProtectConfig.prevent_entitytarget) && !user.isAuthorized("essentials.protect.entitytarget.bypass")) {
if ((event.getReason() == TargetReason.CLOSEST_PLAYER || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.TARGET_ATTACKED_NEARBY_ENTITY || event.getReason() == TargetReason.RANDOM_TARGET || event.getReason() == TargetReason.DEFEND_VILLAGE || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET) && prot.getSettingBool(ProtectConfig.prevent_entitytarget) && !user.isAuthorized("essentials.protect.entitytarget.bypass")) {
event.setCancelled(true);
}
}
@@ -11,7 +11,7 @@ import org.bukkit.event.weather.WeatherChangeEvent;
public class EssentialsProtectWeatherListener implements Listener {
private final IProtect prot;
public EssentialsProtectWeatherListener(final IProtect prot) {
EssentialsProtectWeatherListener(final IProtect prot) {
this.prot = prot;
}
@@ -49,19 +49,11 @@ public enum ProtectConfig {
private final boolean isList;
private final boolean isString;
private ProtectConfig(final String configName) {
this(configName, null, false, true, false);
}
private ProtectConfig(final String configName, final String defValueString) {
this(configName, defValueString, false, false, true);
}
private ProtectConfig(final String configName, final boolean defValueBoolean) {
ProtectConfig(final String configName, final boolean defValueBoolean) {
this(configName, null, defValueBoolean, false, false);
}
private ProtectConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) {
ProtectConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString) {
this.configName = configName;
this.defValueString = defValueString;
this.defValueBoolean = defValueBoolean;
+1 -1
View File
@@ -6,5 +6,5 @@ version: ${full.version}
website: http://tiny.cc/EssentialsCommands
description: Provides protection for various parts of the world.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
api-version: 1.13
softdepend: [Essentials]
api-version: 1.13
+33 -8
View File
@@ -6,20 +6,40 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXSpawn</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXSpawn-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>net.ess3:EssentialsXSpawn</includes>
</artifactSet>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>com.earth2me.essentials.paperlib</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
@@ -28,5 +48,10 @@
<artifactId>EssentialsX</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
@@ -13,7 +13,7 @@ public class Commandsetspawn extends EssentialsCommand {
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
public void run(final Server server, final User user, final String commandLabel, final String[] args) {
final String group = args.length > 0 ? getFinalArg(args, 0) : "default";
((SpawnStorage) module).setSpawn(user.getLocation(), group);
user.sendMessage(tl("spawnSet", group));
@@ -1,37 +1,32 @@
package com.earth2me.essentials.spawn;
import com.earth2me.essentials.metrics.Metrics;
import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn {
private static final Logger LOGGER = Bukkit.getLogger();
private transient IEssentials ess;
private transient SpawnStorage spawns;
private transient Metrics metrics = null;
@Override
public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
@@ -45,22 +40,18 @@ public class EssentialsSpawn extends JavaPlugin implements IEssentialsSpawn {
EventPriority respawnPriority = ess.getSettings().getRespawnPriority();
if (respawnPriority != null) {
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
}
}, this);
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, respawnPriority, (ll, event) ->
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event), this);
}
EventPriority joinPriority = ess.getSettings().getSpawnJoinPriority();
if (joinPriority != null) {
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
}
}, this);
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, joinPriority, (ll, event) ->
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event), this);
}
if (metrics == null) {
metrics = new Metrics(this);
}
}
@@ -6,8 +6,8 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextPager;
import io.papermc.lib.PaperLib;
import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@@ -23,18 +23,18 @@ import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsSpawnPlayerListener implements Listener {
private static final Logger LOGGER = Bukkit.getLogger();
class EssentialsSpawnPlayerListener implements Listener {
private static final Logger logger = Logger.getLogger("EssentialsSpawn");
private final transient IEssentials ess;
private final transient SpawnStorage spawns;
public EssentialsSpawnPlayerListener(final IEssentials ess, final SpawnStorage spawns) {
EssentialsSpawnPlayerListener(final IEssentials ess, final SpawnStorage spawns) {
super();
this.ess = ess;
this.spawns = spawns;
}
public void onPlayerRespawn(final PlayerRespawnEvent event) {
void onPlayerRespawn(final PlayerRespawnEvent event) {
final User user = ess.getUser(event.getPlayer());
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
@@ -60,33 +60,24 @@ public class EssentialsSpawnPlayerListener implements Listener {
}
}
public void onPlayerJoin(final PlayerJoinEvent event) {
ess.runTaskAsynchronously(new Runnable() {
@Override
public void run() {
delayedJoin(event.getPlayer());
}
});
void onPlayerJoin(final PlayerJoinEvent event) {
ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer()));
}
public void delayedJoin(final Player player) {
private void delayedJoin(final Player player) {
if (player.hasPlayedBefore()) {
LOGGER.log(Level.FINE, "Old player join");
logger.log(Level.FINE, "Old player join");
List<String> spawnOnJoinGroups = ess.getSettings().getSpawnOnJoinGroups();
if (!spawnOnJoinGroups.isEmpty()) {
final User user = ess.getUser(player);
if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) {
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
Location spawn = spawns.getSpawn(user.getGroup());
try {
// We don't use user.getTeleport() because it stores last location, which is unwanted in this case.
user.getBase().teleport(spawn, TeleportCause.PLUGIN);
} catch (Exception e) {
ess.showError(user.getSource(), e, "spawn-on-join");
}
ess.scheduleSyncDelayedTask(() -> {
Location spawn = spawns.getSpawn(user.getGroup());
try {
PaperLib.teleportAsync(user.getBase(), spawn, TeleportCause.PLUGIN);
} catch (Exception e) {
ess.showError(user.getSource(), e, "spawn-on-join");
}
});
}
@@ -101,35 +92,32 @@ public class EssentialsSpawnPlayerListener implements Listener {
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
}
ess.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
if (!user.getBase().isOnline()) {
return;
}
//This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg
if (ess.getSettings().getAnnounceNewPlayers()) {
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess);
final SimpleTextPager pager = new SimpleTextPager(output);
for (String line : pager.getLines()) {
ess.broadcastMessage(user, line);
}
}
final String kitName = ess.getSettings().getNewPlayerKit();
if (!kitName.isEmpty()) {
try {
final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess);
kit.expandItems(user);
} catch (Exception ex) {
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
LOGGER.log(Level.FINE, "New player join");
ess.scheduleSyncDelayedTask(() -> {
if (!user.getBase().isOnline()) {
return;
}
//This method allows for multiple line player announce messages using multiline yaml syntax #EasterEgg
if (ess.getSettings().getAnnounceNewPlayers()) {
final IText output = new KeywordReplacer(ess.getSettings().getAnnounceNewPlayerFormat(), user.getSource(), ess);
final SimpleTextPager pager = new SimpleTextPager(output);
for (String line : pager.getLines()) {
ess.broadcastMessage(user, line);
}
}
final String kitName = ess.getSettings().getNewPlayerKit();
if (!kitName.isEmpty()) {
try {
final Kit kit = new Kit(kitName.toLowerCase(Locale.ENGLISH), ess);
kit.expandItems(user);
} catch (Exception ex) {
logger.log(Level.WARNING, ex.getMessage());
}
}
logger.log(Level.FINE, "New player join");
}, 2L);
}
@@ -137,7 +125,7 @@ public class EssentialsSpawnPlayerListener implements Listener {
private class NewPlayerTeleport implements Runnable {
private final transient User user;
public NewPlayerTeleport(final User user) {
NewPlayerTeleport(final User user) {
this.user = user;
}
@@ -153,7 +141,7 @@ public class EssentialsSpawnPlayerListener implements Listener {
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);
}
} catch (Exception ex) {
Bukkit.getLogger().log(Level.WARNING, tl("teleportNewPlayerError"), ex);
logger.log(Level.WARNING, tl("teleportNewPlayerError"), ex);
}
}
}
@@ -14,7 +14,7 @@ public interface IEssentialsSpawn extends Plugin {
*
* @throws IllegalArgumentException If group is null
*/
public void setSpawn(Location loc, String group);
void setSpawn(Location loc, String group);
/**
* Gets the spawn location for a given group.
@@ -25,5 +25,5 @@ public interface IEssentialsSpawn extends Plugin {
*
* @throws IllegalArgumentException If group is null
*/
public Location getSpawn(String group);
Location getSpawn(String group);
}
@@ -14,7 +14,7 @@ import java.util.Map;
public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule {
public SpawnStorage(final IEssentials ess) {
SpawnStorage(final IEssentials ess) {
super(ess, Spawns.class);
reloadConfig();
}
@@ -25,18 +25,16 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
}
@Override
public void finishRead() {
}
public void finishRead() { }
@Override
public void finishWrite() {
}
public void finishWrite() { }
public void setSpawn(final Location loc, final String group) {
void setSpawn(final Location loc, final String group) {
acquireWriteLock();
try {
if (getData().getSpawns() == null) {
getData().setSpawns(new HashMap<String, Location>());
getData().setSpawns(new HashMap<>());
}
getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), loc);
} finally {
@@ -48,7 +46,7 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
}
}
public Location getSpawn(final String group) {
Location getSpawn(final String group) {
acquireReadLock();
try {
if (getData().getSpawns() == null || group == null) {
+3 -2
View File
@@ -7,13 +7,14 @@ website: http://tiny.cc/EssentialsCommands
description: Provides spawn control commands, utilizing Essentials.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
depend: [Essentials]
api-version: 1.13
commands:
setspawn:
description: Set the spawnpoint to your current position.
description: Sets the spawn point to your current position.
usage: /<command> <group>
aliases: [esetspawn]
spawn:
description: Teleport to the spawnpoint.
description: Teleports to the spawn point.
usage: /<command> [player]
aliases: [espawn]
permissions:
+22 -29
View File
@@ -6,17 +6,32 @@
<parent>
<groupId>net.ess3</groupId>
<artifactId>EssentialsXParent</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</parent>
<artifactId>EssentialsXXMPP</artifactId>
<licenses>
<license>
<name>GPLv3</name>
<url>http://www.gnu.org/copyleft/gpl.html</url>
</license>
</licenses>
<build>
<finalName>EssentialsXXMPP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
@@ -32,26 +47,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>EssentialsXXMPP-${full.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -1,6 +1,7 @@
package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.metrics.Metrics;
import net.ess3.api.IUser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -11,19 +12,18 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.earth2me.essentials.I18n.tl;
public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static EssentialsXMPP instance = null;
private transient UserManager users;
private transient XMPPManager xmpp;
private transient IEssentials ess;
private transient Metrics metrics = null;
public static IEssentialsXMPP getInstance() {
static IEssentialsXMPP getInstance() {
return instance;
}
@@ -34,7 +34,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP {
final PluginManager pluginManager = getServer().getPluginManager();
ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
getLogger().log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
@@ -49,6 +49,11 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP {
ess.addReloadListener(users);
ess.addReloadListener(xmpp);
if (metrics == null) {
metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("config-valid", () -> xmpp.isConfigValid() ? "yes" : "no"));
}
}
@Override
@@ -104,10 +109,8 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP {
return instance.xmpp.sendMessage(address, message);
}
// @Override
public static boolean updatePresence() {
static void updatePresence() {
instance.xmpp.updatePresence();
return true;
}
@Override
@@ -124,9 +127,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP {
sendMessage(address, message);
}
}
} catch (Exception ex) {
// Ignore exceptions
}
} catch (Exception ignored) {}
}
@Override
@@ -25,12 +25,7 @@ class EssentialsXMPPPlayerListener implements Listener {
public void onPlayerJoin(final PlayerJoinEvent event) {
final User user = ess.getUser(event.getPlayer());
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() {
@Override
public void run() {
EssentialsXMPP.updatePresence();
}
});
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, EssentialsXMPP::updatePresence);
sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game");
}
@@ -45,12 +40,7 @@ class EssentialsXMPPPlayerListener implements Listener {
public void onPlayerQuit(final PlayerQuitEvent event) {
final User user = ess.getUser(event.getPlayer());
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() {
@Override
public void run() {
EssentialsXMPP.updatePresence();
}
});
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, EssentialsXMPP::updatePresence);
sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game");
@@ -61,17 +51,9 @@ class EssentialsXMPPPlayerListener implements Listener {
List<String> users = EssentialsXMPP.getInstance().getSpyUsers();
synchronized (users) {
for (final String address : users) {
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable() {
@Override
public void run() {
EssentialsXMPP.getInstance().sendMessage(address, message);
}
});
Bukkit.getScheduler().scheduleSyncDelayedTask(ess, () -> EssentialsXMPP.getInstance().sendMessage(address, message));
}
}
} catch (Exception ex) {
// Ignore exceptions
}
} catch (Exception ignored) {}
}
}
@@ -9,48 +9,48 @@ import java.util.*;
public class UserManager implements IConf {
private final transient EssentialsConf users;
private final transient List<String> spyusers = Collections.synchronizedList(new ArrayList<String>());
private final transient List<String> spyusers = Collections.synchronizedList(new ArrayList<>());
private static final String ADDRESS = "address";
private static final String SPY = "spy";
public UserManager(final File folder) {
UserManager(final File folder) {
users = new EssentialsConf(new File(folder, "users.yml"));
reloadConfig();
}
public final boolean isSpy(final String username) {
final boolean isSpy(final String username) {
return users.getBoolean(username.toLowerCase(Locale.ENGLISH) + "." + SPY, false);
}
public void setSpy(final String username, final boolean spy) {
void setSpy(final String username, final boolean spy) {
setUser(username.toLowerCase(Locale.ENGLISH), getAddress(username), spy);
}
public final String getAddress(final String username) {
final String getAddress(final String username) {
return users.getString(username.toLowerCase(Locale.ENGLISH) + "." + ADDRESS, null);
}
public final String getUserByAddress(final String search) {
final String getUserByAddress(final String search) {
final Set<String> usernames = users.getKeys(false);
for (String username : usernames) {
final String address = users.getString(username + "." + ADDRESS, null);
if (address != null && search.equalsIgnoreCase(address)) {
if (search.equalsIgnoreCase(address)) {
return username;
}
}
return null;
}
public void setAddress(final String username, final String address) {
void setAddress(final String username, final String address) {
setUser(username.toLowerCase(Locale.ENGLISH), address, isSpy(username));
}
public List<String> getSpyUsers() {
List<String> getSpyUsers() {
return spyusers;
}
private void setUser(final String username, final String address, final boolean spy) {
final Map<String, Object> userdata = new HashMap<String, Object>();
final Map<String, Object> userdata = new HashMap<>();
userdata.put(ADDRESS, address);
userdata.put(SPY, spy);
users.setProperty(username, userdata);
@@ -18,13 +18,13 @@ import java.util.logging.*;
public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static final Logger logger = Logger.getLogger("EssentialsXMPP");
private static final SimpleFormatter formatter = new SimpleFormatter();
private final transient EssentialsConf config;
private transient XMPPConnection connection;
private transient ChatManager chatManager;
private final transient Map<String, Chat> chats = Collections.synchronizedMap(new HashMap<String, Chat>());
private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<LogRecord>());
private final transient Map<String, Chat> chats = Collections.synchronizedMap(new HashMap<>());
private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<>());
private final transient IEssentialsXMPP parent;
private transient List<String> logUsers;
private transient Level logLevel;
@@ -32,7 +32,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private transient Thread loggerThread;
private transient boolean threadrunning = true;
public XMPPManager(final IEssentialsXMPP parent) {
XMPPManager(final IEssentialsXMPP parent) {
super();
this.parent = parent;
config = new EssentialsConf(new File(parent.getDataFolder(), "config.yml"));
@@ -40,7 +40,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
reloadConfig();
}
public boolean sendMessage(final String address, final String message) {
boolean sendMessage(final String address, final String message) {
if (address != null && !address.isEmpty()) {
try {
startChat(address);
@@ -86,7 +86,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private boolean connect() {
final String server = config.getString("xmpp.server");
if (server == null || server.equals("example.com")) {
LOGGER.log(Level.WARNING, "config broken for xmpp");
logger.log(Level.WARNING, "config broken for xmpp");
return false;
}
final int port = config.getInt("xmpp.port", 5222);
@@ -94,10 +94,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
final String xmppuser = config.getString("xmpp.user");
final String password = config.getString("xmpp.password");
final ConnectionConfiguration connConf = new ConnectionConfiguration(server, port, serviceName);
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Connecting to xmpp server ").append(server).append(":").append(port);
stringBuilder.append(" as user ").append(xmppuser).append(".");
LOGGER.log(Level.INFO, stringBuilder.toString());
String stringBuilder = "Connecting to xmpp server " + server + ":" + port + " as user " + xmppuser + ".";
logger.log(Level.INFO, stringBuilder);
connConf.setSASLAuthenticationEnabled(config.getBoolean("xmpp.sasl-enabled", false));
connConf.setSendPresence(true);
connConf.setReconnectionAllowed(true);
@@ -114,12 +112,12 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
chatManager.addChatListener(this);
return true;
} catch (XMPPException ex) {
LOGGER.log(Level.WARNING, "Failed to connect to server: " + server, ex);
logger.log(Level.WARNING, "Failed to connect to server: " + server, ex);
return false;
}
}
public final void disconnect() {
final void disconnect() {
if (loggerThread != null) {
loggerThread.interrupt();
}
@@ -133,7 +131,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
}
public final void updatePresence() {
final void updatePresence() {
final int usercount;
final StringBuilder stringBuilder = new StringBuilder();
@@ -166,7 +164,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
@Override
public final void reloadConfig() {
LOGGER.removeHandler(this);
logger.removeHandler(this);
config.load();
synchronized (chats) {
disconnect();
@@ -177,7 +175,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
startLoggerThread();
}
if (config.getBoolean("log-enabled", false)) {
LOGGER.addHandler(this);
logger.addHandler(this);
logUsers = config.getStringList("log-users");
final String level = config.getString("log-level", "info");
try {
@@ -200,7 +198,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
logrecords.add(logRecord);
}
}
} catch (Exception e) {
} catch (Exception ignored) {
// Ignore all exceptions
// Otherwise we create a loop.
}
@@ -217,51 +215,48 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
}
private void startLoggerThread() {
loggerThread = new Thread(new Runnable() {
@Override
public void run() {
final Set<LogRecord> copy = new HashSet<LogRecord>();
final Set<String> failedUsers = new HashSet<String>();
while (threadrunning) {
synchronized (logrecords) {
if (!logrecords.isEmpty()) {
copy.addAll(logrecords);
logrecords.clear();
}
}
if (!copy.isEmpty()) {
for (String user : logUsers) {
try {
XMPPManager.this.startChat(user);
for (LogRecord logRecord : copy) {
final String message = formatter.format(logRecord);
if (!XMPPManager.this.sendMessage(user, FormatUtil.stripLogColorFormat(message))) {
failedUsers.add(user);
break;
}
}
} catch (XMPPException ex) {
failedUsers.add(user);
LOGGER.removeHandler(XMPPManager.this);
LOGGER.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex);
}
}
logUsers.removeAll(failedUsers);
if (logUsers.isEmpty()) {
LOGGER.removeHandler(XMPPManager.this);
threadrunning = false;
}
copy.clear();
}
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
threadrunning = false;
loggerThread = new Thread(() -> {
final Set<LogRecord> copy = new HashSet<>();
final Set<String> failedUsers = new HashSet<>();
while (threadrunning) {
synchronized (logrecords) {
if (!logrecords.isEmpty()) {
copy.addAll(logrecords);
logrecords.clear();
}
}
LOGGER.removeHandler(XMPPManager.this);
if (!copy.isEmpty()) {
for (String user : logUsers) {
try {
XMPPManager.this.startChat(user);
for (LogRecord logRecord : copy) {
final String message = formatter.format(logRecord);
if (!XMPPManager.this.sendMessage(user, FormatUtil.stripLogColorFormat(message))) {
failedUsers.add(user);
break;
}
}
} catch (XMPPException ex) {
failedUsers.add(user);
logger.removeHandler(XMPPManager.this);
logger.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex);
}
}
logUsers.removeAll(failedUsers);
if (logUsers.isEmpty()) {
logger.removeHandler(XMPPManager.this);
threadrunning = false;
}
copy.clear();
}
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
threadrunning = false;
}
}
logger.removeHandler(XMPPManager.this);
});
loggerThread.start();
}
@@ -290,7 +285,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
try {
chat.sendMessage("User " + parts[0] + " not found");
} catch (XMPPException ex) {
LOGGER.log(Level.WARNING, "Failed to send xmpp message.", ex);
logger.log(Level.WARNING, "Failed to send xmpp message.", ex);
}
} else {
final String from = "[" + parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
@@ -306,7 +301,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
try {
parent.getServer().dispatchCommand(Console.getInstance().getCommandSender(), message.substring(1));
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
@@ -318,4 +313,9 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
chats.remove(address);
}
}
public boolean isConfigValid() {
final String server = config.getString("xmpp.server");
return server != null && !server.equals("example.com");
}
}
+1 -3
View File
@@ -6,12 +6,10 @@ xmpp:
# port: 5222
# sasl-enabled: false
debug: false
op-users:
# - 'name@example.com'
debug: false
log-enabled: false
# Level is minimum level that should be send: info, warning, severe
log-level: warning
+6 -6
View File
@@ -4,17 +4,17 @@ main: com.earth2me.essentials.xmpp.EssentialsXMPP
# Note to developers: This next line cannot change, or the automatic versioning system will break.
version: ${full.version}
website: http://ess.khhq.net/wiki/XMPP
description: Provides xmpp communication.
authors:
- snowleo
description: Provides XMPP communication.
authors: [snowleo]
depend: [Essentials]
api-version: 1.13
commands:
setxmpp:
description: set your xmpp address
description: Sets your XMPP address.
usage: /<command> <address>
xmpp:
description: send a message to a player
description: Sends a message to a player.
usage: /<command> <player> <message>
xmppspy:
description: toggle xmpp spy for all messages
description: Toggles XMPP spy for all messages.
usage: /<command> <player>
+6 -1
View File
@@ -26,7 +26,7 @@ EssentialsX is almost a completely drop-in replacement for Essentials. However,
* **EssentialsX requires Java 8 or higher.** On older versions, the plugin may not work properly.
* **EssentialsX supports Minecraft versions 1.8.8, 1.9.4, 1.10.2, 1.11.2 and 1.12.2.** Support for 1.13.2 is coming soon.
* **EssentialsX supports Minecraft versions 1.8.8, 1.9.4, 1.10.2, 1.11.2, 1.12.2 and 1.13.2.**
Support
@@ -55,6 +55,11 @@ mvn clean install
Each module's jar can be found in `target/` inside each module's directory.
Using EssentialsX in your plugin
--------------------------------
Writing a plugin and want to support EssentialsX? We have a Maven repository at https://ci.ender.zone/plugin/repository/everything/, and the EssentialsX artifact is `net.ess3:EssentialsX:2.16.1`. More information at the [wiki](https://github.com/EssentialsX/Essentials/wiki/Common-Issues#how-do-i-add-essentialsx-as-a-dependency).
Contributing
------------
+28
View File
@@ -0,0 +1,28 @@
files:
- source: "/Essentials/src/messages.properties"
translation: "/Essentials/src/messages_%locale_with_underscore%.properties"
languages_mapping:
locale_with_underscore: # right side is xx[_YY] of messages_xx[_YY].properties, left is language code from https://support.crowdin.com/api/language-codes/
cs: cs
da: da
de: de
el: el
en-US: en
es-ES: es
fi: fi
fr: fr
hu: hu
it: it
ko: ko
nl: nl
"no": "no" # no is a YAML keyword
pl: pl
pt-PT: pt
ro: ro
ru: ru
sr: sr
sv-SE: sv
tr: tr
uk: uk
vi: vi
zh-CN: zh
-134
View File
@@ -1,134 +0,0 @@
default: Default
groups:
Default:
permissions:
- essentials.spawn
- essentials.rules
- essentials.motd
- essentials.list
- essentials.helpop
- essentials.help
groups: []
meta: []
Builder:
permissions:
- essentials.build
- essentials.afk
- essentials.back
- essentials.back.ondeath
- essentials.balance
- essentials.balance.others
- essentials.balancetop
- essentials.chat.color
- essentials.chat.shout
- essentials.chat.question
- essentials.compass
- essentials.depth
- essentials.home
- essentials.ignore
- essentials.kit
- essentials.kits.tools
- essentials.mail
- essentials.mail.send
- essentials.me
- essentials.msg
- essentials.nick
- essentials.pay
- essentials.ping
- essentials.powertool
- essentials.protect
- essentials.sethome
- essentials.signs.use.*
- essentials.signs.create.disposal
- essentials.signs.create.mail
- essentials.signs.create.protection
- essentials.signs.create.trade
- essentials.signs.break.disposal
- essentials.signs.break.mail
- essentials.signs.break.protection
- essentials.signs.break.trade
- essentials.suicide
- essentials.time
- essentials.tpa
- essentials.tpaccept
- essentials.tpahere
- essentials.tpdeny
- essentials.warp
- essentials.warp.list
- essentials.worth
groups:
- Default
meta:
priority: '20'
Moderator:
permissions:
- essentials.ban
- essentials.ban.notify
- essentials.banip
- essentials.broadcast
- essentials.clearinventory
- essentials.delwarp
- essentials.eco.loan
- essentials.ext
- essentials.getpos
- essentials.helpop.recieve
- essentials.home.others
- essentials.invsee
- essentials.jails
- essentials.jump
- essentials.kick
- essentials.kick.notify
- essentials.kits.*
- essentials.kill
- essentials.mute
- essentials.nick.others
- essentials.realname
- essentials.setwarp
- essentials.signs.create.*
- essentials.signs.break.*
- essentials.spawner
- essentials.thunder
- essentials.time
- essentials.time.set
- essentials.protect.alerts
- essentials.protect.admin
- essentials.protect.ownerinfo
- essentials.ptime
- essentials.ptime.others
- essentials.togglejail
- essentials.top
- essentials.tp
- essentials.tphere
- essentials.tppos
- essentials.tptoggle
- essentials.unban
- essentials.unbanip
- essentials.warps.*
- essentials.weather
- essentials.whois
- essentials.world
- essentials.worlds.*
groups:
- Builder
meta:
priority: '40'
Admin:
permissions:
# Since we use essentials.* permission here, we can still disable commands like this
# This can be done with any pemission nodes
- ^essentials.backup
- ^essentials.essentials
- ^essentials.setspawn
- ^essentials.reloadall
- essentials.*
groups:
- Moderator
meta:
priority: '80'
Owner:
permissions:
- essentials.*
groups:
- Admin
meta:
priority: '100'
-133
View File
@@ -1,133 +0,0 @@
users:
snowleo:
groups:
- Admin
groups:
Default:
permissions:
permissions.build: false
essentials.spawn: true
essentials.rules: true
essentials.motd: true
essentials.list: true
essentials.helpop: true
essentials.help: true
Builder:
permissions:
permissions.build: true
essentials.afk: true
essentials.back: true
essentials.back.ondeath: true
essentials.balance: true
essentials.balance.others: true
essentials.balancetop: true
essentials.chat.color: true
essentials.chat.shout: true
essentials.chat.question: true
essentials.compass: true
essentials.depth: true
essentials.home: true
essentials.ignore: true
essentials.kit: true
essentials.kits.tools: true
essentials.mail: true
essentials.mail.send: true
essentials.me: true
essentials.msg: true
essentials.nick: true
essentials.pay: true
essentials.ping: true
essentials.powertool: true
essentials.protect: true
essentials.sethome: true
essentials.signs.use.*: true
essentials.signs.create.disposal: true
essentials.signs.create.mail: true
essentials.signs.create.protection: true
essentials.signs.create.trade: true
essentials.signs.break.disposal: true
essentials.signs.break.mail: true
essentials.signs.break.protection: true
essentials.signs.break.trade: true
essentials.suicide: true
essentials.time: true
essentials.tpa: true
essentials.tpaccept: true
essentials.tpahere: true
essentials.tpdeny: true
essentials.warp: true
essentials.warp.list: true
essentials.worth: true
inheritance:
- Default
Moderator:
permissions:
essentials.ban: true
essentials.ban.notify: true
essentials.banip: true
essentials.broadcast: true
essentials.clearinventory: true
essentials.delwarp: true
essentials.eco.loan: true
essentials.ext: true
essentials.getpos: true
essentials.helpop.recieve: true
essentials.home.others: true
essentials.invsee: true
essentials.jails: true
essentials.jump: true
essentials.kick: true
essentials.kick.notify: true
essentials.kill: true
essentials.mute: true
essentials.nick.others: true
essentials.realname: true
essentials.setwarp: true
essentials.signs.create.*: true
essentials.signs.break.*: true
essentials.spawner: true
essentials.thunder: true
essentials.time: true
essentials.time.set: true
essentials.protect.alerts: true
essentials.protect.admin: true
essentials.protect.ownerinfo: true
essentials.ptime: true
essentials.ptime.others: true
essentials.togglejail: true
essentials.top: true
essentials.tp: true
essentials.tphere: true
essentials.tppos: true
essentials.tptoggle: true
essentials.unban: true
essentials.unbanip: true
essentials.weather: true
essentials.whois: true
essentials.world: true
essentials.worlds.*: true
inheritance:
- Builder
Admin:
permissions:
permissions.*: true
# Since we use essentials.* permission here, we can still disable commands like this
# This is only available for essentials permissions
-essentials.backup: true
-essentials.essentials: true
-essentials.setspawn: true
-essentials.reloadall: true
essentials.*: true
inheritance:
- Moderator
Owner:
permissions:
# Double negation
-essentials.backup: false
-essentials.essentials: false
-essentials.setspawn: false
-essentials.reloadall: false
inheritance:
- Admin
messages:
build: '&cYou do not have permission to build here.'
-150
View File
@@ -1,150 +0,0 @@
groups:
Default:
default: true
permissions:
- essentials.spawn
- essentials.rules
- essentials.motd
- essentials.list
- essentials.helpop
- essentials.help
- modifyworld.*
prefix: '&e'
options:
build: false
rank: '1000'
Builder:
permissions:
- essentials.afk
- essentials.back
- essentials.back.ondeath
- essentials.balance
- essentials.balance.others
- essentials.balancetop
- essentials.chat.color
- essentials.chat.shout
- essentials.chat.question
- essentials.compass
- essentials.depth
- essentials.home
- essentials.ignore
- essentials.kit
- essentials.kits.tools
- essentials.mail
- essentials.mail.send
- essentials.me
- essentials.msg
- essentials.nick
- essentials.pay
- essentials.ping
- essentials.powertool
- essentials.protect
- essentials.sethome
- essentials.signs.use.*
- essentials.signs.create.disposal
- essentials.signs.create.mail
- essentials.signs.create.protection
- essentials.signs.create.trade
- essentials.signs.break.disposal
- essentials.signs.break.mail
- essentials.signs.break.protection
- essentials.signs.break.trade
- essentials.suicide
- essentials.time
- essentials.tpa
- essentials.tpaccept
- essentials.tpahere
- essentials.tpdeny
- essentials.warp
- essentials.warp.list
- essentials.worth
inheritance:
- default
prefix: '&2'
options:
build: true
rank: '500'
Moderator:
permissions:
- essentials.ban
- essentials.ban.notify
- essentials.banip
- essentials.broadcast
- essentials.clearinventory
- essentials.delwarp
- essentials.eco.loan
- essentials.ext
- essentials.getpos
- essentials.helpop.recieve
- essentials.home.others
- essentials.invsee
- essentials.jails
- essentials.jump
- essentials.kick
- essentials.kick.notify
- essentials.kill
- essentials.mute
- essentials.nick.others
- essentials.realname
- essentials.setwarp
- essentials.signs.create.*
- essentials.signs.break.*
- essentials.spawner
- essentials.thunder
- essentials.time
- essentials.time.set
- essentials.protect.alerts
- essentials.protect.admin
- essentials.protect.ownerinfo
- essentials.ptime
- essentials.ptime.others
- essentials.togglejail
- essentials.top
- essentials.tp
- essentials.tphere
- essentials.tppos
- essentials.tptoggle
- essentials.unban
- essentials.unbanip
- essentials.weather
- essentials.whois
- essentials.world
- essentials.worlds.*
- permissions.user.promote.default
- permissions.user.demote.default
- permissions.manage.membership
inheritance:
- builder
prefix: '&5'
options:
build: true
rank: '200'
Admin:
permissions:
- -essentials.backup
- -essentials.essentials
- -essentials.setspawn
- -essentials.reloadall
- essentials.*
- permissions.manage.users
- permissions.manage.users.permissions
- permissions.manage.users.permissions.timed
inheritance:
- moderator
prefix: '&c'
options:
build: true
rank: '100'
Owner:
permissions:
- '*'
inheritance:
- admin
prefix: '&4'
options:
build: true
rank: '0'
users:
snowleo:
group:
- Builder
-1
View File
@@ -1 +0,0 @@
Put a 1.8 Spigot/CraftBukkit JAR with filename `craftbukkit-1.8-R0.1-SNAPSHOT.jar` in `lib/org/bukkit/craftbukkit/1.8-R0.1-SNAPSHOT`.
+2 -10
View File
@@ -5,21 +5,13 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.16.0</version>
<version>2.16.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>1_8_R1Provider</artifactId>
<repositories>
<repository>
<id>project.local</id>
<name>local repo</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
@@ -30,7 +22,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
</dependencies>
</project>
-1
View File
@@ -1 +0,0 @@
Put a 1.8.3 Spigot/CraftBukkit JAR with filename `craftbukkit-1.8.3-R0.1-SNAPSHOT.jar` in `lib/org/bukkit/craftbukkit/1.8.3-R0.1-SNAPSHOT`.
+2 -10
View File
@@ -5,21 +5,13 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.16.0</version>
<version>2.16.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>1_8_R2Provider</artifactId>
<repositories>
<repository>
<id>project.local</id>
<name>local repo</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
@@ -30,7 +22,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
</dependencies>
</project>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.16.0</version>
<version>2.16.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -16,7 +16,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
</dependencies>
</project>
+2 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>EssentialsXParent</artifactId>
<groupId>net.ess3</groupId>
<version>2.16.0</version>
<version>2.16.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -16,7 +16,7 @@
<dependency>
<groupId>net.ess3</groupId>
<artifactId>NMSProvider</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
</dependencies>
</project>
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more