Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.File;
- import java.io.IOException;
- import java.util.Random;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class KitPvP extends JavaPlugin{
- public static Logger mclogger = Logger.getLogger("§8[§7KitPvP-System§8] §a");
- public static Logger logger = Logger.getLogger("[KitPvP-System] ");
- public static File file = new File("plugins/KitPvP-System", "config.yml");
- public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- File file2 = new File("plugins/KitPvP-System", "maps.yml");
- FileConfiguration cfg2 = YamlConfiguration.loadConfiguration(file2);
- @Override
- public void onEnable() {
- Bukkit.getPluginManager().registerEvents(new Listeners(), this);
- logger.info("lade System...");
- logger.info("version: " + getDescription().getVersion());
- logger.info("author: " + getDescription().getAuthors());
- logger.info("Danke fuers benutzen!");
- if(!(file.exists())) {
- file.getParentFile().mkdirs();
- try {
- loadConfig();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }else{
- try {
- loadConfig();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- getCommand("kitpvp").setExecutor(new Commands());
- getCommand("kploschen").setExecutor(new Commands());
- getCommand("kpcreate").setExecutor(new Commands());
- getCommand("kpinterval").setExecutor(new Commands());
- getCommand("kpteleport").setExecutor(new Commands());
- //SYSTEM
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
- @Override
- public void run() {
- Random r = new Random();
- final int zufall = r.nextInt(20);
- if(cfg2.getBoolean("EnableMap" + zufall + ".enabled")) {
- double x = cfg2.getDouble("Map" + zufall + ".X");
- double y = cfg2.getDouble("Map" + zufall + ".Y");
- double z = cfg2.getDouble("Map" + zufall + ".Z");
- double yaw = cfg2.getDouble("Map" + zufall + ".Yaw");
- double pitch = cfg2.getDouble("Map" + zufall + ".Pitch");
- String worldname = cfg2.getString("Map" + zufall + ".world");
- World world = Bukkit.getWorld(worldname);
- Location loc = new Location(world, x, y, z, (float)yaw, (float)pitch);
- for(Player op : Bukkit.getOnlinePlayers()) {
- op.teleport(loc);
- }
- }else{
- System.err.println("FATAL: Die Map " + zufall + " gibt es nicht! Teleportiere zu Map 2");
- double x = cfg2.getDouble("Map2.X");
- double y = cfg2.getDouble("Map2.Y");
- double z = cfg2.getDouble("Map2.Z");
- double yaw = cfg2.getDouble("Map2.Yaw");
- double pitch = cfg2.getDouble("Map2.Pitch");
- String worldname = cfg2.getString("Map2.world");
- World world = Bukkit.getWorld(worldname);
- Location loc = new Location(world, x, y, z, (float)yaw, (float)pitch);
- for(Player op : Bukkit.getOnlinePlayers()) {
- op.teleport(loc);
- }
- }
- }
- }, 0L, cfg.getInt("interval")*20L);
- }
- @Override
- public void onDisable() {
- logger.info("endlade System...");
- logger.info("version: " + getDescription().getVersion());
- logger.info("author: " + getDescription().getAuthors());
- logger.info("Danke fuers benutzen!");
- }
- public void loadConfig() throws IOException {
- FileConfiguration c = cfg;
- c.options().copyDefaults(true);
- c.options().copyHeader(true);
- c.options().header("Hier kannst du die Zeit zum ändern der Map einstellen!");
- c.addDefault("interval", 10800*20L);
- for(int i = 1; i <= 20; i++) {
- c.addDefault("EnableMap" + i + ".enabled", true);
- }
- c.save(file);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement