AntiVoid
This commit is contained in:
parent
e103195300
commit
354670ed2b
6
resources/antivoid.yml
Normal file
6
resources/antivoid.yml
Normal file
@ -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
|
@ -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());
|
||||
|
@ -35,9 +35,4 @@ public class Base extends Feature {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
}
|
||||
|
||||
}
|
||||
|
60
src/cz/marwland/mc/essentials/features/AntiVoid.java
Normal file
60
src/cz/marwland/mc/essentials/features/AntiVoid.java
Normal file
@ -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<World> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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 + " @ " +
|
||||
|
Loading…
Reference in New Issue
Block a user