Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / интересно вещь тако доллар {help dev} / 24 сообщений из 24, страница 1 из 1
26.03.2014, 21:46
    #38597480
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Кто поможет мне дописать код ?
Декомпилировал все 3 файла:
Gavno.class
Gavno$1.class
Gavno$2.class

--- Теперь мозг взрывается ,не могу дописать код .Все время ошибки и возможно были баги при декомпиле .Но это не страшно , decompile я покупал за хорошую цену .
Кто может сопроводить меня и научить ,как с этой $1*class ,$2class иметь дело.
...
Рейтинг: 0 / 0
27.03.2014, 00:03
    #38597551
mayton
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Чтоб помогать дописывать код надо хотя-бы посмотреть на этот код.
...
Рейтинг: 0 / 0
27.03.2014, 10:26
    #38597745
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
mayton,
MetricsLite.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
package com.gmail.cbodels27.AdminChannel;

import java.io.*;
import java.net.*;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.file.YamlConfigurationOptions;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;

public class MetricsLite
{

    public MetricsLite(Plugin plugin)
        throws IOException
    {
        task = null;
        if(plugin == null)
            throw new IllegalArgumentException("Plugin cannot be null");
        this.plugin = plugin;
        configuration = YamlConfiguration.loadConfiguration(configurationFile);
        configuration.addDefault("opt-out", ((Object) (Boolean.valueOf(false))));
        configuration.addDefault("guid", ((Object) (UUID.randomUUID().toString())));
        configuration.addDefault("debug", ((Object) (Boolean.valueOf(false))));
        if(configuration.get("guid", ((Object) (null))) == null)
        {
            configuration.options().header("http://mcstats.org").copyDefaults(true);
            configuration.save(configurationFile);
        }
        guid = configuration.getString("guid");
        debug = configuration.getBoolean("debug", false);
    }

    public boolean start()
    {
label0:
        {
            synchronized(optOutLock)
            {
                if(!isOptOut())
                    break label0;
            }
            return false;
        }
        if(task == null)
            break MISSING_BLOCK_LABEL_29;
        obj;
        JVM INSTR monitorexit ;
        return true;
        task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {

            public void run()
            {
                try
                {
                    synchronized(optOutLock)
                    {
                        if(isOptOut() && task != null)
                        {
                            task.cancel();
                            task = null;
                        }
                    }
                    postPlugin(!firstPost);
                    firstPost = false;
                }
                catch(IOException e)
                {
                    if(debug)
                        Bukkit.getLogger().log(Level.INFO, (new StringBuilder("[Metrics] ")).append(e.getMessage()).toString());
                }
            }

            private boolean firstPost;
            final MetricsLite this$0;

            
            {
                this$0 = MetricsLite.this;
                super();
                firstPost = true;
            }
        }
, 0L, 12000L);
        obj;
        JVM INSTR monitorexit ;
        return true;
    }

    public boolean isOptOut()
    {
        Object obj = optOutLock;
        JVM INSTR monitorenter ;
        configuration.load(getConfigFile());
        break MISSING_BLOCK_LABEL_101;
        IOException ex;
        ex;
        if(debug)
            Bukkit.getLogger().log(Level.INFO, (new StringBuilder("[Metrics] ")).append(ex.getMessage()).toString());
        return true;
        ex;
        if(debug)
            Bukkit.getLogger().log(Level.INFO, (new StringBuilder("[Metrics] ")).append(((InvalidConfigurationException) (ex)).getMessage()).toString());
        obj;
        JVM INSTR monitorexit ;
        return true;
        configuration.getBoolean("opt-out", false);
        obj;
        JVM INSTR monitorexit ;
        return;
        obj;
        JVM INSTR monitorexit ;
        throw ;
    }

    public void enable()
        throws IOException
    {
        synchronized(optOutLock)
        {
            if(isOptOut())
            {
                configuration.set("opt-out", ((Object) (Boolean.valueOf(false))));
                configuration.save(configurationFile);
            }
            if(task == null)
                start();
        }
    }

    public void disable()
        throws IOException
    {
        synchronized(optOutLock)
        {
            if(!isOptOut())
            {
                configuration.set("opt-out", ((Object) (Boolean.valueOf(true))));
                configuration.save(configurationFile);
            }
            if(task != null)
            {
                task.cancel();
                task = null;
            }
        }
    }

    public File getConfigFile()
    {
        File pluginsFolder = plugin.getDataFolder().getParentFile();
        return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
    }

    private void postPlugin(boolean isPing)
        throws IOException
    {
        PluginDescriptionFile description = plugin.getDescription();
        String pluginName = description.getName();
        boolean onlineMode = Bukkit.getServer().getOnlineMode();
        String pluginVersion = description.getVersion();
        String serverVersion = Bukkit.getVersion();
        int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
        StringBuilder data = new StringBuilder();
        data.append(encode("guid")).append('=').append(encode(guid));
        encodeDataPair(data, "version", pluginVersion);
        encodeDataPair(data, "server", serverVersion);
        encodeDataPair(data, "players", Integer.toString(playersOnline));
        encodeDataPair(data, "revision", String.valueOf(6));
        String osname = System.getProperty("os.name");
        String osarch = System.getProperty("os.arch");
        String osversion = System.getProperty("os.version");
        String java_version = System.getProperty("java.version");
        int coreCount = Runtime.getRuntime().availableProcessors();
        if(osarch.equals("amd64"))
            osarch = "x86_64";
        encodeDataPair(data, "osname", osname);
        encodeDataPair(data, "osarch", osarch);
        encodeDataPair(data, "osversion", osversion);
        encodeDataPair(data, "cores", Integer.toString(coreCount));
        encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
        encodeDataPair(data, "java_version", java_version);
        if(isPing)
            encodeDataPair(data, "ping", "true");
        URL url = new URL((new StringBuilder("http://mcstats.org")).append(String.format("/report/%s", new Object[] {
            encode(pluginName)
        })).toString());
        URLConnection connection;
        if(isMineshafterPresent())
            connection = url.openConnection(Proxy.NO_PROXY);
        else
            connection = url.openConnection();
        connection.setDoOutput(true);
        OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
        writer.write(data.toString());
        writer.flush();
        BufferedReader reader = new BufferedReader(((java.io.Reader) (new InputStreamReader(connection.getInputStream()))));
        String response = reader.readLine();
        writer.close();
        reader.close();
        if(response == null || response.startsWith("ERR"))
            throw new IOException(response);
        else
            return;
    }

    private boolean isMineshafterPresent()
    {
        try
        {
            Class.forName("mineshafter.MineServer");
        }
        catch(Exception e)
        {
            return false;
        }
        return true;
    }

    private static void encodeDataPair(StringBuilder buffer, String key, String value)
        throws UnsupportedEncodingException
    {
        buffer.append('&').append(encode(key)).append('=').append(encode(value));
    }

    private static String encode(String text)
        throws UnsupportedEncodingException
    {
        return URLEncoder.encode(text, "UTF-8");
    }

    private static final int REVISION = 6;
    private static final String BASE_URL = "http://mcstats.org";
    private static final String REPORT_URL = "/report/%s";
    private static final int PING_INTERVAL = 10;
    private final Plugin plugin;
    private final YamlConfiguration configuration;
    private final File configurationFile = getConfigFile();
    private final String guid;
    private final boolean debug;
    private final Object optOutLock = new Object();
    private volatile BukkitTask task;





}


MetricsLite$1.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
package com.gmail.cbodels27.AdminChannel;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;

class MetricsLite$1
    implements Runnable
{

    public void run()
    {
        try
        {
            synchronized(MetricsLite.access$0(MetricsLite.this))
            {
                if(isOptOut() && MetricsLite.access$1(MetricsLite.this) != null)
                {
                    MetricsLite.access$1(MetricsLite.this).cancel();
                    MetricsLite.access$2(MetricsLite.this, ((BukkitTask) (null)));
                }
            }
            MetricsLite.access$3(MetricsLite.this, !firstPost);
            firstPost = false;
        }
        catch(IOException e)
        {
            if(MetricsLite.access$4(MetricsLite.this))
                Bukkit.getLogger().log(Level.INFO, (new StringBuilder("[Metrics] ")).append(e.getMessage()).toString());
        }
    }

    private boolean firstPost;
    final MetricsLite this$0;

    MetricsLite$1()
    {
        this$0 = MetricsLite.this;
        super();
        firstPost = true;
    }
}



$1 побочный класс при компиле его.Мне нужно довести код до 100% из двух имеющихся классов .
...
Рейтинг: 0 / 0
27.03.2014, 10:45
    #38597773
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

А что за декомилятор Вы купили? Смахивает на jad, да и это http://jd.benow.ca/ тоже не за деньги.

MetricsLite$1.java можете удалить, он есть в MetricsLite.java

Вот сюда посмотрите https://github.com/mbax/mcstats.org/blob/master/Bukkit/MetricsLite.java на взгляд, вроде код один в один
...
Рейтинг: 0 / 0
27.03.2014, 10:56
    #38597782
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,
Updater.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
package com.gmail.cbodels27.AdminChannel;

import java.io.*;
import java.net.*;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.xml.namespace.QName;
import javax.xml.stream.*;
import javax.xml.stream.events.*;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;

public class Updater
{
    public static final class UpdateResult extends Enum
    {

        public static UpdateResult[] values()
        {
            UpdateResult aupdateresult[];
            int i;
            UpdateResult aupdateresult1[];
            System.arraycopy(((Object) (aupdateresult = ENUM$VALUES)), 0, ((Object) (aupdateresult1 = new UpdateResult[i = aupdateresult.length])), 0, i);
            return aupdateresult1;
        }

        public static UpdateResult valueOf(String s)
        {
            return (UpdateResult)Enum.valueOf(com/gmail/cbodels27/AdminChannel/Updater$UpdateResult, s);
        }

        public static final UpdateResult SUCCESS;
        public static final UpdateResult NO_UPDATE;
        public static final UpdateResult FAIL_DOWNLOAD;
        public static final UpdateResult FAIL_DBO;
        public static final UpdateResult FAIL_NOVERSION;
        public static final UpdateResult FAIL_BADSLUG;
        public static final UpdateResult UPDATE_AVAILABLE;
        private static final UpdateResult ENUM$VALUES[];

        static 
        {
            SUCCESS = new UpdateResult("SUCCESS", 0);
            NO_UPDATE = new UpdateResult("NO_UPDATE", 1);
            FAIL_DOWNLOAD = new UpdateResult("FAIL_DOWNLOAD", 2);
            FAIL_DBO = new UpdateResult("FAIL_DBO", 3);
            FAIL_NOVERSION = new UpdateResult("FAIL_NOVERSION", 4);
            FAIL_BADSLUG = new UpdateResult("FAIL_BADSLUG", 5);
            UPDATE_AVAILABLE = new UpdateResult("UPDATE_AVAILABLE", 6);
            ENUM$VALUES = (new UpdateResult[] {
                SUCCESS, NO_UPDATE, FAIL_DOWNLOAD, FAIL_DBO, FAIL_NOVERSION, FAIL_BADSLUG, UPDATE_AVAILABLE
            });
        }

        private UpdateResult(String s, int i)
        {
            super(s, i);
        }
    }

    private class UpdateRunnable
        implements Runnable
    {

        public void run()
        {
            if(url != null && readFeed() && versionCheck(versionTitle))
            {
                String fileLink = getFile(versionLink);
                if(fileLink != null && type != UpdateType.NO_DOWNLOAD)
                {
                    String name = file.getName();
                    if(fileLink.endsWith(".zip"))
                    {
                        String split[] = fileLink.split("/");
                        name = split[split.length - 1];
                    }
                    saveFile(new File((new StringBuilder("plugins/")).append(updateFolder).toString()), name, fileLink);
                } else
                {
                    result = UpdateResult.UPDATE_AVAILABLE;
                }
            }
        }

        final Updater this$0;

        private UpdateRunnable()
        {
            this$0 = Updater.this;
            super();
        }

        UpdateRunnable(UpdateRunnable updaterunnable)
        {
            this();
        }
    }

    public static final class UpdateType extends Enum
    {

