[Gelöst] Plugin fixen

Wenn ihr bei eurem Plugin nicht weiter kommt, könnt ihr hier euer Problem beschreiben und um Hilfe bitten.

[Gelöst] Plugin fixen

Beitragvon Kampfprofessor » Di 19. Apr 2016, 14:17

Mit der 1.8 hat sich was verändert, und ich will das Plugin updaten und bin auch schon fast fertig. Mir fehlen nur noch ein paar kleine Sachen:

1.
Code: Alles auswählen
  1. Object ss = new ArrayList<Object>();
  2.     for (Location loc : this.spawns_R) {
  3.       ((List)ss).add(loc2str(loc));
  4.     }

Code: Alles auswählen
  1. Fehler
  2. ((List)ss).add(loc2str(loc));
  3. Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized


2.
Code: Alles auswählen
  1. File[] files = new File(this.plugin.getDataFolder(), "/Stuff/Hats").listFiles();
  2.     File[] arrayOfFile1;
  3.     IOException localIOException1 = (arrayOfFile1 = files).length;
  4.     for (int e = 0; e < localIOException1; e++)
  5.     {
  6.       File file = arrayOfFile1[e];
  7.       this.plugin.log.warning(file.getPath());
  8.       if ((file.isFile()) && (file.getPath().endsWith(".yml")))
  9.       {
  10.         FileConfiguration config = YamlConfiguration.loadConfiguration(file);
  11.         if (config.contains("Implementation"))
  12.         {
  13.           this.plugin.log.info(file.getPath() + " found implementation");
  14.           HatBasic hat = HatFactory.getInstance(config.getString("Implementation"), file.getPath());
  15.           if (hat == null) {
  16.             this.plugin.log.severe(file.getPath() + " invalid implementation");
  17.           } else {
  18.             this.hats.add(hat);
  19.           }
  20.         }
  21.       }
  22.     }

Code: Alles auswählen
  1. Fehler
  2. IOException localIOException1 = (arrayOfFile1 = files).length;
  3. Type mismatch: cannot convert from int to IOException


3.
Code: Alles auswählen
  1. public static Enum<?> getNMSEnum(String className)
  2.   {
  3.     String enumFullName = "net.minecraft.server." + getVersion() + className;
  4.     String[] x = enumFullName.split("\\.(?=[^\\.]+$)");
  5.     if (x.length == 2)
  6.     {
  7.       String enumClassName = x[0];
  8.       String enumName = x[1];
  9.       try
  10.       {
  11.         Class<Enum> cl = Class.forName(enumClassName);
  12.         return Enum.valueOf(cl, enumName);
  13.       }
  14.       catch (ClassNotFoundException e)
  15.       {
  16.         e.printStackTrace();
  17.       }
  18.     }
  19.     return null;
  20.   }

Code: Alles auswählen
  1. Fehler
  2. Class<Enum> cl = Class.forName(enumClassName);
  3. <Enum> » Enum is a raw type. References to generic type Enum<E> should be parameterized
  4. Class.forName(enumClassName); » Type mismatch: cannot convert from Class<capture#5-of ?> to Class<Enum>
  5. return Enum.valueOf(cl, enumName);
  6. Type safety: Unchecked invocation valueOf(Class<Enum>, String) of the generic method valueOf(Class<T>, String) of type Enum


