Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SignsDataManager {
- FileConfiguration signs = Main.signsConfig;
- String path = "signs.";
- public SignsDataManager(){}
- public void addSign(Location loc, String serverID, int MaxPlayer, String displayName, String minigame){
- String path = "signs." + serverID;
- /*Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + " Rajout Sign a la location:");
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " X: " + ChatColor.GREEN + loc.getBlockX());
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Y: " + ChatColor.GREEN + loc.getBlockY());
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Z: " + ChatColor.GREEN + loc.getBlockZ());
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Serveur de Redirection: " + ChatColor.GREEN + serverID);
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Joueurs Maximum: " + ChatColor.GREEN + MaxPlayer);
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " MiniJeux: " + ChatColor.GREEN + minigame);*/
- signs.set(path+".x", loc.getBlockX());
- signs.set(path+".y", loc.getBlockY());
- signs.set(path+".z", loc.getBlockZ());
- signs.set(path+".world", loc.getWorld().getName());
- signs.set(path+".maxplayer", MaxPlayer);
- signs.set(path+".serverid", serverID);
- signs.set(path+".displayname", displayName);
- signs.set(path+".minigame", minigame);
- try{
- signs.save(Main.signs);
- }catch(IOException e) {
- e.printStackTrace();
- }
- }
- public void update(){
- Set<String> keys = signs.getConfigurationSection("signs").getKeys(false);
- for(String entry: keys){
- String path = "signs." + entry;
- Location l = new Location((World) signs.get(path + ".world"), signs.getInt(path + ".x"), signs.getInt(path + ".y"), signs.getInt(path + ".z"));
- if(l.getBlock().getType().equals(Material.SIGN) || l.getBlock().getType().equals(Material.SIGN_POST)){
- Sign s = (Sign) l.getBlock().getState();
- ByteArrayDataOutput out = ByteStreams.newDataOutput();
- out.writeUTF("PlayerCount");
- out.writeUTF(path + ".serverid");
- String connected = out.toString();
- String motd = signs.getString(path + ".motd");
- motd.replaceAll("&", "§");
- if(connected != null){
- s.setLine(0, "[" + signs.getString(path + ".minigame").replaceAll("&", "§") + ChatColor.RESET + "]");
- s.setLine(1, connected + "/" + signs.getInt(path+".maxplayer"));
- s.setLine(2, signs.getString(path + ".motd").replaceAll("&", "§"));
- s.setLine(3, signs.getString(path + ".displayname").replaceAll("&", "§"));
- }else{
- s.setLine(0, "[" + signs.getString(path + ".minigame").replaceAll("&", "§") + ChatColor.RESET + "]");
- s.setLine(1, "");
- s.setLine(2, ChatColor.RED + "OFFLINE");
- s.setLine(3, "");
- }
- }
- }
- }
- public void delete(String serverid){
- String path = "signs." + serverid;
- signs.set(path, null);
- try{
- signs.save(Main.signs);
- }catch(IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement