Skip to content

Commit 04cd4bd

Browse files
Update to 1.19.3
Disable origins support
1 parent 653f487 commit 04cd4bd

File tree

4 files changed

+55
-84
lines changed

4 files changed

+55
-84
lines changed

build.gradle

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.12.+'
2+
id 'fabric-loom' version '1.0.+'
33
id 'maven-publish'
44
}
55

@@ -48,18 +48,10 @@ dependencies {
4848
modImplementation include("eu.pb4:sgui:${project.sgui_version}")
4949

5050
modImplementation "dev.emi:trinkets:${project.trinkets_version}"
51-
modImplementation "com.github.apace100:apoli:${project.apoli_version}"
52-
/*
53-
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:3.0.0"
54-
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:3.0.0"
51+
//modImplementation "com.github.apace100:apoli:${project.apoli_version}"
5552

56-
modImplementation ("com.github.apace100:origins-fabric:${project.origins_version}") {
57-
exclude group: "com.terraformersmc"
58-
}
59-
*/
60-
61-
modImplementation "me.lucko:fabric-permissions-api:0.1-SNAPSHOT"
62-
include "me.lucko:fabric-permissions-api:0.1-SNAPSHOT"
53+
modImplementation "me.lucko:fabric-permissions-api:0.2-SNAPSHOT"
54+
include "me.lucko:fabric-permissions-api:0.2-SNAPSHOT"
6355

6456
compileOnly 'net.luckperms:api:5.3'
6557
}

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://fabricmc.net/develop/
5-
minecraft_version=1.19
6-
yarn_mappings=1.19+build.1
7-
loader_version=0.14.6
5+
minecraft_version=1.19.3
6+
yarn_mappings=1.19.3+build.3
7+
loader_version=0.14.11
88
# Mod Properties
9-
mod_version=1.4.9
9+
mod_version=1.4.10
1010
maven_group=us.potatoboy
1111
archives_base_name=InvView
1212
# Dependencies
1313
# check this on https://fabricmc.net/develop/
14-
fabric_version=0.55.2+1.19
15-
trinkets_version=3.4.0
16-
apoli_version=2.5.0
17-
sgui_version=1.1.3+1.19
14+
fabric_version=0.69.1+1.19.3
15+
trinkets_version=3.5.0
16+
apoli_version=e8b66eb
17+
sgui_version=1.2.0+1.19.3

src/main/java/us/potatoboy/invview/InvView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void onInitialize() {
7474
viewNode.addChild(trinketNode);
7575
}
7676
if (isOrigins) {
77-
viewNode.addChild(originNode);
77+
//viewNode.addChild(originNode);
7878
}
7979
});
8080

src/main/java/us/potatoboy/invview/ViewCommand.java

Lines changed: 42 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
import dev.emi.trinkets.api.TrinketInventory;
99
import dev.emi.trinkets.api.TrinketsApi;
1010
import eu.pb4.sgui.api.gui.SimpleGui;
11-
import io.github.apace100.apoli.component.PowerHolderComponent;
12-
import io.github.apace100.apoli.power.InventoryPower;
1311
import me.lucko.fabric.api.permissions.v0.Permissions;
14-
import net.luckperms.api.LuckPermsProvider;
15-
import net.luckperms.api.cacheddata.CachedPermissionData;
16-
import net.luckperms.api.util.Tristate;
1712
import net.minecraft.command.argument.GameProfileArgumentType;
1813
import net.minecraft.inventory.EnderChestInventory;
1914
import net.minecraft.nbt.NbtCompound;
@@ -29,23 +24,24 @@
2924
import us.potatoboy.invview.gui.SavingPlayerDataGui;
3025
import us.potatoboy.invview.gui.UnmodifiableSlot;
3126

32-
import java.util.List;
3327
import java.util.Map;
34-
import java.util.concurrent.CompletableFuture;
35-
3628

