Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[Problem] KukuStone - edit.


idrakus

Rekomendowane odpowiedzi

Opublikowano

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

                                                                                                 |

 

 Witam, chciałbym edytować plugin KukuStone. Dlaczego ?, ponieważ w configu nie ma craftingu i chce go edytować. 

I jak przepisuje kod są dwa błędy oto takie:

 package com.gmail.kukubaczek.Stone;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
 
public class Config
{
  private static List<RConfig> configs = new ArrayList();
  
  public static boolean registerConfig(String id, String fileName, JavaPlugin plugin)
  {
    File file = new File(plugin.getDataFolder(), fileName);
    if (!file.exists())
    {
      file.getParentFile().mkdirs();
      try
      {
        copy(plugin.getResource(fileName), file);
      }
      catch (Exception localException) {}
    }
    RConfig c = new RConfig(id, file, null);
    for (RConfig x : configs) {
      if (x.equals(c)) {
        return false;
      }
    }
    configs.add(c);
    return true;
  }
  
  public static boolean unregisterConfig(String id)
  {
    return configs.remove(getConfig(id));
  }
  
  public static RConfig getConfig(String id)
  {
    for (RConfig c : configs) {
      if (c.getConfigId().equalsIgnoreCase(id)) {
        return c;
      }
    }
    return null;
  }
  
  public static boolean save(String id)
  {
    RConfig c = getConfig(id);
    if (c == null) {
      return false;
    }
    try
    {
      c.save();
    }
    catch (Exception e)
    {
      print("An error occurred while saving a config with id " + id);
      e.printStackTrace();
      return false;
    }
    return true;
  }
  
  public static boolean saveAll()
  {
    try
    {
      for (RConfig c : configs) {
        c.save();
      }
    }
    catch (Exception e)
    {
      print("An error occurred while saving all configs");
      e.printStackTrace();
      return false;
    }
    return true;
  }
  
  public static boolean load(String id)
  {
    RConfig c = getConfig(id);
    if (c == null) {
      return false;
    }
    try
    {
      c.load();
    }
    catch (Exception e)
    {
      print("An error occurred while loading a config with id " + id);
      e.printStackTrace();
      return false;
    }
    return true;
  }
  
  public static boolean loadAll()
  {
    try
    {
      for (RConfig c : configs) {
        c.load();
      }
    }
    catch (Exception e)
    {
      print("An error occurred while loading all configs");
      e.printStackTrace();
      return false;
    }
    return true;
  }
  
  public static void clear(String id)
  {
    RConfig c = getConfig(id);
    if (c == null) {
      return;
    }
    configs.remove(c);
    configs.add(new RConfig(c.getConfigId(), c.getFile(), null));
  }
  
  private static void print(String msg)
  {
    System.out.println("Config: " + msg);
  }
  
  public static class RConfig
    extends YamlConfiguration
  {
    private String id;
    private File file;
    
    public String getConfigId()
    {
      return this.id;
    }
    
    public File getFile()
    {
      return this.file;
    }
    
    private RConfig(String id, File file)
    {
      this.id = id;
      this.file = file;
    }
    
    public void save()
      throws IOException
    {
      save(this.file);
    }
    
    public void load()
      throws InvalidConfigurationException, FileNotFoundException, IOException
    {
      load(this.file);
    }
    
    public boolean equals(RConfig c)
    {
      return c.getConfigId().equalsIgnoreCase(this.id);
    }
  }
  
  private static void copy(InputStream in, File file)
    throws IOException
  {
    OutputStream out = new FileOutputStream(file);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0)
    {
      int len;
      out.write(buf, 0, len);
    }
    out.close();
    in.close();
  }
}

BŁĘDY: 

 

      int len;

 

 

 

 

    configs.remove©;
    configs.add(new RConfig(c.getConfigId(), c.getFile(), null));

 

 

 

 

 

    RConfig c = new RConfig(id, file, null);

Opublikowano

Musisz napisać do kukubaczka Ci by nie użyczył SRC kodu pluginu ;) Bo raczej w JD-GUI nie naprawisz ;3

26_unnamed.png

Opublikowano

Kod który pokazałeś (Config.java) to ConfigManager v2.0 by Regzand. Chcesz linka do tego kodu bez błędów?

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...