Add basic player hider and command canceller

This commit is contained in:
Bea 2022-11-11 17:55:50 +01:00
parent 2be7381e87
commit 568b719512
5 changed files with 92 additions and 8 deletions

View File

@ -0,0 +1,34 @@
package wtf.beatrice.limbomanager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import wtf.beatrice.limbomanager.listeners.PlayerHider;
public class LimboManager extends JavaPlugin {
private PluginManager pluginManager;
private static LimboManager instance;
@Override
public void onEnable()
{
instance = this;
pluginManager = Bukkit.getServer().getPluginManager();
pluginManager.registerEvents(new PlayerHider(), this);
}
@Override
public void onDisable()
{
}
public static LimboManager getInstance()
{
return instance;
}
}

View File

@ -1,7 +0,0 @@
package wtf.beatrice.limbomanager;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,16 @@
package wtf.beatrice.limbomanager.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandCanceller implements Listener
{
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent event)
{
// block literally all commands (except from proxy ones)
event.setCancelled(true);
}
}

View File

@ -0,0 +1,41 @@
package wtf.beatrice.limbomanager.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import wtf.beatrice.limbomanager.LimboManager;
public class PlayerHider implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
// remove join msg
event.setJoinMessage(null);
LimboManager plugin = LimboManager.getInstance();
Player joiner = event.getPlayer();
// hide player from everyone
for(Player otherPlayer : Bukkit.getServer().getOnlinePlayers())
{
otherPlayer.hidePlayer(plugin, joiner);
joiner.hidePlayer(plugin, otherPlayer);
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
event.setQuitMessage(null);
}
}

View File

@ -1,5 +1,5 @@
name: LimboManager
main: wtf.beatrice.limbomanager.Main
main: wtf.beatrice.limbomanager.LimboManager
version: 0.0.1
description: Mix of tools to run a Limbo server
api-version: 1.19