4.
Code: Alles auswählen
  1. List<String> l = (e = files).length;
  2.     for (LeatherArmorMeta meta = 0; meta < l; meta++)
  3.     {
  4.       File file = e[meta];
  5.       this.plugin.log.warning(file.getPath());
  6.       if ((file.isFile()) && (file.getPath().endsWith(".yml")))
  7.       {
  8.         FileConfiguration config = YamlConfiguration.loadConfiguration(file);
  9.         if (config.contains("Implementation"))
  10.         {
  11.           this.plugin.log.info(file.getPath() + " found implementation");
  12.           ArmorBasic armor = ArmorFactory.getInstance(config.getString("Implementation"), file.getPath());
  13.           if (armor == null) {
  14.             this.plugin.log.severe(file.getPath() + " invalid implementation");
  15.           } else {
  16.             this.armors.add(armor);
  17.           }
  18.         }
  19.       }

Code: Alles auswählen
  1. Fehler
  2. List<String> l = (e = files).length;
  3. e cannot be resolved to a variable
  4. LeatherArmorMeta meta = 0;
  5. Type mismatch: cannot convert from int to LeatherArmorMeta
  6. meta < l und meta++
  7. The operator < is undefined for the argument type(s) LeatherArmorMeta, List<String>


5.
Code: Alles auswählen
  1. private void postPlugin(boolean isPing)
  2.     throws IOException
  3.   {
  4.     PluginDescriptionFile description = this.plugin.getDescription();
  5.     String pluginName = description.getName();
  6.     boolean onlineMode = Bukkit.getServer().getOnlineMode();
  7.     String pluginVersion = description.getVersion();
  8.     String serverVersion = Bukkit.getVersion();
  9.     int playersOnline = Bukkit.getServer().getOnlinePlayers().size();
  10.    
  11.     StringBuilder json = new StringBuilder(1024);
  12.     json.append('{');
  13.    
  14.     appendJSONPair(json, "guid", this.guid);
  15.     appendJSONPair(json, "plugin_version", pluginVersion);
  16.     appendJSONPair(json, "server_version", serverVersion);
  17.     appendJSONPair(json, "players_online", Integer.toString(playersOnline));
  18.    
  19.     String osname = System.getProperty("os.name");
  20.     String osarch = System.getProperty("os.arch");
  21.     String osversion = System.getProperty("os.version");
  22.     String java_version = System.getProperty("java.version");
  23.     int coreCount = Runtime.getRuntime().availableProcessors();
  24.     if (osarch.equals("amd64")) {
  25.       osarch = "x86_64";
  26.     }
  27.     appendJSONPair(json, "osname", osname);
  28.     appendJSONPair(json, "osarch", osarch);
  29.     appendJSONPair(json, "osversion", osversion);
  30.     appendJSONPair(json, "cores", Integer.toString(coreCount));
  31.     appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
  32.     appendJSONPair(json, "java_version", java_version);
  33.     if (isPing) {
  34.       appendJSONPair(json, "ping", "1");
  35.     }
  36.     if (this.graphs.size() > 0) {
  37.       synchronized (this.graphs)
  38.       {
  39.         json.append(',');
  40.         json.append('"');
  41.         json.append("graphs");
  42.         json.append('"');
  43.         json.append(':');
  44.         json.append('{');
  45.        
  46.         boolean firstGraph = true;
  47.        
  48.         Iterator<Graph> iter = this.graphs.iterator();
  49.         while (iter.hasNext())
  50.         {
  51.           Graph graph = (Graph)iter.next();
  52.          
  53.           StringBuilder graphJson = new StringBuilder();
  54.           graphJson.append('{');
  55.           for (Plotter plotter : graph.getPlotters()) {
  56.             appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
  57.           }
  58.           graphJson.append('}');
  59.           if (!firstGraph) {
  60.             json.append(',');
  61.           }
  62.           json.append(escapeJSON(graph.getName()));
  63.           json.append(':');
  64.           json.append(graphJson);
  65.          
  66.           firstGraph = false;
  67.         }
  68.         json.append('}');
  69.       }
  70.     }
  71.     json.append('}');
  72.    
  73.     URL url = new URL("http://report.mcstats.org" + String.format("/plugin/%s", new Object[] { urlEncode(pluginName) }));
  74.     URLConnection connection;
  75.     if (isMineshafterPresent()) {
  76.       connection = url.openConnection(Proxy.NO_PROXY);
  77.     } else {
  78.       connection = url.openConnection();
  79.     }
  80.     byte[] uncompressed = json.toString().getBytes();
  81.     byte[] compressed = gzip(json.toString());
  82.    
  83.     connection.addRequestProperty("User-Agent", "MCStats/7");
  84.     connection.addRequestProperty("Content-Type", "application/json");
  85.     connection.addRequestProperty("Content-Encoding", "gzip");
  86.     connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
  87.     connection.addRequestProperty("Accept", "application/json");
  88.     connection.addRequestProperty("Connection", "close");
  89.    
  90.     connection.setDoOutput(true);
  91.     if (this.debug) {
  92.       System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
  93.     }
  94.     OutputStream os = connection.getOutputStream();
  95.     os.write(compressed);
  96.     os.flush();
  97.    
  98.     BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  99.     String response = reader.readLine();
  100.    
  101.     os.close();
  102.     reader.close();
  103.     if ((response == null) || (response.startsWith("ERR")) || (response.startsWith("7")))
  104.     {
  105.       if (response == null) {
  106.         response = "null";
  107.       } else if (response.startsWith("7")) {
  108.         response = response.substring(response.startsWith("7,") ? 2 : 1);
  109.       }
  110.       throw new IOException(response);
  111.     }
  112.     if ((response.equals("1")) || (response.contains("This is your first update this hour"))) {
  113.       synchronized (this.graphs)
  114.       {
  115.         Iterator<Graph> iter = this.graphs.iterator();
  116.         Iterator localIterator2;
  117.         for (; iter.hasNext(); localIterator2.hasNext())
  118.         {
  119.           Graph graph = (Graph)iter.next();
  120.          
  121.           localIterator2 = graph.getPlotters().iterator();
  122.           continue;
  123.           Plotter plotter = (Plotter)localIterator2.next();
  124.           plotter.reset();
  125.         }
  126.       }
  127.     }
  128.   }

Code: Alles auswählen
  1. Fehler
  2. Iterator localIterator2;
  3. Iterator is a raw type. References to generic type Iterator<E> should be parameterized
  4. » Nach was? <String>???
  5. Plotter plotter = (Plotter)localIterator2.next();
  6. Unreachable code



Danke im Voraus
Zuletzt geändert von Kampfprofessor am Fr 22. Apr 2016, 11:52, insgesamt 1-mal geändert.
Benutzeravatar
Kampfprofessor
 
Beiträge: 71
Registriert: Fr 12. Feb 2016, 15:48

Re: Plugin fixen

Beitragvon Letsplaybar » Di 19. Apr 2016, 14:23

komm mal ts ich erzähl dir deine fehler hab bei erstens zb. gesehen das du nur List und nicht List<?> zustehen hast in den Klammern und dies bemergelt er.
Bild
Helfe Wo ich kann.
Mein MinecraftServer: Letsplaybaro.de - Suchen Developer/Bilder

I hacked 127.0.0.1!!! :)
Benutzeravatar
Letsplaybar
 
Beiträge: 195
Registriert: Mo 1. Feb 2016, 17:21
Wohnort: Berlin

Re: Plugin fixen

Beitragvon Kampfprofessor » Di 19. Apr 2016, 18:38

Danke Letsplaybar :)

#closed
Benutzeravatar
Kampfprofessor
 
Beiträge: 71
Registriert: Fr 12. Feb 2016, 15:48


Zurück zu Hilfe und Support

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 14 Gäste