Skip to content

Commit 3ed4537

Browse files
committed
add function of storageDisplay
1 parent 5228cd9 commit 3ed4537

28 files changed

+1960
-26
lines changed

build.gradle

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,53 @@ base {
1111
}
1212

1313
repositories {
14+
gradlePluginPortal()
15+
mavenLocal()
16+
mavenCentral()
1417
maven {
1518
url 'https://maven.aliyun.com/nexus/content/groups/public'
1619
}
1720
maven {
1821
url 'https://repository.hanbings.io/proxy'
1922
}
23+
maven {
24+
url 'https://jitpack.io'
25+
}
26+
maven {
27+
url 'https://repo.destroystokyo.com/repository/maven-public'
28+
}
29+
maven {
30+
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots'
31+
}
32+
2033
}
34+
//apply plugin: 'com.gradleup.shadow'
35+
//apply plugin: 'java'
2136

2237

2338
fabricApi {
2439
configureDataGeneration()
2540
}
41+
configurations {
42+
//buildtoolsImplementation.extendsFrom(compileClasspath)
43+
// Dependencies only used for the guide export, but not shipped
44+
45+
runtimeClasspath.extendsFrom implementation
46+
}
2647

2748
dependencies {
2849
// To change the versions see the gradle.properties file
29-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
50+
minecraft ("com.mojang:minecraft:${project.minecraft_version}"){
51+
transitive = false
52+
}
3053
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
3154
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
32-
3355
// Fabric API. This is technically optional, but you probably want it anyway.
3456
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
35-
implementation 'org.yaml:snakeyaml:1.30'
57+
modImplementation 'org.yaml:snakeyaml:1.30'
58+
modImplementation "org.bukkit:bukkit:1.20.1-R0.1-SNAPSHOT"
59+
include "org.bukkit:bukkit:1.20.1-R0.1-SNAPSHOT"
60+
3661
}
3762

3863
processResources {
@@ -61,8 +86,10 @@ jar {
6186
from("LICENSE") {
6287
rename { "${it}_${project.base.archivesName.get()}"}
6388
}
89+
6490
}
6591

92+
6693
// configure the maven publication
6794
publishing {
6895
publications {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package me.matl114.Access;
2+
3+
import net.minecraft.client.MinecraftClient;
4+
import net.minecraft.client.gui.DrawContext;
5+
import net.minecraft.client.util.math.MatrixStack;
6+
7+
public interface DrawContextAccess {
8+
MinecraftClient getMinecraftClient();
9+
MatrixStack getMatrixStack();
10+
static DrawContextAccess of(DrawContext drawContext) {
11+
return (DrawContextAccess) drawContext;
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package me.matl114.Access;
2+
3+
import com.mojang.authlib.properties.Property;
4+
5+
public interface PropertyAccess {
6+
public String safeGetName();
7+
public String safeGetValue();
8+
public String safeGetSiginature();
9+
public boolean reallyHasSignature();
10+
static PropertyAccess of(Property property) {
11+
return (PropertyAccess) property;
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.matl114.Access;
2+
3+
import net.minecraft.nbt.NbtElement;
4+
import net.minecraft.nbt.StringNbtReader;
5+
6+
public interface StringNbtReaderAccess {
7+
public NbtElement type(String type);
8+
static StringNbtReaderAccess of(StringNbtReader reader) {
9+
return (StringNbtReaderAccess) reader;
10+
}
11+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package me.matl114.BukkitUtiils;
2+
3+
import com.mojang.brigadier.StringReader;
4+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5+
import me.matl114.Access.StringNbtReaderAccess;
6+
import me.matl114.SlimefunUtils.Debug;
7+
import net.minecraft.nbt.*;
8+
9+
import java.util.List;
10+
import java.util.Map;
11+
import java.util.regex.Pattern;
12+
13+
public class BukkitConfigDeserializor {
14+
private static final Pattern ARRAY = Pattern.compile("^\\[.*]");
15+
private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)?i", Pattern.CASE_INSENSITIVE);
16+
private static final Pattern DOUBLE = Pattern.compile("[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d", Pattern.CASE_INSENSITIVE);
17+
private static final StringNbtReader MOJANGSON_PARSER = new StringNbtReader(new StringReader(""));
18+
19+
public static NbtElement deserializeObject(Object object) {
20+
if (object instanceof Map) {
21+
NbtCompound compound = new NbtCompound();
22+
for (Map.Entry<String, Object> entry : ((Map<String, Object>) object).entrySet()) {
23+
compound.put(entry.getKey(), deserializeObject(entry.getValue()));
24+
}
25+
26+
return compound;
27+
} else if (object instanceof List) {
28+
List<Object> list = (List<Object>) object;
29+
if (list.isEmpty()) {
30+
return new NbtList(); // Default
31+
}
32+
33+
NbtList tagList = new NbtList();
34+
for (Object tag : list) {
35+
tagList.add(deserializeObject(tag));
36+
}
37+
38+
return tagList;
39+
} else if (object instanceof String) {
40+
String string = (String) object;
41+
42+
if (ARRAY.matcher(string).matches()) {
43+
try {
44+
return new StringNbtReader(new StringReader(string)).parseElement();
45+
} catch (CommandSyntaxException e) {
46+
throw new RuntimeException("Could not deserialize found list ", e);
47+
}
48+
} else if (INTEGER.matcher(string).matches()) { //Read integers on our own
49+
return NbtInt.of(Integer.parseInt(string.substring(0, string.length() - 1)));
50+
} else if (DOUBLE.matcher(string).matches()) {
51+
return NbtDouble.of(Double.parseDouble(string.substring(0, string.length() - 1)));
52+
} else {
53+
NbtElement nbtBase = StringNbtReaderAccess.of( MOJANGSON_PARSER).type(string);
54+
55+
if (nbtBase instanceof NbtInt) { // If this returns an integer, it did not use our method from above
56+
return NbtString.of(nbtBase.asString()); // It then is a string that was falsely read as an int
57+
} else if (nbtBase instanceof NbtDouble) {
58+
return NbtString.of(String.valueOf(((NbtDouble) nbtBase).doubleValue())); // Doubles add "d" at the end
59+
} else {
60+
return nbtBase;
61+
}
62+
}
63+
}
64+
65+
throw new RuntimeException("Could not deserialize NBTBase");
66+
}
67+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.matl114.BukkitUtiils;
2+
3+
import org.bukkit.Material;
4+
import org.bukkit.inventory.meta.ItemMeta;
5+
6+
public class BukkitItemFactory {
7+
public BukkitItemFactory() {
8+
9+
}
10+
public ItemMeta getItemMeta(Material material) {
11+
return new BukkitMetaItem(material);
12+
}
13+
public boolean equals(ItemMeta meta1, ItemMeta meta2){
14+
return meta1!=null?meta1.equals(meta2):meta2==null;
15+
}
16+
public ItemMeta asMetaFor(ItemMeta meta,Material material) {
17+
if(meta instanceof BukkitMetaItem bmi){
18+
bmi.item=material;
19+
}
20+
return meta;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)