Skip to content

Commit e717697

Browse files
Fixed region file naming, fixed bungee memory leak, packets can now have a target server, fixed sqlite, rewrote island file copying, fixed missing apache commons exception, worlds no longer create / load if they already exist on startup
1 parent b2f708e commit e717697

File tree

17 files changed

+140
-63
lines changed

17 files changed

+140
-63
lines changed

build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ repositories {
99
jcenter()
1010
mavenCentral()
1111

12-
maven { url = 'http://nexus.hc.to/content/repositories/pub_releases' }
12+
maven { url = 'https://nexus.hc.to/content/repositories/pub_releases' }
1313
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
1414
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
15-
maven { url = "http://repo.dmulloy2.net/nexus/repository/public/" }
16-
maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi'}
15+
maven { url = "https://repo.dmulloy2.net/nexus/repository/public/" }
16+
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi'}
1717
maven { url = 'https://mvn.intellectualsites.com/content/repositories/releases/'}
18-
maven { url "https://repo.glaremasters.me/repository/concuncan/" }
18+
maven { url = "https://repo.glaremasters.me/repository/concuncan/" }
1919

2020
mavenLocal()
2121

@@ -26,8 +26,8 @@ dependencies {
2626
implementation group: 'net.md-5', name: 'bungeecord-api', version: '1.16-R0.5-SNAPSHOT'
2727
implementation 'org.spigotmc:spigot:1.8.8-R0.1-SNAPSHOT'
2828

29-
implementation 'org.projectlombok:lombok:1.18.20'
30-
annotationProcessor('org.projectlombok:lombok:1.18.20')
29+
implementation 'org.projectlombok:lombok:1.18.22'
30+
annotationProcessor('org.projectlombok:lombok:1.18.22')
3131

3232
implementation fileTree(dir: 'libs', include: ['*.jar'])
3333
implementation 'de.tr7zw:item-nbt-api-plugin:2.1.0'
13.7 MB
Binary file not shown.

libs/WorldEdit.jar

1.65 MB
Binary file not shown.

src/main/java/me/illusion/skyblockcore/bungee/listener/SpigotListener.java

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import me.illusion.skyblockcore.shared.packet.PacketProcessor;
66
import me.illusion.skyblockcore.shared.packet.data.ProxyToServerPacket;
77
import net.md_5.bungee.api.ProxyServer;
8+
import net.md_5.bungee.api.config.ServerInfo;
89
import net.md_5.bungee.api.event.PluginMessageEvent;
910
import net.md_5.bungee.api.plugin.Listener;
1011
import net.md_5.bungee.event.EventHandler;
@@ -34,6 +35,12 @@ public void send(Packet packet) {
3435

3536
ProxyToServerPacket proxyToServerPacket = (ProxyToServerPacket) packet;
3637

38+
String targetServer = proxyToServerPacket.getTargetServer();
39+
40+
if (targetServer == null) {
41+
for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values())
42+
serverInfo.sendData("SkyblockChannel", packet.getAllBytes());
43+
}
3744
ProxyServer
3845
.getInstance()
3946
.getServerInfo(proxyToServerPacket.getTargetServer())

src/main/java/me/illusion/skyblockcore/bungee/utilities/YMLBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public YMLBase(Plugin plugin, File file, boolean existsOnSource) {
2525
this.file = file;
2626

2727
if (!file.exists()) {
28-
try {
28+
try (InputStream stream = plugin.getResourceAsStream(file.getName())) {
2929
file.getParentFile().mkdirs();
3030
if (existsOnSource) {
31-
InputStream stream = plugin.getResourceAsStream(file.getName());
3231
Files.copy(stream, file.toPath());
32+
stream.close();
3333
} else
3434
file.createNewFile();
3535
} catch (IOException e) {

src/main/java/me/illusion/skyblockcore/shared/packet/Packet.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void writeByte(byte value) {
5454
stream.writeByte(value);
5555
}
5656

57-
protected void writeByteArray(byte[] bytes) {
57+
protected void writeByteArray(byte... bytes) {
5858
validateStream();
5959
writeInt(bytes.length);
6060
stream.write(bytes);
@@ -100,21 +100,19 @@ protected void writeUUID(UUID uuid) {
100100
writeLong(uuid.getLeastSignificantBits());
101101
}
102102

103-
protected void writeBungeeText(BaseComponent[] text) {
103+
protected void writeBungeeText(BaseComponent... text) {
104104
writeString(ComponentSerializer.toString(text));
105105
}
106106

107107

108108
@SneakyThrows
109109
protected void writeObject(Object object) {
110110
validateStream();
111-
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
112-
ObjectOutputStream out = new ObjectOutputStream(bos);
111+
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos)) {
113112
out.writeObject(object);
114113
out.flush();
115114
byte[] bytes = bos.toByteArray();
116115
writeByteArray(bytes);
117-
out.close();
118116
}
119117
// ignore close exception
120118
}

src/main/java/me/illusion/skyblockcore/shared/storage/SerializedFile.java

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.Serializable;
88
import java.nio.file.Files;
99
import java.util.concurrent.CompletableFuture;
10+
import java.util.concurrent.ExecutionException;
1011

1112
@EqualsAndHashCode
1213
public class SerializedFile implements Serializable {
@@ -18,6 +19,15 @@ public SerializedFile(File file) {
1819
setFile(file);
1920
}
2021

22+
private SerializedFile(File file, byte[] contents) {
23+
this.file = file;
24+
this.contents = contents;
25+
}
26+
27+
public SerializedFile copy() {
28+
return new SerializedFile(this.file, contents);
29+
}
30+
2131
public static SerializedFile[] loadArray(File[] array) {
2232
SerializedFile[] newArray = new SerializedFile[array.length];
2333

@@ -27,6 +37,14 @@ public static SerializedFile[] loadArray(File[] array) {
2737
return newArray;
2838
}
2939

40+
public void save() {
41+
try {
42+
getFile().get();
43+
} catch (InterruptedException | ExecutionException e) {
44+
e.printStackTrace();
45+
}
46+
}
47+
3048
public CompletableFuture<File> getFile() {
3149
return CompletableFuture.supplyAsync(() -> {
3250
if (!file.exists()) {
@@ -48,7 +66,15 @@ public CompletableFuture<File> getFile() {
4866
}
4967

5068
public final void setFile(File file) {
69+
setFile(file, true);
70+
}
71+
72+
public final void setFile(File file, boolean readNewContents) {
5173
this.file = file;
74+
75+
if (!file.exists() || !readNewContents)
76+
return;
77+
5278
try {
5379
this.contents = Files.readAllBytes(file.toPath());
5480
} catch (IOException e) {

src/main/java/me/illusion/skyblockcore/shared/storage/handler/SQLiteHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public CompletableFuture<Boolean> setup(String ip, int port, String database, St
4040

4141
@Override
4242
public boolean isFileBased() {
43-
return false;
43+
return true;
4444
}
4545
}

src/main/java/me/illusion/skyblockcore/spigot/SkyblockPlugin.java

+18-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import me.illusion.skyblockcore.spigot.hook.VaultHook;
1212
import me.illusion.skyblockcore.spigot.island.IslandManager;
1313
import me.illusion.skyblockcore.spigot.island.world.EmptyWorldGenerator;
14+
import me.illusion.skyblockcore.spigot.listener.DeathListener;
15+
import me.illusion.skyblockcore.spigot.listener.DebugListener;
1416
import me.illusion.skyblockcore.spigot.listener.JoinListener;
1517
import me.illusion.skyblockcore.spigot.listener.LeaveListener;
1618
import me.illusion.skyblockcore.spigot.messaging.BungeeMessaging;
@@ -21,6 +23,7 @@
2123
import org.bukkit.Bukkit;
2224
import org.bukkit.WorldCreator;
2325
import org.bukkit.entity.Player;
26+
import org.bukkit.generator.ChunkGenerator;
2427
import org.bukkit.plugin.java.JavaPlugin;
2528

2629
import java.io.File;
@@ -89,6 +92,14 @@ Bungee messaging handler, responsible for communication to proxy(ies)
8992

9093
@Override
9194
public void onEnable() {
95+
emptyWorldGenerator = new EmptyWorldGenerator();
96+
97+
System.out.println("Registering configuration files");
98+
messages = new MessagesFile(this);
99+
islandConfig = new IslandConfig(this);
100+
101+
System.out.println("Creating worlds");
102+
worldManager = new WorldManager(this);
92103
// Loads the SQL, when that's complete with a response (true|false), loads if false
93104
setupStorage().whenComplete((val, throwable) -> {
94105
if (!val) // if the setup is incorrect, don't load
@@ -104,27 +115,22 @@ public void onEnable() {
104115
}
105116

106117
private void load() {
107-
System.out.println("Registering configuration files");
108118

109-
messages = new MessagesFile(this);
110-
islandConfig = new IslandConfig(this);
111119
islandManager = new IslandManager(this);
112120
commandManager = new CommandManager(this);
113121
playerManager = new PlayerManager();
114-
emptyWorldGenerator = new EmptyWorldGenerator();
115122

116123
System.out.println("Setting up pasting handler");
117124
pastingHandler = PastingType.enable(this, islandConfig.getPastingSelection());
118125

119126
System.out.println("Registering start files");
120127
startSchematic = startFiles();
121128

122-
System.out.println("Creating worlds");
123-
worldManager = new WorldManager(this);
124-
125129
System.out.println("Registering listeners");
126130
Bukkit.getPluginManager().registerEvents(new JoinListener(this), this);
127131
Bukkit.getPluginManager().registerEvents(new LeaveListener(this), this);
132+
Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
133+
Bukkit.getPluginManager().registerEvents(new DebugListener(this), this);
128134

129135
System.out.println("Registering default commands.");
130136
registerDefaultCommands();
@@ -206,7 +212,7 @@ private File[] startFiles() {
206212
if (pastingHandler.getType() == PastingType.FAWE)
207213
saveResource("start-schematic" + File.separator + "skyblock-schematic.schematic", false);
208214
else
209-
saveResource("start-schematic" + File.separator + "r0.0.mca", false);
215+
saveResource("start-schematic" + File.separator + "r.0.0.mca", false);
210216
}
211217

212218
return startSchematicFolder.listFiles();
@@ -216,4 +222,8 @@ private void sync(Runnable runnable) {
216222
Bukkit.getScheduler().runTask(this, runnable);
217223
}
218224

225+
@Override
226+
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
227+
return emptyWorldGenerator;
228+
}
219229
}

src/main/java/me/illusion/skyblockcore/spigot/command/comparison/ComparisonResult.java

+8-11
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,31 @@ public class ComparisonResult {
1010
private boolean fullyMatches;
1111
private int[] wildcardPositions = null;
1212

13-
private final String[] currentSplit;
14-
15-
public ComparisonResult(String current, String test, String[] aliases) {
16-
currentSplit = StringUtil.split(current, '.');
17-
test(test);
13+
public ComparisonResult(String identifier, String test, String[] aliases) {
14+
test(identifier, test);
1815

1916
if (!fullyMatches)
2017
for (String str : aliases) {
21-
test(str);
18+
test(str, test);
2219

2320
if (fullyMatches)
2421
break;
2522
}
2623

2724
partiallyMatches = fullyMatches || partiallyMatches;
28-
2925
}
3026

31-
private void test(String test) {
27+
private void test(String identifier, String test) {
28+
String[] identifierSplit = StringUtil.split(identifier, '.');
3229
String[] testSplit = StringUtil.split(test, '.');
3330

34-
int length = currentSplit.length;
31+
int length = identifierSplit.length;
3532

3633
wildcardPositions = new int[length];
3734
int wildcard = 0;
3835

39-
for(int i = 0; i < length; i++) {
40-
String word = currentSplit[i];
36+
for (int i = 0; i < length; i++) {
37+
String word = identifierSplit[i];
4138
String testWord = testSplit[i];
4239

4340
if ("*".equals(word)) { // If word is wildcard

0 commit comments

Comments
 (0)