feat: don't allow players to create a portal
This commit is contained in:
parent
3a9df9cddc
commit
bc6074436c
3 changed files with 53 additions and 0 deletions
|
@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import de.cliffbreak.varo.commands.VaroCommand;
|
||||
import de.cliffbreak.varo.listeners.BannedActionListener;
|
||||
import de.cliffbreak.varo.listeners.BannedItemListener;
|
||||
import de.cliffbreak.varo.listeners.ChatListener;
|
||||
import de.cliffbreak.varo.listeners.CreatureSpawnListener;
|
||||
|
@ -35,6 +36,8 @@ public class Varo extends JavaPlugin {
|
|||
public PlayerCache playerCache;
|
||||
public BanUtils banUtils;
|
||||
|
||||
public boolean canCreatePortal = false;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
|
@ -57,6 +60,7 @@ public class Varo extends JavaPlugin {
|
|||
getServer().getPluginManager().registerEvents(new EntityRegainHealthListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BannedItemListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new BannedActionListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new CreatureSpawnListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerInteractNPCListener(this), this);
|
||||
|
||||
|
|
|
@ -77,6 +77,17 @@ public class VaroCommand implements CommandExecutor {
|
|||
sender.sendMessage(MessageUtils.getRichTextComponent("§9" + "Team 08", ""));
|
||||
sender.sendMessage(MessageUtils.getRichTextComponent("§d" + "Team 09", ""));
|
||||
sender.sendMessage(MessageUtils.getRichTextComponent("§5" + "Team 10", ""));
|
||||
|
||||
} else if (args.length == 2 && args[0].equals("portal")) {
|
||||
if (args[1].equals("enable")) {
|
||||
this.plugin.canCreatePortal = true;
|
||||
sender.sendMessage("§c§lWarnung: §r§cPortale können nun von JEDEM Spieler erstellt werden.");
|
||||
} else if (args[1].equals("disable")) {
|
||||
this.plugin.canCreatePortal = false;
|
||||
sender.sendMessage("§a§lErfolg: §r§aEs können nun keine Portale mehr erstellt werden..");
|
||||
} else {
|
||||
sender.sendMessage("§c§lFehler: §r§cBitte überprüfe deine Eingabe.");
|
||||
}
|
||||
} else if (args.length == 1 && args[0].equals("test")) {
|
||||
if (sender instanceof Player) {
|
||||
plugin.npcManager.createClone((Player) sender, false);
|
||||
|
@ -93,6 +104,7 @@ public class VaroCommand implements CommandExecutor {
|
|||
sender.sendMessage("\n§6========== §b§lCliffbreak.de VARO §r§6============\n ");
|
||||
sender.sendMessage("§a/varo start: §rStarte das Varo Projekt!");
|
||||
sender.sendMessage("§a/varo unban [Spieler]: §rSpieler wieder auf den Server lassen");
|
||||
sender.sendMessage("§a/varo portal [enable|disable]: §rAktiviere/Deaktiviere die Portal-Erstellung");
|
||||
sender.sendMessage("§a/varo teamcolors: §rZeige verfügbare Team-Farben an");
|
||||
sender.sendMessage("§a/varo test: §rErstelle einen Klon");
|
||||
sender.sendMessage("§a/varo testremove: §rLösche den Klon");
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package de.cliffbreak.varo.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.PortalCreateEvent;
|
||||
|
||||
import de.cliffbreak.varo.Varo;
|
||||
|
||||
public class BannedActionListener implements Listener {
|
||||
|
||||
private final Varo plugin;
|
||||
|
||||
public BannedActionListener(Varo plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPortalCreate(final PortalCreateEvent e) {
|
||||
if (!this.plugin.canCreatePortal) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(final PlayerInteractEvent e) {
|
||||
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
if (e.getClickedBlock().getType().equals(Material.OBSIDIAN)) {
|
||||
e.getPlayer()
|
||||
.sendMessage("§cEin Nether-Portal kann nicht erzeugt werden.\n §rGehe hierzu in die Mitte.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue