|
1 | 1 | package com.github.sanctum.labyrinth.data.service;
|
2 | 2 |
|
3 | 3 | import com.github.sanctum.labyrinth.Labyrinth;
|
4 |
| -import com.github.sanctum.labyrinth.data.FileList; |
5 | 4 | import com.github.sanctum.labyrinth.data.FileManager;
|
6 | 5 | import com.github.sanctum.labyrinth.data.Registry;
|
| 6 | +import java.io.File; |
7 | 7 | import java.io.InputStream;
|
8 | 8 | import org.bukkit.Bukkit;
|
9 | 9 | import org.bukkit.plugin.ServicePriority;
|
10 | 10 |
|
11 | 11 | public class ServiceHandshake {
|
12 | 12 |
|
13 | 13 | public static void locate() {
|
14 |
| - FileManager fm = FileList.search(Labyrinth.getInstance()).find("Test", "Service"); |
15 | 14 | String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].substring(1);
|
16 | 15 | InputStream stream = Labyrinth.getInstance().getResource(version + ".jar");
|
| 16 | + |
17 | 17 | if (stream == null) {
|
18 | 18 | Labyrinth.getInstance().getLogger().severe("===================================================================");
|
19 | 19 | Labyrinth.getInstance().getLogger().severe("- Version service " + version + " not found. Consult labyrinth developers.");
|
20 | 20 | Labyrinth.getInstance().getLogger().severe("===================================================================");
|
21 | 21 | return;
|
22 | 22 | }
|
23 |
| - FileManager.copy(stream, fm.getFile()); |
24 |
| - Labyrinth.getInstance().getLogger().info("==================================================================="); |
25 |
| - Labyrinth.getInstance().getLogger().info("- Version service " + version + " injected into directory."); |
26 |
| - Labyrinth.getInstance().getLogger().info("==================================================================="); |
| 23 | + |
| 24 | + File file = new File("plugins/Labyrinth/Service/" + version + ".jar"); |
| 25 | + |
| 26 | + for (File f : file.getParentFile().listFiles()) { |
| 27 | + if (f.isFile()) { |
| 28 | + if (f.delete()) { |
| 29 | + Labyrinth.getInstance().getLogger().info("- Deleting old version traces."); |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + if (!file.exists()) { |
| 35 | + FileManager.copy(stream, file); |
| 36 | + Labyrinth.getInstance().getLogger().info("==================================================================="); |
| 37 | + Labyrinth.getInstance().getLogger().info("- Compiling version " + version + "."); |
| 38 | + Labyrinth.getInstance().getLogger().info("==================================================================="); |
| 39 | + } |
27 | 40 | }
|
28 | 41 |
|
29 | 42 | public static void register() {
|
|
0 commit comments