Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.tarkod.api;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- public class Config {
- private static FileConfiguration getConfigFile;
- public Config(FileConfiguration file) {
- Config.getConfigFile = file;
- }
- //To get a location with direction from "config" file
- public Location getLocationWithDirection(String arguments, World world) {
- String[] configLocation = getConfigFile.getString(arguments).split(", ");
- Double X = Double.parseDouble(configLocation[0]);
- Double Y = Double.parseDouble(configLocation[1]);
- Double Z = Double.parseDouble(configLocation[2]);
- Float yaw = Float.parseFloat(configLocation[3]);
- Float pitch = Float.parseFloat(configLocation[4]);
- Location finalLocation;
- if(yaw == null || pitch == null) {
- finalLocation = new Location(world, X, Y, Z);
- } else {
- finalLocation = new Location(world, X, Y, Z, yaw, pitch);
- }
- return finalLocation;
- }
- //To get a location without direction from "config" file
- public Location getLocation(String arguments, World world) {
- String[] configLocation = getConfigFile.getString(arguments).split(", ");
- Double X = Double.parseDouble(configLocation[0]);
- Double Y = Double.parseDouble(configLocation[1]);
- Double Z = Double.parseDouble(configLocation[2]);
- Location finalLocation = new Location(world, X, Y, Z);
- return finalLocation;
- }
- //To get a String from "config" file
- public String getString(String arguments, Player p) {
- String configString = getConfigFile.getString(arguments).replace("{player}", p.getPlayer().getName());
- if(configString == null) {
- throw new IllegalStateException("The " + arguments + " was not loaded correctly.");
- } else {
- return configString;
- }
- }
- //To get a String from "config" file
- public String getString(String arguments) {
- String configString = getConfigFile.getString(arguments);
- return configString;
- }
- //To get Integer from "config" file
- public Integer getInt(String arguments) {
- Integer configInt = getConfigFile.getInt(arguments);
- return configInt;
- }
- //To get Double from "config" file
- public Double getDouble(String arguments) {
- Double configDouble = getConfigFile.getDouble(arguments);
- return configDouble;
- }
- //A refaire...
- public String getTeamMessage(String arguments, Player p, String teamName) {
- String configTeamMessage = getConfigFile.getString(arguments).replace("&", "ยง").replace("{player}", p.getPlayer().getName()).replace("{team}", teamName);
- if(configTeamMessage == null) {
- throw new IllegalStateException("The " + arguments + " was not loaded correctly.");
- } else {
- return configTeamMessage;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement