Initial MC 1.13.2 support (todo: cleanup)

This commit is contained in:
mathias 2019-08-01 17:23:35 +03:00
parent cf9dfaefce
commit e99aef29d0
5 changed files with 31 additions and 16 deletions

18
pom.xml
View file

@ -5,15 +5,15 @@
<version>master</version> <version>master</version>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>1.6</maven.compiler.target>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version> <version>1.13.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
@ -26,6 +26,18 @@
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build> </build>
</project> </project>

View file

@ -38,6 +38,8 @@ class CommandIcu implements CommandExecutor {
controller.sendMessage("Player \"" + target.getName() + "\" is already being controlled"); controller.sendMessage("Player \"" + target.getName() + "\" is already being controlled");
} else if (main.targetFor.containsKey(target.getUniqueId())) { } else if (main.targetFor.containsKey(target.getUniqueId())) {
controller.sendMessage("Player \"" + target.getName() + "\" is already controlling another player"); controller.sendMessage("Player \"" + target.getName() + "\" is already controlling another player");
} else if (controller.canSee(target) == false) {
controller.sendMessage("You may not control this player");
} else { } else {
controller.teleport(target); controller.teleport(target);
@ -63,13 +65,13 @@ class CommandIcu implements CommandExecutor {
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
public void run() { public void run() {
for (Player player: Bukkit.getOnlinePlayers()) { for (Player player: Bukkit.getOnlinePlayers()) {
player.showPlayer(controllerRun); player.showPlayer(main, controllerRun);
} }
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = scoreboard.getTeam("iControlU_List"); Team team = scoreboard.getTeam("iControlU_List");
if (team != null && team.hasPlayer(controllerRun) == true) { if (team != null && team.hasEntry(controllerRun.getName()) == true) {
team.removePlayer(controllerRun); team.removeEntry(controllerRun.getName());
} }
controllerRun.removePotionEffect(PotionEffectType.INVISIBILITY); controllerRun.removePotionEffect(PotionEffectType.INVISIBILITY);

View file

@ -51,7 +51,7 @@ class Tick extends BukkitRunnable {
} }
if (target.getHealth() > 0) { if (target.getHealth() > 0) {
target.teleport(controller); target.teleportAsync(controller.getLocation());
} }
target.setAllowFlight(controller.getAllowFlight()); target.setAllowFlight(controller.getAllowFlight());
@ -64,7 +64,7 @@ class Tick extends BukkitRunnable {
target.setSprinting(controller.isSprinting()); target.setSprinting(controller.isSprinting());
for (Player player: Bukkit.getOnlinePlayers()) { for (Player player: Bukkit.getOnlinePlayers()) {
player.hidePlayer(controller); player.hidePlayer(main, controller);
} }
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
@ -76,8 +76,8 @@ class Tick extends BukkitRunnable {
team.setCanSeeFriendlyInvisibles(false); team.setCanSeeFriendlyInvisibles(false);
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER); team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
if (team.hasPlayer(controller) == false) { if (team.hasEntry(controller.getName()) == false) {
team.addPlayer(controller); team.addEntry(controller.getName());
} }
controller.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999, 0, false, false)); controller.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 99999, 0, false, false));
@ -177,13 +177,13 @@ class Events implements Listener {
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
public void run() { public void run() {
for (Player allPlayers: Bukkit.getOnlinePlayers()) { for (Player allPlayers: Bukkit.getOnlinePlayers()) {
allPlayers.showPlayer(controller); allPlayers.showPlayer(main, controller);
} }
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = scoreboard.getTeam("iControlU_List"); Team team = scoreboard.getTeam("iControlU_List");
if (team != null && team.hasPlayer(controller) == true) { if (team != null && team.hasEntry(controller.getName()) == true) {
team.removePlayer(controller); team.removeEntry(controller.getName());
} }
controller.removePotionEffect(PotionEffectType.INVISIBILITY); controller.removePotionEffect(PotionEffectType.INVISIBILITY);
@ -208,7 +208,7 @@ class Events implements Listener {
if (main.controllerFor.containsKey(player.getUniqueId())) { if (main.controllerFor.containsKey(player.getUniqueId())) {
Player controller = main.controllerFor.get(player.getUniqueId()); Player controller = main.controllerFor.get(player.getUniqueId());
controller.teleport(player); controller.teleportAsync(player.getLocation());
} }
} }
} }

View file

@ -36,7 +36,7 @@ public class Main extends JavaPlugin {
Player target = Main.targetFor.get(controller.getUniqueId()); Player target = Main.targetFor.get(controller.getUniqueId());
if (target != null) { if (target != null) {
for (Player player: Bukkit.getOnlinePlayers()) { for (Player player: Bukkit.getOnlinePlayers()) {
player.showPlayer(controller); player.showPlayer(this, controller);
} }
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();

View file

@ -1,6 +1,7 @@
name: iControlU name: iControlU
main: pw.kaboom.icontrolu.Main main: pw.kaboom.icontrolu.Main
description: Plugin that allows players to control other players. description: Plugin that allows players to control other players.
api-version: 1.13
version: master version: master
commands: commands: