Update Paper API & Use adventure for messages (#9)
* Update Paper API & Use adventure for messages * Compile with Java 17 i almost forgor * Remove the unused `ChatColor` import (which i probably should have removed before) * oops i messed up the usage
This commit is contained in:
parent
c18d750bf8
commit
b80b443de3
|
@ -15,7 +15,7 @@ jobs:
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 8
|
java-version: 17
|
||||||
|
|
||||||
- name: Cache maven packages to speed up build
|
- name: Cache maven packages to speed up build
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
|
|
9
pom.xml
9
pom.xml
|
@ -5,17 +5,18 @@
|
||||||
<version>master</version>
|
<version>master</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.test.skip>true</maven.test.skip>
|
<maven.test.skip>true</maven.test.skip>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import pw.kaboom.icontrolu.utilities.PlayerList;
|
import pw.kaboom.icontrolu.utilities.PlayerList;
|
||||||
|
|
||||||
class Tick extends BukkitRunnable {
|
class Tick extends BukkitRunnable {
|
||||||
|
@ -228,12 +230,12 @@ class ControlPlayer implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||||
controller.sendMessage("You are now visible");
|
controller.sendMessage(Component.text("You are now visible"));
|
||||||
}
|
}
|
||||||
}.runTaskLater(JavaPlugin.getPlugin(Main.class), tickDelay);
|
}.runTaskLater(JavaPlugin.getPlugin(Main.class), tickDelay);
|
||||||
|
|
||||||
otherPlayer.sendMessage("The player you were controlling has disconnected. "
|
otherPlayer.sendMessage(Component.text("The player you were controlling has "
|
||||||
+ "You are invisible for 10 seconds.");
|
+ "disconnected. You are invisible for 10 seconds."));
|
||||||
|
|
||||||
} else if (PlayerList.getTarget(player.getUniqueId()) != null
|
} else if (PlayerList.getTarget(player.getUniqueId()) != null
|
||||||
&& PlayerList.getTarget(player.getUniqueId()).equals(otherPlayer)) {
|
&& PlayerList.getTarget(player.getUniqueId()).equals(otherPlayer)) {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import pw.kaboom.icontrolu.commands.CommandIcu;
|
import pw.kaboom.icontrolu.commands.CommandIcu;
|
||||||
import pw.kaboom.icontrolu.utilities.PlayerList;
|
import pw.kaboom.icontrolu.utilities.PlayerList;
|
||||||
|
|
||||||
|
@ -45,8 +47,11 @@ public final class Main extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||||
controller.sendMessage("You are no longer controlling \"" + target.getName()
|
controller.sendMessage(
|
||||||
+ "\" due to server reload");
|
Component.text("You are no longer controlling \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\" due to server reload"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package pw.kaboom.icontrolu.commands;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -15,13 +14,17 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
import pw.kaboom.icontrolu.Main;
|
import pw.kaboom.icontrolu.Main;
|
||||||
import pw.kaboom.icontrolu.utilities.PlayerList;
|
import pw.kaboom.icontrolu.utilities.PlayerList;
|
||||||
|
|
||||||
public final class CommandIcu implements CommandExecutor {
|
public final class CommandIcu implements CommandExecutor {
|
||||||
private void controlCommand(final Player controller, final String label, final String[] args) {
|
private void controlCommand(final Player controller, final String label, final String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " control <player>");
|
controller.sendMessage(Component
|
||||||
|
.text("Usage: /" + label + " control <player>", NamedTextColor.RED));
|
||||||
} else {
|
} else {
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
Player target = Bukkit.getPlayer(args[1]);
|
||||||
|
|
||||||
|
@ -31,18 +34,27 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (target == controller) {
|
if (target == controller) {
|
||||||
controller.sendMessage("You are already controlling yourself");
|
controller.sendMessage(Component.text("You are already controlling yourself"));
|
||||||
} else if (PlayerList.getTarget(controller.getUniqueId()) != null) {
|
} else if (PlayerList.getTarget(controller.getUniqueId()) != null) {
|
||||||
controller.sendMessage("You are already controlling \""
|
controller.sendMessage(
|
||||||
+ target.getName() + "\"");
|
Component.text("You are already controlling \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\""))
|
||||||
|
);
|
||||||
} else if (PlayerList.getController(target.getUniqueId()) != null) {
|
} else if (PlayerList.getController(target.getUniqueId()) != null) {
|
||||||
controller.sendMessage("Player \"" + target.getName()
|
controller.sendMessage(
|
||||||
+ "\" is already being controlled");
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\" is already being controlled"))
|
||||||
|
);
|
||||||
} else if (PlayerList.getTarget(target.getUniqueId()) != null) {
|
} else if (PlayerList.getTarget(target.getUniqueId()) != null) {
|
||||||
controller.sendMessage("Player \"" + target.getName()
|
controller.sendMessage(
|
||||||
+ "\" is already controlling another player");
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\" is already controlling another player"))
|
||||||
|
);
|
||||||
} else if (!controller.canSee(target)) {
|
} else if (!controller.canSee(target)) {
|
||||||
controller.sendMessage("You may not control this player");
|
controller.sendMessage(Component.text("You may not control this player"));
|
||||||
} else {
|
} else {
|
||||||
controller.teleportAsync(target.getLocation());
|
controller.teleportAsync(target.getLocation());
|
||||||
|
|
||||||
|
@ -51,10 +63,18 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
PlayerList.setTarget(controller.getUniqueId(), target);
|
PlayerList.setTarget(controller.getUniqueId(), target);
|
||||||
PlayerList.setController(target.getUniqueId(), controller);
|
PlayerList.setController(target.getUniqueId(), controller);
|
||||||
|
|
||||||
controller.sendMessage("You are now controlling \"" + target.getName() + "\"");
|
controller.sendMessage(
|
||||||
|
Component.text("You are now controlling \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\""))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
controller.sendMessage("Player \"" + args[1] + "\" not found");
|
controller.sendMessage(
|
||||||
|
Component.text("Player \"")
|
||||||
|
.append(Component.text(args[1]))
|
||||||
|
.append(Component.text("\" not found"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,16 +102,21 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||||
controller.sendMessage("You are now visible");
|
controller.sendMessage(Component.text("You are now visible"));
|
||||||
}
|
}
|
||||||
}.runTaskLater(JavaPlugin.getPlugin(Main.class), tickDelay);
|
}.runTaskLater(JavaPlugin.getPlugin(Main.class), tickDelay);
|
||||||
|
|
||||||
final int seconds = tickDelay / 20;
|
final int seconds = tickDelay / 20;
|
||||||
|
|
||||||
controller.sendMessage("You are no longer controlling \"" + target.getName()
|
controller.sendMessage(
|
||||||
+ "\". You are invisible for " + seconds + " seconds.");
|
Component.text("You are no longer controlling \"")
|
||||||
|
.append(Component.text(target.getName()))
|
||||||
|
.append(Component.text("\". You are invisible for "))
|
||||||
|
.append(Component.text(seconds))
|
||||||
|
.append(Component.text(" seconds."))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
controller.sendMessage("You are not controlling anyone at the moment");
|
controller.sendMessage(Component.text("You are not controlling anyone at the moment"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,14 +124,15 @@ public final class CommandIcu implements CommandExecutor {
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label,
|
public boolean onCommand(final CommandSender sender, final Command command, final String label,
|
||||||
final String[] args) {
|
final String[] args) {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Command has to be run by a player");
|
sender.sendMessage(Component.text("Command has to be run by a player"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player controller = (Player) sender;
|
final Player controller = (Player) sender;
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " <control|stop>");
|
controller.sendMessage(Component
|
||||||
|
.text("Usage: /" + label + " <control|stop>", NamedTextColor.RED));
|
||||||
} else if (args[0].equalsIgnoreCase("control")) {
|
} else if (args[0].equalsIgnoreCase("control")) {
|
||||||
controlCommand(controller, label, args);
|
controlCommand(controller, label, args);
|
||||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||||
|
|
Loading…
Reference in New Issue