refactoring for organization
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.util;
|
||||
|
||||
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 java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConfigUtil {
|
||||
private static ConfigUtil instance;
|
||||
private final File file;
|
||||
private final FileConfiguration config;
|
||||
public static ConfigUtil getConfigUtil() {
|
||||
if (instance != null) return instance;
|
||||
instance = new ConfigUtil("config.yml");
|
||||
return instance;
|
||||
}
|
||||
private ConfigUtil(String path) {
|
||||
this.file = new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("spawn")).getDataFolder().getAbsolutePath() + "/" + path);
|
||||
this.config = YamlConfiguration.loadConfiguration(this.file);
|
||||
}
|
||||
public boolean save() {
|
||||
try {
|
||||
this.config.save(this.file);
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public FileConfiguration getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
public Location getVillagerLocation() {
|
||||
List<Double> cordsList = this.config.getDoubleList("villagerLocation");
|
||||
World world = Bukkit.getWorld("world");
|
||||
double x = cordsList.get(0);
|
||||
double y = cordsList.get(1);
|
||||
double z = cordsList.get(2);
|
||||
double yaw = cordsList.get(3);
|
||||
double pitch = cordsList.get(4);
|
||||
Location location = new Location(world, x, y, z);
|
||||
location.setYaw((float) yaw);
|
||||
location.setPitch((float) pitch);
|
||||
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerOnlineUtil {
|
||||
private static final List<Player> playerOnWorldMuseum= new ArrayList<>(); // if player is in list --> he will be connected to worldmuseum
|
||||
|
||||
public static void addPlayer(Player player) {
|
||||
playerOnWorldMuseum.add(player);
|
||||
}
|
||||
public static boolean worldMuseumCheck(Player player) {
|
||||
return playerOnWorldMuseum.contains(player);
|
||||
}
|
||||
public static void remove(Player player) {
|
||||
playerOnWorldMuseum.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.util;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import eu.mhsl.craftattack.spawn.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PluginMessage {
|
||||
private final Main plugin = Main.getInstance();
|
||||
public void connect(Player player, String server) {
|
||||
ByteArrayDataOutput output = ByteStreams.newDataOutput();
|
||||
output.writeUTF("Connect");
|
||||
output.writeUTF(server);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", output.toByteArray());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package eu.mhsl.craftattack.spawn.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
|
||||
public class VillagerSpawner {
|
||||
private static Villager staticVillager;
|
||||
public static void spawnVillager() {
|
||||
ConfigUtil config = ConfigUtil.getConfigUtil();
|
||||
Location location = config.getVillagerLocation();
|
||||
|
||||
assert EntityType.VILLAGER.getEntityClass() != null;
|
||||
Villager villager = (Villager) location.getWorld().spawn(location, EntityType.VILLAGER.getEntityClass());
|
||||
|
||||
villager.setAI(false);
|
||||
villager.setInvulnerable(true);
|
||||
villager.setSilent(true);
|
||||
villager.setCollidable(false);
|
||||
villager.setRemoveWhenFarAway(false);
|
||||
villager.setProfession(Villager.Profession.LIBRARIAN);
|
||||
|
||||
staticVillager = villager;
|
||||
}
|
||||
public static void killVillager() {
|
||||
staticVillager.remove();
|
||||
}
|
||||
|
||||
public static Villager getStaticVillager() {
|
||||
return staticVillager;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user