This commit is contained in:
Erik Bročko 2018-09-13 23:57:25 +02:00
parent e103195300
commit 354670ed2b
5 changed files with 69 additions and 6 deletions

6
resources/antivoid.yml Normal file
View 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

View File

@ -7,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import cz.marwland.mc.core.config.ConfigManager; import cz.marwland.mc.core.config.ConfigManager;
import cz.marwland.mc.core.features.Base; import cz.marwland.mc.core.features.Base;
import cz.marwland.mc.core.features.Feature; 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.Borders;
import cz.marwland.mc.essentials.features.ChatNotifier; import cz.marwland.mc.essentials.features.ChatNotifier;
import cz.marwland.mc.essentials.features.ChorusLimiter; import cz.marwland.mc.essentials.features.ChorusLimiter;
@ -25,6 +26,7 @@ public class MarwCore extends JavaPlugin {
configManager = new ConfigManager(this); configManager = new ConfigManager(this);
this.addFeature(new AntiVoid());
this.addFeature(new Base()); this.addFeature(new Base());
this.addFeature(new Borders()); this.addFeature(new Borders());
this.addFeature(new ChatNotifier()); this.addFeature(new ChatNotifier());

View File

@ -35,9 +35,4 @@ public class Base extends Feature {
}); });
} }
@Override
public void onEnable() {
super.onEnable();
}
} }

View 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);
}
}
}

View File

@ -70,7 +70,7 @@ public class Borders extends Feature {
return true; return true;
} }
Object val = entry.getFrom(cfg, w.getName()); Object val = entry.getFrom(cfg, w.getName());
System.out.println("sending");
sender.sendMessage( sender.sendMessage(
ChatColor.YELLOW + args[1] + ChatColor.YELLOW + args[1] +
ChatColor.GRAY + " @ " + ChatColor.GRAY + " @ " +