mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-10 10:28:22 +01:00
Merge branch '2.x' into l10n_2.x
This commit is contained in:
commit
cff2d94c6c
20
.github/workflows/build-master.yml
vendored
20
.github/workflows/build-master.yml
vendored
@ -16,26 +16,32 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Git repo
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
uses: gradle/gradle-build-action@v3
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --stacktrace
|
||||
|
||||
- name: Publish JUnit report
|
||||
uses: mikepenz/action-junit-report@v4
|
||||
if: success() || failure() # Run even if the previous step fails
|
||||
with:
|
||||
report_paths: '**/build/test-results/test*/TEST-*.xml'
|
||||
|
||||
- name: Archive plugin jars on GitHub
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: EssentialsX plugin jars
|
||||
path: jars/
|
||||
@ -61,7 +67,7 @@ jobs:
|
||||
cp -r EssentialsXMPP/build/docs/javadoc/ javadocs/EssentialsXMPP/
|
||||
|
||||
- name: Archive Javadocs
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: javadocs
|
||||
path: javadocs/
|
||||
@ -74,12 +80,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Download Javadocs
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: javadocs
|
||||
path: javadocs/
|
||||
|
14
.github/workflows/build-pr.yml
vendored
14
.github/workflows/build-pr.yml
vendored
@ -18,26 +18,32 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Git repo
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
uses: gradle/gradle-build-action@v3
|
||||
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --stacktrace
|
||||
|
||||
- name: Publish JUnit report
|
||||
uses: mikepenz/action-junit-report@v4
|
||||
if: success() || failure() # Run even if the previous step fails
|
||||
with:
|
||||
report_paths: '**/build/test-results/test*/TEST-*.xml'
|
||||
|
||||
- name: Archive plugin jars on GitHub
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: EssentialsX plugin jars
|
||||
path: jars/
|
||||
|
@ -59,7 +59,9 @@ import net.ess3.nms.refl.providers.ReflServerStateProvider;
|
||||
import net.ess3.nms.refl.providers.ReflSpawnEggProvider;
|
||||
import net.ess3.nms.refl.providers.ReflSpawnerBlockProvider;
|
||||
import net.ess3.nms.refl.providers.ReflSyncCommandsProvider;
|
||||
import net.ess3.provider.BiomeKeyProvider;
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import net.ess3.provider.DamageEventProvider;
|
||||
import net.ess3.provider.FormattedCommandAliasProvider;
|
||||
import net.ess3.provider.ItemUnbreakableProvider;
|
||||
import net.ess3.provider.KnownCommandsProvider;
|
||||
@ -83,15 +85,18 @@ import net.ess3.provider.providers.BukkitMaterialTagProvider;
|
||||
import net.ess3.provider.providers.BukkitSpawnerBlockProvider;
|
||||
import net.ess3.provider.providers.FixedHeightWorldInfoProvider;
|
||||
import net.ess3.provider.providers.FlatSpawnEggProvider;
|
||||
import net.ess3.provider.providers.LegacyDamageEventProvider;
|
||||
import net.ess3.provider.providers.LegacyItemUnbreakableProvider;
|
||||
import net.ess3.provider.providers.LegacyPlayerLocaleProvider;
|
||||
import net.ess3.provider.providers.LegacyPotionMetaProvider;
|
||||
import net.ess3.provider.providers.LegacySpawnEggProvider;
|
||||
import net.ess3.provider.providers.ModernDamageEventProvider;
|
||||
import net.ess3.provider.providers.ModernDataWorldInfoProvider;
|
||||
import net.ess3.provider.providers.ModernItemUnbreakableProvider;
|
||||
import net.ess3.provider.providers.ModernPersistentDataProvider;
|
||||
import net.ess3.provider.providers.ModernPlayerLocaleProvider;
|
||||
import net.ess3.provider.providers.ModernSignDataProvider;
|
||||
import net.ess3.provider.providers.PaperBiomeKeyProvider;
|
||||
import net.ess3.provider.providers.PaperContainerProvider;
|
||||
import net.ess3.provider.providers.PaperKnownCommandsProvider;
|
||||
import net.ess3.provider.providers.PaperMaterialTagProvider;
|
||||
@ -193,6 +198,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
private transient WorldInfoProvider worldInfoProvider;
|
||||
private transient PlayerLocaleProvider playerLocaleProvider;
|
||||
private transient SignDataProvider signDataProvider;
|
||||
private transient DamageEventProvider damageEventProvider;
|
||||
private transient BiomeKeyProvider biomeKeyProvider;
|
||||
private transient Kits kits;
|
||||
private transient RandomTeleport randomTeleport;
|
||||
private transient UpdateChecker updateChecker;
|
||||
@ -475,6 +482,16 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
playerLocaleProvider = new LegacyPlayerLocaleProvider();
|
||||
}
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_4_R01)) {
|
||||
damageEventProvider = new ModernDamageEventProvider();
|
||||
} else {
|
||||
damageEventProvider = new LegacyDamageEventProvider();
|
||||
}
|
||||
|
||||
if (PaperLib.isPaper() && VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_19_4_R01)) {
|
||||
biomeKeyProvider = new PaperBiomeKeyProvider();
|
||||
}
|
||||
|
||||
execTimer.mark("Init(Providers)");
|
||||
reload();
|
||||
|
||||
@ -625,6 +642,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
public void reload() {
|
||||
Trade.closeLog();
|
||||
|
||||
if (bukkitAudience != null) {
|
||||
bukkitAudience.close();
|
||||
bukkitAudience = null;
|
||||
}
|
||||
|
||||
for (final IConf iConf : confList) {
|
||||
iConf.reloadConfig();
|
||||
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
|
||||
@ -642,6 +664,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
registerListeners(pm);
|
||||
|
||||
AdventureUtil.setEss(this);
|
||||
bukkitAudience = BukkitAudiences.create(this);
|
||||
}
|
||||
|
||||
@ -863,7 +886,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
sender.sendMessage(command.getUsage().replace("<command>", commandLabel));
|
||||
}
|
||||
if (!ex.getMessage().isEmpty()) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
sender.sendComponent(AdventureUtil.miniMessage().deserialize(ex.getMessage()));
|
||||
}
|
||||
if (ex.getCause() != null && settings.isDebug()) {
|
||||
ex.getCause().printStackTrace();
|
||||
@ -904,7 +927,8 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
@Override
|
||||
public void showError(final CommandSource sender, final Throwable exception, final String commandLabel) {
|
||||
if (exception instanceof TranslatableException) {
|
||||
sender.sendTl(((TranslatableException) exception).getTlKey(), ((TranslatableException) exception).getArgs());
|
||||
final String tlMessage = sender.tl(((TranslatableException) exception).getTlKey(), ((TranslatableException) exception).getArgs());
|
||||
sender.sendTl("errorWithMessage", AdventureUtil.parsed(tlMessage));
|
||||
} else {
|
||||
sender.sendTl("errorWithMessage", exception.getMessage());
|
||||
}
|
||||
@ -1404,6 +1428,16 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
return playerLocaleProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageEventProvider getDamageEventProvider() {
|
||||
return damageEventProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeKeyProvider getBiomeKeyProvider() {
|
||||
return biomeKeyProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignDataProvider getSignDataProvider() {
|
||||
return signDataProvider;
|
||||
|
@ -455,7 +455,7 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
user.getBase().setAllowFlight(true);
|
||||
user.getBase().setFlying(true);
|
||||
if (ess.getSettings().isSendFlyEnableOnJoin()) {
|
||||
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), true), CommonPlaceholders.displayName(user));
|
||||
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), true), user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -642,11 +642,10 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
if (!user.isAuthorized("essentials.chat.spy.exempt")) {
|
||||
for (final User spyer : ess.getOnlineUsers()) {
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(spyer.getBase())) {
|
||||
if (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers()) {
|
||||
spyer.sendMessage(spyer.playerTl("socialSpyMutedPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
} else {
|
||||
spyer.sendMessage(spyer.playerTl("socialSpyPrefix") + player.getDisplayName() + ": " + event.getMessage());
|
||||
}
|
||||
final Component base = (user.isMuted() && ess.getSettings().getSocialSpyListenMutedPlayers())
|
||||
? spyer.tlComponent("socialSpyMutedPrefix")
|
||||
: spyer.tlComponent("socialSpyPrefix");
|
||||
spyer.sendComponent(base.append(AdventureUtil.legacyToAdventure(player.getDisplayName())).append(Component.text(": " + event.getMessage())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,8 +182,10 @@ public class I18n implements net.ess3.api.II18n {
|
||||
}
|
||||
|
||||
final Object[] processedArgs = mutateArgs(objects, arg -> {
|
||||
final String str = arg instanceof AdventureUtil.ParsedPlaceholder ? arg.toString() : AdventureUtil.miniMessage().escapeTags(arg.toString());
|
||||
return AdventureUtil.legacyToMini(str);
|
||||
if (arg instanceof AdventureUtil.ParsedPlaceholder) {
|
||||
return arg.toString();
|
||||
}
|
||||
return AdventureUtil.legacyToMini(AdventureUtil.miniMessage().escapeTags(arg.toString()));
|
||||
});
|
||||
|
||||
return messageFormat.format(processedArgs).replace(' ', ' '); // replace nbsp with a space
|
||||
|
@ -9,7 +9,9 @@ import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.updatecheck.UpdateChecker;
|
||||
import com.earth2me.essentials.userstorage.IUserMap;
|
||||
import net.ess3.nms.refl.providers.ReflOnlineModeProvider;
|
||||
import net.ess3.provider.BiomeKeyProvider;
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import net.ess3.provider.DamageEventProvider;
|
||||
import net.ess3.provider.FormattedCommandAliasProvider;
|
||||
import net.ess3.provider.ItemUnbreakableProvider;
|
||||
import net.ess3.provider.KnownCommandsProvider;
|
||||
@ -183,5 +185,9 @@ public interface IEssentials extends Plugin {
|
||||
|
||||
PlayerLocaleProvider getPlayerLocaleProvider();
|
||||
|
||||
DamageEventProvider getDamageEventProvider();
|
||||
|
||||
BiomeKeyProvider getBiomeKeyProvider();
|
||||
|
||||
PluginCommand getPluginCommand(String cmd);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -31,4 +32,11 @@ public class PlayerExtension {
|
||||
public Location getLocation() {
|
||||
return base.getLocation();
|
||||
}
|
||||
|
||||
public OfflinePlayer getOffline() {
|
||||
if (base instanceof OfflinePlayerStub) {
|
||||
return ((OfflinePlayerStub) base).base;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,12 @@ import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import net.ess3.provider.BiomeKeyProvider;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
@ -76,14 +75,10 @@ public class RandomTeleport implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public Set<Biome> getExcludedBiomes() {
|
||||
final List<String> biomeNames = config.getList("excluded-biomes", String.class);
|
||||
final Set<Biome> excludedBiomes = new HashSet<>();
|
||||
for (final String biomeName : biomeNames) {
|
||||
try {
|
||||
excludedBiomes.add(Biome.valueOf(biomeName.toUpperCase()));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
}
|
||||
public Set<String> getExcludedBiomes() {
|
||||
final Set<String> excludedBiomes = new HashSet<>();
|
||||
for (final String key : config.getList("excluded-biomes", String.class)) {
|
||||
excludedBiomes.add(key.toLowerCase());
|
||||
}
|
||||
return excludedBiomes;
|
||||
}
|
||||
@ -204,7 +199,31 @@ public class RandomTeleport implements IConf {
|
||||
}
|
||||
|
||||
private boolean isValidRandomLocation(final Location location) {
|
||||
return location.getBlockY() > ess.getWorldInfoProvider().getMinHeight(location.getWorld()) && !this.getExcludedBiomes().contains(location.getBlock().getBiome());
|
||||
return location.getBlockY() > ess.getWorldInfoProvider().getMinHeight(location.getWorld()) && !isExcludedBiome(location);
|
||||
}
|
||||
|
||||
// Exclude biome if enum or namespaced key matches
|
||||
private boolean isExcludedBiome(final Location location) {
|
||||
final Set<String> excluded = getExcludedBiomes();
|
||||
final String enumKey = location.getBlock().getBiome().name().toLowerCase();
|
||||
// Try with good old bukkit enum
|
||||
if (excluded.contains(enumKey)) {
|
||||
return true;
|
||||
}
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_14_4_R01)) {
|
||||
// No way to get the biome key on versions below this
|
||||
return false;
|
||||
}
|
||||
final String biomeKey;
|
||||
final BiomeKeyProvider biomeKeyProvider = ess.getBiomeKeyProvider();
|
||||
if (biomeKeyProvider != null) {
|
||||
// Works with custom biome keys
|
||||
biomeKey = biomeKeyProvider.getBiomeKey(location.getBlock()).toString();
|
||||
} else {
|
||||
// Custom biome keys resolve as "minecraft:custom" which is unfortunate
|
||||
biomeKey = location.getBlock().getBiome().getKey().toString();
|
||||
}
|
||||
return excluded.contains(biomeKey);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
|
@ -53,6 +53,8 @@ import static com.earth2me.essentials.I18n.tlLiteral;
|
||||
public class Settings implements net.ess3.api.ISettings {
|
||||
private static final BigDecimal DEFAULT_MAX_MONEY = new BigDecimal("10000000000000");
|
||||
private static final BigDecimal DEFAULT_MIN_MONEY = new BigDecimal("-10000000000000");
|
||||
private static final Tag DEFAULT_PRIMARY_COLOR = Tag.styling(NamedTextColor.GOLD);
|
||||
private static final Tag DEFAULT_SECONDARY_COLOR = Tag.styling(NamedTextColor.RED);
|
||||
private final transient EssentialsConfiguration config;
|
||||
private final transient IEssentials ess;
|
||||
private final transient AtomicInteger reloadCount = new AtomicInteger(0);
|
||||
@ -141,8 +143,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private double maxProjectileSpeed;
|
||||
private boolean removeEffectsOnHeal;
|
||||
private Map<String, String> worldAliases;
|
||||
private Tag primaryColor = Tag.styling(NamedTextColor.GOLD);
|
||||
private Tag secondaryColor = Tag.styling(NamedTextColor.RED);
|
||||
private Tag primaryColor = DEFAULT_PRIMARY_COLOR;
|
||||
private Tag secondaryColor = DEFAULT_SECONDARY_COLOR;
|
||||
|
||||
public Settings(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
@ -1970,7 +1972,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
|
||||
private Tag _getPrimaryColor() {
|
||||
final String color = config.getString("message-colors.primary", "#ffaa00");
|
||||
return Tag.styling(_getTagColor(color, NamedTextColor.GOLD));
|
||||
final TextColor textColor = _getTagColor(color);
|
||||
return textColor != null ? Tag.styling(textColor) : DEFAULT_PRIMARY_COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1980,24 +1983,23 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
|
||||
private Tag _getSecondaryColor() {
|
||||
final String color = config.getString("message-colors.secondary", "#ff5555");
|
||||
return Tag.styling(_getTagColor(color, NamedTextColor.RED));
|
||||
final TextColor textColor = _getTagColor(color);
|
||||
return textColor != null ? Tag.styling(textColor) : DEFAULT_SECONDARY_COLOR;
|
||||
}
|
||||
|
||||
private TextColor _getTagColor(final String color, final TextColor def) {
|
||||
private TextColor _getTagColor(final String color) {
|
||||
try {
|
||||
if (color.startsWith("#") && color.length() == 7 && NumberUtil.isNumeric(color.substring(1))) {
|
||||
if (color.startsWith("#") && color.length() == 7 && NumberUtil.isHexadecimal(color.substring(1))) {
|
||||
return TextColor.color(Color.fromRGB(Integer.decode(color)).asRGB());
|
||||
}
|
||||
|
||||
if (color.length() == 1) {
|
||||
final NamedTextColor named = AdventureUtil.fromChar(color.charAt(0));
|
||||
return named != null ? named : def;
|
||||
return AdventureUtil.fromChar(color.charAt(0));
|
||||
}
|
||||
|
||||
final NamedTextColor named = NamedTextColor.NAMES.value(color.toLowerCase(Locale.ENGLISH));
|
||||
return named != null ? named : def;
|
||||
return NamedTextColor.NAMES.value(color.toLowerCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
return def;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.messaging.SimpleMessageRecipient;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
@ -16,8 +15,8 @@ import com.earth2me.essentials.utils.TriState;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import net.ess3.api.events.JailStatusChangeEvent;
|
||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||
@ -227,7 +226,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
cooldownTime.add(Calendar.SECOND, (int) cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int) ((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass")) {
|
||||
throw new Exception(playerTl("timeBeforeHeal", DateUtil.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
throw new TranslatableException("timeBeforeHeal", DateUtil.formatDateDiff(cooldownTime.getTimeInMillis()));
|
||||
}
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
@ -250,7 +249,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
setMoney(getMoney().add(value), cause);
|
||||
sendTl("addedToAccount", NumberUtil.displayCurrency(value, ess));
|
||||
if (initiator != null) {
|
||||
initiator.sendTl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this), NumberUtil.displayCurrency(getMoney(), ess));
|
||||
initiator.sendTl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,8 +266,8 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
if (canAfford(value)) {
|
||||
setMoney(getMoney().subtract(value), cause);
|
||||
reciever.setMoney(reciever.getMoney().add(value), cause);
|
||||
sendTl("moneySentTo", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) reciever));
|
||||
reciever.sendTl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this));
|
||||
sendTl("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName());
|
||||
reciever.sendTl("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName());
|
||||
final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value);
|
||||
ess.getServer().getPluginManager().callEvent(transactionEvent);
|
||||
} else {
|
||||
@ -297,7 +296,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
sendTl("takenFromAccount", NumberUtil.displayCurrency(value, ess));
|
||||
if (initiator != null) {
|
||||
initiator.sendTl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), CommonPlaceholders.displayName((IUser) this), NumberUtil.displayCurrency(getMoney(), ess));
|
||||
initiator.sendTl("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess));
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,7 +408,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
teleportRequestQueue.remove(playerUsername);
|
||||
if (inform) {
|
||||
sendTl("requestTimedOutFrom", CommonPlaceholders.displayName((IUser) ess.getUser(request.getRequesterUuid())));
|
||||
sendTl("requestTimedOutFrom", ess.getUser(request.getRequesterUuid()).getDisplayName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -443,7 +442,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
} else {
|
||||
if (inform) {
|
||||
sendTl("requestTimedOutFrom", CommonPlaceholders.displayName((IUser) ess.getUser(request.getRequesterUuid())));
|
||||
sendTl("requestTimedOutFrom", ess.getUser(request.getRequesterUuid()).getDisplayName());
|
||||
}
|
||||
teleportRequestQueue.remove(key);
|
||||
}
|
||||
@ -806,9 +805,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
if (broadcast && !isHidden() && !isAfk()) {
|
||||
setDisplayNick();
|
||||
if (ess.getSettings().broadcastAfkMessage()) {
|
||||
ess.broadcastTl(this, u -> u == this, "userIsNotAway", CommonPlaceholders.displayName((IUser) this));
|
||||
ess.broadcastTl(this, u -> u == this, "userIsNotAway", getDisplayName());
|
||||
}
|
||||
sendTl("userIsNotAwaySelf", CommonPlaceholders.displayName((IUser) this));
|
||||
sendTl("userIsNotAwaySelf", getDisplayName());
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
@ -834,7 +833,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
|
||||
public void checkActivity() {
|
||||
// Graceful time before the first afk check call.
|
||||
// Graceful time before the first afk check call.
|
||||
if (System.currentTimeMillis() - lastActivity <= 10000) {
|
||||
return;
|
||||
}
|
||||
@ -847,7 +846,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
lastActivity = 0;
|
||||
final double kickTime = autoafkkick / 60.0;
|
||||
|
||||
this.getBase().kickPlayer(playerTl("autoAfkKickReason", kickTime));
|
||||
this.getBase().kickPlayer(AdventureUtil.miniToLegacy(playerTl("autoAfkKickReason", kickTime)));
|
||||
|
||||
for (final User user : ess.getOnlineUsers()) {
|
||||
if (user.isAuthorized("essentials.kick.notify")) {
|
||||
@ -861,9 +860,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
if (isAfk() && !isHidden()) {
|
||||
setDisplayNick();
|
||||
if (ess.getSettings().broadcastAfkMessage()) {
|
||||
ess.broadcastTl(this, u -> u == this, "userIsAway", CommonPlaceholders.displayName((IUser) this));
|
||||
ess.broadcastTl(this, u -> u == this, "userIsAway", getDisplayName());
|
||||
}
|
||||
sendTl("userIsAwaySelf", CommonPlaceholders.displayName((IUser) this));
|
||||
sendTl("userIsAwaySelf", getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
@ -97,10 +95,10 @@ public class Commandafk extends EssentialsCommand {
|
||||
}
|
||||
if (!tlKey.isEmpty() && ess.getSettings().broadcastAfkMessage()) {
|
||||
// exclude user from receiving general AFK announcement in favor of personal message
|
||||
ess.broadcastTl(user, u -> u == user, tlKey, CommonPlaceholders.displayName((IUser) user), message);
|
||||
ess.broadcastTl(user, u -> u == user, tlKey, user.getDisplayName(), message);
|
||||
}
|
||||
if (!selfTlKey.isEmpty()) {
|
||||
user.sendTl(selfTlKey, CommonPlaceholders.displayName((IUser) user), message);
|
||||
user.sendTl(selfTlKey, user.getDisplayName(), message);
|
||||
}
|
||||
user.setDisplayNick(); // Set this again after toggling
|
||||
}
|
||||
|
@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -22,14 +20,14 @@ public class Commandbalance extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final User target = getPlayer(server, args, 0, false, true);
|
||||
sender.sendTl("balanceOther", target.isHidden() ? target.getName() : CommonPlaceholders.displayName((IUser) target), NumberUtil.displayCurrency(target.getMoney(), ess));
|
||||
sender.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 1 && user.isAuthorized("essentials.balance.others")) {
|
||||
final User target = getPlayer(server, args, 0, true, true);
|
||||
user.sendTl("balanceOther", target.isHidden() ? target.getName() : CommonPlaceholders.displayName((IUser) target), NumberUtil.displayCurrency(target.getMoney(), ess));
|
||||
user.sendTl("balanceOther", target.isHidden() ? target.getName() : target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess));
|
||||
} else if (args.length < 2) {
|
||||
user.sendTl("balance", NumberUtil.displayCurrency(user.getMoney(), ess));
|
||||
} else {
|
||||
|
@ -55,7 +55,7 @@ public class Commandban extends EssentialsCommand {
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
|
||||
user.getBase().kickPlayer(banDisplay);
|
||||
user.getBase().kickPlayer(AdventureUtil.miniToLegacy(banDisplay));
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerBanned", senderDisplayName, user.getName(), banDisplay)));
|
||||
|
||||
if (nomatch) {
|
||||
|
@ -52,7 +52,7 @@ public class Commandbanip extends EssentialsCommand {
|
||||
banReason = tlLiteral("defaultBanReason");
|
||||
}
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
final String banDisplay = AdventureUtil.miniToLegacy(tlLiteral("banFormat", banReason, senderDisplayName));
|
||||
|
||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, null, senderName);
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerBanIpAddress", senderDisplayName, ipAddress, banReason)));
|
||||
|
@ -19,13 +19,13 @@ public class Commandbroadcastworld extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
World world = user.getWorld();
|
||||
String message = getFinalArg(args, 0);
|
||||
if (args.length > 1 && ess.getSettings().isAllowWorldInBroadcastworld()) {
|
||||
if (ess.getSettings().isAllowWorldInBroadcastworld()) {
|
||||
final World argWorld = ess.getWorld(args[0]);
|
||||
if (argWorld != null) {
|
||||
world = argWorld;
|
||||
@ -39,7 +39,7 @@ public class Commandbroadcastworld extends EssentialsCommand {
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new NotEnoughArgumentsException("world");
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final World world = ess.getWorld(args[0]);
|
||||
@ -53,7 +53,7 @@ public class Commandbroadcastworld extends EssentialsCommand {
|
||||
if (message.isEmpty()) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.broadcastTl(null, u -> u.getBase().getWorld().equals(world), true, "broadcast", message, AdventureUtil.parsed(AdventureUtil.legacyToMini(name)));
|
||||
ess.broadcastTl(null, u -> !u.getBase().getWorld().equals(world), true, "broadcast", message, AdventureUtil.parsed(AdventureUtil.legacyToMini(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -22,7 +20,7 @@ public class Commandburn extends EssentialsCommand {
|
||||
|
||||
final User user = getPlayer(server, sender, args, 0);
|
||||
user.getBase().setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
sender.sendTl("burnMsg", CommonPlaceholders.displayName((IUser) user), Integer.parseInt(args[1]));
|
||||
sender.sendTl("burnMsg", user.getDisplayName(), Integer.parseInt(args[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,10 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
@ -67,7 +65,7 @@ public class Commandeco extends EssentialsLoopCommand {
|
||||
final boolean aboveMax = userAmount.compareTo(maxBal) > 0;
|
||||
player.setMoney(underMin ? minBal : aboveMax ? maxBal : userAmount, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
player.sendTl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess));
|
||||
sender.sendTl("setBalOthers", CommonPlaceholders.displayName((IUser) player), NumberUtil.displayCurrency(player.getMoney(), ess));
|
||||
sender.sendTl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.earth2me.essentials.economy.EconomyLayers;
|
||||
import com.earth2me.essentials.userstorage.ModernUserMap;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommandMapUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.FloatUtil;
|
||||
@ -22,7 +21,6 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonNull;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -485,7 +483,7 @@ public class Commandessentials extends EssentialsCommand {
|
||||
}
|
||||
final User user = getPlayer(server, args, 1, true, true);
|
||||
user.reset();
|
||||
sender.sendMessage("Reset Essentials userdata for player: " + CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
|
||||
}
|
||||
|
||||
// Toggles debug mode.
|
||||
|
@ -4,8 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
@ -99,7 +97,7 @@ public class Commandexp extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
private void showExp(final CommandSource sender, final IUser target) {
|
||||
sender.sendTl("exp", CommonPlaceholders.displayNameRecipient((IMessageRecipient) target), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase()));
|
||||
sender.sendTl("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target.getBase()), target.getBase().getLevel(), SetExpFix.getExpUntilNextLevel(target.getBase()));
|
||||
}
|
||||
|
||||
//TODO: Limit who can give negative exp?
|
||||
@ -131,7 +129,7 @@ public class Commandexp extends EssentialsLoopCommand {
|
||||
amount = 0L;
|
||||
}
|
||||
SetExpFix.setTotalExperience(target.getBase(), (int) amount);
|
||||
sender.sendTl("expSet", CommonPlaceholders.displayNameRecipient((IMessageRecipient) target), amount);
|
||||
sender.sendTl("expSet", target.getDisplayName(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -38,7 +36,7 @@ public class Commandext extends EssentialsLoopCommand {
|
||||
@Override
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) {
|
||||
extPlayer(player.getBase());
|
||||
sender.sendTl("extinguishOthers", CommonPlaceholders.displayName((IUser) player));
|
||||
sender.sendTl("extinguishOthers", player.getDisplayName());
|
||||
}
|
||||
|
||||
private void extPlayer(final Player player) {
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
@ -44,7 +42,7 @@ public class Commandfeed extends EssentialsLoopCommand {
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
|
||||
try {
|
||||
feedPlayer(player.getBase());
|
||||
sender.sendTl("feedOther", CommonPlaceholders.displayName((IUser) player));
|
||||
sender.sendTl("feedOther", player.getDisplayName());
|
||||
} catch (final QuietAbortException e) {
|
||||
//Handle Quietly
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.events.FlyStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@ -39,9 +38,9 @@ public class Commandfly extends EssentialsToggleCommand {
|
||||
user.getBase().setFlying(false);
|
||||
}
|
||||
|
||||
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), CommonPlaceholders.displayName((IUser) user));
|
||||
user.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), user.getDisplayName());
|
||||
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
|
||||
sender.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl("flyMode", CommonPlaceholders.enableDisable(user.getSource(), enabled), user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
@ -62,7 +60,7 @@ public class Commandgamemode extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
user.getBase().setGameMode(gameMode);
|
||||
user.sendTl("gameMode", user.playerTl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayNameRecipient((IMessageRecipient) user));
|
||||
user.sendTl("gameMode", user.playerTl(user.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName());
|
||||
}
|
||||
|
||||
private void setUserGamemode(final CommandSource sender, final GameMode gameMode, final User user) throws NotEnoughArgumentsException {
|
||||
@ -76,7 +74,7 @@ public class Commandgamemode extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
user.getBase().setGameMode(gameMode);
|
||||
sender.sendTl("gameMode", sender.tl(gameMode.toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayNameRecipient((IMessageRecipient) user));
|
||||
sender.sendTl("gameMode", sender.tl(gameMode.toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName());
|
||||
}
|
||||
|
||||
// essentials.gamemode will let them change to any but essentials.gamemode.survival would only let them change to survival.
|
||||
|
@ -4,11 +4,9 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@ -81,7 +79,7 @@ public class Commandgive extends EssentialsLoopCommand {
|
||||
final boolean isDropItemsIfFull = ess.getSettings().isDropItemsIfFull();
|
||||
final ItemStack finalStack = stack;
|
||||
loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> {
|
||||
sender.sendTl("giveSpawn", finalStack.getAmount(), itemName, CommonPlaceholders.displayName((IUser) player));
|
||||
sender.sendTl("giveSpawn", finalStack.getAmount(), itemName, player.getDisplayName());
|
||||
|
||||
final Map<Integer, ItemStack> leftovers = Inventories.addItem(player.getBase(), player.isAuthorized("essentials.oversizedstacks") ? ess.getSettings().getOversizedStackSize() : 0, finalStack);
|
||||
|
||||
@ -90,7 +88,7 @@ public class Commandgive extends EssentialsLoopCommand {
|
||||
final World w = player.getWorld();
|
||||
w.dropItemNaturally(player.getLocation(), item);
|
||||
} else {
|
||||
sender.sendTl("giveSpawnFailure", item.getAmount(), itemName, CommonPlaceholders.displayName((IUser) player));
|
||||
sender.sendTl("giveSpawnFailure", item.getAmount(), itemName, player.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
@ -71,7 +69,7 @@ public class Commandheal extends EssentialsLoopCommand {
|
||||
player.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
sender.sendTl("healOther", CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl("healOther", user.getDisplayName());
|
||||
} catch (final QuietAbortException e) {
|
||||
//Handle Quietly
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
@ -44,7 +45,7 @@ public class Commandhelp extends EssentialsCommand {
|
||||
final IEssentialsCommand essCommand = isEssCommand ? ess.getCommandMap().get(knownCmd.getValue().getName()) : null;
|
||||
if (essCommand != null && !essCommand.getUsageStrings().isEmpty()) {
|
||||
for (Map.Entry<String, String> usage : essCommand.getUsageStrings().entrySet()) {
|
||||
user.sendTl("commandHelpLineUsage", usage.getKey().replace("<command>", cmd), usage.getValue());
|
||||
user.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", cmd)), AdventureUtil.parsed(usage.getValue()));
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(knownCmd.getValue().getUsage());
|
||||
|
@ -5,7 +5,6 @@ import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.essentialsx.api.v2.events.HelpopMessageSendEvent;
|
||||
@ -40,8 +39,7 @@ public class Commandhelpop extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final String message = FormatUtil.stripFormat(getFinalArg(args, 0));
|
||||
final AdventureUtil.ParsedPlaceholder displayName = CommonPlaceholders.displayNameRecipient(from);
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("helpOp", displayName, message)));
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("helpOp", from.getDisplayName(), message)));
|
||||
|
||||
final List<IUser> recipients = new ArrayList<>();
|
||||
for (IUser user : ess.getOnlineUsers()) {
|
||||
@ -54,7 +52,7 @@ public class Commandhelpop extends EssentialsCommand {
|
||||
ess.getServer().getPluginManager().callEvent(sendEvent);
|
||||
|
||||
for (IUser recipient : sendEvent.getRecipients()) {
|
||||
recipient.sendTl("helpOp", displayName, message);
|
||||
recipient.sendTl("helpOp", from.getDisplayName(), message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.OfflinePlayerStub;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.TranslatableException;
|
||||
@ -97,7 +98,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
homes.add(user.playerTl("bedNull"));
|
||||
}
|
||||
}
|
||||
user.sendTl("homes", StringUtil.joinList(homes), count, getHomeLimit(finalPlayer));
|
||||
user.sendTl("homes", AdventureUtil.parsed(StringUtil.joinList(homes)), count, getHomeLimit(finalPlayer));
|
||||
}
|
||||
});
|
||||
if (!player.getBase().isOnline() || player.getBase() instanceof OfflinePlayerStub) {
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
@ -39,7 +38,7 @@ public class Commandice extends EssentialsLoopCommand {
|
||||
@Override
|
||||
protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException {
|
||||
freezePlayer(user);
|
||||
sender.sendTl("iceOther", CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl("iceOther", user.getDisplayName());
|
||||
}
|
||||
|
||||
private void freezePlayer(final IUser user) {
|
||||
|
@ -39,7 +39,7 @@ public class Commandkick extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : tlLiteral("kickDefault");
|
||||
String kickReason = args.length > 1 ? getFinalArg(args, 1) : AdventureUtil.miniToLegacy(tlLiteral("kickDefault"));
|
||||
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
final UserKickEvent event = new UserKickEvent(user, target, kickReason);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,7 +15,7 @@ public class Commandkickall extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : tlLiteral("kickDefault");
|
||||
String kickReason = args.length > 0 ? getFinalArg(args, 0) : AdventureUtil.miniToLegacy(tlLiteral("kickDefault"));
|
||||
kickReason = FormatUtil.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
|
||||
|
||||
for (final Player onlinePlayer : ess.getOnlinePlayers()) {
|
||||
|
@ -29,8 +29,7 @@ public class Commandkill extends EssentialsLoopCommand {
|
||||
if (sender.isPlayer() && user.isAuthorized("essentials.kill.exempt") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) {
|
||||
throw new PlayerExemptException("killExempt", matchPlayer.getDisplayName());
|
||||
}
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender.isPlayer() && sender.getPlayer().getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Float.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
final EntityDamageEvent ede = ess.getDamageEventProvider().callDamageEvent(matchPlayer, sender.isPlayer() && sender.getPlayer().getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Float.MAX_VALUE);
|
||||
if (ede.isCancelled() && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.kill.force")) {
|
||||
return;
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Kit;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@ -24,7 +23,7 @@ public class Commandkit extends EssentialsCommand {
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
final String kitList = ess.getKits().listKits(ess, user);
|
||||
user.sendTl(kitList.length() > 0 ? "kits" : "noKits", kitList);
|
||||
user.sendTl(kitList.length() > 0 ? "kits" : "noKits", AdventureUtil.parsed(kitList));
|
||||
throw new NoChargeException();
|
||||
} else if (args.length > 1 && user.isAuthorized("essentials.kit.others")) {
|
||||
giveKits(getPlayer(server, user, args, 1), user, StringUtil.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim());
|
||||
@ -37,7 +36,7 @@ public class Commandkit extends EssentialsCommand {
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
final String kitList = ess.getKits().listKits(ess, null);
|
||||
sender.sendTl(kitList.length() > 0 ? "kits" : "noKits", kitList);
|
||||
sender.sendTl(kitList.length() > 0 ? "kits" : "noKits", AdventureUtil.parsed(kitList));
|
||||
throw new NoChargeException();
|
||||
} else {
|
||||
final User userTo = getPlayer(server, args, 1, true, false);
|
||||
@ -45,7 +44,7 @@ public class Commandkit extends EssentialsCommand {
|
||||
for (final String kitName : args[0].toLowerCase(Locale.ENGLISH).split(",")) {
|
||||
new Kit(kitName, ess).expandItems(userTo);
|
||||
|
||||
sender.sendTl("kitGiveTo", kitName, CommonPlaceholders.displayName((IUser) userTo));
|
||||
sender.sendTl("kitGiveTo", kitName, userTo.getDisplayName());
|
||||
userTo.sendTl("kitReceive", kitName);
|
||||
}
|
||||
}
|
||||
@ -81,7 +80,7 @@ public class Commandkit extends EssentialsCommand {
|
||||
kit.chargeUser(userTo);
|
||||
|
||||
if (!userFrom.equals(userTo)) {
|
||||
userFrom.sendTl("kitGiveTo", kit.getName(), CommonPlaceholders.displayName((IUser) userTo));
|
||||
userFrom.sendTl("kitGiveTo", kit.getName(), userTo.getDisplayName());
|
||||
}
|
||||
|
||||
userTo.sendTl("kitReceive", kit.getName());
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@ -36,7 +34,7 @@ public class Commandkitreset extends EssentialsCommand {
|
||||
if (user.equals(target)) {
|
||||
user.sendTl("kitReset", kitName);
|
||||
} else {
|
||||
user.sendTl("kitResetOther", kitName, CommonPlaceholders.displayName((IUser) target));
|
||||
user.sendTl("kitResetOther", kitName, target.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +51,7 @@ public class Commandkitreset extends EssentialsCommand {
|
||||
|
||||
final User target = getPlayer(server, sender, args, 1);
|
||||
target.setKitTimestamp(kitName, 0);
|
||||
sender.sendTl("kitResetOther", kitName, CommonPlaceholders.displayName((IUser) target));
|
||||
sender.sendTl("kitResetOther", kitName, target.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
|
||||
@ -35,7 +33,7 @@ public class Commandlightning extends EssentialsLoopCommand {
|
||||
}
|
||||
final int finalPower = power;
|
||||
loopOnlinePlayersConsumer(server, sender, false, true, args[0], player -> {
|
||||
sender.sendTl("lightningUse", CommonPlaceholders.displayName((IUser) player));
|
||||
sender.sendTl("lightningUse", player.getDisplayName());
|
||||
final LightningStrike strike = player.getBase().getWorld().strikeLightningEffect(player.getBase().getLocation());
|
||||
|
||||
if (!player.isGodModeEnabled()) {
|
||||
|
@ -6,13 +6,11 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import com.earth2me.essentials.textreader.SimpleTextPager;
|
||||
import com.earth2me.essentials.textreader.SimpleTranslatableText;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.essentialsx.api.v2.services.mail.MailMessage;
|
||||
import org.bukkit.Server;
|
||||
@ -102,7 +100,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
u.sendMail(user, msg);
|
||||
}
|
||||
|
||||
user.sendTl("mailSentTo", CommonPlaceholders.displayName((IUser) u), u.getName());
|
||||
user.sendTl("mailSentTo", u.getDisplayName(), u.getName());
|
||||
user.sendMessage(msg);
|
||||
return;
|
||||
}
|
||||
@ -145,7 +143,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
u.sendMail(user, msg, dateDiff);
|
||||
}
|
||||
|
||||
user.sendTl("mailSentToExpire", CommonPlaceholders.displayName((IUser) u), DateUtil.formatDateDiff(dateDiff), u.getName());
|
||||
user.sendTl("mailSentToExpire", u.getDisplayName(), DateUtil.formatDateDiff(dateDiff), u.getName());
|
||||
user.sendMessage(msg);
|
||||
return;
|
||||
}
|
||||
@ -187,7 +185,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
|
||||
final ArrayList<MailMessage> mails = mailUser.getMailMessages();
|
||||
if (mails == null || mails.isEmpty()) {
|
||||
user.sendTl(mailUser == user ? "noMail" : "noMailOther", CommonPlaceholders.displayName((IUser) mailUser));
|
||||
user.sendTl(mailUser == user ? "noMail" : "noMailOther", mailUser.getDisplayName());
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@ -227,7 +225,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
|
||||
final ArrayList<MailMessage> mails = mailUser.getMailMessages();
|
||||
if (mails == null || mails.isEmpty()) {
|
||||
sender.sendTl("noMailOther", CommonPlaceholders.displayName((IUser) mailUser));
|
||||
sender.sendTl("noMailOther", mailUser.getDisplayName());
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.essentialsx.api.v2.events.UserActionEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,8 +17,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tlLiteral;
|
||||
|
||||
public class Commandme extends EssentialsCommand {
|
||||
public Commandme() {
|
||||
super("me");
|
||||
@ -45,9 +41,8 @@ public class Commandme extends EssentialsCommand {
|
||||
|
||||
user.setDisplayNick();
|
||||
long radius = ess.getSettings().getChatRadius();
|
||||
final String toSend = tlLiteral("action", CommonPlaceholders.displayName((IUser) user), message);
|
||||
if (radius < 1) {
|
||||
ess.broadcastMessage(user, toSend);
|
||||
ess.broadcastTl("action", user.getDisplayName(), message);
|
||||
ess.getServer().getPluginManager().callEvent(new UserActionEvent(user, message, Collections.unmodifiableCollection(ess.getServer().getOnlinePlayers())));
|
||||
return;
|
||||
}
|
||||
@ -55,7 +50,7 @@ public class Commandme extends EssentialsCommand {
|
||||
|
||||
final World world = user.getWorld();
|
||||
final Location loc = user.getLocation();
|
||||
final Set<Player> outList = new HashSet<>();
|
||||
final Set<User> outList = new HashSet<>();
|
||||
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
final User onlineUser = ess.getUser(player);
|
||||
@ -74,13 +69,13 @@ public class Commandme extends EssentialsCommand {
|
||||
}
|
||||
if (abort) {
|
||||
if (onlineUser.isAuthorized("essentials.chat.spy")) {
|
||||
outList.add(player); // Just use the same list unless we wanted to format spyying for this.
|
||||
outList.add(onlineUser); // Just use the same list unless we wanted to format spyying for this.
|
||||
}
|
||||
} else {
|
||||
outList.add(player);
|
||||
outList.add(onlineUser);
|
||||
}
|
||||
} else {
|
||||
outList.add(player); // Add yourself to the list.
|
||||
outList.add(onlineUser); // Add yourself to the list.
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,10 +83,19 @@ public class Commandme extends EssentialsCommand {
|
||||
user.sendTl("localNoOne");
|
||||
}
|
||||
|
||||
for (final Player onlinePlayer : outList) {
|
||||
onlinePlayer.sendMessage(toSend);
|
||||
for (final User onlineUser : outList) {
|
||||
onlineUser.sendTl("action", user.getDisplayName(), message);
|
||||
}
|
||||
|
||||
// Only take the time to generate this list if there are listeners.
|
||||
if (UserActionEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
final Set<Player> outListPlayers = new HashSet<>();
|
||||
for (final User onlineUser : outList) {
|
||||
outListPlayers.add(onlineUser.getBase());
|
||||
}
|
||||
|
||||
ess.getServer().getPluginManager().callEvent(new UserActionEvent(user, message, Collections.unmodifiableCollection(outListPlayers)));
|
||||
}
|
||||
ess.getServer().getPluginManager().callEvent(new UserActionEvent(user, message, Collections.unmodifiableCollection(outList)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,7 +107,7 @@ public class Commandme extends EssentialsCommand {
|
||||
String message = getFinalArg(args, 0);
|
||||
message = FormatUtil.replaceFormat(message);
|
||||
|
||||
ess.getServer().broadcastMessage(tlLiteral("action", "@", message));
|
||||
ess.broadcastTl("action", "@", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandmsgtoggle extends EssentialsToggleCommand {
|
||||
@ -31,7 +29,7 @@ public class Commandmsgtoggle extends EssentialsToggleCommand {
|
||||
|
||||
user.sendTl(!enabled ? "msgEnabled" : "msgDisabled");
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(!enabled ? "msgEnabledFor" : "msgDisabledFor", CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl(!enabled ? "msgEnabledFor" : "msgDisabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.OfflinePlayerStub;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||
@ -87,18 +86,18 @@ public class Commandmute extends EssentialsCommand {
|
||||
if (muted) {
|
||||
if (muteTimestamp > 0) {
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendTl("mutedPlayerFor", CommonPlaceholders.displayName(user), muteTime);
|
||||
sender.sendTl("mutedPlayerFor", user.getDisplayName(), muteTime);
|
||||
user.sendTl("playerMutedFor", muteTime);
|
||||
} else {
|
||||
sender.sendTl("mutedPlayerForReason", CommonPlaceholders.displayName(user), muteTime, user.getMuteReason());
|
||||
sender.sendTl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason());
|
||||
user.sendTl("playerMutedForReason", muteTime, user.getMuteReason());
|
||||
}
|
||||
} else {
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendTl("mutedPlayer", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl("mutedPlayer", user.getDisplayName());
|
||||
user.sendTl("playerMuted");
|
||||
} else {
|
||||
sender.sendTl("mutedPlayerReason", CommonPlaceholders.displayName(user), user.getMuteReason());
|
||||
sender.sendTl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason());
|
||||
user.sendTl("playerMutedReason", user.getMuteReason());
|
||||
}
|
||||
}
|
||||
@ -121,7 +120,7 @@ public class Commandmute extends EssentialsCommand {
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral(tlKey, objects)));
|
||||
ess.broadcastTl(null, "essentials.mute.notify", tlKey, objects);
|
||||
} else {
|
||||
sender.sendTl("unmutedPlayer", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl("unmutedPlayer", user.getDisplayName());
|
||||
user.sendTl("playerUnmuted");
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@ -58,7 +57,7 @@ public class Commandnear extends EssentialsCommand {
|
||||
if (otherUser == null || !user.isAuthorized("essentials.near.others")) {
|
||||
otherUser = user;
|
||||
}
|
||||
user.sendTl("nearbyPlayers", getLocal(user.getSource(), otherUser, radius));
|
||||
user.sendTl("nearbyPlayers", AdventureUtil.parsed(getLocal(user.getSource(), otherUser, radius)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,7 +73,7 @@ public class Commandnear extends EssentialsCommand {
|
||||
} catch (final NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
sender.sendTl("nearbyPlayers", getLocal(sender, otherUser, radius));
|
||||
sender.sendTl("nearbyPlayers", AdventureUtil.parsed(getLocal(sender, otherUser, radius)));
|
||||
}
|
||||
|
||||
private String getLocal(final CommandSource source, final User user, final long radius) {
|
||||
@ -108,7 +107,7 @@ public class Commandnear extends EssentialsCommand {
|
||||
if (nearbyPlayer == null) {
|
||||
continue;
|
||||
}
|
||||
output.append(user.playerTl("nearbyPlayersList", CommonPlaceholders.displayName((IUser) nearbyPlayer), (long)nearbyPlayer.getLocation().distance(loc)));
|
||||
output.append(user.playerTl("nearbyPlayersList", nearbyPlayer.getDisplayName(), (long)nearbyPlayer.getLocation().distance(loc)));
|
||||
}
|
||||
|
||||
return output.length() > 1 ? output.toString() : source.tl("none");
|
||||
|
@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.NickChangeEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -54,12 +52,12 @@ public class Commandnick extends EssentialsLoopCommand {
|
||||
if (!target.getDisplayName().equalsIgnoreCase(target.getDisplayName())) {
|
||||
target.sendTl("nickNoMore");
|
||||
}
|
||||
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? CommonPlaceholders.displayName((IUser) target) : nick);
|
||||
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? target.getDisplayName() : nick);
|
||||
} else if (nickInUse(target, nick)) {
|
||||
throw new NotEnoughArgumentsException(sender.tl("nickInUse"));
|
||||
} else {
|
||||
setNickname(server, sender, target, nick);
|
||||
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? CommonPlaceholders.displayName((IUser) target) : nick);
|
||||
target.sendTl("nickSet", ess.getSettings().changeDisplayName() ? target.getDisplayName() : nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,9 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
@ -88,7 +86,7 @@ public class Commandpay extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
if (!player.isAcceptingPay() || (ess.getSettings().isPayExcludesIgnoreList() && player.isIgnoredPlayer(user))) {
|
||||
user.sendTl("notAcceptingPay", CommonPlaceholders.displayName((IUser) player));
|
||||
user.sendTl("notAcceptingPay", player.getDisplayName());
|
||||
return;
|
||||
}
|
||||
if (user.isPromptingPayConfirm() && !amount.equals(user.getConfirmingPayments().get(player))) { // checks if exists and if command needs to be repeated.
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandpaytoggle extends EssentialsToggleCommand {
|
||||
@ -38,7 +36,7 @@ public class Commandpaytoggle extends EssentialsToggleCommand {
|
||||
|
||||
user.sendTl(enabled ? "payToggleOn" : "payToggleOff");
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(enabled ? "payEnabledFor" : "payDisabledFor", CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl(enabled ? "payEnabledFor" : "payDisabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.DescParseTickFormat;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
@ -82,7 +83,7 @@ public class Commandptime extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
final String formattedTime = DescParseTickFormat.format(ticks);
|
||||
sender.sendTl(fixed ? "pTimeSetFixed" : "pTimeSet", formattedTime, joiner.toString());
|
||||
sender.sendTl(fixed ? "pTimeSetFixed" : "pTimeSet", AdventureUtil.parsed(formattedTime), joiner.toString());
|
||||
}
|
||||
|
||||
public void getUserTime(final CommandSource sender, final IUser user) {
|
||||
@ -96,7 +97,7 @@ public class Commandptime extends EssentialsLoopCommand {
|
||||
}
|
||||
|
||||
final String time = DescParseTickFormat.format(user.getBase().getPlayerTime());
|
||||
sender.sendTl(user.getBase().isPlayerTimeRelative() ? "pTimeCurrent" : "pTimeCurrentFixed", user.getName(), time);
|
||||
sender.sendTl(user.getBase().isPlayerTimeRelative() ? "pTimeCurrent" : "pTimeCurrentFixed", user.getName(), AdventureUtil.parsed(time));
|
||||
}
|
||||
|
||||
private void setUserTime(final User user, final Long ticks, final Boolean relative) {
|
||||
|
@ -2,9 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -31,7 +29,7 @@ public class Commandrealname extends EssentialsCommand {
|
||||
u.setDisplayNick();
|
||||
if (FormatUtil.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH).contains(lookup)) {
|
||||
foundUser = true;
|
||||
sender.sendTl("realName", CommonPlaceholders.displayName((IUser) u), u.getName());
|
||||
sender.sendTl("realName", u.getDisplayName(), u.getName());
|
||||
}
|
||||
}
|
||||
if (!foundUser) {
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Statistic;
|
||||
@ -35,7 +34,7 @@ public class Commandrest extends EssentialsLoopCommand {
|
||||
@Override
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws PlayerExemptException {
|
||||
restPlayer(player);
|
||||
sender.sendTl("restOther", CommonPlaceholders.displayName(player));
|
||||
sender.sendTl("restOther", player.getDisplayName());
|
||||
}
|
||||
|
||||
private void restPlayer(final IUser user) {
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandrtoggle extends EssentialsToggleCommand {
|
||||
@ -30,7 +29,7 @@ public class Commandrtoggle extends EssentialsToggleCommand {
|
||||
|
||||
user.sendTl(!enabled ? "replyLastRecipientDisabled" : "replyLastRecipientEnabled");
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(!enabled ? "replyLastRecipientDisabledFor" : "replyLastRecipientEnabledFor", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl(!enabled ? "replyLastRecipientDisabledFor" : "replyLastRecipientEnabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class Commandseen extends EssentialsCommand {
|
||||
private void seenOnline(final CommandSource sender, final User user, final boolean showIp) {
|
||||
|
||||
user.setDisplayNick();
|
||||
sender.sendTl("seenOnline", CommonPlaceholders.displayName(user), DateUtil.formatDateDiff(user.getLastLogin()));
|
||||
sender.sendTl("seenOnline", user.getDisplayName(), DateUtil.formatDateDiff(user.getLastLogin()));
|
||||
|
||||
final List<String> history = user.getPastUsernames();
|
||||
if (history != null && !history.isEmpty()) {
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.TranslatableException;
|
||||
@ -123,7 +122,7 @@ public class Commandsell extends EssentialsCommand {
|
||||
final String typeName = is.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final String worthDisplay = NumberUtil.displayCurrency(worth, ess);
|
||||
user.sendTl("itemSold", NumberUtil.displayCurrency(result, ess), amount, typeName, worthDisplay);
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("itemSoldConsole", user.getName(), typeName, NumberUtil.displayCurrency(result, ess), amount, worthDisplay, CommonPlaceholders.displayName(user))));
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("itemSoldConsole", user.getName(), typeName, NumberUtil.displayCurrency(result, ess), amount, worthDisplay, user.getDisplayName())));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,9 @@ public class Commandsocialspy extends EssentialsToggleCommand {
|
||||
|
||||
user.setSocialSpyEnabled(enabled);
|
||||
|
||||
user.sendTl("socialSpy", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
user.sendTl("socialSpy", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
|
||||
sender.sendTl("socialSpy", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
sender.sendTl("socialSpy", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.FloatUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -54,11 +53,11 @@ public class Commandspeed extends EssentialsCommand {
|
||||
|
||||
if (isFly) {
|
||||
user.getBase().setFlySpeed(getRealMoveSpeed(speed, true, isBypass));
|
||||
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("flying")), speed, CommonPlaceholders.displayName(user));
|
||||
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("flying")), speed, user.getDisplayName());
|
||||
return;
|
||||
}
|
||||
user.getBase().setWalkSpeed(getRealMoveSpeed(speed, false, isBypass));
|
||||
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("walking")), speed, CommonPlaceholders.displayName(user));
|
||||
user.sendTl("moveSpeed", AdventureUtil.parsed(user.playerTl("walking")), speed, user.getDisplayName());
|
||||
}
|
||||
|
||||
private void speedOtherPlayers(final Server server, final CommandSource sender, final boolean isFly, final boolean isBypass, final float speed, final String name) throws PlayerNotFoundException {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
@ -15,13 +14,12 @@ public class Commandsuicide extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Float.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
final EntityDamageEvent ede = ess.getDamageEventProvider().callDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Float.MAX_VALUE);
|
||||
ede.getEntity().setLastDamageCause(ede);
|
||||
user.getBase().setHealth(0);
|
||||
user.sendTl("suicideMessage");
|
||||
user.setDisplayNick();
|
||||
ess.broadcastTl(user, "suicideSuccess", CommonPlaceholders.displayName(user));
|
||||
ess.broadcastTl(user, "suicideSuccess", new Object[]{user.getDisplayName()});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,8 @@ public class Commandtempban extends EssentialsCommand {
|
||||
ess.getServer().getBanList(BanList.Type.NAME).addBan(user.getName(), banReason, new Date(banTimestamp), senderName);
|
||||
final String expiry = DateUtil.formatDateDiff(banTimestamp);
|
||||
|
||||
user.getBase().kickPlayer(user.playerTl("tempBanned", expiry, senderDisplayName, banReason));
|
||||
final String banDisplay = user.playerTl("tempBanned", expiry, senderDisplayName, banReason);
|
||||
user.getBase().kickPlayer(AdventureUtil.miniToLegacy(banDisplay));
|
||||
|
||||
ess.getLogger().log(Level.INFO, AdventureUtil.miniToLegacy(tlLiteral("playerTempBanned", senderDisplayName, user.getName(), expiry, banReason)));
|
||||
ess.broadcastTl((IUser) null, "essentials.ban.notify", "playerTempBanned", senderDisplayName, user.getName(), expiry, banReason);
|
||||
|
@ -63,7 +63,7 @@ public class Commandtempbanip extends EssentialsCommand {
|
||||
|
||||
ess.getServer().getBanList(BanList.Type.IP).addBan(ipAddress, banReason, new Date(banTimestamp), senderName);
|
||||
|
||||
final String banDisplay = tlLiteral("banFormat", banReason, senderDisplayName);
|
||||
final String banDisplay = AdventureUtil.miniToLegacy(tlLiteral("banFormat", banReason, senderDisplayName));
|
||||
for (final Player player : ess.getServer().getOnlinePlayers()) {
|
||||
if (player.getAddress().getAddress().getHostAddress().equalsIgnoreCase(ipAddress)) {
|
||||
player.kickPlayer(banDisplay);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.DescParseTickFormat;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -95,12 +96,12 @@ public class Commandtime extends EssentialsCommand {
|
||||
private void getWorldsTime(final CommandSource sender, final Collection<World> worlds) {
|
||||
if (worlds.size() == 1) {
|
||||
final Iterator<World> iter = worlds.iterator();
|
||||
sender.sendMessage(DescParseTickFormat.format(iter.next().getTime()));
|
||||
sender.sendComponent(AdventureUtil.miniMessage().deserialize(DescParseTickFormat.format(iter.next().getTime())));
|
||||
return;
|
||||
}
|
||||
|
||||
for (final World world : worlds) {
|
||||
sender.sendTl("timeWorldCurrent", world.getName(), DescParseTickFormat.format(world.getTime()));
|
||||
sender.sendTl("timeWorldCurrent", world.getName(), AdventureUtil.parsed(DescParseTickFormat.format(world.getTime())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,18 +83,18 @@ public class Commandtogglejail extends EssentialsCommand {
|
||||
if (args.length > 2) {
|
||||
player.setJailTimeout(timeDiff);
|
||||
// 50 MSPT (milliseconds per tick)
|
||||
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getBase().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
|
||||
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getOffline().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
|
||||
}
|
||||
|
||||
final String tlKey;
|
||||
final Object[] objects;
|
||||
if (timeDiff > 0) {
|
||||
tlKey = "jailNotifyJailedFor";
|
||||
objects = new Object[]{player.getName(), DateUtil.formatDateDiff(finalDisplayTime)};
|
||||
objects = new Object[]{player.getName(), DateUtil.formatDateDiff(finalDisplayTime), sender.getSender().getName()};
|
||||
sender.sendTl("playerJailedFor", player.getName(), DateUtil.formatDateDiff(finalDisplayTime));
|
||||
} else {
|
||||
tlKey = "jailNotifyJailed";
|
||||
objects = new Object[]{player.getName(), sender.getSender().getName()};
|
||||
objects = new Object[]{player.getName(), sender.getSender().getName(), sender.getSender().getName()};
|
||||
sender.sendTl("playerJailed", player.getName());
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ public class Commandtogglejail extends EssentialsCommand {
|
||||
final long displayTimeDiff = DateUtil.parseDateDiff(unparsedTime, true);
|
||||
final long timeDiff = DateUtil.parseDateDiff(unparsedTime, true, ess.getSettings().isJailOnlineTime());
|
||||
player.setJailTimeout(timeDiff);
|
||||
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getBase().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
|
||||
player.setOnlineJailedTime(ess.getSettings().isJailOnlineTime() ? ((player.getOffline().getStatistic(PLAY_ONE_TICK)) + (timeDiff / 50)) : 0);
|
||||
sender.sendTl("jailSentenceExtended", DateUtil.formatDateDiff(displayTimeDiff));
|
||||
|
||||
final String tlKey = "jailNotifySentenceExtended";
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@ -29,12 +28,12 @@ public class Commandtp extends EssentialsCommand {
|
||||
final User player = getPlayer(server, user, args, 0, false, true);
|
||||
|
||||
if (!player.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportDisabled", player.getDisplayName());
|
||||
}
|
||||
|
||||
if (!player.getBase().isOnline()) {
|
||||
if (user.isAuthorized("essentials.tpoffline")) {
|
||||
throw new TranslatableException("teleportOffline", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportOffline", player.getDisplayName());
|
||||
}
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
@ -80,7 +79,7 @@ public class Commandtp extends EssentialsCommand {
|
||||
}
|
||||
final Location locposother = new Location(target2.getWorld(), x, y, z, target2.getLocation().getYaw(), target2.getLocation().getPitch());
|
||||
if (!target2.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(target2));
|
||||
throw new TranslatableException("teleportDisabled", target2.getDisplayName());
|
||||
}
|
||||
user.sendTl("teleporting", locposother.getWorld().getName(), locposother.getBlockX(), locposother.getBlockY(), locposother.getBlockZ());
|
||||
target2.getAsyncTeleport().now(locposother, false, TeleportCause.COMMAND, future);
|
||||
@ -98,15 +97,15 @@ public class Commandtp extends EssentialsCommand {
|
||||
final User target = getPlayer(server, user, args, 0);
|
||||
final User toPlayer = getPlayer(server, user, args, 1);
|
||||
if (!target.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(target));
|
||||
throw new TranslatableException("teleportDisabled", target.getDisplayName());
|
||||
}
|
||||
if (!toPlayer.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(toPlayer));
|
||||
throw new TranslatableException("teleportDisabled", toPlayer.getDisplayName());
|
||||
}
|
||||
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + toPlayer.getWorld().getName())) {
|
||||
throw new TranslatableException("noPerm", "essentials.worlds." + toPlayer.getWorld().getName());
|
||||
}
|
||||
target.sendTl("teleportAtoB", CommonPlaceholders.displayName(user), CommonPlaceholders.displayName(toPlayer));
|
||||
target.sendTl("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName());
|
||||
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future);
|
||||
break;
|
||||
}
|
||||
@ -121,7 +120,7 @@ public class Commandtp extends EssentialsCommand {
|
||||
final User target = getPlayer(server, args, 0, true, false);
|
||||
if (args.length == 2) {
|
||||
final User toPlayer = getPlayer(server, args, 1, true, false);
|
||||
target.sendTl("teleportAtoB", Console.DISPLAY_NAME, CommonPlaceholders.displayName(toPlayer));
|
||||
target.sendTl("teleportAtoB", Console.DISPLAY_NAME, toPlayer.getDisplayName());
|
||||
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, getNewExceptionFuture(sender, commandLabel));
|
||||
} else if (args.length > 3) {
|
||||
final double x = args[1].startsWith("~") ? target.getLocation().getX() + (args[1].length() > 1 ? Double.parseDouble(args[1].substring(1)) : 0) : Double.parseDouble(args[1]);
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.AsyncTeleport;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
@ -29,10 +28,10 @@ public class Commandtpa extends EssentialsCommand {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (!player.isAuthorized("essentials.tpaccept")) {
|
||||
throw new TranslatableException("teleportNoAcceptPermission", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportNoAcceptPermission", player.getDisplayName());
|
||||
}
|
||||
if (!player.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportDisabled", player.getDisplayName());
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + player.getWorld().getName())) {
|
||||
throw new TranslatableException("noPerm", "essentials.worlds." + player.getWorld().getName());
|
||||
@ -40,7 +39,7 @@ public class Commandtpa extends EssentialsCommand {
|
||||
|
||||
// Don't let sender request teleport twice to the same player.
|
||||
if (player.hasOutstandingTpaRequest(user.getName(), false)) {
|
||||
throw new TranslatableException("requestSentAlready", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("requestSentAlready", player.getDisplayName());
|
||||
}
|
||||
|
||||
if (player.isAutoTeleportEnabled() && !player.isIgnoredPlayer(user)) {
|
||||
@ -51,8 +50,8 @@ public class Commandtpa extends EssentialsCommand {
|
||||
teleport.teleport(player.getBase(), charge, PlayerTeleportEvent.TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
player.sendTl("requestAcceptedAuto", CommonPlaceholders.displayName(user));
|
||||
user.sendTl("requestAcceptedFromAuto", CommonPlaceholders.displayName(player));
|
||||
player.sendTl("requestAcceptedAuto", user.getDisplayName());
|
||||
user.sendTl("requestAcceptedFromAuto", player.getDisplayName());
|
||||
}
|
||||
});
|
||||
throw new NoChargeException();
|
||||
@ -62,10 +61,10 @@ public class Commandtpa extends EssentialsCommand {
|
||||
final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, false);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
throw new TranslatableException("teleportRequestCancelled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportRequestCancelled", player.getDisplayName());
|
||||
}
|
||||
player.requestTeleport(user, false);
|
||||
player.sendTl("teleportRequest", CommonPlaceholders.displayName(user));
|
||||
player.sendTl("teleportRequest", user.getDisplayName());
|
||||
player.sendTl("typeTpaccept");
|
||||
player.sendTl("typeTpdeny");
|
||||
if (ess.getSettings().getTpaAcceptCancellation() != 0) {
|
||||
@ -73,7 +72,7 @@ public class Commandtpa extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
user.sendTl("requestSent", CommonPlaceholders.displayName(player));
|
||||
user.sendTl("requestSent", player.getDisplayName());
|
||||
if (user.isAuthorized("essentials.tpacancel")) {
|
||||
user.sendTl("typeTpacancel");
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@ -45,11 +44,11 @@ public class Commandtpaall extends EssentialsCommand {
|
||||
final TPARequestEvent tpaEvent = new TPARequestEvent(sender, player, true);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
sender.sendTl("teleportRequestCancelled", CommonPlaceholders.displayName(player));
|
||||
sender.sendTl("teleportRequestCancelled", player.getDisplayName());
|
||||
continue;
|
||||
}
|
||||
player.requestTeleport(target, true);
|
||||
player.sendTl("teleportHereRequest", CommonPlaceholders.displayName(target));
|
||||
player.sendTl("teleportHereRequest", target.getDisplayName());
|
||||
player.sendTl("typeTpaccept");
|
||||
if (ess.getSettings().getTpaAcceptCancellation() != 0) {
|
||||
player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation());
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.AsyncTeleport;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.essentialsx.api.v2.events.TeleportRequestResponseEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -105,7 +104,7 @@ public class Commandtpaccept extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
requester.sendTl("requestAcceptedFrom", CommonPlaceholders.displayName(user));
|
||||
requester.sendTl("requestAcceptedFrom", user.getDisplayName());
|
||||
|
||||
final CompletableFuture<Boolean> future = getNewExceptionFuture(requester.getSource(), commandLabel);
|
||||
future.exceptionally(e -> {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
@ -25,10 +24,10 @@ public class Commandtpahere extends EssentialsCommand {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (!player.isAuthorized("essentials.tpaccept")) {
|
||||
throw new TranslatableException("teleportNoAcceptPermission", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportNoAcceptPermission", player.getDisplayName());
|
||||
}
|
||||
if (!player.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportDisabled", player.getDisplayName());
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
|
||||
throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName());
|
||||
@ -36,24 +35,24 @@ public class Commandtpahere extends EssentialsCommand {
|
||||
|
||||
// Don't let sender request teleport twice to the same player.
|
||||
if (player.hasOutstandingTpaRequest(user.getName(), true)) {
|
||||
throw new TranslatableException("requestSentAlready", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("requestSentAlready", player.getDisplayName());
|
||||
}
|
||||
|
||||
if (!player.isIgnoredPlayer(user)) {
|
||||
final TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, true);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
throw new TranslatableException("teleportRequestCancelled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportRequestCancelled", player.getDisplayName());
|
||||
}
|
||||
player.requestTeleport(user, true);
|
||||
player.sendTl("teleportHereRequest", CommonPlaceholders.displayName(user));
|
||||
player.sendTl("teleportHereRequest", user.getDisplayName());
|
||||
player.sendTl("typeTpaccept");
|
||||
player.sendTl("typeTpdeny");
|
||||
if (ess.getSettings().getTpaAcceptCancellation() != 0) {
|
||||
player.sendTl("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation());
|
||||
}
|
||||
}
|
||||
user.sendTl("requestSent", CommonPlaceholders.displayName(player));
|
||||
user.sendTl("requestSent", player.getDisplayName());
|
||||
user.sendTl("typeTpacancel");
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandtpauto extends EssentialsToggleCommand {
|
||||
@ -33,7 +32,7 @@ public class Commandtpauto extends EssentialsToggleCommand {
|
||||
user.sendTl("teleportationDisabledWarning");
|
||||
}
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(enabled ? "autoTeleportEnabledFor" : "autoTeleportDisabledFor", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl(enabled ? "autoTeleportEnabledFor" : "autoTeleportDisabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import net.essentialsx.api.v2.events.TeleportRequestResponseEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -55,7 +54,7 @@ public class Commandtpdeny extends EssentialsCommand {
|
||||
}
|
||||
|
||||
user.sendTl("requestDenied");
|
||||
player.sendTl("requestDeniedFrom", CommonPlaceholders.displayName(user));
|
||||
player.sendTl("requestDeniedFrom", user.getDisplayName());
|
||||
user.removeTpaRequest(denyRequest.getName());
|
||||
}
|
||||
|
||||
@ -70,7 +69,7 @@ public class Commandtpdeny extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (player != null && player.getBase().isOnline()) {
|
||||
player.sendTl("requestDeniedFrom", CommonPlaceholders.displayName(user));
|
||||
player.sendTl("requestDeniedFrom", user.getDisplayName());
|
||||
}
|
||||
|
||||
user.removeTpaRequest(request.getName());
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@ -19,7 +18,7 @@ public class Commandtphere extends EssentialsCommand {
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final User player = getPlayer(server, user, args, 0);
|
||||
if (!player.isTeleportEnabled()) {
|
||||
throw new TranslatableException("teleportDisabled", CommonPlaceholders.displayName(player));
|
||||
throw new TranslatableException("teleportDisabled", player.getDisplayName());
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + user.getWorld().getName())) {
|
||||
throw new TranslatableException("noPerm", "essentials.worlds." + user.getWorld().getName());
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@ -44,7 +43,7 @@ public class Commandtpo extends EssentialsCommand {
|
||||
target.getAsyncTeleport().now(toPlayer.getBase(), false, TeleportCause.COMMAND, future);
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
target.sendTl("teleportAtoB", CommonPlaceholders.displayName(user), CommonPlaceholders.displayName(toPlayer));
|
||||
target.sendTl("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName());
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@ -22,7 +21,7 @@ public class Commandtpoffline extends EssentialsCommand {
|
||||
final Location logout = target.getLogoutLocation();
|
||||
|
||||
if (logout == null) {
|
||||
user.sendTl("teleportOfflineUnknown", CommonPlaceholders.displayName(user));
|
||||
user.sendTl("teleportOfflineUnknown", user.getDisplayName());
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandtptoggle extends EssentialsToggleCommand {
|
||||
@ -30,7 +29,7 @@ public class Commandtptoggle extends EssentialsToggleCommand {
|
||||
|
||||
user.sendTl(enabled ? "teleportationEnabled" : "teleportationDisabled");
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(enabled ? "teleportationEnabledFor" : "teleportationDisabledFor", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl(enabled ? "teleportationEnabledFor" : "teleportationDisabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.Inventories;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@ -30,7 +30,7 @@ public class Commandunlimited extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list")) {
|
||||
user.sendMessage(getList(user, target));
|
||||
user.sendComponent(AdventureUtil.miniMessage().deserialize(getList(user, target)));
|
||||
} else if (args[0].equalsIgnoreCase("clear")) {
|
||||
for (final Material m : new HashSet<>(target.getUnlimited())) {
|
||||
if (m == null) {
|
||||
@ -57,7 +57,7 @@ public class Commandunlimited extends EssentialsCommand {
|
||||
}
|
||||
joiner.add(material.toString().toLowerCase(Locale.ENGLISH).replace("_", ""));
|
||||
}
|
||||
output.append(joiner.toString());
|
||||
output.append(joiner);
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
@ -82,9 +82,9 @@ public class Commandunlimited extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (user != target) {
|
||||
user.sendTl(message, itemname, CommonPlaceholders.displayName(target));
|
||||
user.sendTl(message, itemname, target.getDisplayName());
|
||||
}
|
||||
target.sendTl(message, itemname, CommonPlaceholders.displayName(target));
|
||||
target.sendTl(message, itemname, target.getDisplayName());
|
||||
target.setUnlimited(stack, enableUnlimited);
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ public class Commandvanish extends EssentialsToggleCommand {
|
||||
}
|
||||
|
||||
user.setVanished(enabled);
|
||||
user.sendTl("vanish", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
user.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
|
||||
if (enabled) {
|
||||
user.sendTl("vanished");
|
||||
}
|
||||
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase())) {
|
||||
sender.sendTl("vanish", CommonPlaceholders.displayName(user), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
sender.sendTl("vanish", user.getDisplayName(), CommonPlaceholders.enableDisable(user.getSource(), enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class Commandwhois extends EssentialsCommand {
|
||||
|
||||
sender.sendTl("whoisTop", user.getName());
|
||||
user.setDisplayNick();
|
||||
sender.sendTl("whoisNick", CommonPlaceholders.displayName(user));
|
||||
sender.sendTl("whoisNick", user.getDisplayName());
|
||||
sender.sendTl("whoisUuid", user.getBase().getUniqueId().toString());
|
||||
sender.sendTl("whoisHealth", user.getBase().getHealth());
|
||||
sender.sendTl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation());
|
||||
|
@ -10,7 +10,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.ess3.api.TranslatableException;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -67,7 +67,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||
final Matcher matcher = ARGUMENT_PATTERN.matcher(usage);
|
||||
while (matcher.find()) {
|
||||
final String color = matcher.group(3).equals("<") ? tlLiteral("commandArgumentRequired") : tlLiteral("commandArgumentOptional");
|
||||
matcher.appendReplacement(buffer, "$1" + color + matcher.group(2).replace("|", tlLiteral("commandArgumentOr") + "|" + color) + ChatColor.RESET);
|
||||
matcher.appendReplacement(buffer, "$1" + color + matcher.group(2).replace("|", tlLiteral("commandArgumentOr") + "|" + color) + "<reset>");
|
||||
}
|
||||
matcher.appendTail(buffer);
|
||||
usageStrings.put(buffer.toString(), description);
|
||||
@ -181,7 +181,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||
}
|
||||
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
throw new Exception(tlLiteral("onlyPlayers", commandLabel));
|
||||
throw new TranslatableException("onlyPlayers", commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,9 +3,7 @@ package com.earth2me.essentials.signs;
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -40,7 +38,7 @@ public class SignGameMode extends EssentialsSign {
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
performSetMode(mode.toLowerCase(Locale.ENGLISH), player.getBase());
|
||||
player.sendTl("gameMode", player.playerTl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), CommonPlaceholders.displayName((IUser) player));
|
||||
player.sendTl("gameMode", player.playerTl(player.getBase().getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName());
|
||||
Trade.log("Sign", "gameMode", "Interact", username, null, username, charge, sign.getBlock().getLocation(), player.getMoney(), ess);
|
||||
charge.charge(player);
|
||||
return true;
|
||||
|
@ -28,7 +28,7 @@ public class HelpInput implements IText {
|
||||
String pluginName = "";
|
||||
String pluginNameLow = "";
|
||||
if (!match.equalsIgnoreCase("")) {
|
||||
lines.add(user.playerTl("helpMatching", match));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpMatching", match)));
|
||||
}
|
||||
|
||||
final Multimap<Plugin, Command> pluginCommands = HashMultimap.create();
|
||||
@ -50,7 +50,7 @@ public class HelpInput implements IText {
|
||||
if (pluginNameLow.equals(match)) {
|
||||
lines.clear();
|
||||
newLines.clear();
|
||||
lines.add(user.playerTl("helpFrom", p.getDescription().getName()));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpFrom", p.getDescription().getName())));
|
||||
}
|
||||
final boolean isOnWhitelist = user.isAuthorized("essentials.help." + pluginNameLow);
|
||||
|
||||
@ -69,7 +69,7 @@ public class HelpInput implements IText {
|
||||
if (pluginNameLow.contains("essentials")) {
|
||||
final String node = "essentials." + commandName;
|
||||
if (!ess.getSettings().isCommandDisabled(commandName) && user.isAuthorized(node)) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().showNonEssCommandsInHelp()) {
|
||||
@ -82,7 +82,7 @@ public class HelpInput implements IText {
|
||||
}
|
||||
|
||||
if (isOnWhitelist || user.isAuthorized("essentials.help." + pluginNameLow + "." + commandName)) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
} else if (permissions.length != 0) {
|
||||
boolean enabled = false;
|
||||
|
||||
@ -94,11 +94,11 @@ public class HelpInput implements IText {
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
} else {
|
||||
if (!ess.getSettings().hidePermissionlessHelp()) {
|
||||
pluginLines.add(user.playerTl("helpLine", commandName, commandDescription));
|
||||
pluginLines.add(AdventureUtil.miniToLegacy(user.playerTl("helpLine", commandName, commandDescription)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class HelpInput implements IText {
|
||||
break;
|
||||
}
|
||||
if (match.equalsIgnoreCase("")) {
|
||||
lines.add(user.playerTl("helpPlugin", pluginName, pluginNameLow));
|
||||
lines.add(AdventureUtil.miniToLegacy(user.playerTl("helpPlugin", pluginName, pluginNameLow)));
|
||||
}
|
||||
}
|
||||
} catch (final NullPointerException ignored) {
|
||||
|
@ -4,40 +4,55 @@ import net.ess3.api.IEssentials;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.flattener.ComponentFlattener;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.CharacterAndFormat;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.Reset;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class AdventureUtil {
|
||||
private static final LegacyComponentSerializer LEGACY_SERIALIZER;
|
||||
private static final MiniMessage MINI_MESSAGE_INSTANCE;
|
||||
private static IEssentials ess;
|
||||
private static final Pattern NAMED_PATTERN = Pattern.compile(ChatColor.COLOR_CHAR + "[0-9a-fk-orA-FK-OR]");
|
||||
private static final Pattern HEX_PATTERN = Pattern.compile(ChatColor.COLOR_CHAR + "x((?:" + ChatColor.COLOR_CHAR + "[0-9a-fA-F]){6})");
|
||||
private static final MiniMessage MINI_MESSAGE_NO_TAGS;
|
||||
private static final String LOOKUP = "0123456789abcdefklmnor";
|
||||
private static final String[] MINI_TAGS = new String[] {"black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", "white", "obf", "b", "st", "u", "i", "reset"};
|
||||
private static final NamedTextColor[] COLORS = new NamedTextColor[] {NamedTextColor.BLACK, NamedTextColor.DARK_BLUE, NamedTextColor.DARK_GREEN, NamedTextColor.DARK_AQUA, NamedTextColor.DARK_RED, NamedTextColor.DARK_PURPLE, NamedTextColor.GOLD, NamedTextColor.GRAY, NamedTextColor.DARK_GRAY, NamedTextColor.BLUE, NamedTextColor.GREEN, NamedTextColor.AQUA, NamedTextColor.RED, NamedTextColor.LIGHT_PURPLE, NamedTextColor.YELLOW, NamedTextColor.WHITE};
|
||||
private static final NamedTextColor[] COLORS = new NamedTextColor[]{NamedTextColor.BLACK, NamedTextColor.DARK_BLUE, NamedTextColor.DARK_GREEN, NamedTextColor.DARK_AQUA, NamedTextColor.DARK_RED, NamedTextColor.DARK_PURPLE, NamedTextColor.GOLD, NamedTextColor.GRAY, NamedTextColor.DARK_GRAY, NamedTextColor.BLUE, NamedTextColor.GREEN, NamedTextColor.AQUA, NamedTextColor.RED, NamedTextColor.LIGHT_PURPLE, NamedTextColor.YELLOW, NamedTextColor.WHITE};
|
||||
private static IEssentials ess;
|
||||
private static MiniMessage miniMessageInstance;
|
||||
|
||||
static {
|
||||
final LegacyComponentSerializer.Builder builder = LegacyComponentSerializer.builder().flattener(ComponentFlattener.basic()).useUnusualXRepeatedCharacterHexFormat();
|
||||
final List<CharacterAndFormat> formats = new ArrayList<>();
|
||||
formats.addAll(CharacterAndFormat.defaults());
|
||||
formats.addAll(Arrays.asList(
|
||||
CharacterAndFormat.characterAndFormat('A', NamedTextColor.GREEN),
|
||||
CharacterAndFormat.characterAndFormat('B', NamedTextColor.AQUA),
|
||||
CharacterAndFormat.characterAndFormat('C', NamedTextColor.RED),
|
||||
CharacterAndFormat.characterAndFormat('D', NamedTextColor.LIGHT_PURPLE),
|
||||
CharacterAndFormat.characterAndFormat('E', NamedTextColor.YELLOW),
|
||||
CharacterAndFormat.characterAndFormat('F', NamedTextColor.WHITE),
|
||||
CharacterAndFormat.characterAndFormat('K', TextDecoration.OBFUSCATED),
|
||||
CharacterAndFormat.characterAndFormat('L', TextDecoration.BOLD),
|
||||
CharacterAndFormat.characterAndFormat('M', TextDecoration.STRIKETHROUGH),
|
||||
CharacterAndFormat.characterAndFormat('N', TextDecoration.UNDERLINED),
|
||||
CharacterAndFormat.characterAndFormat('O', TextDecoration.ITALIC),
|
||||
CharacterAndFormat.characterAndFormat('R', Reset.INSTANCE)
|
||||
));
|
||||
final LegacyComponentSerializer.Builder builder = LegacyComponentSerializer.builder()
|
||||
.flattener(ComponentFlattener.basic())
|
||||
.formats(formats)
|
||||
.useUnusualXRepeatedCharacterHexFormat();
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_16_1_R01)) {
|
||||
builder.hexColors();
|
||||
}
|
||||
LEGACY_SERIALIZER = builder.build();
|
||||
|
||||
MINI_MESSAGE_INSTANCE = MiniMessage.builder()
|
||||
.tags(TagResolver.builder()
|
||||
.resolvers(TagResolver.standard())
|
||||
.resolver(TagResolver.resolver("primary", supplyTag(true)))
|
||||
.resolver(TagResolver.resolver("secondary", supplyTag(false)))
|
||||
.build())
|
||||
.build();
|
||||
MINI_MESSAGE_NO_TAGS = MiniMessage.miniMessage();
|
||||
|
||||
miniMessageInstance = createMiniMessageInstance();
|
||||
}
|
||||
|
||||
private AdventureUtil() {
|
||||
@ -45,10 +60,21 @@ public final class AdventureUtil {
|
||||
|
||||
public static void setEss(final IEssentials ess) {
|
||||
AdventureUtil.ess = ess;
|
||||
miniMessageInstance = createMiniMessageInstance();
|
||||
}
|
||||
|
||||
private static MiniMessage createMiniMessageInstance() {
|
||||
return MiniMessage.builder()
|
||||
.tags(TagResolver.builder()
|
||||
.resolvers(TagResolver.standard())
|
||||
.resolver(TagResolver.resolver("primary", supplyTag(true)))
|
||||
.resolver(TagResolver.resolver("secondary", supplyTag(false)))
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static MiniMessage miniMessage() {
|
||||
return MINI_MESSAGE_INSTANCE;
|
||||
return miniMessageInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,37 +107,16 @@ public final class AdventureUtil {
|
||||
|
||||
/**
|
||||
* Converts a section sign legacy string to a MiniMessage string.
|
||||
*
|
||||
* @param useCustomTags true if gold and red colors should use primary and secondary tags instead.
|
||||
*/
|
||||
public static String legacyToMini(String text, boolean useCustomTags) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Matcher matcher = HEX_PATTERN.matcher(text);
|
||||
while (matcher.find()) {
|
||||
final String code = matcher.group(1).replace(String.valueOf(ChatColor.COLOR_CHAR), "");
|
||||
matcher.appendReplacement(buffer, "<#" + code + ">");
|
||||
final Component deserializedText = LEGACY_SERIALIZER.deserialize(text);
|
||||
if (useCustomTags) {
|
||||
return miniMessageInstance.serialize(deserializedText);
|
||||
} else {
|
||||
return MINI_MESSAGE_NO_TAGS.serialize(deserializedText);
|
||||
}
|
||||
matcher.appendTail(buffer);
|
||||
|
||||
matcher = NAMED_PATTERN.matcher(buffer.toString());
|
||||
buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
final int format = LOOKUP.indexOf(Character.toLowerCase(matcher.group().charAt(1)));
|
||||
if (format != -1) {
|
||||
String tagName = MINI_TAGS[format];
|
||||
if (useCustomTags) {
|
||||
if (tagName.equals("gold")) {
|
||||
tagName = "primary";
|
||||
} else if (tagName.equals("red")) {
|
||||
tagName = "secondary";
|
||||
}
|
||||
}
|
||||
|
||||
matcher.appendReplacement(buffer, "<" + tagName + ">");
|
||||
}
|
||||
}
|
||||
matcher.appendTail(buffer);
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,6 +130,13 @@ public final class AdventureUtil {
|
||||
return COLORS[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for submodules to escape MiniMessage tags.
|
||||
*/
|
||||
public static String escapeTags(final String input) {
|
||||
return miniMessage().escapeTags(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for a translation message are not parsed for MiniMessage by default to avoid injection. If you want
|
||||
* a parameter to be parsed for MiniMessage you must wrap it in a ParsedPlaceholder by using this method.
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials.utils;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.messaging.IMessageRecipient;
|
||||
import net.ess3.api.IUser;
|
||||
|
||||
public final class CommonPlaceholders {
|
||||
private CommonPlaceholders() {
|
||||
@ -15,12 +13,4 @@ public final class CommonPlaceholders {
|
||||
public static AdventureUtil.ParsedPlaceholder trueFalse(final CommandSource source, final boolean condition) {
|
||||
return AdventureUtil.parsed(source.tl(condition ? "true" : "false"));
|
||||
}
|
||||
|
||||
public static AdventureUtil.ParsedPlaceholder displayNameRecipient(final IMessageRecipient recipient) {
|
||||
return AdventureUtil.parsed(AdventureUtil.legacyToMini(recipient.getDisplayName()));
|
||||
}
|
||||
|
||||
public static AdventureUtil.ParsedPlaceholder displayName(final IUser user) {
|
||||
return AdventureUtil.parsed(AdventureUtil.legacyToMini(user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,13 @@ public final class FormatUtil {
|
||||
return ChatColor.stripColor(input);
|
||||
}
|
||||
|
||||
public static String stripMiniFormat(final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
return AdventureUtil.miniMessage().stripTags(input);
|
||||
}
|
||||
|
||||
//This method is used to simply strip the & convention colour codes
|
||||
public static String stripEssentialsFormat(final String input) {
|
||||
if (input == null) {
|
||||
|
@ -129,6 +129,15 @@ public final class NumberUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isHexadecimal(final String sNum) {
|
||||
try {
|
||||
Integer.parseInt(sNum, 16);
|
||||
return true;
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport from Guava.
|
||||
*/
|
||||
|
@ -3,8 +3,6 @@ package com.earth2me.essentials.chat;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.EssentialsToggleCommand;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Server;
|
||||
|
||||
public class Commandtoggleshout extends EssentialsToggleCommand {
|
||||
@ -32,7 +30,7 @@ public class Commandtoggleshout extends EssentialsToggleCommand {
|
||||
|
||||
user.sendTl(enabled ? "shoutEnabled" : "shoutDisabled");
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendTl(enabled ? "shoutEnabledFor" : "shoutDisabledFor", CommonPlaceholders.displayName((IUser) user));
|
||||
sender.sendTl(enabled ? "shoutEnabledFor" : "shoutDisabledFor", user.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,8 +227,10 @@ public abstract class AbstractChatHandler {
|
||||
server.getPluginManager().callEvent(spyEvent);
|
||||
|
||||
if (!spyEvent.isCancelled()) {
|
||||
final String legacyString = AdventureUtil.miniToLegacy(String.format(spyEvent.getFormat(), AdventureUtil.legacyToMini(user.getDisplayName()), AdventureUtil.escapeTags(spyEvent.getMessage())));
|
||||
|
||||
for (final Player onlinePlayer : spyEvent.getRecipients()) {
|
||||
onlinePlayer.sendMessage(String.format(spyEvent.getFormat(), user.getDisplayName(), spyEvent.getMessage()));
|
||||
onlinePlayer.sendMessage(legacyString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,13 @@ public interface InteractionEvent {
|
||||
*/
|
||||
void reply(String message);
|
||||
|
||||
/**
|
||||
* Appends the given string to the initial response message and creates one if it doesn't exist.
|
||||
* @param tlKey The tlKey of the message to append.
|
||||
* @param args The args for the message to append.
|
||||
*/
|
||||
void replyTl(String tlKey, Object... args);
|
||||
|
||||
/**
|
||||
* Gets the member which caused this event.
|
||||
* @return the member which caused the event.
|
||||
|
@ -61,7 +61,7 @@ public class InteractionControllerImpl extends ListenerAdapter implements Intera
|
||||
final InteractionEvent interactionEvent = new InteractionEventImpl(event);
|
||||
final List<String> commandSnowflakes = jda.getSettings().getCommandSnowflakes(command.getName());
|
||||
if (commandSnowflakes != null && !DiscordUtil.hasRoles(event.getMember(), commandSnowflakes)) {
|
||||
interactionEvent.reply(tlLiteral("noAccessCommand"));
|
||||
interactionEvent.replyTl("noAccessCommand");
|
||||
return;
|
||||
}
|
||||
jda.getPlugin().getEss().scheduleSyncDelayedTask(() -> command.onCommand(interactionEvent));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.essentialsx.discord.interactions;
|
||||
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.google.common.base.Joiner;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
@ -18,6 +19,8 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tlLiteral;
|
||||
|
||||
/**
|
||||
* A class which provides information about what triggered an interaction event.
|
||||
*/
|
||||
@ -45,6 +48,11 @@ public class InteractionEventImpl implements InteractionEvent {
|
||||
.queue(null, error -> logger.log(Level.SEVERE, "Error while editing command interaction response", error));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replyTl(String tlKey, Object... args) {
|
||||
reply(AdventureUtil.miniToLegacy(tlLiteral(tlKey, args)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionMember getMember() {
|
||||
return member;
|
||||
|
@ -21,7 +21,7 @@ public class ExecuteCommand extends InteractionCommandImpl {
|
||||
@Override
|
||||
public void onCommand(final InteractionEvent event) {
|
||||
final String command = event.getStringArgument("command");
|
||||
event.reply(tlLiteral("discordCommandExecuteReply", command));
|
||||
event.replyTl("discordCommandExecuteReply", command);
|
||||
Bukkit.getScheduler().runTask(jda.getPlugin(), () -> {
|
||||
try {
|
||||
Bukkit.dispatchCommand(new DiscordCommandSender(jda, Bukkit.getConsoleSender(), message -> event.reply(MessageUtil.sanitizeDiscordMarkdown(message))).getSender(), command);
|
||||
|
@ -3,6 +3,7 @@ package net.essentialsx.discord.interactions.commands;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.PlayerList;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionCommandArgument;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionCommandArgumentType;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionEvent;
|
||||
@ -45,8 +46,8 @@ public class ListCommand extends InteractionCommandImpl {
|
||||
|
||||
final StringBuilder stringBuilder = new StringBuilder();
|
||||
for (final String str : output) {
|
||||
stringBuilder.append(str).append("\n");
|
||||
stringBuilder.append(FormatUtil.stripMiniFormat(str)).append("\n");
|
||||
}
|
||||
event.reply(MessageUtil.sanitizeDiscordMarkdown(stringBuilder.substring(0, stringBuilder.length() - 2)));
|
||||
event.reply(MessageUtil.sanitizeDiscordMarkdown(stringBuilder.substring(0, stringBuilder.length() - 1)));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.essentialsx.discord.interactions.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.PlayerNotFoundException;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionCommandArgument;
|
||||
import net.essentialsx.api.v2.services.discord.InteractionCommandArgumentType;
|
||||
@ -30,28 +31,28 @@ public class MessageCommand extends InteractionCommandImpl {
|
||||
try {
|
||||
user = jda.getPlugin().getEss().matchUser(Bukkit.getServer(), null, event.getStringArgument("username"), getHidden, false);
|
||||
} catch (PlayerNotFoundException e) {
|
||||
event.reply(tlLiteral("errorWithMessage", e.getMessage()));
|
||||
event.replyTl("errorWithMessage", e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getHidden && user.isIgnoreMsg()) {
|
||||
event.reply(tlLiteral("msgIgnore", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName())));
|
||||
event.replyTl("msgIgnore", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.isAfk()) {
|
||||
if (user.getAfkMessage() != null) {
|
||||
event.reply(tlLiteral("userAFKWithMessage", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()), MessageUtil.sanitizeDiscordMarkdown(user.getAfkMessage())));
|
||||
event.replyTl("userAFKWithMessage", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()), MessageUtil.sanitizeDiscordMarkdown(user.getAfkMessage()));
|
||||
} else {
|
||||
event.reply(tlLiteral("userAFK", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName())));
|
||||
event.replyTl("userAFK", MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
final String message = event.getMember().hasRoles(jda.getSettings().getPermittedFormattingRoles()) ?
|
||||
FormatUtil.replaceFormat(event.getStringArgument("message")) : FormatUtil.stripFormat(event.getStringArgument("message"));
|
||||
event.reply(tlLiteral("msgFormat", tlLiteral("meSender"), MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()), MessageUtil.sanitizeDiscordMarkdown(message)));
|
||||
event.replyTl("msgFormat", tlLiteral("meSender"), MessageUtil.sanitizeDiscordMarkdown(user.getDisplayName()), MessageUtil.sanitizeDiscordMarkdown(message));
|
||||
|
||||
user.sendMessage(tlLiteral("msgFormat", event.getMember().getTag(), user.playerTl("meRecipient"), message));
|
||||
user.sendTl("msgFormat", event.getMember().getTag(), AdventureUtil.parsed(user.playerTl("meRecipient")), message);
|
||||
// We use an atomic reference here so that java will garbage collect the recipient
|
||||
final AtomicReference<DiscordMessageRecipient> ref = new AtomicReference<>(new DiscordMessageRecipient(event.getMember()));
|
||||
jda.getPlugin().getEss().runTaskLaterAsynchronously(() -> ref.set(null), 6000); // Expires after 5 minutes
|
||||
|
@ -53,14 +53,14 @@ public class AccountInteractionCommand implements InteractionCommand {
|
||||
final InteractionMember effectiveUser = userArg == null ? event.getMember() : userArg;
|
||||
final IUser user = accounts.getUser(effectiveUser.getId());
|
||||
if (user == null) {
|
||||
event.reply(tlLiteral(event.getMember().getId().equals(effectiveUser.getId()) ? "discordCommandAccountResponseNotLinked" : "discordCommandAccountResponseNotLinkedOther", effectiveUser.getAsMention()));
|
||||
event.replyTl(event.getMember().getId().equals(effectiveUser.getId()) ? "discordCommandAccountResponseNotLinked" : "discordCommandAccountResponseNotLinkedOther", effectiveUser.getAsMention());
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMember().getId().equals(effectiveUser.getId())) {
|
||||
event.reply(tlLiteral("discordCommandAccountResponseLinked", user.getName()));
|
||||
event.replyTl("discordCommandAccountResponseLinked", user.getName());
|
||||
return;
|
||||
}
|
||||
event.reply(tlLiteral("discordCommandAccountResponseLinkedOther", effectiveUser.getAsMention(), user.getName()));
|
||||
event.replyTl("discordCommandAccountResponseLinkedOther", effectiveUser.getAsMention(), user.getName());
|
||||
}
|
||||
}
|
||||
|
@ -25,18 +25,18 @@ public class LinkInteractionCommand implements InteractionCommand {
|
||||
@Override
|
||||
public void onCommand(InteractionEvent event) {
|
||||
if (accounts.isLinked(event.getMember().getId())) {
|
||||
event.reply(tlLiteral("discordCommandLinkHasAccount"));
|
||||
event.replyTl("discordCommandLinkHasAccount");
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = accounts.getPendingUUID(event.getStringArgument("code"));
|
||||
if (uuid == null) {
|
||||
event.reply(tlLiteral("discordCommandLinkInvalidCode"));
|
||||
event.replyTl("discordCommandLinkInvalidCode");
|
||||
return;
|
||||
}
|
||||
|
||||
accounts.registerAccount(uuid, event.getMember(), DiscordLinkStatusChangeEvent.Cause.SYNC_PLAYER);
|
||||
event.reply(tlLiteral("discordCommandLinkLinked"));
|
||||
event.replyTl("discordCommandLinkLinked");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,10 +20,10 @@ public class UnlinkInteractionCommand implements InteractionCommand {
|
||||
@Override
|
||||
public void onCommand(InteractionEvent event) {
|
||||
if (!accounts.removeAccount(event.getMember(), DiscordLinkStatusChangeEvent.Cause.UNSYNC_PLAYER)) {
|
||||
event.reply(tlLiteral("discordCommandUnlinkInvalidCode"));
|
||||
event.replyTl("discordCommandUnlinkInvalidCode");
|
||||
return;
|
||||
}
|
||||
event.reply(tlLiteral("discordCommandUnlinkUnlinked"));
|
||||
event.replyTl("discordCommandUnlinkUnlinked");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.essentialsx.discordlink.listeners;
|
||||
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent;
|
||||
import net.essentialsx.api.v2.events.UserMailEvent;
|
||||
@ -59,7 +60,7 @@ public class LinkBukkitListener implements Listener {
|
||||
} catch (IllegalArgumentException e) {
|
||||
code = e.getMessage();
|
||||
}
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, tlLiteral("discordLinkLoginKick", "/link " + code, ess.getApi().getInviteUrl()));
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, AdventureUtil.miniToLegacy(tlLiteral("discordLinkLoginKick", "/link " + code, ess.getApi().getInviteUrl())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +154,7 @@ public class LinkBukkitListener implements Listener {
|
||||
|
||||
switch (ess.getSettings().getLinkPolicy()) {
|
||||
case KICK: {
|
||||
final Runnable kickTask = () -> event.getUser().getBase().kickPlayer(event.getUser().playerTl("discordLinkLoginKick", "/link " + finalCode, ess.getApi().getInviteUrl()));
|
||||
final Runnable kickTask = () -> event.getUser().getBase().kickPlayer(AdventureUtil.miniToLegacy(event.getUser().playerTl("discordLinkLoginKick", "/link " + finalCode, ess.getApi().getInviteUrl())));
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
kickTask.run();
|
||||
} else {
|
||||
|
@ -4,7 +4,6 @@ import com.earth2me.essentials.IConf;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.config.EssentialsConfiguration;
|
||||
import com.earth2me.essentials.utils.AdventureUtil;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarInputStream;
|
||||
import com.maxmind.geoip2.DatabaseReader;
|
||||
@ -13,7 +12,6 @@ import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CityResponse;
|
||||
import com.maxmind.geoip2.model.CountryResponse;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IUser;
|
||||
import net.essentialsx.api.v2.events.AsyncUserDataLoadEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -102,7 +100,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
|
||||
for (final Player online : player.getServer().getOnlinePlayers()) {
|
||||
final User user = ess.getUser(online);
|
||||
if (user.isAuthorized("essentials.geoip.show")) {
|
||||
user.sendTl("geoipCantFind", CommonPlaceholders.displayName((IUser) u));
|
||||
user.sendTl("geoipCantFind", u.getDisplayName());
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -121,7 +119,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf {
|
||||
for (final Player onlinePlayer : player.getServer().getOnlinePlayers()) {
|
||||
final User user = ess.getUser(onlinePlayer);
|
||||
if (user.isAuthorized("essentials.geoip.show")) {
|
||||
user.sendTl("geoipJoinFormat", CommonPlaceholders.displayName((IUser) u), sb.toString());
|
||||
user.sendTl("geoipJoinFormat", u.getDisplayName(), sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.utils.CommonPlaceholders;
|
||||
import net.ess3.api.IUser;
|
||||
import net.essentialsx.api.v2.events.UserTeleportSpawnEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@ -33,7 +31,7 @@ public class Commandspawn extends EssentialsCommand {
|
||||
future.thenAccept(success -> {
|
||||
if (success) {
|
||||
if (!otherUser.equals(user)) {
|
||||
otherUser.sendTl("teleportAtoB", CommonPlaceholders.displayName((IUser) user), "spawn");
|
||||
otherUser.sendTl("teleportAtoB", user.getDisplayName(), "spawn");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -9,5 +9,5 @@ repositories {
|
||||
dependencies {
|
||||
implementation("net.kyori", "indra-common", "3.1.3")
|
||||
implementation("com.github.johnrengelman", "shadow", "8.1.1")
|
||||
implementation("xyz.jpenilla", "run-task", "2.1.0")
|
||||
implementation("xyz.jpenilla", "run-task", "2.2.3")
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ val baseExtension = extensions.create<EssentialsBaseExtension>("essentials", pro
|
||||
|
||||
val checkstyleVersion = "8.36.2"
|
||||
val spigotVersion = "1.20.4-R0.1-SNAPSHOT"
|
||||
val junit5Version = "5.7.0"
|
||||
val mockitoVersion = "3.2.0"
|
||||
val junit5Version = "5.10.2"
|
||||
val mockitoVersion = "3.12.4"
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.junit.jupiter", "junit-jupiter", junit5Version)
|
||||
@ -26,6 +26,12 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
testLogging {
|
||||
events("PASSED", "SKIPPED", "FAILED")
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
if (baseExtension.injectBukkitApi.get()) {
|
||||
dependencies {
|
||||
@ -117,6 +123,8 @@ indra {
|
||||
javaVersions {
|
||||
target(8)
|
||||
minimumToolchain(17)
|
||||
// Don't enforce running tests on Java 8; we only care about the release for compiling, not running tests
|
||||
strictVersions(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
22
gradlew
vendored
22
gradlew
vendored
@ -83,7 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@ -130,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@ -198,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -64,8 +64,8 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OfflinePlayerStub implements Player {
|
||||
protected final transient org.bukkit.OfflinePlayer base;
|
||||
private final transient Server server;
|
||||
private final transient org.bukkit.OfflinePlayer base;
|
||||
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private transient World world;
|
||||
private boolean allowFlight = false;
|
||||
|
@ -0,0 +1,19 @@
|
||||
package net.ess3.provider.providers;
|
||||
|
||||
import net.ess3.provider.DamageEventProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class LegacyDamageEventProvider implements DamageEventProvider {
|
||||
@Override
|
||||
public EntityDamageEvent callDamageEvent(Player player, EntityDamageEvent.DamageCause cause, double damage) {
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(player, cause, damage);
|
||||
player.getServer().getPluginManager().callEvent(ede);
|
||||
return ede;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Legacy Damage Event Provider";
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package net.ess3.provider;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public interface BiomeKeyProvider extends Provider {
|
||||
NamespacedKey getBiomeKey(Block block);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user