Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.funzocker1.MtsSystem;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import net.minecraft.server.v1_5_R1.Position;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.block.Block;
- import org.bukkit.block.Sign;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.craftbukkit.v1_5_R1.block.CraftSign;
- import org.bukkit.event.Listener;
- import org.bukkit.plugin.java.JavaPlugin;
- import SignChangeEvent.SignChangeEvent1;
- public class MtsSystem extends JavaPlugin implements Listener {
- private FileConfiguration ProsiebenLocationConfig = null;
- private FileConfiguration ProsiebenTimeConfig = null;
- private File ProsiebenTimeFile = null;
- private File ProsiebenLocationConfigFile = null;
- public String stringKey = "BLOCKSXX12345";
- @Override
- public void onEnable() {
- System.out.println("Mts by Funzocker1 Enabled. ");
- saveConfig();
- getProSiebenTime().set("d", 1);
- new SignChangeEvent1(this);
- reloadProsiebenLocation();
- getProsiebenLocation().options().header("##AUF KEINEN FALL ETWAS EINTRAGEN ODER ENTFERNEN");
- saveProSiebenLocation();
- saveProSiebentimes();
- saveProSiebentimes();
- reloadProSiebenTime();
- this.getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
- @Override
- public void run() {
- Date d = new Date();
- SimpleDateFormat t = new SimpleDateFormat("dd/MM/yyyy/HH/mm");
- System.out.println(t.format(d));
- if(getProSiebenTime().contains(t.format(d) )== true) {
- System.out.println("Schiler werden upgedatet");
- String[] help = getProsiebenLocation().getString(stringKey).split(Position.SepPos);
- for (int i = 0; i < help.length; i++) {
- String[] p = help[i].split(Position.SepCo);
- double x = Double.parseDouble(p[0]);
- double y = Double.parseDouble(p[1]);
- double z = Double.parseDouble(p[2]);
- Position pos = new Position(x, y, z);
- Location loc = new Location(getServer().getWorld("world"), pos.x, pos.y, pos.z);
- Sign s = (Sign) loc.getBlock().getState();
- s.setLine(0, ChatColor.GOLD + "Pro7");
- s.setLine(1, getProSiebenTime().getString(t.format(d)));
- s.getLocation().setX(pos.x);
- s.getLocation().setY(pos.y);
- s.getLocation().setZ(pos.z);
- }
- }else {
- System.out.println("hi");
- }
- }
- }, 0, 1200);
- }
- @Override
- public void onDisable() {
- }
- public String getConfigForPath() {
- return getProsiebenLocation().getString(this.stringKey);
- }
- public void addNewConfig() {
- getProsiebenLocation().addDefault(this.stringKey, "");
- getProsiebenLocation().options().copyDefaults();
- saveProSiebenLocation();
- }
- public void saveValue(String s) {
- getProsiebenLocation().set(this.stringKey, s);
- saveProSiebenLocation();
- }
- public void saveProSiebenLocation() {
- if (ProsiebenLocationConfig == null || ProsiebenLocationConfigFile == null) {
- return;
- }
- try {
- ProsiebenLocationConfig.save(ProsiebenLocationConfigFile);
- } catch (IOException ex) {
- Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Konfiguration konnte nicht nach " + ProsiebenLocationConfigFile + " geschrieben werden.", ex);
- }
- }
- public FileConfiguration getProsiebenLocation() {
- if (ProsiebenLocationConfig == null) {
- reloadProsiebenLocation();
- }
- return ProsiebenLocationConfig;
- }
- public void reloadProsiebenLocation() {
- if (ProsiebenLocationConfigFile == null) {
- ProsiebenLocationConfigFile = new File(getDataFolder(), "ProsiebenLocation.yml");
- }
- ProsiebenLocationConfig = YamlConfiguration.loadConfiguration(ProsiebenLocationConfigFile);
- // Look for defaults in the jar
- InputStream defConfigStream = this.getResource("ProsiebenLocation.yml");
- if (defConfigStream != null) {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- ProsiebenLocationConfig.setDefaults(defConfig);
- }
- }
- //###########################################################################################################################
- public void saveProSiebentimes() {
- if (ProsiebenTimeConfig == null || ProsiebenTimeFile == null) {
- return;
- }
- try {
- ProsiebenTimeConfig.save(ProsiebenTimeFile);
- } catch (IOException ex) {
- Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Konfiguration konnte nicht nach " + ProsiebenTimeFile + " geschrieben werden.", ex);
- }
- }
- public FileConfiguration getProSiebenTime() {
- if (ProsiebenTimeConfig == null) {
- reloadProSiebenTime();
- }
- return ProsiebenTimeConfig;
- }
- public void reloadProSiebenTime() {
- if (ProsiebenTimeFile == null) {
- ProsiebenTimeFile = new File(getDataFolder(), "ProsiebenTimeFile.yml");
- }
- ProsiebenTimeConfig = YamlConfiguration.loadConfiguration(ProsiebenTimeFile);
- // Look for defaults in the jar
- InputStream defConfigStream = this.getResource("ProsiebenTimeFile.yml");
- if (defConfigStream != null) {
- YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
- ProsiebenTimeConfig.setDefaults(defConfig);
- }
- }
- class Position {
- public static final String SepPos = ":";
- public static final String SepCo = "/";
- public Position(double x, double y, double z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
- private double x = 0;
- private double y = 0;
- private double z = 0;
- public String getStringforCoordinates() {
- return String.valueOf(x) + SepCo + String.valueOf(y) + SepCo
- + String.valueOf(z);
- }
- public boolean isInRadius(Position pos, double r) {
- return getDistance(pos) <= r;
- }
- public double getDistance(Position pos) {
- double d = Math.sqrt(Math.pow((x - pos.x), 2)
- + Math.pow((y - pos.y), 2) + Math.pow((z - pos.z), 2));
- return d;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement