forked from kaboomserver/extras
Replace string concatenation with appending text components (#325)
* Replace string concatenation with appending text
* Fix inconsistent indentation
oops
* indentation
i forgor 💀
This commit is contained in:
parent
03a2fec6f4
commit
a1007853dd
4 changed files with 35 additions and 12 deletions
|
@ -46,15 +46,20 @@ public final class CommandJumpscare implements CommandExecutor {
|
||||||
final Player target = Bukkit.getPlayer(args[0]);
|
final Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage(Component
|
sender.sendMessage(
|
||||||
.text("Player \"" + args[0] + "\" not found"));
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(args[0]))
|
||||||
|
.append(Component.text("\" not found"))
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
createJumpscare(target);
|
createJumpscare(target);
|
||||||
sender.sendMessage(Component
|
sender.sendMessage(
|
||||||
.text("Successfully created jumpscare for player \""
|
Component.text("Successfully created jumpscare for player \"")
|
||||||
+ target.getName() + "\""));
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\""))
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,27 @@ public final class CommandPumpkin implements CommandExecutor {
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
placePumpkin(onlinePlayer);
|
placePumpkin(onlinePlayer);
|
||||||
}
|
}
|
||||||
sender.sendMessage("Everyone is now a pumpkin");
|
sender.sendMessage(Component.text("Everyone is now a pumpkin"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player target = Bukkit.getPlayer(args[0]);
|
final Player target = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage("Player \"" + args[0] + "\" not found");
|
sender.sendMessage(
|
||||||
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(args[0]))
|
||||||
|
.append(Component.text("\" not found"))
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
placePumpkin(target);
|
placePumpkin(target);
|
||||||
sender.sendMessage("Player \"" + target.getName() + "\" is now a pumpkin");
|
sender.sendMessage(
|
||||||
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\" is now a pumpkin"))
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,11 @@ public final class CommandUsername implements CommandExecutor {
|
||||||
player.setPlayerProfile(profile);
|
player.setPlayerProfile(profile);
|
||||||
millis = System.currentTimeMillis();
|
millis = System.currentTimeMillis();
|
||||||
|
|
||||||
player.sendMessage(Component
|
player.sendMessage(
|
||||||
.text("Successfully set your username to \"" + name + "\""));
|
Component.text("Successfully set your username to \"")
|
||||||
|
.append(Component.text(name))
|
||||||
|
.append(Component.text("\""))
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
@ -40,7 +42,11 @@ public final class SkinDownloader {
|
||||||
profile.setProperty(new ProfileProperty("textures", texture, signature));
|
profile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||||
|
|
||||||
if (shouldSendMessage) {
|
if (shouldSendMessage) {
|
||||||
player.sendMessage("Successfully set your skin to " + name + "'s");
|
player.sendMessage(
|
||||||
|
Component.text("Successfully set your skin to ")
|
||||||
|
.append(Component.text(name))
|
||||||
|
.append(Component.text("'s"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
try {
|
try {
|
||||||
|
@ -50,7 +56,8 @@ public final class SkinDownloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldSendMessage) {
|
if (shouldSendMessage) {
|
||||||
player.sendMessage("A player with that username doesn't exist");
|
player.sendMessage(Component
|
||||||
|
.text("A player with that username doesn't exist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue