Skip to content

Commit 7338792

Browse files
committed
todo: adventure chat
1 parent 35bbc98 commit 7338792

File tree

5 files changed

+337
-313
lines changed

5 files changed

+337
-313
lines changed

pom.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,14 @@
205205
<shadedPattern>org.maxgamer.quickshop.shade.com.github.ben-manes.caffeine.</shadedPattern>
206206
</relocation>
207207
<relocation>
208-
<pattern>org.enginehub:squirrelid.</pattern>
209-
<shadedPattern>org.maxgamer.quickshop.shade.org.enginehub:squirrelid.</shadedPattern>
208+
<pattern>org.enginehub.squirrelid.</pattern>
209+
<shadedPattern>org.maxgamer.quickshop.shade.org.enginehub.squirrelid.</shadedPattern>
210210
</relocation>
211+
<relocation>
212+
<pattern>net.kyori.</pattern>
213+
<shadedPattern>org.maxgamer.quickshop.shade.org.net.kyori.</shadedPattern>
214+
</relocation>
215+
211216

212217
<!-- <relocation>-->
213218
<!-- <pattern>de.leonhard</pattern>-->
@@ -342,10 +347,6 @@
342347
<id>CodeMC</id>
343348
<url>https://repo.codemc.io/repository/maven-public/</url>
344349
</repository>
345-
<repository>
346-
<id>fanciful-repo</id>
347-
<url>https://github.com/mkremins/fanciful/tree/mvn-repo</url>
348-
</repository>
349350
<!-- <repository>-->
350351
<!-- <id>dmulloy2-repo</id>-->
351352
<!-- <url>https://repo.dmulloy2.net/nexus/repository/public/</url>-->
@@ -832,18 +833,18 @@
832833
<version>[1.0,)</version>
833834
<artifactId>rollbar-java</artifactId>
834835
</dependency>
836+
<!-- <dependency>-->
837+
<!-- <groupId>de.themoep</groupId>-->
838+
<!-- <artifactId>minedown</artifactId>-->
839+
<!-- <version>1.7.1-SNAPSHOT</version>-->
840+
<!-- <scope>compile</scope>-->
841+
<!-- </dependency>-->
835842
<dependency>
836843
<groupId>de.themoep</groupId>
837-
<artifactId>minedown</artifactId>
844+
<artifactId>minedown-adventure</artifactId>
838845
<version>1.7.1-SNAPSHOT</version>
839846
<scope>compile</scope>
840847
</dependency>
841-
<!-- <dependency>-->
842-
<!-- <groupId>de.themoep</groupId>-->
843-
<!-- <artifactId>minedown-adventure</artifactId>-->
844-
<!-- <version>1.7.1-SNAPSHOT</version>-->
845-
<!-- <scope>compile</scope>-->
846-
<!-- </dependency>-->
847848
<dependency>
848849
<groupId>me.xanium</groupId>
849850
<artifactId>GemsEconomy</artifactId>
@@ -948,5 +949,11 @@
948949
<systemPath>${project.basedir}/lib/IridiumSkyblock-3.1.1.jar</systemPath>
949950
<scope>system</scope>
950951
</dependency>
952+
<dependency>
953+
<groupId>net.kyori</groupId>
954+
<artifactId>adventure-platform-bukkit</artifactId>
955+
<version>4.0.0</version>
956+
<scope>compile</scope>
957+
</dependency>
951958
</dependencies>
952959
</project>

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
import com.google.common.collect.Lists;
2424
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
2525
import lombok.Getter;
26+
import lombok.NonNull;
2627
import lombok.Setter;
2728
import me.minebuilders.clearlag.Clearlag;
2829
import me.minebuilders.clearlag.listeners.ItemMergeListener;
30+
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
2931
import org.apache.commons.lang.StringUtils;
3032
import org.bukkit.Bukkit;
3133
import org.bukkit.ChatColor;
@@ -47,6 +49,7 @@
4749
import org.maxgamer.quickshop.api.QuickShopAPI;
4850
import org.maxgamer.quickshop.chat.QuickChat;
4951
import org.maxgamer.quickshop.chat.QuickChatType;
52+
import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
5053
import org.maxgamer.quickshop.chat.platform.minedown.BungeeQuickChat;
5154
import org.maxgamer.quickshop.command.CommandManager;
5255
import org.maxgamer.quickshop.database.*;
@@ -254,9 +257,9 @@ public class QuickShop extends JavaPlugin {
254257
@Getter
255258
private BuildInfo buildInfo;
256259
@Getter
257-
private QuickChatType quickChatType = QuickChatType.BUNGEECHAT;
260+
private QuickChatType quickChatType = QuickChatType.ADVENTURE;
258261
@Getter
259-
private QuickChat quickChat = new BungeeQuickChat();
262+
private QuickChat quickChat = new AdventureQuickChat();
260263
@Getter
261264
@Nullable
262265
private String currency = null;
@@ -268,6 +271,7 @@ public class QuickShop extends JavaPlugin {
268271
private Plugin worldEditPlugin;
269272
@Getter
270273
private WorldEditAdapter worldEditAdapter;
274+
private BukkitAudiences adventure;
271275

272276
/**
273277
* Use for mock bukkit
@@ -660,6 +664,11 @@ public final void onDisable() {
660664
HandlerList.unregisterAll(this);
661665
Util.debugLog("Unregistering plugin services...");
662666
getServer().getServicesManager().unregisterAll(this);
667+
Util.debugLog("Cleanup...");
668+
if(this.adventure != null) {
669+
this.adventure.close();
670+
this.adventure = null;
671+
}
663672
Util.debugLog("All shutdown work is finished.");
664673

665674
}
@@ -774,9 +783,11 @@ public final void onEnable() {
774783

775784
getLogger().info("Reading the configuration...");
776785
this.initConfiguration();
786+
777787
getLogger().info("Developers: " + Util.list2String(this.getDescription().getAuthors()));
778788
getLogger().info("Original author: Netherfoam, Timtower, KaiNoMood");
779789
getLogger().info("Let's start loading the plugin");
790+
this.adventure = BukkitAudiences.create(this);
780791
getLogger().info("Chat processor selected: " + this.quickChatType.name());
781792

782793
/* Process Metrics and Sentry error reporter. */
@@ -1946,4 +1957,11 @@ public void registerCustomCommands() {
19461957
}
19471958
Util.debugLog("Command alias successfully registered.");
19481959
}
1960+
1961+
public @NonNull BukkitAudiences adventure() {
1962+
if(this.adventure == null) {
1963+
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
1964+
}
1965+
return this.adventure;
1966+
}
19491967
}

src/main/java/org/maxgamer/quickshop/chat/QuickChatType.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
package org.maxgamer.quickshop.chat;
2121

2222
import org.jetbrains.annotations.NotNull;
23-
import org.maxgamer.quickshop.chat.platform.minedown.BungeeQuickChat;
23+
import org.maxgamer.quickshop.chat.platform.minedown.AdventureQuickChat;
2424

2525
public enum QuickChatType {
2626
/*
2727
* BUNGEECHAT = Use the chat lib that Spigot offered.
2828
* ADVENTURE = Use the chat lib Adventure, it can resolve player disconnected issue but have no message output bug.
2929
*/
30-
BUNGEECHAT(0);
31-
//ADVENTURE(1);
30+
//BUNGEECHAT(0),
31+
ADVENTURE(1);
3232

3333
private final int id;
3434

@@ -42,28 +42,28 @@ public enum QuickChatType {
4242
return type;
4343
}
4444
}
45-
return BUNGEECHAT;
45+
return ADVENTURE;
4646
}
4747

4848
public static int toID(@NotNull QuickChatType type) {
4949
return type.id;
5050
}
5151

5252
public static QuickChat createById(int id) {
53-
// QuickChatType type = fromID(id);
54-
// if (type == QuickChatType.ADVENTURE) {
55-
// return new AdventureQuickChat();
56-
// }
57-
return new BungeeQuickChat();
53+
QuickChatType type = fromID(id);
54+
if (type == QuickChatType.ADVENTURE) {
55+
return new AdventureQuickChat();
56+
}
57+
return new AdventureQuickChat();
58+
// return new BungeeQuickChat();
5859
}
5960

6061
public static QuickChat createByType(QuickChatType type) {
61-
// if (type == QuickChatType.ADVENTURE) {
62-
// return new AdventureQuickChat();
63-
// }
64-
return new BungeeQuickChat();
62+
if (type == QuickChatType.ADVENTURE) {
63+
return new AdventureQuickChat();
64+
}
65+
return new AdventureQuickChat();
6566
}
66-
6767
public int toID() {
6868
return id;
6969
}

0 commit comments

Comments
 (0)