        public static UpdateType[] values()
        {
            UpdateType aupdatetype[];
            int i;
            UpdateType aupdatetype1[];
            System.arraycopy(((Object) (aupdatetype = ENUM$VALUES)), 0, ((Object) (aupdatetype1 = new UpdateType[i = aupdatetype.length])), 0, i);
            return aupdatetype1;
        }

        public static UpdateType valueOf(String s)
        {
            return (UpdateType)Enum.valueOf(com/gmail/cbodels27/AdminChannel/Updater$UpdateType, s);
        }

        public static final UpdateType DEFAULT;
        public static final UpdateType NO_VERSION_CHECK;
        public static final UpdateType NO_DOWNLOAD;
        private static final UpdateType ENUM$VALUES[];

        static 
        {
            DEFAULT = new UpdateType("DEFAULT", 0);
            NO_VERSION_CHECK = new UpdateType("NO_VERSION_CHECK", 1);
            NO_DOWNLOAD = new UpdateType("NO_DOWNLOAD", 2);
            ENUM$VALUES = (new UpdateType[] {
                DEFAULT, NO_VERSION_CHECK, NO_DOWNLOAD
            });
        }

        private UpdateType(String s, int i)
        {
            super(s, i);
        }
    }


    public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce)
    {
        updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder");
        result = UpdateResult.SUCCESS;
        this.plugin = plugin;
        this.type = type;
        this.announce = announce;
        this.file = file;
        try
        {
            url = new URL((new StringBuilder("http://dev.bukkit.org/server-mods/")).append(slug).append("/files.rss").toString());
        }
        catch(MalformedURLException ex)
        {
            plugin.getLogger().warning((new StringBuilder("The author of this plugin (")).append((String)plugin.getDescription().getAuthors().get(0)).append(") has misconfigured their Auto Update system").toString());
            plugin.getLogger().warning((new StringBuilder("The project slug given ('")).append(slug).append("') is invalid. Please nag the author about this.").toString());
            result = UpdateResult.FAIL_BADSLUG;
        }
        thread = new Thread(((Runnable) (new UpdateRunnable(((UpdateRunnable) (null))))));
        thread.start();
    }

    public UpdateResult getResult()
    {
        waitForThread();
        return result;
    }

    public long getFileSize()
    {
        waitForThread();
        return totalSize;
    }

    public String getLatestVersionString()
    {
        waitForThread();
        return versionTitle;
    }

    public void waitForThread()
    {
        if(thread.isAlive())
            try
            {
                thread.join();
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
            }
    }

    private void saveFile(File folder, String file, String u)
    {
        BufferedInputStream in;
        FileOutputStream fout;
        if(!folder.exists())
            folder.mkdir();
        in = null;
        fout = null;
        try
        {
            URL url = new URL(u);
            int fileLength = url.openConnection().getContentLength();
            in = new BufferedInputStream(url.openStream());
            fout = new FileOutputStream((new StringBuilder(String.valueOf(((Object) (folder.getAbsolutePath()))))).append("/").append(file).toString());
            byte data[] = new byte[1024];
            if(announce)
                plugin.getLogger().info((new StringBuilder("About to download a new update: ")).append(versionTitle).toString());
            long downloaded = 0L;
            int count;
            while((count = in.read(data, 0, 1024)) != -1) 
            {
                downloaded += count;
                fout.write(data, 0, count);
                int percent = (int)((downloaded * 100L) / (long)fileLength);
                if(announce & (percent % 10 == 0))
                    plugin.getLogger().info((new StringBuilder("Downloading update: ")).append(percent).append("% of ").append(fileLength).append(" bytes.").toString());
            }
            File afile[];
            int j = (afile = (new File((new StringBuilder("plugins/")).append(updateFolder).toString())).listFiles()).length;
            for(int i = 0; i < j; i++)
            {
                File xFile = afile[i];
                if(xFile.getName().endsWith(".zip"))
                    xFile.delete();
            }

            File dFile = new File((new StringBuilder(String.valueOf(((Object) (folder.getAbsolutePath()))))).append("/").append(file).toString());
            if(dFile.getName().endsWith(".zip"))
                unzip(dFile.getCanonicalPath());
            if(announce)
                plugin.getLogger().info("Finished updating.");
            break MISSING_BLOCK_LABEL_499;
        }
        catch(Exception ex)
        {
            plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
            result = UpdateResult.FAIL_DOWNLOAD;
        }
        try
        {
            if(in != null)
                in.close();
            if(fout != null)
                fout.close();
        }
        catch(Exception exception1) { }
        break MISSING_BLOCK_LABEL_524;
        Exception exception;
        exception;
        try
        {
            if(in != null)
                in.close();
            if(fout != null)
                fout.close();
        }
        catch(Exception exception2) { }
        throw exception;
        try
        {
            if(in != null)
                in.close();
            if(fout != null)
                fout.close();
        }
        catch(Exception exception3) { }
    }

    private void unzip(String file)
    {
        try
        {
            File fSourceZip = new File(file);
            String zipPath = file.substring(0, file.length() - 4);
            ZipFile zipFile = new ZipFile(fSourceZip);
            Enumeration e;
            for(e = zipFile.entries(); e.hasMoreElements();)
            {
                ZipEntry entry = (ZipEntry)e.nextElement();
                File destinationFilePath = new File(zipPath, entry.getName());
                destinationFilePath.getParentFile().mkdirs();
                if(!entry.isDirectory())
                {
                    BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry));
                    byte buffer[] = new byte[1024];
                    FileOutputStream fos = new FileOutputStream(destinationFilePath);
                    BufferedOutputStream bos = new BufferedOutputStream(((java.io.OutputStream) (fos)), 1024);
                    int b;
                    while((b = bis.read(buffer, 0, 1024)) != -1) 
                        bos.write(buffer, 0, b);
                    bos.flush();
                    bos.close();
                    bis.close();
                    String name = destinationFilePath.getName();
                    if(name.endsWith(".jar") && pluginFile(name))
                        destinationFilePath.renameTo(new File((new StringBuilder("plugins/")).append(updateFolder).append("/").append(name).toString()));
                    entry = null;
                    destinationFilePath = null;
                }
            }

            e = null;
            zipFile.close();
            zipFile = null;
            File afile[];
            int j = (afile = (new File(zipPath)).listFiles()).length;
            for(int i = 0; i < j; i++)
            {
                File dFile = afile[i];
                if(dFile.isDirectory() && pluginFile(dFile.getName()))
                {
                    File oFile = new File((new StringBuilder("plugins/")).append(dFile.getName()).toString());
                    File contents[] = oFile.listFiles();
                    File afile1[];
                    int l = (afile1 = dFile.listFiles()).length;
                    for(int k = 0; k < l; k++)
                    {
                        File cFile = afile1[k];
                        boolean found = false;
                        File afile2[];
                        int j1 = (afile2 = contents).length;
                        for(int i1 = 0; i1 < j1; i1++)
                        {
                            File xFile = afile2[i1];
                            if(!xFile.getName().equals(((Object) (cFile.getName()))))
                                continue;
                            found = true;
                            break;
                        }

                        if(!found)
                            cFile.renameTo(new File((new StringBuilder()).append(((Object) (oFile.getCanonicalFile()))).append("/").append(cFile.getName()).toString()));
                        else
                            cFile.delete();
                    }

                }
                dFile.delete();
            }

            (new File(zipPath)).delete();
            fSourceZip.delete();
        }
        catch(IOException ex)
        {
            ex.printStackTrace();
            plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
            result = UpdateResult.FAIL_DOWNLOAD;
        }
        (new File(file)).delete();
    }

    public boolean pluginFile(String name)
    {
        File afile[];
        int j = (afile = (new File("plugins")).listFiles()).length;
        for(int i = 0; i < j; i++)
        {
            File file = afile[i];
            if(file.getName().equals(((Object) (name))))
                return true;
        }

        return false;
    }

    private String getFile(String link)
    {
        String download = null;
        try
        {
            URL url = new URL(link);
            URLConnection urlConn = url.openConnection();
            InputStreamReader inStream = new InputStreamReader(urlConn.getInputStream());
            BufferedReader buff = new BufferedReader(((java.io.Reader) (inStream)));
            int counter = 0;
            String line;
            while((line = buff.readLine()) != null) 
            {
                counter++;
                if(line.contains("<li class=\"user-action user-action-download\">"))
                    download = line.split("<a href=\"")[1].split("\">Download</a>")[0];
                else
                if(line.contains("<dt>Size</dt>"))
                    sizeLine = counter + 1;
                else
                if(counter == sizeLine)
                {
                    String size = line.replaceAll("<dd>", "").replaceAll("</dd>", "");
                    multiplier = size.contains("MiB") ? 0x100000 : 1024;
                    size = size.replace(" KiB", "").replace(" MiB", "");
                    totalSize = (long)(Double.parseDouble(size) * (double)multiplier);
                }
            }
            urlConn = null;
            inStream = null;
            buff.close();
            buff = null;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
            plugin.getLogger().warning("The auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
            result = UpdateResult.FAIL_DBO;
            return null;
        }
        return download;
    }

    private boolean versionCheck(String title)
    {
        if(type != UpdateType.NO_VERSION_CHECK)
        {
            String version = plugin.getDescription().getVersion();
            if(title.split(" v").length == 2)
            {
                String remoteVersion = title.split(" v")[1].split(" ")[0];
                int remVer = -1;
                int curVer = 0;
                try
                {
                    remVer = calVer(remoteVersion).intValue();
                    curVer = calVer(version).intValue();
                }
                catch(NumberFormatException nfe)
                {
                    remVer = -1;
                }
                if(hasTag(version) || version.equalsIgnoreCase(remoteVersion) || curVer >= remVer)
                {
                    result = UpdateResult.NO_UPDATE;
                    return false;
                }
            } else
            {
                plugin.getLogger().warning((new StringBuilder("The author of this plugin (")).append((String)plugin.getDescription().getAuthors().get(0)).append(") has misconfigured their Auto Update system").toString());
                plugin.getLogger().warning("Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
                plugin.getLogger().warning("Please notify the author of this error.");
                result = UpdateResult.FAIL_NOVERSION;
                return false;
            }
        }
        return true;
    }

    private Integer calVer(String s)
        throws NumberFormatException
    {
        if(s.contains("."))
        {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < s.length(); i++)
            {
                Character c = Character.valueOf(s.charAt(i));
                if(Character.isLetterOrDigit(c.charValue()))
                    sb.append(((Object) (c)));
            }

            return Integer.valueOf(Integer.parseInt(sb.toString()));
        } else
        {
            return Integer.valueOf(Integer.parseInt(s));
        }
    }

    private boolean hasTag(String version)
    {
        String as[];
        int j = (as = noUpdateTag).length;
        for(int i = 0; i < j; i++)
        {
            String string = as[i];
            if(version.contains(((CharSequence) (string))))
                return true;
        }

        return false;
    }

    private boolean readFeed()
    {
label0:
        {
            try
            {
                String title = "";
                String link = "";
                XMLInputFactory inputFactory = XMLInputFactory.newInstance();
                InputStream in = read();
                if(in == null)
                    break label0;
                XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
                while(eventReader.hasNext()) 
                {
                    XMLEvent event = eventReader.nextEvent();
                    if(event.isStartElement())
                    {
                        if(event.asStartElement().getName().getLocalPart().equals("title"))
                        {
                            event = eventReader.nextEvent();
                            title = event.asCharacters().getData();
                        } else
                        if(event.asStartElement().getName().getLocalPart().equals("link"))
                        {
                            event = eventReader.nextEvent();
                            link = event.asCharacters().getData();
                        }
                        continue;
                    }
                    if(!event.isEndElement() || !event.asEndElement().getName().getLocalPart().equals("item"))
                        continue;
                    versionTitle = title;
                    versionLink = link;
                    break;
                }
            }
            catch(XMLStreamException e)
            {
                plugin.getLogger().warning("Could not reach dev.bukkit.org for update checking. Is it offline?");
                return false;
            }
            return true;
        }
        return false;
    }

    private InputStream read()
    {
        try
        {
            return url.openStream();
        }
        catch(IOException e)
        {
            plugin.getLogger().warning("Could not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
        }
        return null;
    }

    private Plugin plugin;
    private UpdateType type;
    private String versionTitle;
    private String versionLink;
    private long totalSize;
    private int sizeLine;
    private int multiplier;
    private boolean announce;
    private URL url;
    private File file;
    private Thread thread;
    private static final String DBOUrl = "http://dev.bukkit.org/server-mods/";
    private String noUpdateTag[] = {
        "-DEV", "-PRE", "-SNAPSHOT"
    };
    private static final int BYTE_SIZE = 1024;
    private String updateFolder;
    private UpdateResult result;
    private static final String TITLE = "title";
    private static final String LINK = "link";
    private static final String ITEM = "item";











}


Updater$UpdateType.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
package com.gmail.cbodels27.AdminChannel;

public static final class Updater$UpdateType extends Enum
{

    public static Updater$UpdateType[] values()
    {
        Updater$UpdateType aupdater$updatetype[];
        int i;
        Updater$UpdateType aupdater$updatetype1[];
        System.arraycopy(((Object) (aupdater$updatetype = ENUM$VALUES)), 0, ((Object) (aupdater$updatetype1 = new Updater$UpdateType[i = aupdater$updatetype.length])), 0, i);
        return aupdater$updatetype1;
    }

    public static Updater$UpdateType valueOf(String s)
    {
        return (Updater$UpdateType)Enum.valueOf(com/gmail/cbodels27/AdminChannel/Updater$UpdateType, s);
    }

    public static final Updater$UpdateType DEFAULT;
    public static final Updater$UpdateType NO_VERSION_CHECK;
    public static final Updater$UpdateType NO_DOWNLOAD;
    private static final Updater$UpdateType ENUM$VALUES[];

    static 
    {
        DEFAULT = new Updater$UpdateType("DEFAULT", 0);
        NO_VERSION_CHECK = new Updater$UpdateType("NO_VERSION_CHECK", 1);
        NO_DOWNLOAD = new Updater$UpdateType("NO_DOWNLOAD", 2);
        ENUM$VALUES = (new Updater$UpdateType[] {
            DEFAULT, NO_VERSION_CHECK, NO_DOWNLOAD
        });
    }

    private Updater$UpdateType(String s, int i)
    {
        super(s, i);
    }
}


Updater$UpdateRunnable.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
package com.gmail.cbodels27.AdminChannel;

import java.io.File;

private class Updater$UpdateRunnable
    implements Runnable
{

    public void run()
    {
        if(Updater.access$0(Updater.this) != null && Updater.access$1(Updater.this) && Updater.access$3(Updater.this, Updater.access$2(Updater.this)))
        {
            String fileLink = Updater.access$5(Updater.this, Updater.access$4(Updater.this));
            if(fileLink != null && Updater.access$6(Updater.this) != Updater.UpdateType.NO_DOWNLOAD)
            {
                String name = Updater.access$7(Updater.this).getName();
                if(fileLink.endsWith(".zip"))
                {
                    String split[] = fileLink.split("/");
                    name = split[split.length - 1];
                }
                Updater.access$9(Updater.this, new File((new StringBuilder("plugins/")).append(Updater.access$8(Updater.this)).toString()), name, fileLink);
            } else
            {
                Updater.access$10(Updater.this, Updater.UpdateResult.UPDATE_AVAILABLE);
            }
        }
    }

    final Updater this$0;

    private Updater$UpdateRunnable()
    {
        this$0 = Updater.this;
        super();
    }

    Updater$UpdateRunnable(Updater$UpdateRunnable updater$updaterunnable)
    {
        this();
    }
}


Updater$UpdateResult.java
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
package com.gmail.cbodels27.AdminChannel;

public static final class Updater$UpdateResult extends Enum
{

    public static Updater$UpdateResult[] values()
    {
        Updater$UpdateResult aupdater$updateresult[];
        int i;
        Updater$UpdateResult aupdater$updateresult1[];
        System.arraycopy(((Object) (aupdater$updateresult = ENUM$VALUES)), 0, ((Object) (aupdater$updateresult1 = new Updater$UpdateResult[i = aupdater$updateresult.length])), 0, i);
        return aupdater$updateresult1;
    }

    public static Updater$UpdateResult valueOf(String s)
    {
        return (Updater$UpdateResult)Enum.valueOf(com/gmail/cbodels27/AdminChannel/Updater$UpdateResult, s);
    }

    public static final Updater$UpdateResult SUCCESS;
    public static final Updater$UpdateResult NO_UPDATE;
    public static final Updater$UpdateResult FAIL_DOWNLOAD;
    public static final Updater$UpdateResult FAIL_DBO;
    public static final Updater$UpdateResult FAIL_NOVERSION;
    public static final Updater$UpdateResult FAIL_BADSLUG;
    public static final Updater$UpdateResult UPDATE_AVAILABLE;
    private static final Updater$UpdateResult ENUM$VALUES[];

    static 
    {
        SUCCESS = new Updater$UpdateResult("SUCCESS", 0);
        NO_UPDATE = new Updater$UpdateResult("NO_UPDATE", 1);
        FAIL_DOWNLOAD = new Updater$UpdateResult("FAIL_DOWNLOAD", 2);
        FAIL_DBO = new Updater$UpdateResult("FAIL_DBO", 3);
        FAIL_NOVERSION = new Updater$UpdateResult("FAIL_NOVERSION", 4);
        FAIL_BADSLUG = new Updater$UpdateResult("FAIL_BADSLUG", 5);
        UPDATE_AVAILABLE = new Updater$UpdateResult("UPDATE_AVAILABLE", 6);
        ENUM$VALUES = (new Updater$UpdateResult[] {
            SUCCESS, NO_UPDATE, FAIL_DOWNLOAD, FAIL_DBO, FAIL_NOVERSION, FAIL_BADSLUG, UPDATE_AVAILABLE
        });
    }

    private Updater$UpdateResult(String s, int i)
    {
        super(s, i);
    }
}



Вот еще такая суматоха .
Decompile я купил в New York
...
Рейтинг: 0 / 0
27.03.2014, 11:01
    #38597793
Alexey Tomin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан$1 побочный класс при компиле его.Мне нужно довести код до 100% из двух имеющихся классов .

Не надо декомпилировать классы с $1 и $2.
Это внутренние анонимные классы основного- они и так в нём.
Основной- надо label убрать. Но всё это настолько базовые вещи, что объяснять- лень.
...
Рейтинг: 0 / 0
27.03.2014, 11:06
    #38597803
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

Э-э нет, дальше сами.

Не ответили что за декомилятор и сколько заплатили (место мне не важно :) ).
...
Рейтинг: 0 / 0
27.03.2014, 11:07
    #38597806
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Alexey Tomin,

