diff --git a/resources/antivoid.yml b/resources/antivoid.yml new file mode 100644 index 0000000..5f3043d --- /dev/null +++ b/resources/antivoid.yml @@ -0,0 +1,6 @@ +# Here you can specify worlds to enable this feature in +# and the threshold Y coordinate below which a player gets +# teleported to the world's spawn. +triggery: 10 +worlds: + - world \ No newline at end of file diff --git a/src/cz/marwland/mc/core/MarwCore.java b/src/cz/marwland/mc/core/MarwCore.java index c05b4f0..526d586 100644 --- a/src/cz/marwland/mc/core/MarwCore.java +++ b/src/cz/marwland/mc/core/MarwCore.java @@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin; import cz.marwland.mc.core.config.ConfigManager; import cz.marwland.mc.core.features.Base; import cz.marwland.mc.core.features.Feature; +import cz.marwland.mc.essentials.features.AntiVoid; import cz.marwland.mc.essentials.features.Borders; import cz.marwland.mc.essentials.features.ChatNotifier; import cz.marwland.mc.essentials.features.ChorusLimiter; @@ -25,6 +26,7 @@ public class MarwCore extends JavaPlugin { configManager = new ConfigManager(this); + this.addFeature(new AntiVoid()); this.addFeature(new Base()); this.addFeature(new Borders()); this.addFeature(new ChatNotifier()); diff --git a/src/cz/marwland/mc/core/features/Base.java b/src/cz/marwland/mc/core/features/Base.java index 7584b64..72dc7bc 100644 --- a/src/cz/marwland/mc/core/features/Base.java +++ b/src/cz/marwland/mc/core/features/Base.java @@ -35,9 +35,4 @@ public class Base extends Feature { }); } - @Override - public void onEnable() { - super.onEnable(); - } - } diff --git a/src/cz/marwland/mc/essentials/features/AntiVoid.java b/src/cz/marwland/mc/essentials/features/AntiVoid.java new file mode 100644 index 0000000..71ea3f9 --- /dev/null +++ b/src/cz/marwland/mc/essentials/features/AntiVoid.java @@ -0,0 +1,60 @@ +package cz.marwland.mc.essentials.features; + +import java.util.ArrayList; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; + +import cz.marwland.mc.core.features.Feature; + +public class AntiVoid extends Feature { + + private FileConfiguration cfg; + private ArrayList allowedWorlds = new ArrayList<>(); + private double triggery = 0d; + + public AntiVoid() { + super(); + this.registerConfig("antivoid.yml"); + } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent e) { + Player p = e.getPlayer(); + if (p.getLocation().getY() > triggery) + return; + + World w = p.getWorld(); + if (!allowedWorlds.contains(w)) + return; + + p.teleport(w.getSpawnLocation()); + p.sendMessage(triggery + " / cfg: " + cfg.getDouble("triggery", 0d)); + } + + @Override + public void onEnable() { + super.onEnable(); + this.onReload(); + } + + @Override + public void onReload() { + super.onReload(); + cfg = getConfig("antivoid.yml"); + + triggery = cfg.getDouble("triggery", 0d); + for (String wname : cfg.getStringList("worlds")) { + World w = Bukkit.getWorld(wname); + + if (w == null) + continue; + allowedWorlds.add(w); + } + } + +} diff --git a/src/cz/marwland/mc/essentials/features/Borders.java b/src/cz/marwland/mc/essentials/features/Borders.java index 2d786d8..2c9e2a5 100644 --- a/src/cz/marwland/mc/essentials/features/Borders.java +++ b/src/cz/marwland/mc/essentials/features/Borders.java @@ -70,7 +70,7 @@ public class Borders extends Feature { return true; } Object val = entry.getFrom(cfg, w.getName()); - System.out.println("sending"); + sender.sendMessage( ChatColor.YELLOW + args[1] + ChatColor.GRAY + " @ " +