3729
public class ViewCommand {
3830
private static MinecraftServer minecraftServer = InvView.getMinecraftServer();
3931

32+
private static final String permProtected = "invview.protected";
33+
private static final String permModify = "invview.can_modify";
34+
private static final String msgProtected = "Requested inventory is protected";
35+
4036
public static int inv(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
4137
ServerPlayerEntity player = context.getSource().getPlayer();
4238
ServerPlayerEntity requestedPlayer = getRequestedPlayer(context);
4339

44-
boolean canModify = Permissions.check(context.getSource(), "invview.can_modify", true);
40+
boolean canModify = Permissions.check(context.getSource(), permModify, true);
4541

46-
isProtected(requestedPlayer).thenAcceptAsync(isProtected -> {
42+
Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> {
4743
if (isProtected) {
48-
context.getSource().sendError(Text.literal("Requested inventory is protected"));
44+
context.getSource().sendError(Text.literal(msgProtected));
4945
} else {
5046
SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X5, player, requestedPlayer);
5147
gui.setTitle(requestedPlayer.getName());
@@ -65,11 +61,11 @@ public static int eChest(CommandContext<ServerCommandSource> context) throws Com
6561
ServerPlayerEntity requestedPlayer = getRequestedPlayer(context);
6662
EnderChestInventory requestedEchest = requestedPlayer.getEnderChestInventory();
6763

68-
boolean canModify = Permissions.check(context.getSource(), "invview.can_modify", true);
64+
boolean canModify = Permissions.check(context.getSource(), permModify, true);
6965

70-
isProtected(requestedPlayer).thenAcceptAsync(isProtected -> {
66+
Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> {
7167
if (isProtected) {
72-
context.getSource().sendError(Text.literal("Requested inventory is protected"));
68+
context.getSource().sendError(Text.literal(msgProtected));
7369
} else {
7470
SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X3, player, requestedPlayer);
7571
gui.setTitle(requestedPlayer.getName());
@@ -89,11 +85,11 @@ public static int trinkets(CommandContext<ServerCommandSource> context) throws C
8985
ServerPlayerEntity requestedPlayer = getRequestedPlayer(context);
9086
TrinketComponent requestedComponent = TrinketsApi.getTrinketComponent(requestedPlayer).get();
9187

92-
boolean canModify = Permissions.check(context.getSource(), "invview.can_modify", true);
88+
boolean canModify = Permissions.check(context.getSource(), permModify, true);
9389

94-
isProtected(requestedPlayer).thenAcceptAsync(isProtected -> {
90+
Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> {
9591
if (isProtected) {
96-
context.getSource().sendError(Text.literal("Requested inventory is protected"));
92+
context.getSource().sendError(Text.literal(msgProtected));
9793
} else {
9894
SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X2, player, requestedPlayer);
9995
gui.setTitle(requestedPlayer.getName());
@@ -115,34 +111,34 @@ public static int trinkets(CommandContext<ServerCommandSource> context) throws C
115111
}
116112

117113
public static int origin(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
118-
ServerPlayerEntity player = context.getSource().getPlayer();
119-
ServerPlayerEntity requestedPlayer = getRequestedPlayer(context);
120-
121-
boolean canModify = Permissions.check(context.getSource(), "invview.can_modify", true);
122-
123-
isProtected(requestedPlayer).thenAcceptAsync(isProtected -> {
124-
if (isProtected) {
125-
context.getSource().sendError(Text.literal("Requested inventory is protected"));
126-
} else {
127-
List<InventoryPower> inventories = PowerHolderComponent.getPowers(requestedPlayer,
128-
InventoryPower.class);
129-
if (inventories.isEmpty()) {
130-
context.getSource().sendError(Text.literal("Requested player has no inventory power"));
131-
} else {
132-
SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X5, player, requestedPlayer);
133-
gui.setTitle(requestedPlayer.getName());
134-
int index = 0;
135-
for (InventoryPower inventory : inventories) {
136-
for (int i = 0; i < inventory.size(); i++) {
137-
gui.setSlotRedirect(index, canModify ? new Slot(inventory, i, 0, 0) : new UnmodifiableSlot(inventory, i));
138-
index += 1;
139-
}
140-
}
141-
142-
gui.open();
143-
}
144-
}
145-
});
114+
// ServerPlayerEntity player = context.getSource().getPlayer();
115+
// ServerPlayerEntity requestedPlayer = getRequestedPlayer(context);
116+
//
117+
// boolean canModify = Permissions.check(context.getSource(), permModify, true);
118+
//
119+
// Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> {
120+
// if (isProtected) {
121+
// context.getSource().sendError(Text.literal(msgProtected));
122+
// } else {
123+
// List<InventoryPower> inventories = PowerHolderComponent.getPowers(requestedPlayer,
124+
// InventoryPower.class);
125+
// if (inventories.isEmpty()) {
126+
// context.getSource().sendError(Text.literal("Requested player has no inventory power"));
127+
// } else {
128+
// SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X5, player, requestedPlayer);
129+
// gui.setTitle(requestedPlayer.getName());
130+
// int index = 0;
131+
// for (InventoryPower inventory : inventories) {
132+
// for (int i = 0; i < inventory.size(); i++) {
133+
// gui.setSlotRedirect(index, canModify ? new Slot(inventory, i, 0, 0) : new UnmodifiableSlot(inventory, i));
134+
// index += 1;
135+
// }
136+
// }
137+
//
138+
// gui.open();
139+
// }
140+
// }
141+
// });
146142

147143
return 1;
148144
}
@@ -153,7 +149,7 @@ private static ServerPlayerEntity getRequestedPlayer(CommandContext<ServerComman
153149
ServerPlayerEntity requestedPlayer = minecraftServer.getPlayerManager().getPlayer(requestedProfile.getName());
154150

155151
if (requestedPlayer == null) {
156-
requestedPlayer = minecraftServer.getPlayerManager().createPlayer(requestedProfile, null);
152+
requestedPlayer = minecraftServer.getPlayerManager().createPlayer(requestedProfile);
157153
NbtCompound compound = minecraftServer.getPlayerManager().loadPlayerData(requestedPlayer);
158154
if (compound != null) {
159155
ServerWorld world = minecraftServer.getWorld(
@@ -168,21 +164,4 @@ private static ServerPlayerEntity getRequestedPlayer(CommandContext<ServerComman
168164

169165
return requestedPlayer;
170166
}
171-
172-
private static CompletableFuture<Boolean> isProtected(ServerPlayerEntity playerEntity) {
173-
if (!InvView.isLuckPerms)
174-
return CompletableFuture.completedFuture(false);
175-
176-
return LuckPermsProvider.get().getUserManager().loadUser(playerEntity.getUuid())
177-
.thenApplyAsync(user -> {
178-
CachedPermissionData permissionData = user.getCachedData()
179-
.getPermissionData(user.getQueryOptions());
180-
Tristate tristate = permissionData.checkPermission("invview.protected");
181-
if (tristate.equals(Tristate.UNDEFINED)) {
182-
return false;
183-
}
184-
185-
return tristate.asBoolean();
186-
});
187-
}
188167
}

0 commit comments

Comments
 (0)