Интересная тема ,объясни . (Я рад читать твои ответы)
Ты про эту label ?
Код: java
1.
break MISSING_BLOCK_LABEL_499;


тут еще что-то "JVM INSTR monitorexit,obj
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
            {
                _fld0 = com.gmail.cbodels27.AdminChannel.MetricsLite.this;
                super();
                firstPost = true;
            }
        }
, 0L, 12000L);
        obj;
        JVM INSTR monitorexit;
        return true;
    }

...
Рейтинг: 0 / 0
27.03.2014, 11:09
    #38597809
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,

Сайт decompile: http://dj.navexpress.com/
...
Рейтинг: 0 / 0
27.03.2014, 11:19
    #38597827
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

Зря потратили деньги, этот 'декомпилятор' использует jad(очень старый), по сути это графическая обертка над консольным jad.

Теперь попробуйте декомпилировать вот этим http://jd.benow.ca/ , возможно LABEL и исчезнут.
...
Рейтинг: 0 / 0
27.03.2014, 11:21
    #38597829
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,

Дай мне твой skype ! или другие соц.сети .
...
Рейтинг: 0 / 0
27.03.2014, 11:25
    #38597838
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,

Взял JD-GUI ,а вот cfg
[Manifest]
Version=2
[RecentDirectories]
LoadPath=D:\\Base\\Minecraft\\Плагины\\AdminChannel\\
SavePath=C:\\Users\\Dev\\Desktop\\
[GUI]
MainWindowPosition=212,80 600x400
[RecentFiles]
Path0=D:\\Base\\Minecraft\\Плагины\\AdminChannel\\AdminChannel.jar

