More work on PSPlayer and porting some commands
This commit is contained in:
parent
c69fc81a87
commit
44dab9e11b
16 changed files with 1341 additions and 526 deletions
77
dist/methodmaps/PSPlayer.csv
vendored
Normal file
77
dist/methodmaps/PSPlayer.csv
vendored
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
TYPE ,CATEGORY ,NULLVALUE,RETURN TYPE ,METHODNAME ,"METHODARGUMENTS"
|
||||||
|
STATIC ,Lists ,@NotNull ,PSPlayer @NotNull [] ,getOnline ,""
|
||||||
|
STATIC ,Broadcast , ,void ,broadcast ,"@NotNull String message"
|
||||||
|
STATIC ,Broadcast , ,void ,broadcastTranslatable ,"@NotNull LanguageString languageString, boolean includePrefix, @NotNull Map.Entry<@NotNull String, @NotNull String> @Nullable ... placeholders"
|
||||||
|
STATIC ,Broadcast , ,void ,broadcastRaw ,"@NotNull String message"
|
||||||
|
CONSTRUC,Constructors , , ,<init> ,""
|
||||||
|
INSTANCE,Air left , ,int ,getLeftAir ,""
|
||||||
|
INSTANCE,Air left ,@NotNull ,PSPlayer ,setLeftAir ,"int airPoints"
|
||||||
|
INSTANCE,Attributes ,@Nullable,AttributeInstance ,getAttribute ,"@NotNull Attribute attribute"
|
||||||
|
INSTANCE,Connection , ,void ,terminate ,""
|
||||||
|
INSTANCE,Connection , ,void ,kick ,"@NotNull String reason"
|
||||||
|
INSTANCE,Connection , ,void ,kick ,"@NotNull String reason, @NotNull PlayerKickEvent.Cause cause"
|
||||||
|
INSTANCE,Connection , ,void ,kickTranslatable ,"@NotNull LanguageString languageString, @NotNull Map.Entry<@NotNull String, @NotNull String> @Nullable... placeholders"
|
||||||
|
INSTANCE,Connection , ,void ,kickTranslatable ,"@NotNull PlayerKickEvent.Cause cause, @NotNull LanguageString languageString, @NotNull Map.Entry<@NotNull String, @NotNull String> @Nullable... placeholders"
|
||||||
|
INSTANCE,Connection , ,void ,kickRaw ,"@NotNull String reason"
|
||||||
|
INSTANCE,Connection , ,void ,kickRaw ,"@NotNull String reason, @NotNull PlayerKickEvent.Cause cause"
|
||||||
|
INSTANCE,Fall distance , ,float ,getFallDistance ,""
|
||||||
|
INSTANCE,Fall distance ,@NotNull ,PSPlayer ,setFallDistance ,"float fallDistance"
|
||||||
|
INSTANCE,Gamemode ,@NotNull ,GameMode ,getGamemode ,""
|
||||||
|
INSTANCE,Gamemode ,@NotNull ,PSPlayer ,setGamemode ,"@NotNull GameMode gamemode"
|
||||||
|
INSTANCE,Getters ,@NotNull ,Player ,getBukkitPlayer ,""
|
||||||
|
INSTANCE,Getters ,@NotNull ,PSPlayer.Data ,getData ,""
|
||||||
|
INSTANCE,Health , ,double ,getHealth ,""
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,setHealth ,"double healthPoints"
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,heal ,"double healthPoints"
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,heal ,"double healthPoints, @NotNull EntityRegainHealthEvent.RegainReason reason"
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,damage ,"double healthPoints"
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,damage ,"double healthPoints, @NotNull Entity entity"
|
||||||
|
INSTANCE,Health ,@NotNull ,PSPlayer ,damage ,"double healthPoints, @NotNull DamageSource damageSource"
|
||||||
|
INSTANCE,Hunger , ,int ,getHunger ,""
|
||||||
|
INSTANCE,Hunger , ,float ,getSaturation ,""
|
||||||
|
INSTANCE,Hunger ,@NotNull ,PSPlayer ,setHunger ,"int hungerPoints"
|
||||||
|
INSTANCE,Hunger ,@NotNull ,PSPlayer ,setSaturation ,"float saturationPoints"
|
||||||
|
INSTANCE,Location ,@NotNull ,World ,getWorld ,""
|
||||||
|
INSTANCE,Location ,@NotNull ,Location ,getLocation ,""
|
||||||
|
INSTANCE,Location ,@Nullable,Location ,getRespawnLocation ,""
|
||||||
|
INSTANCE,Location ,@NotNull ,PSPlayer ,teleport ,"@NotNull Location location"
|
||||||
|
INSTANCE,Location ,@NotNull ,PSPlayer ,teleport ,"@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause"
|
||||||
|
INSTANCE,Location ,@NotNull ,PSPlayer ,teleport ,"@NotNull Location location, @NotNull TeleportFlag... flags"
|
||||||
|
INSTANCE,Location ,@NotNull ,PSPlayer ,teleport ,"@NotNull Location location, @NotNull PlayerTeleportEvent.TeleportCause cause, @NotNull TeleportFlag... flags"
|
||||||
|
INSTANCE,Messaging ,@NotNull ,PSPlayer ,message ,"@NotNull String message"
|
||||||
|
INSTANCE,Messaging ,@NotNull ,PSPlayer ,messageTranslatable ,"@NotNull LanguageString languageString, boolean includePrefix, @NotNull Map.Entry<@NotNull String, @NotNull String> @Nullable... placeholders"
|
||||||
|
INSTANCE,Messaging ,@NotNull ,PSPlayer ,messageRaw ,"@NotNull String message"
|
||||||
|
INSTANCE,Particles ,@NotNull ,PSPlayer ,particle ,"@NotNull Particle particle, int count"
|
||||||
|
INSTANCE,Particles ,@NotNull ,PSPlayer ,particle ,"@NotNull Particle particle, int count, @NotNull Location location"
|
||||||
|
INSTANCE,Permissions , ,boolean ,hasPermission ,"@NotNull String permission"
|
||||||
|
INSTANCE,Permissions , ,boolean ,hasPermission ,"@NotNull Permission permission"
|
||||||
|
INSTANCE,Player identification , ,boolean ,isOnline ,""
|
||||||
|
INSTANCE,Player identification ,@NotNull ,UUID ,getUUID ,""
|
||||||
|
INSTANCE,Player identification ,@NotNull ,String ,getUsername ,""
|
||||||
|
INSTANCE,Player identification ,@NotNull ,String ,getIdentificationString ,""
|
||||||
|
INSTANCE,Potion effects ,@NotNull ,PotionEffect @NotNull [],getPotions ,""
|
||||||
|
INSTANCE,Potion effects ,@NotNull ,PSPlayer ,getPotion ,"@NotNull PotionEffectType type"
|
||||||
|
INSTANCE,Potion effects ,@NotNull ,PSPlayer ,hasPotion ,"@NotNull PotionEffectType type"
|
||||||
|
INSTANCE,Potion effects ,@NotNull ,PSPlayer ,applyPotion ,"@NotNull PotionEffect effect"
|
||||||
|
INSTANCE,Potion effects ,@NotNull ,PSPlayer ,removePotion ,"@NotNull PotionEffectType type"
|
||||||
|
INSTANCE,Scheduling ,@NotNull ,PSPlayer ,schedule ,"@NotNull Runnable task, long delay"
|
||||||
|
INSTANCE,Scheduling ,@NotNull ,PSPlayer ,schedule ,"@NotNull Runnable task, @NotNull Runnable retired, long delay"
|
||||||
|
INSTANCE,Scheduling ,@NotNull ,PSPlayer ,scheduleRepeatedly ,"@NotNull Runnable task, long delay"
|
||||||
|
INSTANCE,Screen effects ,@NotNull ,PSPlayer ,showCredits ,""
|
||||||
|
INSTANCE,Screen effects ,@NotNull ,PSPlayer ,showDemoPopup ,""
|
||||||
|
INSTANCE,Screen effects ,@NotNull ,PSPlayer ,showElderGuardian ,""
|
||||||
|
INSTANCE,Screen effects ,@NotNull ,PSPlayer ,showElderGuardian ,"boolean silent"
|
||||||
|
INSTANCE,Sounds ,@NotNull ,PSPlayer ,sound ,"@NotNull Sound sound"
|
||||||
|
INSTANCE,Sounds ,@NotNull ,PSPlayer ,sound ,"@NotNull Key sound, @NotNull Sound.Source type, float volume, float pitch"
|
||||||
|
INSTANCE,Sounds ,@NotNull ,PSPlayer ,sound ,"@NotNull Key sound, @NotNull Sound.Source type"
|
||||||
|
INSTANCE,Sounds ,@NotNull ,PSPlayer ,stopSounds ,""
|
||||||
|
INSTANCE,Sounds ,@NotNull ,PSPlayer ,stopSound ,"@NotNull Sound sound"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,title ,""
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,title ,"@NotNull Title title"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,title ,"@Nullable Component title, @Nullable Component subtitle, @NotNull Title.Times times"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,title ,"@Nullable Component title, @Nullable Component subtitle, @NotNull Duration fadeIn, @NotNull Duration stay, @NotNull Duration fadeOut"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,title ,"@Nullable Component title, @Nullable Component subtitle, long fadeIn, long stay, long fadeOut"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,titleRaw ,"@Nullable String title, @Nullable String subtitle, @NotNull Title.Times times"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,titleRaw ,"@Nullable String title, @Nullable String subtitle, @NotNull Duration fadeIn, @NotNull Duration stay, @NotNull Duration fadeOut"
|
||||||
|
INSTANCE,Times ,@NotNull ,PSPlayer ,titleRaw ,"@Nullable String title, @Nullable String subtitle, long fadeIn, long stay, long fadeOut"
|
||||||
|
INSTANCE,Data ,@NotNull ,PSPlayer ,applyPlayerAttributes ,""
|
|
9
dist/methodmaps/template.csv
vendored
Normal file
9
dist/methodmaps/template.csv
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
TYPE ,CATEGORY ,NULLVALUE,RETURN TYPE ,METHODNAME ,"METHODARGUMENTS"
|
||||||
|
STATIC ,Getters ,@NotNull ,Class<?> @Nullable [] ,getSomeClass ,"@NotNull String name"
|
||||||
|
CONSTRUC,Constructors , , ,<init> ,""
|
||||||
|
INSTANCE,Termination , ,void ,terminate ,""
|
||||||
|
INSTANCE,Termination , ,void ,terminate ,"@NotNull Cause cause"
|
||||||
|
INSTANCE,Termination , ,void ,terminate ,"@NotNull String reason"
|
||||||
|
INSTANCE,Termination , ,void ,terminate ,"@NotNull String reason, @NotNull Cause cause"
|
||||||
|
INSTANCE,Checks , ,boolean ,exists ,"@NotNull Object thing"
|
||||||
|
INSTANCE,Checks , ,boolean ,existsWithCondition ,"@NotNull Object thing, @NotNull Condition ... conditions"
|
|
|
@ -328,6 +328,7 @@ public abstract class Command implements CommandExecutor {
|
||||||
true,
|
true,
|
||||||
entry("player", arguments[index])
|
entry("player", arguments[index])
|
||||||
));
|
));
|
||||||
|
|
||||||
throw new IllegalArgumentException("The specified target player '" + arguments[index] + "' isn't online or is invalid");
|
throw new IllegalArgumentException("The specified target player '" + arguments[index] + "' isn't online or is invalid");
|
||||||
} else
|
} else
|
||||||
player = PSPlayerFactory.get(bukkitPlayer);
|
player = PSPlayerFactory.get(bukkitPlayer);
|
||||||
|
@ -338,6 +339,42 @@ public abstract class Command implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the target player.
|
||||||
|
*
|
||||||
|
* @param player command sender
|
||||||
|
* @param arguments array of arguments
|
||||||
|
* @param index index of the player name to check at
|
||||||
|
* @return target player and if the supplied command sender was used
|
||||||
|
* @throws IndexOutOfBoundsException if the size of {@code arguments} is smaller than the specified {@code index}
|
||||||
|
* @throws IllegalCallerException if no target was specified in {@code arguments} and the sender is the server console
|
||||||
|
* @throws IllegalArgumentException if the specified target in {@code arguments} is invalid or does not exist
|
||||||
|
* @since v1-release0
|
||||||
|
*/
|
||||||
|
public static @NotNull Map.Entry<@NotNull PSPlayer, @NotNull Boolean> determineTarget(@NotNull PSPlayer player, @NotNull String @NotNull [] arguments, int index) throws IndexOutOfBoundsException, IllegalCallerException, IllegalArgumentException {
|
||||||
|
if (arguments.length == index) {
|
||||||
|
return entry(player, true);
|
||||||
|
} else if (arguments.length > index) {
|
||||||
|
Player bukkitPlayer = Bukkit.getPlayer(arguments[index]);
|
||||||
|
PSPlayer target;
|
||||||
|
|
||||||
|
if (bukkitPlayer == null) {
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.ERROR_PLAYER_NOT_FOUND,
|
||||||
|
true,
|
||||||
|
entry("player", arguments[index])
|
||||||
|
);
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("The specified target player '" + arguments[index] + "' isn't online or is invalid");
|
||||||
|
} else
|
||||||
|
target = PSPlayerFactory.get(bukkitPlayer);
|
||||||
|
|
||||||
|
return entry(target, target.getUsername().equals(player.getUsername()));
|
||||||
|
} else {
|
||||||
|
throw new IndexOutOfBoundsException("Size of 'arguments' is smaller than the specified 'index'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----> Inner classes
|
// -----> Inner classes
|
||||||
/**
|
/**
|
||||||
* Represents by whom a command can be used.
|
* Represents by whom a command can be used.
|
||||||
|
@ -417,7 +454,7 @@ public abstract class Command implements CommandExecutor {
|
||||||
@NotNull String description,
|
@NotNull String description,
|
||||||
@NotNull String syntax,
|
@NotNull String syntax,
|
||||||
@NotNull String mode,
|
@NotNull String mode,
|
||||||
@Range(from = 0, to = 2) int @Nullable [] executionOrder,
|
@NotNull String @Nullable [] executionOrder,
|
||||||
@NotNull Command.ExecutionTarget executionTarget
|
@NotNull Command.ExecutionTarget executionTarget
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
|
@ -426,28 +463,28 @@ public abstract class Command implements CommandExecutor {
|
||||||
*/
|
*/
|
||||||
public Information {
|
public Information {
|
||||||
if (executionOrder == null)
|
if (executionOrder == null)
|
||||||
executionOrder = new int[]{ 0, 1, 2 };
|
executionOrder = new String[]{ "all", "console", "player" };
|
||||||
|
|
||||||
// Verify 'executionOrder'
|
// Verify 'executionOrder'
|
||||||
// -> Amount of items
|
// -> Amount of items
|
||||||
if (executionOrder.length != 3)
|
if (executionOrder.length != 3)
|
||||||
throw new IllegalStateException("'executionOrder' does not contain exactly three items");
|
throw new IllegalStateException("'executionOrder' does not contain exactly three items");
|
||||||
|
|
||||||
// -> Bounds
|
// -> Options
|
||||||
if (
|
if (
|
||||||
(executionOrder[0] < 0 || executionOrder[0] > 2)
|
(!executionOrder[0].equals("all") && !executionOrder[0].equals("console") && !executionOrder[0].equals("player"))
|
||||||
|| (executionOrder[1] < 0 || executionOrder[1] > 2)
|
|| (!executionOrder[1].equals("all") && !executionOrder[1].equals("console") && !executionOrder[1].equals("player"))
|
||||||
|| (executionOrder[2] < 0 || executionOrder[2] > 2)
|
|| (!executionOrder[2].equals("all") && !executionOrder[2].equals("console") && !executionOrder[2].equals("player"))
|
||||||
)
|
)
|
||||||
throw new IllegalStateException("Some item in 'executionOrder' is either smaller than '0' or bigger than '2'");
|
throw new IllegalStateException("Some item in 'executionOrder' is neither \"all\", \"console\" nor \"player\"");
|
||||||
|
|
||||||
// -> Duplicate values
|
// -> Duplicate values
|
||||||
if (
|
if (
|
||||||
executionOrder[0] == executionOrder[1]
|
executionOrder[0].equals(executionOrder[1])
|
||||||
|| executionOrder[0] == executionOrder[2]
|
|| executionOrder[0].equals(executionOrder[2])
|
||||||
|| executionOrder[1] == executionOrder[2]
|
|| executionOrder[1].equals(executionOrder[2])
|
||||||
)
|
)
|
||||||
throw new IllegalStateException("Two or more items in 'executionOrder' have the same value");
|
throw new IllegalStateException("Duplicate values found in 'executionOrder'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -78,10 +78,10 @@ public enum LanguageString {
|
||||||
|
|
||||||
// Command group 'links'
|
// Command group 'links'
|
||||||
LINKS_WEBSITE,
|
LINKS_WEBSITE,
|
||||||
LINKS_FORUM,
|
LINKS_MESSAGEBOARD,
|
||||||
LINKS_DISCORD,
|
|
||||||
LINKS_TEAMSPEAK,
|
|
||||||
LINKS_MUMBLE,
|
LINKS_MUMBLE,
|
||||||
|
LINKS_TEAMSPEAK,
|
||||||
|
LINKS_DISCORD,
|
||||||
|
|
||||||
// Command /clearchat
|
// Command /clearchat
|
||||||
CLEARCHAT_GENERIC,
|
CLEARCHAT_GENERIC,
|
||||||
|
@ -92,6 +92,7 @@ public enum LanguageString {
|
||||||
|
|
||||||
// Command /home
|
// Command /home
|
||||||
HOME,
|
HOME,
|
||||||
|
HOME_OTHER,
|
||||||
HOME_NORESPAWN,
|
HOME_NORESPAWN,
|
||||||
HOME_NORESPAWN_OTHER,
|
HOME_NORESPAWN_OTHER,
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ public final class LinkCommand extends Command {
|
||||||
|
|
||||||
switch (alias) {
|
switch (alias) {
|
||||||
case "website" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_WEBSITE, sender, true));
|
case "website" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_WEBSITE, sender, true));
|
||||||
case "forum", "messageboard", "mb" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_FORUM, sender, true));
|
case "forum", "messageboard", "mb" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_MESSAGEBOARD, sender, true));
|
||||||
case "discord", "dc" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_DISCORD, sender, true));
|
case "discord", "dc" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_DISCORD, sender, true));
|
||||||
case "teamspeak", "ts" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_TEAMSPEAK, sender, true));
|
case "teamspeak", "ts" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_TEAMSPEAK, sender, true));
|
||||||
case "mumble" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_MUMBLE, sender, true));
|
case "mumble" -> sender.sendRichMessage(TranslationManager.get(LanguageString.LINKS_MUMBLE, sender, true));
|
||||||
|
|
|
@ -23,16 +23,15 @@ import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayerFactory;
|
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import de.jeremystartm.pickshadow.extension.api.type.PlayerAttribute;
|
import de.jeremystartm.pickshadow.extension.api.type.PlayerAttribute;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +91,7 @@ public final class SpeedCommand extends Command {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) {
|
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
if (checkPermission(sender, "pickshadow.command.speed")) return;
|
if (checkPermission(sender, "pickshadow.command.speed")) return;
|
||||||
|
|
||||||
// Check length of 'arguments'
|
// Check length of 'arguments'
|
||||||
|
@ -104,8 +103,8 @@ public final class SpeedCommand extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onSelf;
|
|
||||||
PSPlayer target;
|
PSPlayer target;
|
||||||
|
boolean onSelf;
|
||||||
float speed;
|
float speed;
|
||||||
boolean mode;
|
boolean mode;
|
||||||
|
|
||||||
|
@ -149,46 +148,13 @@ public final class SpeedCommand extends Command {
|
||||||
if (speed < 0f)
|
if (speed < 0f)
|
||||||
speed = 0f;
|
speed = 0f;
|
||||||
|
|
||||||
// Get player/'target'
|
// Get 'target' and 'onSelf'
|
||||||
switch (arguments.length) {
|
try {
|
||||||
case 2 -> {
|
Map.Entry<@NotNull PSPlayer, @NotNull Boolean> targetEntry = determineTarget(sender, arguments, 2);
|
||||||
onSelf = true;
|
target = targetEntry.getKey();
|
||||||
|
onSelf = targetEntry.getValue();
|
||||||
// Check if command sender is a player
|
} catch (Exception exception) {
|
||||||
if (sender instanceof Player senderPlayer)
|
return;
|
||||||
target = PSPlayerFactory.get(senderPlayer);
|
|
||||||
else {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_NOT_A_PLAYER, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 3 -> {
|
|
||||||
Player bukkitPlayer = Bukkit.getPlayer(arguments[2]);
|
|
||||||
|
|
||||||
// Check if 'bukkitPlayer' is null
|
|
||||||
if (bukkitPlayer == null) {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", arguments[2])
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set 'onSelf'
|
|
||||||
try {
|
|
||||||
onSelf = bukkitPlayer.getName().equals(sender.getName());
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
onSelf = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set 'target'
|
|
||||||
target = PSPlayerFactory.get(bukkitPlayer);
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set speed
|
// Set speed
|
||||||
|
|
|
@ -19,23 +19,20 @@
|
||||||
|
|
||||||
package de.jeremystartm.pickshadow.extension.command.general;
|
package de.jeremystartm.pickshadow.extension.command.general;
|
||||||
|
|
||||||
import de.jeremystartm.pickshadow.extension.Extension;
|
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayerFactory;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.title.Title;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -90,7 +87,7 @@ public final class TrollCommand extends Command {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) {
|
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
if (checkPermission(sender, "pickshadow.command.troll"))
|
if (checkPermission(sender, "pickshadow.command.troll"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -99,87 +96,124 @@ public final class TrollCommand extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = Bukkit.getPlayer(arguments[0]);
|
// Determine target
|
||||||
if (target == null) {
|
PSPlayer target;
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND, sender, true, entry("player", arguments[0])));
|
try {
|
||||||
|
target = PSPlayerFactory.get(arguments[0]);
|
||||||
|
} catch (NullPointerException exception) {
|
||||||
|
sender.sendRichMessage(TranslationManager.get(
|
||||||
|
LanguageString.ERROR_PLAYER_NOT_FOUND,
|
||||||
|
sender,
|
||||||
|
true,
|
||||||
|
entry("player", arguments[0])
|
||||||
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (arguments[1]) {
|
switch (arguments[1]) {
|
||||||
case "crash" -> {
|
case "crash" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CRASH, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(
|
||||||
for (int i = 0; i < 10000; i++)
|
LanguageString.TROLL_CRASH,
|
||||||
target.spawnParticle(Particle.EXPLOSION, target.getLocation(), 100000);
|
sender,
|
||||||
|
true,
|
||||||
|
entry("target", target.getUsername())
|
||||||
|
));
|
||||||
|
//for (int i = 0; i < 10000; i++)
|
||||||
|
// target.particle(Particle.EXPLOSION, 1000000, target.getLocation());
|
||||||
|
target.terminate();
|
||||||
}
|
}
|
||||||
case "credits" -> {
|
case "credits" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREDITS, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREDITS, sender, true, entry("target", target.getUsername())));
|
||||||
target.showWinScreen();
|
target.showCredits();
|
||||||
}
|
}
|
||||||
case "creeper" -> {
|
case "creeper" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREEPER, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREEPER, sender, true, entry("target", target.getUsername())));
|
||||||
target.playSound(Sound.sound(Key.key("minecraft:entity.creeper.primed"), Sound.Source.MASTER, 1f, 1f));
|
target.sound(Key.key("minecraft:entity.creeper.primed"), Sound.Source.MASTER);
|
||||||
}
|
}
|
||||||
case "demo" -> {
|
case "demo" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_DEMO, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_DEMO, sender, true, entry("target", target.getUsername())));
|
||||||
target.showDemoScreen();
|
target.showDemoPopup();
|
||||||
}
|
}
|
||||||
case "guardian" -> {
|
case "guardian" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_GUARDIAN, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_GUARDIAN, sender, true, entry("target", target.getUsername())));
|
||||||
target.showElderGuardian();
|
target.showElderGuardian();
|
||||||
}
|
}
|
||||||
case "hack" -> {
|
case "hack" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_HACK, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_HACK, sender, true, entry("target", target.getUsername())));
|
||||||
String format = "<dark_red><bold><obfuscated>";
|
String format = "<dark_red><bold><obfuscated>";
|
||||||
|
|
||||||
// Ugly but it works
|
// Ugly but it works
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + ":/45v.8r9(VU$R)w.9ruv"),
|
MiniMessage.miniMessage().deserialize(format + ":/45v.8r9(VU$R)w.9ruv"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 20);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 20);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "tI=)$t0,ivAEr9+"),
|
MiniMessage.miniMessage().deserialize(format + "tI=)$t0,ivAEr9+"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 60);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 60);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "(U$T98vtiIÜ$)TU9i"),
|
MiniMessage.miniMessage().deserialize(format + "(U$T98vtiIÜ$)TU9i"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 100);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 100);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "L.f-.3_F:_34-,ldMVams"),
|
MiniMessage.miniMessage().deserialize(format + "L.f-.3_F:_34-,ldMVams"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 140);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 140);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + ")$u095u921,EFJKDA"),
|
MiniMessage.miniMessage().deserialize(format + ")$u095u921,EFJKDA"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 180);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 180);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "joIV;;0p98v"),
|
MiniMessage.miniMessage().deserialize(format + "joIV;;0p98v"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 220);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 220);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "IV)=RI(VT=)l9re"),
|
MiniMessage.miniMessage().deserialize(format + "IV)=RI(VT=)l9re"),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 260);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 260);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize(format + "$KL%98vu9485u20k8lü="),
|
MiniMessage.miniMessage().deserialize(format + "$KL%98vu9485u20k8lü="),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
|
Duration.ofMillis(0),
|
||||||
)), null, 300);
|
Duration.ofSeconds(5),
|
||||||
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
|
Duration.ofMillis(0)
|
||||||
|
), 300);
|
||||||
|
target.schedule(() -> target.title(
|
||||||
MiniMessage.miniMessage().deserialize("<dark_red><bold>" + TranslationManager.get(LanguageString.TROLL_HACK_COMPLETE, target, false)),
|
MiniMessage.miniMessage().deserialize("<dark_red><bold>" + TranslationManager.get(LanguageString.TROLL_HACK_COMPLETE, target, false)),
|
||||||
Component.empty(),
|
null,
|
||||||
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(500))
|
Duration.ofMillis(0),
|
||||||
)), null, 340);
|
Duration.ofSeconds(5),
|
||||||
|
Duration.ofMillis(500)
|
||||||
|
), 340);
|
||||||
}
|
}
|
||||||
case "heavens" -> {
|
case "heavens" -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_HEAVENS, sender, true, entry("target", target.getName())));
|
sender.sendRichMessage(TranslationManager.get(
|
||||||
|
LanguageString.TROLL_HEAVENS,
|
||||||
|
sender,
|
||||||
|
true,
|
||||||
|
entry("target", target.getUsername())
|
||||||
|
));
|
||||||
|
|
||||||
Location location = target.getLocation();
|
Location location = target.getLocation();
|
||||||
location.setY(10000);
|
location.setY(10000);
|
||||||
|
|
|
@ -22,16 +22,15 @@ package de.jeremystartm.pickshadow.extension.command.general.replacement;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.craftbukkit.command.ServerCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
|
@ -85,22 +84,19 @@ public final class GamemodeCommand extends Command {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) throws Exception {
|
protected void invokeConsole(@NotNull ServerCommandSender console, @NotNull String alias, @NotNull String[] arguments) throws Exception {
|
||||||
if (checkPermission(sender, "pickshadow.command.gamemode")) return;
|
|
||||||
|
|
||||||
// Check length of 'arguments'
|
// Check length of 'arguments'
|
||||||
if (arguments.length == 0) {
|
if (arguments.length == 0) {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_FEW_ARGUMENTS, sender, true));
|
console.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_FEW_ARGUMENTS, console, true));
|
||||||
return;
|
return;
|
||||||
} else if (arguments.length > 2) {
|
} else if (arguments.length > 2) {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
console.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, console, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean onSelf;
|
|
||||||
GameMode gamemode;
|
GameMode gamemode;
|
||||||
LanguageString gamemodeTranslation;
|
LanguageString gamemodeTranslation;
|
||||||
Player target;
|
PSPlayer target;
|
||||||
|
|
||||||
// Determine gamemode
|
// Determine gamemode
|
||||||
switch (arguments[0]) {
|
switch (arguments[0]) {
|
||||||
|
@ -121,9 +117,9 @@ public final class GamemodeCommand extends Command {
|
||||||
gamemodeTranslation = LanguageString.GAMEMODE_SPECTATOR;
|
gamemodeTranslation = LanguageString.GAMEMODE_SPECTATOR;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(
|
console.sendRichMessage(TranslationManager.get(
|
||||||
LanguageString.ERROR_INVALID_ARGUMENT,
|
LanguageString.ERROR_INVALID_ARGUMENT,
|
||||||
sender,
|
console,
|
||||||
true,
|
true,
|
||||||
entry("argument", arguments[0])
|
entry("argument", arguments[0])
|
||||||
));
|
));
|
||||||
|
@ -131,60 +127,110 @@ public final class GamemodeCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get player
|
// Determine 'target'
|
||||||
switch (arguments.length) {
|
try {
|
||||||
case 1 -> {
|
target = determineTarget(console, arguments, 1).getKey();
|
||||||
onSelf = true;
|
} catch (Exception exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if command sender is a player
|
// Set gamemode
|
||||||
if (sender instanceof Player senderPlayer)
|
updateTargetGamemode(target, gamemode, gamemodeTranslation);
|
||||||
target = senderPlayer;
|
|
||||||
else {
|
// Send success message to console
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_NOT_A_PLAYER, sender, true));
|
console.sendRichMessage(TranslationManager.get(
|
||||||
return;
|
LanguageString.GAMEMODE_REMOTE,
|
||||||
}
|
console,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername()),
|
||||||
|
entry("gamemode", TranslationManager.get(gamemodeTranslation, target, false))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
protected void invokePlayer(@NotNull PSPlayer player, @NotNull String alias, @NotNull String[] arguments) throws Exception {
|
||||||
|
if (checkPermission(player, "pickshadow.command.gamemode")) return;
|
||||||
|
|
||||||
|
// Check length of 'arguments'
|
||||||
|
if (arguments.length == 0) {
|
||||||
|
player.messageTranslatable(LanguageString.ERROR_TOO_FEW_ARGUMENTS, true);
|
||||||
|
return;
|
||||||
|
} else if (arguments.length > 2) {
|
||||||
|
player.messageTranslatable(LanguageString.ERROR_TOO_MANY_ARGUMENTS, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMode gamemode;
|
||||||
|
LanguageString gamemodeTranslation;
|
||||||
|
PSPlayer target;
|
||||||
|
boolean onSelf;
|
||||||
|
|
||||||
|
// Determine gamemode
|
||||||
|
switch (arguments[0]) {
|
||||||
|
case "0", "survival" -> {
|
||||||
|
gamemode = GameMode.SURVIVAL;
|
||||||
|
gamemodeTranslation = LanguageString.GAMEMODE_SURVIVAL;
|
||||||
}
|
}
|
||||||
case 2 -> {
|
case "1", "creative" -> {
|
||||||
target = Bukkit.getPlayer(arguments[1]);
|
gamemode = GameMode.CREATIVE;
|
||||||
try {
|
gamemodeTranslation = LanguageString.GAMEMODE_CREATIVE;
|
||||||
onSelf = Objects.requireNonNull(target).getName().equals(sender.getName());
|
}
|
||||||
} catch (NullPointerException exception) {
|
case "2", "adventure" -> {
|
||||||
onSelf = false;
|
gamemode = GameMode.ADVENTURE;
|
||||||
}
|
gamemodeTranslation = LanguageString.GAMEMODE_ADVENTURE;
|
||||||
|
}
|
||||||
// Check if 'target' is null
|
case "3", "spectator" -> {
|
||||||
if (target == null) {
|
gamemode = GameMode.SPECTATOR;
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND,
|
gamemodeTranslation = LanguageString.GAMEMODE_SPECTATOR;
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", arguments[1])
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
player.messageTranslatable(
|
||||||
|
LanguageString.ERROR_INVALID_ARGUMENT,
|
||||||
|
true,
|
||||||
|
entry("argument", arguments[0])
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set game mode
|
// Determine 'target' and 'onSelf'
|
||||||
target.setGameMode(gamemode);
|
try {
|
||||||
|
Map.Entry<@NotNull PSPlayer, @NotNull Boolean> targetEntry = determineTarget(player, arguments, 1);
|
||||||
|
target = targetEntry.getKey();
|
||||||
|
onSelf = targetEntry.getValue();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set gamemode
|
||||||
|
updateTargetGamemode(target, gamemode, gamemodeTranslation);
|
||||||
|
|
||||||
|
// Send success message to sender
|
||||||
|
if (!onSelf)
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.GAMEMODE_REMOTE,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername()),
|
||||||
|
entry("gamemode", TranslationManager.get(gamemodeTranslation, target, false))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the gamemode of the specified target player.
|
||||||
|
*
|
||||||
|
* @param target target player to update the gamemode for
|
||||||
|
* @param gamemode gamemode to switch to
|
||||||
|
* @param gamemodeTranslation matching {@link LanguageString} for the specified gamemode
|
||||||
|
*/
|
||||||
|
private static void updateTargetGamemode(@NotNull PSPlayer target, @NotNull GameMode gamemode, @NotNull LanguageString gamemodeTranslation) {
|
||||||
|
target.setGamemode(gamemode);
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
target.sendRichMessage(TranslationManager.get(
|
target.messageTranslatable(
|
||||||
LanguageString.GAMEMODE,
|
LanguageString.GAMEMODE,
|
||||||
target,
|
|
||||||
true,
|
true,
|
||||||
entry("gamemode", TranslationManager.get(gamemodeTranslation, target, false))
|
entry("gamemode", TranslationManager.get(gamemodeTranslation, target, false))
|
||||||
));
|
);
|
||||||
if (!onSelf)
|
|
||||||
sender.sendRichMessage(TranslationManager.get(
|
|
||||||
LanguageString.GAMEMODE_REMOTE,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", target.getName()),
|
|
||||||
entry("gamemode", TranslationManager.get(gamemodeTranslation, target, false))
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,16 @@
|
||||||
package de.jeremystartm.pickshadow.extension.command.survival;
|
package de.jeremystartm.pickshadow.extension.command.survival;
|
||||||
|
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StubTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.craftbukkit.command.ServerCommandSender;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
|
@ -52,7 +51,8 @@ public final class HomeCommand extends Command {
|
||||||
* @return tab completion
|
* @return tab completion
|
||||||
* @since v1-release0
|
* @since v1-release0
|
||||||
*/
|
*/
|
||||||
private final @NotNull TabCompletion completion = StubTabCompletion.completion();
|
private final @NotNull TabCompletion completion = new StaticTabCompletion()
|
||||||
|
.players("", 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and initializes an instance of
|
* Creates and initializes an instance of
|
||||||
|
@ -74,64 +74,83 @@ public final class HomeCommand extends Command {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) {
|
protected void invokeConsole(@NotNull ServerCommandSender console, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
if (checkPermission(sender, "pickshadow.command.home")) return;
|
PSPlayer target;
|
||||||
|
|
||||||
boolean onSelf;
|
// Parse arguments
|
||||||
Player player;
|
try {
|
||||||
|
target = determineTarget(console, arguments, 0).getKey();
|
||||||
// Get player
|
} catch (Exception exception) {
|
||||||
switch (arguments.length) {
|
return;
|
||||||
case 0 -> {
|
|
||||||
onSelf = true;
|
|
||||||
|
|
||||||
// Check if command sender is a player
|
|
||||||
if (sender instanceof Player senderPlayer)
|
|
||||||
player = senderPlayer;
|
|
||||||
else {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_NOT_A_PLAYER, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 1 -> {
|
|
||||||
player = Bukkit.getPlayer(arguments[0]);
|
|
||||||
try {
|
|
||||||
onSelf = !Objects.requireNonNull(player).getName().equals(sender.getName());
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
onSelf = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if 'player' is null
|
|
||||||
if (player == null) {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", arguments[0])
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teleport player
|
if (teleportTarget(target))
|
||||||
if (player.getRespawnLocation() == null)
|
console.sendRichMessage(TranslationManager.get(
|
||||||
if (onSelf)
|
LanguageString.HOME_OTHER,
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.HOME_NORESPAWN, sender, true));
|
console,
|
||||||
else
|
true,
|
||||||
sender.sendRichMessage(TranslationManager.get(
|
entry("target", target.getUsername())
|
||||||
LanguageString.HOME_NORESPAWN_OTHER,
|
));
|
||||||
sender,
|
else
|
||||||
|
console.sendRichMessage(TranslationManager.get(
|
||||||
|
LanguageString.HOME_NORESPAWN_OTHER,
|
||||||
|
console,
|
||||||
|
true,
|
||||||
|
entry("target", target.getUsername())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
protected void invokePlayer(@NotNull PSPlayer player, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
|
if (checkPermission(player, "pickshadow.command.home")) return;
|
||||||
|
|
||||||
|
PSPlayer target;
|
||||||
|
boolean onSelf;
|
||||||
|
|
||||||
|
// Parse arguments
|
||||||
|
try {
|
||||||
|
Map.Entry<@NotNull PSPlayer, @NotNull Boolean> targetEntry = determineTarget(player, arguments, 0);
|
||||||
|
target = targetEntry.getKey();
|
||||||
|
onSelf = targetEntry.getValue();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teleportTarget(target)) {
|
||||||
|
if (!onSelf)
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.HOME_OTHER,
|
||||||
true,
|
true,
|
||||||
entry("player", player.getName())
|
entry("target", target.getUsername())
|
||||||
));
|
);
|
||||||
|
} else
|
||||||
|
if (onSelf)
|
||||||
|
player.messageTranslatable(LanguageString.HOME_NORESPAWN, true);
|
||||||
|
else
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.HOME_NORESPAWN_OTHER,
|
||||||
|
true,
|
||||||
|
entry("target", target.getUsername())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports the specified target player to their respawn point.
|
||||||
|
*
|
||||||
|
* @param target target to teleport
|
||||||
|
* @return teleportation successful?
|
||||||
|
* @since v1-release0
|
||||||
|
*/
|
||||||
|
private static boolean teleportTarget(@NotNull PSPlayer target) {
|
||||||
|
// Teleport target
|
||||||
|
if (target.getRespawnLocation() == null)
|
||||||
|
return false;
|
||||||
else {
|
else {
|
||||||
player.teleport(player.getRespawnLocation());
|
target.teleport(target.getRespawnLocation());
|
||||||
player.setFallDistance(0f);
|
target.setFallDistance(0f);
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.HOME, sender, true));
|
target.messageTranslatable(LanguageString.HOME, true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,14 @@ package de.jeremystartm.pickshadow.extension.command.survivalcheat;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.craftbukkit.command.ServerCommandSender;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.*;
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
|
@ -73,63 +72,70 @@ public final class FeedCommand extends Command {
|
||||||
), "feed");
|
), "feed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
protected void invokeConsole(@NotNull ServerCommandSender console, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
|
PSPlayer target;
|
||||||
|
|
||||||
|
// Parse arguments
|
||||||
|
try {
|
||||||
|
target = determineTarget(console, arguments, 0).getKey();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heal target
|
||||||
|
feedTarget(target);
|
||||||
|
|
||||||
|
// Send success message to console
|
||||||
|
console.sendRichMessage(TranslationManager.get(
|
||||||
|
LanguageString.HEAL_REMOTE,
|
||||||
|
console,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) {
|
protected void invokePlayer(@NotNull PSPlayer player, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
if (checkPermission(sender, "pickshadow.command.feed")) return;
|
if (checkPermission(player, "pickshadow.command.heal")) return;
|
||||||
|
|
||||||
Player player;
|
|
||||||
|
|
||||||
|
PSPlayer target;
|
||||||
boolean onSelf;
|
boolean onSelf;
|
||||||
|
|
||||||
// Get player
|
// Parse arguments
|
||||||
switch (arguments.length) {
|
try {
|
||||||
case 0 -> {
|
Map.Entry<@NotNull PSPlayer, @NotNull Boolean> targetEntry = determineTarget(player, arguments, 0);
|
||||||
onSelf = true;
|
target = targetEntry.getKey();
|
||||||
|
onSelf = targetEntry.getValue();
|
||||||
// Check if command sender is a player
|
} catch (Exception exception) {
|
||||||
if (sender instanceof Player senderPlayer)
|
return;
|
||||||
player = senderPlayer;
|
|
||||||
else {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_NOT_A_PLAYER, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 1 -> {
|
|
||||||
player = Bukkit.getPlayer(arguments[0]);
|
|
||||||
try {
|
|
||||||
onSelf = Objects.requireNonNull(player).getName().equals(sender.getName());
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
onSelf = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if 'player' is null
|
|
||||||
if (player == null) {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", arguments[0])
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heal player
|
// Heal player
|
||||||
player.setFoodLevel(20);
|
feedTarget(target);
|
||||||
|
|
||||||
|
// Send success message to sender
|
||||||
|
if (!onSelf)
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.FEED_REMOTE,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heals the specified target player.
|
||||||
|
*
|
||||||
|
* @param target target player to heal
|
||||||
|
* @since v1-release0
|
||||||
|
*/
|
||||||
|
private static void feedTarget(@NotNull PSPlayer target) {
|
||||||
|
// Heal
|
||||||
|
target.setHunger(20);
|
||||||
|
target.setSaturation(20);
|
||||||
|
|
||||||
// Send success message
|
// Send success message
|
||||||
player.sendRichMessage(TranslationManager.get(LanguageString.FEED, player, true));
|
target.messageTranslatable(LanguageString.FEED, true);
|
||||||
if (!onSelf)
|
|
||||||
sender.sendRichMessage(TranslationManager.get(
|
|
||||||
LanguageString.FEED_REMOTE,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", player.getName())
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,22 +23,18 @@ import de.jeremystartm.pickshadow.extension.BuildOptions;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
import de.jeremystartm.pickshadow.extension.api.command.Command;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.TabCompletion;
|
||||||
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
import de.jeremystartm.pickshadow.extension.api.command.completion.StaticTabCompletion;
|
||||||
|
import de.jeremystartm.pickshadow.extension.api.entity.player.PSPlayer;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
import de.jeremystartm.pickshadow.extension.api.translation.LanguageString;
|
||||||
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
import de.jeremystartm.pickshadow.extension.api.translation.TranslationManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.craftbukkit.command.ServerCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static java.util.Map.entry;
|
import static java.util.Map.entry;
|
||||||
|
|
||||||
|
@ -84,77 +80,90 @@ public final class HealCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
protected void invokeConsole(@NotNull ServerCommandSender console, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
protected void invokeAll(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] arguments) {
|
|
||||||
if (checkPermission(sender, "pickshadow.command.heal")) return;
|
|
||||||
|
|
||||||
Player player;
|
|
||||||
List<@NotNull String> argumentsList = new ArrayList<>(Arrays.stream(arguments).toList());
|
List<@NotNull String> argumentsList = new ArrayList<>(Arrays.stream(arguments).toList());
|
||||||
|
boolean allEffects;
|
||||||
|
boolean keepEffects;
|
||||||
|
PSPlayer target;
|
||||||
|
|
||||||
boolean onSelf;
|
// Parse arguments
|
||||||
boolean keepEffects = argumentsList.remove("--keep-effects");
|
try {
|
||||||
|
allEffects = argumentsList.remove("--all-effects");
|
||||||
|
keepEffects = argumentsList.remove("--keep-effects");
|
||||||
|
target = determineTarget(console, argumentsList.toArray(new String[0]), 0).getKey();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heal target
|
||||||
|
healTarget(target, allEffects, keepEffects);
|
||||||
|
|
||||||
|
// Send success message to console
|
||||||
|
console.sendRichMessage(TranslationManager.get(
|
||||||
|
LanguageString.HEAL_REMOTE,
|
||||||
|
console,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername())
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
|
protected void invokePlayer(@NotNull PSPlayer player, @NotNull String alias, @NotNull String @NotNull [] arguments) {
|
||||||
|
if (checkPermission(player, "pickshadow.command.heal")) return;
|
||||||
|
|
||||||
|
List<@NotNull String> argumentsList = new ArrayList<>(Arrays.stream(arguments).toList());
|
||||||
boolean allEffects = argumentsList.remove("--all-effects");
|
boolean allEffects = argumentsList.remove("--all-effects");
|
||||||
|
boolean keepEffects = argumentsList.remove("--keep-effects");
|
||||||
|
PSPlayer target;
|
||||||
|
boolean onSelf;
|
||||||
|
|
||||||
// Get player
|
// Parse arguments
|
||||||
switch (argumentsList.size()) {
|
try {
|
||||||
case 0 -> {
|
Map.Entry<@NotNull PSPlayer, @NotNull Boolean> targetEntry = determineTarget(player, argumentsList.toArray(new String[0]), 0);
|
||||||
onSelf = true;
|
target = targetEntry.getKey();
|
||||||
|
onSelf = targetEntry.getValue();
|
||||||
// Check if command sender is a player
|
} catch (Exception exception) {
|
||||||
if (sender instanceof Player senderPlayer)
|
return;
|
||||||
player = senderPlayer;
|
|
||||||
else {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_NOT_A_PLAYER, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 1 -> {
|
|
||||||
player = Bukkit.getPlayer(argumentsList.getFirst());
|
|
||||||
try {
|
|
||||||
onSelf = Objects.requireNonNull(player).getName().equals(sender.getName());
|
|
||||||
} catch (NullPointerException exception) {
|
|
||||||
onSelf = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if 'player' is null
|
|
||||||
if (player == null) {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", argumentsList.getFirst())
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_MANY_ARGUMENTS, sender, true));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heal player
|
// Heal player
|
||||||
player.heal(Objects.requireNonNull(player.getAttribute(Attribute.MAX_HEALTH)).getValue() - player.getHealth(), EntityRegainHealthEvent.RegainReason.MAGIC);
|
healTarget(target, allEffects, keepEffects);
|
||||||
player.setFoodLevel(20);
|
|
||||||
player.setSaturation(20);
|
// Send success message to sender
|
||||||
player.setRemainingAir(300);
|
if (!onSelf)
|
||||||
|
player.messageTranslatable(
|
||||||
|
LanguageString.HEAL_REMOTE,
|
||||||
|
true,
|
||||||
|
entry("player", target.getUsername())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heals the specified target player.
|
||||||
|
*
|
||||||
|
* @param target target player to heal
|
||||||
|
* @param allEffects whether to remove all effects
|
||||||
|
* @param keepEffects whether to keep all effects
|
||||||
|
* @since v1-release0
|
||||||
|
*/
|
||||||
|
private static void healTarget(@NotNull PSPlayer target, boolean allEffects, boolean keepEffects) {
|
||||||
|
// Heal
|
||||||
|
target.heal(Objects.requireNonNull(target.getAttribute(Attribute.MAX_HEALTH)).getValue() - target.getHealth(), EntityRegainHealthEvent.RegainReason.MAGIC);
|
||||||
|
target.setHunger(20);
|
||||||
|
target.setSaturation(20);
|
||||||
|
target.setAirLeft(300);
|
||||||
|
|
||||||
// Reset bad or all effects
|
// Reset bad or all effects
|
||||||
if (!keepEffects)
|
if (!keepEffects)
|
||||||
if (allEffects)
|
if (allEffects)
|
||||||
for (PotionEffect effect : player.getActivePotionEffects())
|
for (PotionEffect effect : target.getPotions())
|
||||||
player.removePotionEffect(effect.getType());
|
target.removePotion(effect.getType());
|
||||||
else
|
else
|
||||||
for (PotionEffectType effectType : BuildOptions.SETTINGS_EFFECTS_DAMAGING)
|
for (PotionEffectType effectType : BuildOptions.SETTINGS_EFFECTS_DAMAGING)
|
||||||
player.removePotionEffect(effectType);
|
target.removePotion(effectType);
|
||||||
|
|
||||||
// Send success message
|
// Send success message
|
||||||
player.sendRichMessage(TranslationManager.get(LanguageString.HEAL, player, true));
|
target.messageTranslatable(LanguageString.HEAL, true);
|
||||||
if (!onSelf)
|
|
||||||
sender.sendRichMessage(TranslationManager.get(
|
|
||||||
LanguageString.HEAL_REMOTE,
|
|
||||||
sender,
|
|
||||||
true,
|
|
||||||
entry("player", player.getName())
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,20 +68,18 @@ public final class ChatListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void handleChatMessage(@NotNull AsyncChatEvent event) {
|
public void handleChatMessage(@NotNull AsyncChatEvent event) {
|
||||||
PSPlayer player = PSPlayerFactory.get(event.getPlayer());
|
PSPlayer player = PSPlayerFactory.get(event.getPlayer());
|
||||||
|
String message = MiniMessage.miniMessage().serialize(event.originalMessage());
|
||||||
|
|
||||||
// Cancel chat message
|
// Cancel chat message
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Broadcast the message ourselves
|
// Broadcast the message ourselves
|
||||||
if (!BuildOptions.SMALLSTUFF_CHAT_COMMENTS || !MiniMessage.miniMessage().serialize(event.originalMessage()).startsWith("#"))
|
if (!BuildOptions.SMALLSTUFF_CHAT_COMMENTS || !message.startsWith("#"))
|
||||||
PSPlayer.broadcast(
|
PSPlayer.broadcastTranslatable(
|
||||||
TranslationManager.get(
|
LanguageString.MESSAGING_SERVER,
|
||||||
LanguageString.MESSAGING_SERVER,
|
false,
|
||||||
player.getBukkitPlayer(),
|
entry("sender", player.getUsername()),
|
||||||
false,
|
entry("message", message.replace("\\<", "<"))
|
||||||
entry("sender", player.getUsername())
|
|
||||||
)
|
|
||||||
+ MiniMessage.miniMessage().serialize(event.originalMessage()).replace("\\<", "<")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public final class DamageDetection {
|
||||||
if (BuildOptions.SMALLSTUFF_STONECUTTER_DAMAGE)
|
if (BuildOptions.SMALLSTUFF_STONECUTTER_DAMAGE)
|
||||||
switch (player.getData().getDamageState(STONECUTTER)) {
|
switch (player.getData().getDamageState(STONECUTTER)) {
|
||||||
case -1 -> {
|
case -1 -> {
|
||||||
Location location = player.getPosition().clone();
|
Location location = player.getLocation().clone();
|
||||||
location.setX((long) location.getX() - 1);
|
location.setX((long) location.getX() - 1);
|
||||||
location.setY(((long) location.getY()));
|
location.setY(((long) location.getY()));
|
||||||
location.setZ((long) location.getZ());
|
location.setZ((long) location.getZ());
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
"MESSAGING_ERROR_NOLASTCONTACT": "<error>Du hast in der letzten Zeit keinen angeschrieben.</error>",
|
"MESSAGING_ERROR_NOLASTCONTACT": "<error>Du hast in der letzten Zeit keinen angeschrieben.</error>",
|
||||||
|
|
||||||
"LINKS_WEBSITE": "<error>Das PickShadow Netzwerk hat aktuell keine Webseite.</error>",
|
"LINKS_WEBSITE": "<error>Das PickShadow Netzwerk hat aktuell keine Webseite.</error>",
|
||||||
"LINKS_FORUM": "<error>Das PickShadow Netzwerk hat aktuell kein Forum.</error>",
|
"LINKS_MESSAGEBOARD": "<error>Das PickShadow Netzwerk hat aktuell kein Forum.</error>",
|
||||||
"LINKS_DISCORD": "<error>Das PickShadow Netzwerk hat aktuell keine Discord Guilde.</error>",
|
|
||||||
"LINKS_TEAMSPEAK": "<error>Das PickShadow Netzwerk hat aktuell keinen TeamSpeak Server.</error>",
|
|
||||||
"LINKS_MUMBLE": "<error>Das PickShadow Netzwerk hat aktuell keinen Mumble Server.</error>",
|
"LINKS_MUMBLE": "<error>Das PickShadow Netzwerk hat aktuell keinen Mumble Server.</error>",
|
||||||
|
"LINKS_TEAMSPEAK": "<error>Das PickShadow Netzwerk hat aktuell keinen TeamSpeak Server.</error>",
|
||||||
|
"LINKS_DISCORD": "<error>Das PickShadow Netzwerk hat aktuell keine Discord Guilde.</error>",
|
||||||
|
|
||||||
"CLEARCHAT_GENERIC": "<generic>Der Chat wurde von %sender% geleert.</generic>",
|
"CLEARCHAT_GENERIC": "<generic>Der Chat wurde von %sender% geleert.</generic>",
|
||||||
"CLEARCHAT_VOID": "<generic>Der Chat wurde von %sender% ins Void geschubst.</generic>",
|
"CLEARCHAT_VOID": "<generic>Der Chat wurde von %sender% ins Void geschubst.</generic>",
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
"CLEARCHAT_BRAINDAMAGE": "<generic>Um weitverbreitenden Gehirnschaden zu verhinden, hat %sender% den Chat geleert.</generic>",
|
"CLEARCHAT_BRAINDAMAGE": "<generic>Um weitverbreitenden Gehirnschaden zu verhinden, hat %sender% den Chat geleert.</generic>",
|
||||||
"CLEARCHAT_CRINGE": "<generic>Aufgrund von Massen an Cringe musste %sender% den Chat leeren.</generic>",
|
"CLEARCHAT_CRINGE": "<generic>Aufgrund von Massen an Cringe musste %sender% den Chat leeren.</generic>",
|
||||||
|
|
||||||
|
"HOME_OTHER": "<generic><mention>%target%</mention> wurde zu seinem/ihrem Respawnpunkt teleportiert.</generic>",
|
||||||
"HOME_NORESPAWN": "<error>Du hast keinen gültigen Respawnpunkt.</error>\n<error>Stelle sicher, dass dein Bett oder Respawn Anker nicht abgebaut oder behindert ist.</error>",
|
"HOME_NORESPAWN": "<error>Du hast keinen gültigen Respawnpunkt.</error>\n<error>Stelle sicher, dass dein Bett oder Respawn Anker nicht abgebaut oder behindert ist.</error>",
|
||||||
"HOME_NORESPAWN_OTHER": "<error><mention>%player%</mention> hat keinen gültigen Respawnpunkt.</error>\n<error><mention>%player%</mention>'s Bett oder Respawn Anker wurde entweder abgebaut oder ist behindert.</error>",
|
"HOME_NORESPAWN_OTHER": "<error><mention>%player%</mention> hat keinen gültigen Respawnpunkt.</error>\n<error><mention>%player%</mention>'s Bett oder Respawn Anker wurde entweder abgebaut oder ist behindert.</error>",
|
||||||
|
|
||||||
|
|
|
@ -36,17 +36,17 @@
|
||||||
|
|
||||||
"LEGACYEXTENSIONCMD": "<error>What's <mention>PSSP</mention>...?</error>\n<error>The PickShadow Server <italic>Plugin</italic> (PSSP) has been renamed into PickShadow Server <italic>Extension</italic> (PSSE).</error>\n<error>Please use the new name from now on. Thank you.</error>",
|
"LEGACYEXTENSIONCMD": "<error>What's <mention>PSSP</mention>...?</error>\n<error>The PickShadow Server <italic>Plugin</italic> (PSSP) has been renamed into PickShadow Server <italic>Extension</italic> (PSSE).</error>\n<error>Please use the new name from now on. Thank you.</error>",
|
||||||
|
|
||||||
"MESSAGING_SERVER": "<mention>%sender%</mention> <#d60532>»</#d60532> ",
|
"MESSAGING_SERVER": "<mention>%sender%</mention> <#d60532>»</#d60532> %message%",
|
||||||
"MESSAGING_DIRECT": "<generic><mention>%from%</mention> » <mention>%to%</mention> » </generic>%message%",
|
"MESSAGING_DIRECT": "<generic><mention>%from%</mention> » <mention>%to%</mention> » </generic>%message%",
|
||||||
"MESSAGING_LASTCONTACT": "<generic>The last person you've messaged is <mention>%contact%</mention>.</generic>",
|
"MESSAGING_LASTCONTACT": "<generic>The last person you've messaged is <mention>%contact%</mention>.</generic>",
|
||||||
"MESSAGING_ERROR_SELF": "<error>You can't message yourself.</error>",
|
"MESSAGING_ERROR_SELF": "<error>You can't message yourself.</error>",
|
||||||
"MESSAGING_ERROR_NOLASTCONTACT": "<error>You haven't messaged anyone recently.</error>",
|
"MESSAGING_ERROR_NOLASTCONTACT": "<error>You haven't messaged anyone recently.</error>",
|
||||||
|
|
||||||
"LINKS_WEBSITE": "<error>The PickShadow Network doesn't currently have a website.</error>",
|
"LINKS_WEBSITE": "<error>The PickShadow Network doesn't currently have a website.</error>",
|
||||||
"LINKS_FORUM": "<error>The PickShadow Network doesn't currently have a forum.</error>",
|
"LINKS_MESSAGEBOARD": "<error>The PickShadow Network doesn't currently have a forum.</error>",
|
||||||
"LINKS_DISCORD": "<error>The PickShadow Network doesn't currently have a Discord guild.</error>",
|
|
||||||
"LINKS_TEAMSPEAK": "<error>The PickShadow Network doesn't currently have a TeamSpeak server.</error>",
|
|
||||||
"LINKS_MUMBLE": "<error>The PickShadow Network doesn't currently have a Mumble server.</error>",
|
"LINKS_MUMBLE": "<error>The PickShadow Network doesn't currently have a Mumble server.</error>",
|
||||||
|
"LINKS_TEAMSPEAK": "<error>The PickShadow Network doesn't currently have a TeamSpeak server.</error>",
|
||||||
|
"LINKS_DISCORD": "<error>The PickShadow Network doesn't currently have a Discord guild.</error>",
|
||||||
|
|
||||||
"CLEARCHAT_GENERIC": "<generic>The chat has been cleared by %sender%.</generic>",
|
"CLEARCHAT_GENERIC": "<generic>The chat has been cleared by %sender%.</generic>",
|
||||||
"CLEARCHAT_VOID": "<generic>The chat has been pushed into the void by %sender%.</generic>",
|
"CLEARCHAT_VOID": "<generic>The chat has been pushed into the void by %sender%.</generic>",
|
||||||
|
@ -55,6 +55,7 @@
|
||||||
"CLEARCHAT_CRINGE": "<generic>Due to masses of cringe, %sender% had to clear the chat.</generic>",
|
"CLEARCHAT_CRINGE": "<generic>Due to masses of cringe, %sender% had to clear the chat.</generic>",
|
||||||
|
|
||||||
"HOME": "<generic><italic>... woosh ...</italic></generic>",
|
"HOME": "<generic><italic>... woosh ...</italic></generic>",
|
||||||
|
"HOME_OTHER": "<generic><mention>%target%</mention> was teleported to their spawn point.</generic>",
|
||||||
"HOME_NORESPAWN": "<error>You do not have a valid respawn point.</error>\n<error>Please make sure your bed or respawn anchor isn't missing or obstructed.</error>",
|
"HOME_NORESPAWN": "<error>You do not have a valid respawn point.</error>\n<error>Please make sure your bed or respawn anchor isn't missing or obstructed.</error>",
|
||||||
"HOME_NORESPAWN_OTHER": "<error><mention>%player%</mention> does not have a valid respawn point.</error>\n<error><mention>%player%</mention>'s bed or respawn anchor is either missing or obstructed.</error>",
|
"HOME_NORESPAWN_OTHER": "<error><mention>%player%</mention> does not have a valid respawn point.</error>\n<error><mention>%player%</mention>'s bed or respawn anchor is either missing or obstructed.</error>",
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@
|
||||||
"HEAL": "<generic>You have been healed.</generic>",
|
"HEAL": "<generic>You have been healed.</generic>",
|
||||||
"HEAL_REMOTE": "<generic><mention>%player%</mention> has been healed.</generic>",
|
"HEAL_REMOTE": "<generic><mention>%player%</mention> has been healed.</generic>",
|
||||||
|
|
||||||
|
"FEED": "<generic>You have been fed.</generic>",
|
||||||
|
"FEED_REMOTE": "<generic><mention>%player%</mention> has been fed.</generic>",
|
||||||
|
|
||||||
"PLUGINS": "<generic><mention>%count%</mention> extensions are installed on this subserver, these being:</generic>",
|
"PLUGINS": "<generic><mention>%count%</mention> extensions are installed on this subserver, these being:</generic>",
|
||||||
"PLUGINS_FAKE": "<generic>Do you really think you can get internal information so easily?</generic>\n<generic>Luckily, we aren't dicks and credit what we use.\n<generic>The PickShadow network uses <click:open_url:%link_psse%><link>PSSE</link></click>, <click:open_url:%link_luckperms%><link>LuckPerms</link></click>, <click:open_url:%link_viaversion%><link>ViaVersion</link></click> and <click:open_url:%link_freedomchat%><link>FreedomChat</link></click> to manage subservers.",
|
"PLUGINS_FAKE": "<generic>Do you really think you can get internal information so easily?</generic>\n<generic>Luckily, we aren't dicks and credit what we use.\n<generic>The PickShadow network uses <click:open_url:%link_psse%><link>PSSE</link></click>, <click:open_url:%link_luckperms%><link>LuckPerms</link></click>, <click:open_url:%link_viaversion%><link>ViaVersion</link></click> and <click:open_url:%link_freedomchat%><link>FreedomChat</link></click> to manage subservers.",
|
||||||
"PLUGINS_ENTRY_PREFIX": "<generic>- ",
|
"PLUGINS_ENTRY_PREFIX": "<generic>- ",
|
||||||
|
|
Loading…
Reference in a new issue