Moved features to separate projects
This commit is contained in:
56
AntiVoid/src/cz/marwland/mc/features/AntiVoid.java
Normal file
56
AntiVoid/src/cz/marwland/mc/features/AntiVoid.java
Normal file
@ -0,0 +1,56 @@
|
||||
package cz.marwland.mc.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;
|
||||
import cz.marwland.mc.core.util.Cooldown;
|
||||
|
||||
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");
|
||||
Cooldown xd = new Cooldown(this);
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
cfg = getConfig("antivoid.yml");
|
||||
|
||||
triggery = cfg.getDouble("triggery", 0d);
|
||||
allowedWorlds = new ArrayList<>();
|
||||
for (String wname : cfg.getStringList("worlds")) {
|
||||
World w = Bukkit.getWorld(wname);
|
||||
|
||||
if (w == null)
|
||||
continue;
|
||||
allowedWorlds.add(w);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user