2018-08-06 00:36:30 +00:00
|
|
|
package pw.kaboom.icontrolu;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2019-12-17 16:59:28 +00:00
|
|
|
import org.bukkit.potion.PotionEffectType;
|
2018-08-06 00:36:30 +00:00
|
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
import org.bukkit.scoreboard.Team;
|
|
|
|
|
2019-12-17 16:59:28 +00:00
|
|
|
import pw.kaboom.icontrolu.commands.CommandIcu;
|
|
|
|
import pw.kaboom.icontrolu.utilities.PlayerList;
|
2018-08-06 00:36:30 +00:00
|
|
|
|
2019-12-17 16:59:28 +00:00
|
|
|
public final class Main extends JavaPlugin {
|
2022-05-20 02:21:46 +00:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
/* Setup scoreboard team to prevent player collisions */
|
|
|
|
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
|
|
|
final Team team = scoreboard.getTeam("icuCollision");
|
|
|
|
if (team != null) {
|
|
|
|
team.unregister();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Commands */
|
|
|
|
this.getCommand("icu").setExecutor(new CommandIcu());
|
|
|
|
|
|
|
|
new Tick().runTaskTimer(this, 0, 1);
|
|
|
|
this.getServer().getPluginManager().registerEvents(new ControlPlayer(), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
for (Player controller: Bukkit.getOnlinePlayers()) {
|
|
|
|
final Player target = PlayerList.getTarget(controller.getUniqueId());
|
|
|
|
|
|
|
|
if (target != null) {
|
|
|
|
for (Player player: Bukkit.getOnlinePlayers()) {
|
|
|
|
player.showPlayer(this, controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
final Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
|
|
|
final Team team = scoreboard.getTeam("icuCollision");
|
|
|
|
|
|
|
|
if (team != null) {
|
|
|
|
team.unregister();
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.removePotionEffect(PotionEffectType.INVISIBILITY);
|
|
|
|
controller.sendMessage("You are no longer controlling \"" + target.getName() + "\" due to server reload");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-06 00:36:30 +00:00
|
|
|
}
|