Skip to content

Commit 8f5ef82

Browse files
committed
Add view other command, update cloud, compile against 1.21.8
1 parent f15f5ca commit 8f5ef82

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

build.gradle.kts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "io.github.md5sha256"
8-
version = "1.0.0-SNAPSHOT"
8+
version = "1.0.1-SNAPSHOT"
99

1010
repositories {
1111
mavenCentral()
@@ -46,24 +46,32 @@ repositories {
4646
}
4747

4848
dependencies {
49-
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
49+
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
5050
compileOnly("com.arcaniax:HeadDatabase-API:1.3.2")
51-
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
52-
compileOnly("net.essentialsx:EssentialsX:2.20.1")
51+
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
52+
exclude(group = "org.bukkit", module = "bukkit")
53+
exclude(group = "org.spigotmc", module = "spigot-api")
54+
exclude(group = "io.papermc.paper", module = "paper-api")
55+
}
56+
compileOnly("net.essentialsx:EssentialsX:2.21.2") {
57+
exclude(group = "org.bukkit", module = "bukkit")
58+
exclude(group = "org.spigotmc", module = "spigot-api")
59+
exclude(group = "io.papermc.paper", module = "paper-api")
60+
}
5361
// Provided by spigot library
5462
compileOnly("org.mariadb.jdbc:mariadb-java-client:3.4.0")
5563
compileOnly("com.zaxxer:HikariCP:5.1.0")
5664
// Shaded libs
5765
implementation("de.themoep:inventorygui:1.6.1-SNAPSHOT")
5866
implementation("org.spongepowered:configurate-yaml:4.1.2")
5967
implementation("org.spongepowered:configurate-gson:4.1.2")
60-
implementation("org.incendo:cloud-paper:2.0.0-beta.8") {
68+
implementation("org.incendo:cloud-paper:2.0.0-beta.10") {
6169
exclude("com.google.guava")
6270
}
63-
implementation("org.incendo:cloud-processors-confirmation:1.0.0-beta.3") {
71+
implementation("org.incendo:cloud-processors-confirmation:1.0.0-rc.1") {
6472
exclude("com.google.guava")
6573
}
66-
implementation("org.incendo:cloud-annotations:2.0.0-rc.2") {
74+
implementation("org.incendo:cloud-annotations:2.0.0") {
6775
exclude("com.google.guava")
6876
}
6977
testImplementation(platform("org.junit:junit-bom:5.10.2"))
@@ -103,9 +111,9 @@ tasks {
103111
}
104112

105113
runServer {
106-
minecraftVersion("1.21")
114+
minecraftVersion("1.21.8")
107115
downloadPlugins {
108-
github("EssentialsX", "essentials", "2.20.1", "EssentialsX-2.20.1.jar")
116+
github("EssentialsX", "essentials", "2.21.2", "EssentialsX-2.21.2.jar")
109117
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
110118
}
111119
}

src/main/java/io/github/md5sha256/democracypost/command/PostCommand.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.bukkit.command.CommandSender;
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.plugin.Plugin;
12+
import org.checkerframework.checker.units.qual.A;
1213
import org.incendo.cloud.SenderMapper;
1314
import org.incendo.cloud.annotations.AnnotationParser;
1415
import org.incendo.cloud.annotations.Argument;
@@ -18,6 +19,9 @@
1819
import org.incendo.cloud.execution.ExecutionCoordinator;
1920
import org.incendo.cloud.paper.LegacyPaperCommandManager;
2021
import org.incendo.cloud.paper.PaperCommandManager;
22+
import org.incendo.cloud.paper.util.sender.PaperSimpleSenderMapper;
23+
import org.incendo.cloud.paper.util.sender.PlayerSource;
24+
import org.incendo.cloud.paper.util.sender.Source;
2125

2226
import javax.annotation.Nonnull;
2327

@@ -27,10 +31,10 @@ public class PostCommand {
2731

2832
public PostCommand(@Nonnull Plugin plugin, @Nonnull PostOfficeMenu postOfficeMenu) {
2933
this.postOfficeMenu = postOfficeMenu;
30-
var commandManager = PaperCommandManager.builder()
34+
var commandManager = PaperCommandManager.builder(PaperSimpleSenderMapper.simpleSenderMapper())
3135
.executionCoordinator(ExecutionCoordinator.simpleCoordinator())
3236
.buildOnEnable(plugin);
33-
var annotationParser = new AnnotationParser<>(commandManager, CommandSourceStack.class);
37+
var annotationParser = new AnnotationParser<>(commandManager, Source.class);
3438
annotationParser.parse(this);
3539
}
3640

@@ -53,22 +57,35 @@ public void commandOpen(
5357
@Command("post view <player>")
5458
@Permission("democracypost.view")
5559
public void commandView(
56-
@Nonnull CommandSourceStack senderSourceStack,
60+
@Nonnull PlayerSource playerSource,
5761
@Nonnull @Argument(value = "player") OfflinePlayer who) {
58-
CommandSender sender = senderSourceStack.getSender();
59-
if (!(senderSourceStack.getExecutor() instanceof Player executor)) {
60-
sender.sendMessage("Executor must be an instance of a player!");
61-
return;
62-
}
62+
Player sender = playerSource.source();
6363
// Prevent the sender from going "back"
64-
InventoryGui.clearHistory(executor);
64+
InventoryGui.clearHistory(sender);
6565
this.postOfficeMenu.createParcelListUi(who.getUniqueId()).whenComplete((gui, throwable) -> {
6666
if (throwable != null) {
6767
sender.sendMessage(Component.text("Error occurred when retrieving packages for " + who.getName(),
6868
NamedTextColor.RED));
6969
return;
7070
}
71-
gui.show(executor);
71+
gui.show(sender);
72+
});
73+
}
74+
75+
@Command("post view <player> <targetPlayer>")
76+
@Permission("democracypost.view.other")
77+
public void commandViewOther(
78+
@Nonnull @Argument(value = "player") OfflinePlayer who,
79+
@Nonnull @Argument(value = "targetPlayer") Player toOpen) {
80+
// Prevent the sender from going "back"
81+
InventoryGui.clearHistory(toOpen);
82+
this.postOfficeMenu.createParcelListUi(who.getUniqueId()).whenComplete((gui, throwable) -> {
83+
if (throwable != null) {
84+
toOpen.sendMessage(Component.text("Error occurred when retrieving packages for " + who.getName(),
85+
NamedTextColor.RED));
86+
return;
87+
}
88+
gui.show(toOpen);
7289
});
7390
}
7491

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: DemocracyPost
22
version: '${version}'
33
main: io.github.md5sha256.democracypost.DemocracyPost
4-
api-version: '1.20'
4+
api-version: '1.21.8'
55
authors: [andrewandy]
66
depend: ['Vault', 'Essentials']
77
softdepend: ['HeadDatabase']

0 commit comments

Comments
 (0)