Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Straikerinos committed Sep 8, 2024
1 parent c186182 commit 0a92acc
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 53 deletions.
9 changes: 0 additions & 9 deletions Loader - Bukkit Legacy Fallback/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,12 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>elmakers-repo</id>
<url>https://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.TheDevTec</groupId>
<artifactId>TheAPI-Shared</artifactId>
<version>12.9.8</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions Loader - Bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc.io</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
Expand All @@ -29,11 +25,6 @@
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.TheDevTec</groupId>
<artifactId>TheAPI-Shared</artifactId>
<version>12.9.8</version>
</dependency>
<dependency>
<groupId>com.arcaniax</groupId>
<artifactId>HeadDatabase-API</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package me.devtec.theapi.bukkit.game;

import lombok.Getter;
import lombok.Setter;
import me.devtec.shared.Ref;
import me.devtec.shared.json.Json;
import me.devtec.theapi.bukkit.BukkitLoader;
import java.util.HashMap;
import java.util.Map;

import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;

import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import me.devtec.shared.Ref;
import me.devtec.shared.json.Json;
import me.devtec.theapi.bukkit.BukkitLoader;

public class BlockDataStorage implements Cloneable {
private static final Class<?> blockDataClass = Ref.getClass("org.bukkit.block.data.BlockData");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package me.devtec.theapi.bukkit.game;

import me.devtec.shared.Ref;
import me.devtec.shared.annotations.Nonnull;
import me.devtec.shared.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.Map;

import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;

import java.lang.reflect.Field;
import java.util.Map;
import me.devtec.shared.Ref;
import me.devtec.shared.annotations.Nonnull;
import me.devtec.shared.annotations.Nullable;

public enum EnchantmentAPI {
SHARPNESS("DAMAGE_ALL", "SHARPNESS"), DAMAGEALL("DAMAGE_ALL", "SHARPNESS"), ALLDAMAGE("DAMAGE_ALL", "SHARPNESS"), DAMAGE_ALL("DAMAGE_ALL", "SHARPNESS"),
Expand Down Expand Up @@ -179,12 +180,22 @@ public static EnchantmentAPI fromEnchant(Enchantment enchantment) {
* @return boolean state of success
* @apiNote Register enchantment to the bukkit
*/
public static boolean registerEnchantment(Enchantment enchantment) {
@SuppressWarnings("unchecked")
public static boolean registerEnchantment(Enchantment enchantment) {
boolean registered = false;
if (Ref.isNewerThan(20) || Ref.serverVersionInt() == 20 && Ref.serverVersionRelease() >= 3) {
@SuppressWarnings("unchecked")
Map<Object, Object> map = (Map<Object, Object>) Ref.get(Ref.getStatic(Ref.getClass("org.bukkit.Registry"), "ENCHANTMENT"), "map");
map.put(Ref.invoke(enchantment, "getKey"), enchantment);
if(map==null) {
//Then we get "cache" and "byValue"
Object key = Ref.invoke(enchantment, "getKey");
//NamespacedKey, Instance
Map<Object, Object> cache = (Map<Object, Object>) Ref.get(Ref.getStatic(Ref.getClass("org.bukkit.Registry"), "ENCHANTMENT"), "cache");
//Instance, NamespacedKey
Map<Object, Object> byValue = (Map<Object, Object>) Ref.get(Ref.getStatic(Ref.getClass("org.bukkit.Registry"), "ENCHANTMENT"), "byValue");
cache.put(key, enchantment);
byValue.put(enchantment, key);
}else
map.put(Ref.invoke(enchantment, "getKey"), enchantment);
registered = true;
} else {
Ref.set(null, acceptingNew, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package me.devtec.theapi.bukkit.game.particles;

import me.devtec.shared.utility.MathUtils;
import me.devtec.shared.utility.StringUtils;
import me.devtec.theapi.bukkit.BukkitLoader;
import me.devtec.theapi.bukkit.game.Position;
import java.util.Collection;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;

import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import me.devtec.theapi.bukkit.BukkitLoader;
import me.devtec.theapi.bukkit.game.Position;

/**
* @author StraikerinaCZ, M3II0
* @author Straikerinos
*/
public class ParticleAPI {
public static void spawnParticle(Player target, Particle particle, Position pos) {
Expand Down
4 changes: 0 additions & 4 deletions Loader - Velocity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc.io</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
Expand Down
4 changes: 0 additions & 4 deletions Shared - Fallback support 1.7.10/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
</properties>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc.io</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
Expand Down
21 changes: 21 additions & 0 deletions assembly.dtd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!ELEMENT assembly (id,formats,includeBaseDirectory,dependencySets,moduleSets)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT formats (format)>
<!ELEMENT format (#PCDATA)>
<!ELEMENT includeBaseDirectory (#PCDATA)>
<!ELEMENT dependencySets (dependencySet)>
<!ELEMENT dependencySet (outputDirectory,includes,unpack)>
<!ELEMENT outputDirectory (#PCDATA)>
<!ELEMENT includes (include+)>
<!ELEMENT include (#PCDATA)>
<!ELEMENT unpack (#PCDATA)>
<!ELEMENT moduleSets (moduleSet)>
<!ELEMENT moduleSet (useAllReactorProjects,includes,sources)>
<!ELEMENT useAllReactorProjects (#PCDATA)>
<!ELEMENT sources (includeModuleDirectory,fileSets)>
<!ELEMENT includeModuleDirectory (#PCDATA)>
<!ELEMENT fileSets (fileSet)>
<!ELEMENT fileSet (outputDirectory,excludes,directory,includes)>
<!ELEMENT excludes (exclude)>
<!ELEMENT exclude (#PCDATA)>
<!ELEMENT directory (#PCDATA)>
152 changes: 152 additions & 0 deletions assembly.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="assemblyContent" />
</start>
<define name="assemblyContent">
<element name="assembly">
<ref name="idContent" />
<ref name="formatsContent" />
<ref name="includeBaseDirectoryContent" />
<ref name="dependencySetsContent" />
<ref name="moduleSetsContent" />
</element>
</define>
<define name="idContent">
<element name="id">
<text />
</element>
</define>
<define name="formatsContent">
<element name="formats">
<ref name="formatContent" />
</element>
</define>
<define name="formatContent">
<element name="format">
<text />
</element>
</define>
<define name="includeBaseDirectoryContent">
<element name="includeBaseDirectory">
<text />
</element>
</define>
<define name="dependencySetsContent">
<element name="dependencySets">
<ref name="dependencySetContent" />
</element>
</define>
<define name="dependencySetContent">
<element name="dependencySet">
<ref name="outputDirectoryContent" />
<ref name="includesContent" />
<ref name="unpackContent" />
</element>
</define>
<define name="outputDirectoryContent">
<element name="outputDirectory">
<text />
</element>
</define>
<define name="includesContent">
<element name="includes">
<ref name="includeContent" />
</element>
</define>
<define name="includeContent">
<element name="include">
<text />
</element>
</define>
<define name="unpackContent">
<element name="unpack">
<text />
</element>
</define>
<define name="moduleSetsContent">
<element name="moduleSets">
<ref name="moduleSetContent" />
</element>
</define>
<define name="moduleSetContent">
<element name="moduleSet">
<ref name="useAllReactorProjectsContent" />
<ref name="includesContent" />
<ref name="sourcesContent" />
</element>
</define>
<define name="useAllReactorProjectsContent">
<element name="useAllReactorProjects">
<text />
</element>
</define>
<define name="includesContent">
<element name="includes">
<oneOrMore>
<ref name="includeContent" />
</oneOrMore>
</element>
</define>
<define name="includeContent">
<element name="include">
<text />
</element>
</define>
<define name="sourcesContent">
<element name="sources">
<ref name="includeModuleDirectoryContent" />
<ref name="fileSetsContent" />
</element>
</define>
<define name="includeModuleDirectoryContent">
<element name="includeModuleDirectory">
<text />
</element>
</define>
<define name="fileSetsContent">
<element name="fileSets">
<ref name="fileSetContent" />
</element>
</define>
<define name="fileSetContent">
<element name="fileSet">
<ref name="outputDirectoryContent" />
<ref name="excludesContent" />
<ref name="directoryContent" />
<ref name="includesContent" />
</element>
</define>
<define name="outputDirectoryContent">
<element name="outputDirectory">
<text />
</element>
</define>
<define name="excludesContent">
<element name="excludes">
<ref name="excludeContent" />
</element>
</define>
<define name="excludeContent">
<element name="exclude">
<text />
</element>
</define>
<define name="directoryContent">
<element name="directory">
<text />
</element>
</define>
<define name="includesContent">
<element name="includes">
<oneOrMore>
<ref name="includeContent" />
</oneOrMore>
</element>
</define>
<define name="includeContent">
<element name="include">
<text />
</element>
</define>
</grammar>
3 changes: 2 additions & 1 deletion assembly.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!DOCTYPE assembly SYSTEM "assembly.dtd">
<assembly>
<id>all</id>
<formats>
Expand Down Expand Up @@ -29,7 +30,7 @@
<includeModuleDirectory>false</includeModuleDirectory>
<fileSets>
<fileSet>
<outputDirectory>test</outputDirectory>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>${project.build.directory}/**</exclude>
</excludes>
Expand Down
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
call mvn clean compile verify
cd NmsProvider - 1.7.R4
call mvn clean package clean
cd ..
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.TheDevTec</groupId>
<artifactId>TheAPI-Shared</artifactId>
<version>12.9.8</version>
</dependency>
</dependencies>

<build>
<plugins>
Expand Down

0 comments on commit 0a92acc

Please sign in to comment.