Все правильно ?
...
Рейтинг: 0 / 0
27.03.2014, 11:25
    #38597839
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

Есть email в memberinfo
...
Рейтинг: 0 / 0
27.03.2014, 11:28
    #38597844
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

При чем здесь cfg, File->open file ... выбираешь jar и все
...
Рейтинг: 0 / 0
27.03.2014, 11:33
    #38597854
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,

Спасибо ,я даже для удобства убрал нумерацию линий и комментариев .Все отлично ,теперь нужно обратно собрать в jar.

Давай : моя почта mister.swim@yandex.ru . Скайп у тебя есть ? или тебя зарегистрировать ?
...
Рейтинг: 0 / 0
27.03.2014, 12:19
    #38597923
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

Ошибки UpdaterRunnable ,UpdaterResult ,UpdaterType
Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
293.
294.
295.
296.
297.
298.
299.
300.
301.
302.
303.
304.
305.
306.
307.
308.
309.
310.
311.
312.
313.
314.
315.
316.
317.
318.
319.
320.
321.
322.
323.
324.
325.
326.
327.
328.
329.
330.
331.
332.
333.
334.
335.
336.
337.
338.
339.
340.
341.
342.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
package com.gmail.cbodels27.AdminChannel;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;

public class Updater
{
  private Plugin plugin;
  private UpdateType type;
  private String versionTitle;
  private String versionLink;
  private long totalSize;
  private int sizeLine;
  private int multiplier;
  private boolean announce;
  private URL url;
  private File file;
  private Thread thread;
  private static final String DBOUrl = "http://dev.bukkit.org/server-mods/";
  private String[] noUpdateTag = { "-DEV", "-PRE", "-SNAPSHOT" };
  private static final int BYTE_SIZE = 1024;
  private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder");
  private UpdateResult result = UpdateResult.SUCCESS;
  private static final String TITLE = "title";
  private static final String LINK = "link";
  private static final String ITEM = "item";
  
