Skip to content

Commit c2f3201

Browse files
committed
Update to latest Velocity and Waterfall
Also use Java 17 now seeing as Velocity requires it now too!
1 parent b3d9102 commit c2f3201

File tree

5 files changed

+98
-30
lines changed

5 files changed

+98
-30
lines changed

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
<groupId>de.themoep</groupId>
99
<artifactId>snap</artifactId>
10-
<version>1.1-SNAPSHOT</version>
10+
<version>1.2-SNAPSHOT</version>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<maven.compiler.target>1.8</maven.compiler.target>
15-
<maven.compiler.source>1.8</maven.compiler.source>
14+
<maven.compiler.target>17</maven.compiler.target>
15+
<maven.compiler.source>17</maven.compiler.source>
1616
<build.number>${buildNumber}</build.number>
1717
<minecraft.plugin.version>${project.version} ${buildDescription}</minecraft.plugin.version>
1818
</properties>
@@ -28,13 +28,13 @@
2828
<dependency>
2929
<groupId>com.velocitypowered</groupId>
3030
<artifactId>velocity-api</artifactId>
31-
<version>3.1.1</version>
31+
<version>3.3.0-SNAPSHOT</version>
3232
<scope>provided</scope>
3333
</dependency>
3434
<dependency>
3535
<groupId>io.github.waterfallmc</groupId>
3636
<artifactId>waterfall-api</artifactId>
37-
<version>1.19-R0.1-SNAPSHOT</version>
37+
<version>1.20-R0.3-SNAPSHOT</version>
3838
<scope>compile</scope>
3939
</dependency>
4040
<!-- API requirements, not actually part of API -->
@@ -80,7 +80,7 @@
8080
<dependency>
8181
<groupId>com.mysql</groupId>
8282
<artifactId>mysql-connector-j</artifactId>
83-
<version>8.0.33</version>
83+
<version>8.2.0</version>
8484
<scope>runtime</scope>
8585
</dependency>
8686
</dependencies>
@@ -131,15 +131,15 @@
131131
<plugin>
132132
<groupId>org.apache.maven.plugins</groupId>
133133
<artifactId>maven-compiler-plugin</artifactId>
134-
<version>3.8.1</version>
134+
<version>3.11.0</version>
135135
<configuration>
136136
<proc>none</proc>
137137
</configuration>
138138
</plugin>
139139
<plugin>
140140
<groupId>org.apache.maven.plugins</groupId>
141141
<artifactId>maven-shade-plugin</artifactId>
142-
<version>3.2.3</version>
142+
<version>3.5.1</version>
143143
<executions>
144144
<execution>
145145
<phase>package</phase>

src/main/java/de/themoep/snap/PluginConfig.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
* You should have received a copy of the GNU Lesser General Public
1818
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
import com.typesafe.config.ConfigParseOptions;
21-
import com.typesafe.config.ConfigRenderOptions;
22-
import ninja.leaping.configurate.ConfigurationNode;
23-
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
24-
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
20+
21+
import org.spongepowered.configurate.ConfigurationNode;
22+
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
23+
import org.spongepowered.configurate.serialize.SerializationException;
2524

2625
import java.io.BufferedReader;
2726
import java.io.IOException;
@@ -51,9 +50,7 @@ public PluginConfig(Snap plugin, Path configFile, String defaultFile) {
5150
this.configFile = configFile;
5251
this.defaultFile = defaultFile;
5352
configLoader = HoconConfigurationLoader.builder()
54-
.setPath(configFile)
55-
.setParseOptions(ConfigParseOptions.defaults())
56-
.setRenderOptions(ConfigRenderOptions.defaults())
53+
.path(configFile)
5754
.build();
5855
}
5956

@@ -62,13 +59,11 @@ public boolean load() {
6259
config = configLoader.load();
6360
if (defaultFile != null && plugin.getClass().getClassLoader().getResource(defaultFile) != null) {
6461
defaultConfig = HoconConfigurationLoader.builder()
65-
.setPath(configFile)
66-
.setParseOptions(ConfigParseOptions.defaults())
67-
.setRenderOptions(ConfigRenderOptions.defaults())
68-
.setSource(() -> new BufferedReader(new InputStreamReader(plugin.getClass().getClassLoader().getResourceAsStream(defaultFile))))
62+
.path(configFile)
63+
.source(() -> new BufferedReader(new InputStreamReader(plugin.getClass().getClassLoader().getResourceAsStream(defaultFile))))
6964
.build()
7065
.load();
71-
if (config.isEmpty()) {
66+
if (config.empty()) {
7267
config = defaultConfig.copy();
7368
}
7469
}
@@ -113,31 +108,40 @@ public void save() {
113108
}
114109

115110
public Object set(String path, Object value) {
116-
ConfigurationNode node = config.getNode(splitPath(path));
117-
Object prev = node.getValue();
118-
node.setValue(value);
111+
ConfigurationNode node = config.node(splitPath(path));
112+
Object prev = node.raw();
113+
try {
114+
node.set(value);
115+
} catch (SerializationException e) {
116+
plugin.getLogger().error("Could not set node at " + path, e);
117+
}
119118
return prev;
120119
}
121120

122121
public ConfigurationNode remove(String path) {
123-
ConfigurationNode node = config.getNode(splitPath(path));
124-
return node.isVirtual() ? node : node.setValue(null);
122+
ConfigurationNode node = config.node(splitPath(path));
123+
try {
124+
return node.virtual() ? node : node.set(null);
125+
} catch (SerializationException e) {
126+
plugin.getLogger().error("Could not remove node at " + path, e);
127+
return null;
128+
}
125129
}
126130

127131
public ConfigurationNode getRawConfig() {
128132
return config;
129133
}
130134

131135
public ConfigurationNode getRawConfig(String path) {
132-
return getRawConfig().getNode(splitPath(path));
136+
return getRawConfig().node(splitPath(path));
133137
}
134138

135139
public boolean has(String path) {
136-
return !getRawConfig(path).isVirtual();
140+
return !getRawConfig(path).virtual();
137141
}
138142

139143
public boolean isSection(String path) {
140-
return getRawConfig(path).hasMapChildren();
144+
return getRawConfig(path).isMap();
141145
}
142146

143147
public int getInt(String path) {
@@ -157,7 +161,7 @@ public double getDouble(String path, double def) {
157161
}
158162

159163
public String getString(String path) {
160-
return getString(path, null);
164+
return getRawConfig(path).getString();
161165
}
162166

163167
public String getString(String path, String def) {

src/main/java/de/themoep/snap/forwarding/SnapPlayer.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.util.Map;
4848
import java.util.Optional;
4949
import java.util.UUID;
50+
import java.util.concurrent.CompletableFuture;
5051
import java.util.stream.Collectors;
5152

5253
public class SnapPlayer extends SnapCommandSender implements ProxiedPlayer {
@@ -108,6 +109,20 @@ public boolean isLegacy() {
108109
return player.getProtocolVersion().isLegacy();
109110
}
110111

112+
@Override
113+
public boolean isTransferred() {
114+
// TODO: Support 1.20.5 features
115+
snap.unsupported("Transferred connections are not supported in Velocity's API yet!");
116+
return false;
117+
}
118+
119+
@Override
120+
public CompletableFuture<byte[]> retrieveCookie(String s) {
121+
// TODO: Support 1.20.5 features
122+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
123+
return null;
124+
}
125+
111126
@Override
112127
public InetSocketAddress getAddress() {
113128
return player.getRemoteAddress();
@@ -423,6 +438,25 @@ public Scoreboard getScoreboard() {
423438
return (Scoreboard) snap.unsupported("Scoreboards are not supported by Snap");
424439
}
425440

441+
@Override
442+
public CompletableFuture<byte[]> retrieveCookie(String s) {
443+
// TODO: Support 1.20.5 features
444+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
445+
return CompletableFuture.completedFuture(null);
446+
}
447+
448+
@Override
449+
public void storeCookie(String s, byte[] bytes) {
450+
// TODO: Support 1.20.5 features
451+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
452+
}
453+
454+
@Override
455+
public void transfer(String s, int i) {
456+
// TODO: Support 1.20.5 features
457+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
458+
}
459+
426460
@Override
427461
public String getName() {
428462
return player.getUsername();

src/main/java/de/themoep/snap/forwarding/listener/ForwardingListener.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.net.InetSocketAddress;
2929
import java.net.SocketAddress;
3030
import java.util.UUID;
31+
import java.util.concurrent.CompletableFuture;
3132

3233
public abstract class ForwardingListener {
3334
protected final Snap snap;
@@ -94,6 +95,20 @@ public boolean isLegacy() {
9495
return connection.getProtocolVersion().isLegacy();
9596
}
9697

98+
@Override
99+
public boolean isTransferred() {
100+
// TODO: Support 1.20.5 features
101+
snap.unsupported("Transferred connections are not supported in Velocity's API yet!");
102+
return false;
103+
}
104+
105+
@Override
106+
public CompletableFuture<byte[]> retrieveCookie(String s) {
107+
// TODO: Support 1.20.5 features
108+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
109+
return null;
110+
}
111+
97112
@Override
98113
public InetSocketAddress getAddress() {
99114
return connection.getRemoteAddress();

src/main/java/de/themoep/snap/forwarding/listener/PreLoginListener.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.net.InetSocketAddress;
3232
import java.net.SocketAddress;
3333
import java.util.UUID;
34+
import java.util.concurrent.CompletableFuture;
3435

3536
public class PreLoginListener extends ForwardingListener {
3637

@@ -107,6 +108,20 @@ public boolean isLegacy() {
107108
return event.getConnection().getProtocolVersion().isLegacy();
108109
}
109110

111+
@Override
112+
public boolean isTransferred() {
113+
// TODO: Support 1.20.5 features
114+
snap.unsupported("Transferred connections are not supported in Velocity's API yet!");
115+
return false;
116+
}
117+
118+
@Override
119+
public CompletableFuture<byte[]> retrieveCookie(String s) {
120+
// TODO: Support 1.20.5 features
121+
snap.unsupported("Transferred connections and cookies are not supported in Velocity's API yet!");
122+
return null;
123+
}
124+
110125
@Override
111126
public InetSocketAddress getAddress() {
112127
return event.getConnection().getRemoteAddress();

0 commit comments

Comments
 (0)