2018-08-06 00:36:30 +00:00
|
|
|
package pw.kaboom.icontrolu;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
import org.bukkit.scoreboard.Team;
|
|
|
|
|
|
|
|
public class Main extends JavaPlugin {
|
2019-12-15 05:32:41 +00:00
|
|
|
static HashMap<UUID, Player> controllerFor = new HashMap<>();
|
|
|
|
static HashMap<UUID, Player> targetFor = new HashMap<>();
|
2018-08-06 00:36:30 +00:00
|
|
|
|
|
|
|
public void onEnable() {
|
2019-12-15 05:32:41 +00:00
|
|
|
/* Setup scoreboard team to prevent player collisions */
|
|
|
|
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
|
|
|
final Team team = scoreboard.getTeam("icuDisableCollision");
|
2018-08-06 00:36:30 +00:00
|
|
|
if (team != null) {
|
|
|
|
team.unregister();
|
|
|
|
}
|
|
|
|
|
2019-12-15 05:32:41 +00:00
|
|
|
/* Commands */
|
|
|
|
this.getCommand("icu").setExecutor(new CommandIcu());
|
2018-08-06 00:36:30 +00:00
|
|
|
|
2019-12-15 05:32:41 +00:00
|
|
|
new Tick().runTaskTimer(this, 0, 1);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new Events(), this);
|
2018-08-06 00:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onDisable() {
|
|
|
|
for (Player controller: Bukkit.getOnlinePlayers()) {
|
2019-12-15 05:32:41 +00:00
|
|
|
final Player target = Main.targetFor.get(controller.getUniqueId());
|
|
|
|
|
2018-08-06 00:36:30 +00:00
|
|
|
if (target != null) {
|
|
|
|
for (Player player: Bukkit.getOnlinePlayers()) {
|
2019-08-01 14:23:35 +00:00
|
|
|
player.showPlayer(this, controller);
|
2018-08-06 00:36:30 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 05:32:41 +00:00
|
|
|
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
|
|
|
final Team team = scoreboard.getTeam("icuDisableCollision");
|
|
|
|
|
2018-08-06 00:36:30 +00:00
|
|
|
if (team != null) {
|
|
|
|
team.unregister();
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
|
|
|
controller.sendMessage("You are no longer controlling \"" + target.getName() + "\" due to server reload");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|