Compare commits
2 Commits
2be7381e87
...
a33204b7b8
Author | SHA1 | Date | |
---|---|---|---|
a33204b7b8 | |||
568b719512 |
6
pom.xml
6
pom.xml
@ -30,6 +30,12 @@
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>23.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
38
src/main/java/wtf/beatrice/limbomanager/LimboManager.java
Normal file
38
src/main/java/wtf/beatrice/limbomanager/LimboManager.java
Normal file
@ -0,0 +1,38 @@
|
||||
package wtf.beatrice.limbomanager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import wtf.beatrice.limbomanager.listeners.CommandCanceller;
|
||||
import wtf.beatrice.limbomanager.listeners.PlayerHider;
|
||||
import wtf.beatrice.limbomanager.listeners.RiskyBlocksHandler;
|
||||
|
||||
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);
|
||||
pluginManager.registerEvents(new CommandCanceller(), this);
|
||||
pluginManager.registerEvents(new RiskyBlocksHandler(), this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static LimboManager getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package wtf.beatrice.limbomanager;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package wtf.beatrice.limbomanager.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockMultiPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RiskyBlocksHandler implements Listener
|
||||
{
|
||||
List<Material> riskyMaterials = new ArrayList<>()
|
||||
{{
|
||||
add(Material.TNT);
|
||||
add(Material.ANVIL);
|
||||
add(Material.CHIPPED_ANVIL);
|
||||
add(Material.DAMAGED_ANVIL);
|
||||
add(Material.MINECART);
|
||||
add(Material.CHEST_MINECART);
|
||||
add(Material.COMMAND_BLOCK_MINECART);
|
||||
add(Material.HOPPER_MINECART);
|
||||
add(Material.FURNACE_MINECART);
|
||||
add(Material.TNT_MINECART);
|
||||
add(Material.COMMAND_BLOCK);
|
||||
add(Material.CHAIN_COMMAND_BLOCK);
|
||||
add(Material.CHAIN_COMMAND_BLOCK);
|
||||
}};
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
checkAndCancel(event, event.getBlockPlaced().getType());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockMultiPlaceEvent event)
|
||||
{
|
||||
checkAndCancel(event, event.getBlockPlaced().getType());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if(event.getCurrentItem() != null)
|
||||
{
|
||||
checkAndCancel(event, event.getCurrentItem().getType());
|
||||
}
|
||||
|
||||
if(event.getCursor() != null)
|
||||
{
|
||||
checkAndCancel(event, event.getCursor().getType());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent event)
|
||||
{
|
||||
if(event.getCursor() != null)
|
||||
{
|
||||
checkAndCancel(event, event.getCursor().getType());
|
||||
}
|
||||
|
||||
checkAndCancel(event, event.getOldCursor().getType());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInvMoveItem(InventoryMoveItemEvent event)
|
||||
{
|
||||
checkAndCancel(event, event.getItem().getType());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInvPickup(InventoryPickupItemEvent event)
|
||||
{
|
||||
checkAndCancel(event, event.getItem().getItemStack().getType());
|
||||
}
|
||||
|
||||
|
||||
private void checkAndCancel(Cancellable event, @NotNull Material material)
|
||||
{
|
||||
if(riskyMaterials.contains(material))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user