  public static enum UpdateResult
  {
    SUCCESS,  NO_UPDATE,  FAIL_DOWNLOAD,  FAIL_DBO,  FAIL_NOVERSION,  FAIL_BADSLUG,  UPDATE_AVAILABLE;
  }
  
  public static enum UpdateType
  {
    DEFAULT,  NO_VERSION_CHECK,  NO_DOWNLOAD;
  }
  
  public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce)
  {
    this.plugin = plugin;
    this.type = type;
    this.announce = announce;
    this.file = file;
    try
    {
      this.url = new URL("http://dev.bukkit.org/server-mods/" + slug + "/files.rss");
    }
    catch (MalformedURLException ex)
    {
      plugin.getLogger().warning("The author of this plugin (" + (String)plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system");
      plugin.getLogger().warning("The project slug given ('" + slug + "') is invalid. Please nag the author about this.");
      this.result = UpdateResult.FAIL_BADSLUG;
    }
    this.thread = new Thread(new UpdateRunnable(null));
    this.thread.start();
  }
  
  public UpdateResult getResult()
  {
    waitForThread();
    return this.result;
  }
  
  public long getFileSize()
  {
    waitForThread();
    return this.totalSize;
  }
  
  public String getLatestVersionString()
  {
    waitForThread();
    return this.versionTitle;
  }
  
  public void waitForThread()
  {
    if (this.thread.isAlive()) {
      try
      {
        this.thread.join();
      }
      catch (InterruptedException e)
      {
        e.printStackTrace();
      }
    }
  }
  
  private void saveFile(File folder, String file, String u)
  {
    if (!folder.exists()) {
      folder.mkdir();
    }
    BufferedInputStream in = null;
    FileOutputStream fout = null;
    try
    {
      URL url = new URL(u);
      int fileLength = url.openConnection().getContentLength();
      in = new BufferedInputStream(url.openStream());
      fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file);
      
      byte[] data = new byte[1024];
      if (this.announce) {
        this.plugin.getLogger().info("About to download a new update: " + this.versionTitle);
      }
      long downloaded = 0L;
      int count;
      while ((count = in.read(data, 0, 1024)) != -1)
      {
        int count;
        downloaded += count;
        fout.write(data, 0, count);
        int percent = (int)(downloaded * 100L / fileLength);
        if ((this.announce & percent % 10 == 0)) {
          this.plugin.getLogger().info("Downloading update: " + percent + "% of " + fileLength + " bytes.");
        }
      }
      for (File xFile : new File("plugins/" + this.updateFolder).listFiles()) {
        if (xFile.getName().endsWith(".zip")) {
          xFile.delete();
        }
      }
      File dFile = new File(folder.getAbsolutePath() + "/" + file);
      if (dFile.getName().endsWith(".zip")) {
        unzip(dFile.getCanonicalPath());
      }
      if (this.announce) {
        this.plugin.getLogger().info("Finished updating.");
      }
    }
    catch (Exception ex)
    {
      this.plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful.");
      this.result = UpdateResult.FAIL_DOWNLOAD;
      try
      {
        if (in != null) {
          in.close();
        }
        if (fout != null) {
          fout.close();
        }
      }
      catch (Exception localException1) {}
    }
    finally
    {
      try
      {
        if (in != null) {
          in.close();
        }
        if (fout != null) {
          fout.close();
        }
      }
      catch (Exception localException2) {}
    }
  }
  
  private void unzip(String file)
  {
    try
    {
      File fSourceZip = new File(file);
      String zipPath = file.substring(0, file.length() - 4);
      ZipFile zipFile = new ZipFile(fSourceZip);
      Enumeration<? extends ZipEntry> e = zipFile.entries();
      int b;
      String name;
      while (e.hasMoreElements())
      {
        ZipEntry entry = (ZipEntry)e.nextElement();
        destinationFilePath = new File(zipPath, entry.getName());
        destinationFilePath.getParentFile().mkdirs();
        if (!entry.isDirectory())
        {
          bis = new BufferedInputStream(zipFile.getInputStream(entry));
          
          byte[] buffer = new byte[1024];
          FileOutputStream fos = new FileOutputStream(destinationFilePath);
          BufferedOutputStream bos = new BufferedOutputStream(fos, 1024);
          while ((b = bis.read(buffer, 0, 1024)) != -1)
          {
            int b;
            bos.write(buffer, 0, b);
          }
          bos.flush();
          bos.close();
          bis.close();
          name = destinationFilePath.getName();
          if ((name.endsWith(".jar")) && (pluginFile(name))) {
            destinationFilePath.renameTo(new File("plugins/" + this.updateFolder + "/" + name));
          }
          entry = null;
          destinationFilePath = null;
        }
      }
      e = null;
      zipFile.close();
      zipFile = null;
      
      BufferedInputStream bis = (b = new File(zipPath).listFiles()).length;
      for (File destinationFilePath = 0; destinationFilePath < bis; destinationFilePath++)
      {
        File dFile = b[destinationFilePath];
        if (dFile.isDirectory()) {
          if (pluginFile(dFile.getName()))
          {
            File oFile = new File("plugins/" + dFile.getName());
            File[] contents = oFile.listFiles();
            File[] arrayOfFile1;
            String str1 = (arrayOfFile1 = dFile.listFiles()).length;
            for (name = 0; name < str1; name++)
            {
              File cFile = arrayOfFile1[name];
              
              boolean found = false;
              for (File xFile : contents) {
                if (xFile.getName().equals(cFile.getName()))
                {
                  found = true;
                  break;
                }
              }
              if (!found) {
                cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName()));
              } else {
                cFile.delete();
              }
            }
          }
        }
        dFile.delete();
      }
      new File(zipPath).delete();
      fSourceZip.delete();
    }
    catch (IOException ex)
    {
      ex.printStackTrace();
      this.plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful.");
      this.result = UpdateResult.FAIL_DOWNLOAD;
    }
    new File(file).delete();
  }
  
  public boolean pluginFile(String name)
  {
    for (File file : new File("plugins").listFiles()) {
      if (file.getName().equals(name)) {
        return true;
      }
    }
    return false;
  }
  
  private String getFile(String link)
  {
    String download = null;
    try
    {
      URL url = new URL(link);
      URLConnection urlConn = url.openConnection();
      InputStreamReader inStream = new InputStreamReader(urlConn.getInputStream());
      BufferedReader buff = new BufferedReader(inStream);
      
      int counter = 0;
      String line;
      while ((line = buff.readLine()) != null)
      {
        String line;
        counter++;
        if (line.contains("<li class=\"user-action user-action-download\">"))
        {
          download = line.split("<a href=\"")[1].split("\">Download</a>")[0];
        }
        else if (line.contains("<dt>Size</dt>"))
        {
          this.sizeLine = (counter + 1);
        }
        else if (counter == this.sizeLine)
        {
          String size = line.replaceAll("<dd>", "").replaceAll("</dd>", "");
          this.multiplier = (size.contains("MiB") ? 1048576 : 1024);
          size = size.replace(" KiB", "").replace(" MiB", "");
          this.totalSize = ((Double.parseDouble(size) * this.multiplier));
        }
      }
      urlConn = null;
      inStream = null;
      buff.close();
      buff = null;
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
      this.plugin.getLogger().warning("The auto-updater tried to contact dev.bukkit.org, but was unsuccessful.");
      this.result = UpdateResult.FAIL_DBO;
      return null;
    }
    return download;
  }
  
  private boolean versionCheck(String title)
  {
    if (this.type != UpdateType.NO_VERSION_CHECK)
    {
      String version = this.plugin.getDescription().getVersion();
      if (title.split(" v").length == 2)
      {
        String remoteVersion = title.split(" v")[1].split(" ")[0];
        int remVer = -1;int curVer = 0;
        try
        {
          remVer = calVer(remoteVersion).intValue();
          curVer = calVer(version).intValue();
        }
        catch (NumberFormatException nfe)
        {
          remVer = -1;
        }
        if ((hasTag(version)) || (version.equalsIgnoreCase(remoteVersion)) || (curVer >= remVer))
        {
          this.result = UpdateResult.NO_UPDATE;
          return false;
        }
      }
      else
      {
        this.plugin.getLogger().warning("The author of this plugin (" + (String)this.plugin.getDescription().getAuthors().get(0) + ") has misconfigured their Auto Update system");
        this.plugin.getLogger().warning("Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0");
        this.plugin.getLogger().warning("Please notify the author of this error.");
        this.result = UpdateResult.FAIL_NOVERSION;
        return false;
      }
    }
    return true;
  }
  
  private Integer calVer(String s)
    throws NumberFormatException
  {
    if (s.contains("."))
    {
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < s.length(); i++)
      {
        Character c = Character.valueOf(s.charAt(i));
        if (Character.isLetterOrDigit(c.charValue())) {
          sb.append(c);
        }
      }
      return Integer.valueOf(Integer.parseInt(sb.toString()));
    }
    return Integer.valueOf(Integer.parseInt(s));
  }
  
  private boolean hasTag(String version)
  {
    for (String string : this.noUpdateTag) {
      if (version.contains(string)) {
        return true;
      }
    }
    return false;
  }
  
  private boolean readFeed()
  {
    try
    {
      String title = "";
      String link = "";
      
      XMLInputFactory inputFactory = XMLInputFactory.newInstance();
      
      InputStream in = read();
      if (in != null)
      {
        XMLEventReader eventReader = inputFactory.createXMLEventReader(in);
        while (eventReader.hasNext())
        {
          XMLEvent event = eventReader.nextEvent();
          if (event.isStartElement())
          {
            if (event.asStartElement().getName().getLocalPart().equals("title"))
            {
              event = eventReader.nextEvent();
              title = event.asCharacters().getData();
            }
            else if (event.asStartElement().getName().getLocalPart().equals("link"))
            {
              event = eventReader.nextEvent();
              link = event.asCharacters().getData();
            }
          }
          else if (event.isEndElement()) {
            if (event.asEndElement().getName().getLocalPart().equals("item"))
            {
              this.versionTitle = title;
              this.versionLink = link;
              
              break;
            }
          }
        }
        return true;
      }
      return false;
    }
    catch (XMLStreamException e)
    {
      this.plugin.getLogger().warning("Could not reach dev.bukkit.org for update checking. Is it offline?");
    }
    return false;
  }
  
  private InputStream read()
  {
    try
    {
      return this.url.openStream();
    }
    catch (IOException e)
    {
      this.plugin.getLogger().warning("Could not reach BukkitDev file stream for update checking. Is dev.bukkit.org offline?");
    }
    return null;
  }
  
  private class UpdateRunnable
    implements Runnable
  {
    private UpdateRunnable() {}
    
    public void run()
    {
      if (Updater.this.url != null) {
        if (Updater.this.readFeed()) {
          if (Updater.this.versionCheck(Updater.this.versionTitle))
          {
            String fileLink = Updater.this.getFile(Updater.this.versionLink);
            if ((fileLink != null) && (Updater.this.type != Updater.UpdateType.NO_DOWNLOAD))
            {
              String name = Updater.this.file.getName();
              if (fileLink.endsWith(".zip"))
              {
                String[] split = fileLink.split("/");
                name = split[(split.length - 1)];
              }
              Updater.this.saveFile(new File("plugins/" + Updater.this.updateFolder), name, fileLink);
            }
            else
            {
              Updater.this.result = Updater.UpdateResult.UPDATE_AVAILABLE;
            }
          }
        }
      }
    }
  }
}



Помогите ,в чем проблема ?
...
Рейтинг: 0 / 0
27.03.2014, 12:33
    #38597948
0FD
0FD
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

повторное обьявдение в while надо удалять типа
Код: java
1.
2.
3.
while ((count = in.read(data, 0, 1024)) != -1)
 {
        int count; <--удалить, где-то string видел



Неужели декомпилятор сделал вот такое?

Код: java
1.
2.
3.
4.
BufferedInputStream bis = (b = new File(zipPath).listFiles()).length;
for (File destinationFilePath = 0; destinationFilePath < bis; destinationFilePath++)
{
        File dFile = b[destinationFilePath];
...
Рейтинг: 0 / 0
27.03.2014, 13:02
    #38597997
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
0FD,

Да .Я через JD-GUI декомпилил.
...
Рейтинг: 0 / 0
27.03.2014, 13:17
    #38598025
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Майдан,

Ошибки Update.java
Код: java
1.
private UpdateType type;

Код: java
1.
private UpdateResult result = UpdateResult.SUCCESS;

Код: java
1.
public static enum UpdateResult

Код: java
1.
public static enum UpdateType

Код: java
1.
public Updater(Plugin plugin, String slug, File file, UpdateType type, boolean announce)



Вообщем где не смотрел ,везде ошибки UpdaterType ,Result (Среда их выделяет красным) .
...
Рейтинг: 0 / 0
27.03.2014, 14:48
    #38598158
Leonid Kudryavtsev
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Мы реальный проект JAD-ом декомпилировали, иденственные проблемы били, что он не всегда try ... catch блоки правильно делал. Правилось руками за пару минут.

"стою на асфальте я в лыжи обутый, то ли лыжи не едут, то ли...."
...
Рейтинг: 0 / 0
27.03.2014, 15:09
    #38598188
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Leonid Kudryavtsev,

Только он ,один файл Updater из всех 10 файлов .Только его нужно вправить.
...
Рейтинг: 0 / 0
27.03.2014, 15:29
    #38598212
Leonid Kudryavtsev
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
Ну дык напиши по человечески, что нужно сделать и размести в форуме Работа )))

IMHO & AFAIK.
...
Рейтинг: 0 / 0
27.03.2014, 16:02
    #38598267
mayton
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
А сборки от 1.8.x ?
...
Рейтинг: 0 / 0
27.03.2014, 17:10
    #38598328
Майдан
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
интересно вещь тако доллар {help dev}
mayton,

Версия не причем .
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / интересно вещь тако доллар {help dev} / 24 сообщений из 24, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]