Skip to content

Commit

Permalink
formating
Browse files Browse the repository at this point in the history
  • Loading branch information
m1919810 committed Dec 29, 2024
2 parents 9b647ce + 711ebfc commit 63e484b
Show file tree
Hide file tree
Showing 101 changed files with 2,608 additions and 607 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/e2e-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
strategy:
matrix:
include:
- mcVersion: '1.16.5'
javaVersion: '16'
- mcVersion: '1.17.1'
javaVersion: '17'
- mcVersion: '1.18.2'
Expand Down
8 changes: 0 additions & 8 deletions .mvn/maven-git-versioning-extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
${commit.short}-Insider
</version>
</ref>
<ref type="branch">
<pattern>test/(.+)</pattern>
<version>${ref}-${commit.short}</version>
</ref>
<ref type="branch">
<pattern>feat/(.+)</pattern>
<version>${ref}-${commit.short}</version>
</ref>
<ref type = "tag">
<pattern>([0-9].*)></pattern>
<version>${1}</version>
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ Slimefun 4 可以在[鬼斩构建站](https://builds.guizhanss.com)页面中**

以下是两种版本的区别:

| | 测试版 (最新更新) | "稳定版" |
|----------------------|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| **支持的 Minecraft 版本** | :video_game: 1.16.X - 1.20.X | :video_game: 1.16.X - 1.20.X |
| **Java 版本** | :computer: **Java 17+** | :computer: **Java 17+** |
| **自动更新系统** | :heavy_check_mark: | :x: |
| **频繁更新** | :heavy_check_mark: | :x: |
| **享有最新内容** | :heavy_check_mark: | :x: |
| **Discord 支持** | :heavy_check_mark: | :x: |
| **Bug 反馈** | :heavy_check_mark: | :x: |
| **在发布前进行测试** | :x: | :heavy_check_mark: |
| **有无更新日志** | :x: | :memo: **[更新日志(英文)](https://github.com/Slimefun/Slimefun4/blob/master/CHANGELOG.md)** |
| | 测试版 (最新更新) | "稳定版" |
|----------------------|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|
| **支持的 Minecraft 版本** | :video_game: 1.18.X - 1.20.X | :video_game: 1.16.X - 1.20.X |
| **Java 版本** | :computer: **Java 21+** | :computer: **Java 17+** |
| **自动更新系统** | :heavy_check_mark: | :x: |
| **频繁更新** | :heavy_check_mark: | :x: |
| **享有最新内容** | :heavy_check_mark: | :x: |
| **Discord 支持** | :heavy_check_mark: | :x: |
| **Bug 反馈** | :heavy_check_mark: | :x: |
| **在发布前进行测试** | :x: | :heavy_check_mark: |
| **有无更新日志** | :x: | :memo: **[更新日志(英文)](https://github.com/Slimefun/Slimefun4/blob/master/CHANGELOG.md)** |
| **下载链接** | :package: **[下载 最新版](https://builds.guizhanss.com/SlimefunGuguProject/Slimefun4/master)** | :package: **[下载 "稳定版"](https://builds.guizhanss.com/SlimefunGuguProject/Slimefun4/release)** |

**! 建议你使用最新的测试版,可以获得最新的内容更新和 Bug 修复!**
Expand Down
10 changes: 7 additions & 3 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
before_install:
- sdk install java 17.0.5-zulu
- sdk use java 17.0.5-zulu
- sdk install java 21.0.2-open
- sdk use java 21.0.2-open
- sdk install maven

jdk:
- openjdk21

install:
- chmod 777 ./mvnw
- ./mvnw -s .mvn/settings.xml install -DskipTests
- ./mvnw -s .mvn/settings.xml install -DskipTests
50 changes: 43 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

<maven.settings.file>${project.basedir}/.mvn/settings.xml</maven.settings.file>

<!-- Spigot properties -->
<spigot.version>1.21</spigot.version>
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
<!-- Paper properties -->
<paper.version>1.21</paper.version>
<paper.javadocs>https://papermc.io/javadocs</paper.javadocs>
</properties>

<issueManagement>
Expand Down Expand Up @@ -203,6 +203,34 @@
</java>
</configuration>
</plugin>

<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>9.0.1</version>

<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>

<configuration>
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>git.branch</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
</plugins>

<resources>
Expand All @@ -226,6 +254,7 @@
<include>biome-maps/*.json</include>

<include>languages/**/*.yml</include>
<include>git.properties</include>
</includes>
</resource>

Expand All @@ -244,9 +273,9 @@
<dependencies>
<!-- Hard dependencies -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}-R0.1-SNAPSHOT</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${paper.version}-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand All @@ -265,11 +294,18 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.24.1</version>
<scope>provided</scope>
</dependency>

<!-- Shaded packages -->
<dependency>
<groupId>com.github.StarWishsama.dough</groupId>
<artifactId>dough-api</artifactId>
<version>30c7e77b62</version>
<version>4dab7610a2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/city/norain/slimefun4/SlimefunExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import city.norain.slimefun4.compatibillty.VersionedEvent;
import city.norain.slimefun4.listener.SlimefunMigrateListener;
import city.norain.slimefun4.utils.EnvUtil;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.pool.HikariPool;
import io.github.bakedlibs.dough.versions.MinecraftVersion;
import io.github.bakedlibs.dough.versions.UnknownServerVersionException;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import lombok.Getter;
import org.apache.logging.log4j.core.config.Configurator;

public final class SlimefunExtended {
private static SlimefunMigrateListener migrateListener = new SlimefunMigrateListener();
Expand All @@ -21,6 +26,12 @@ public final class SlimefunExtended {
private static void checkDebug() {
if ("true".equals(System.getProperty("slimefun.database.debug"))) {
databaseDebugMode = true;

Slimefun.getSQLProfiler().start();
} else {
Configurator.setLevel(HikariConfig.class.getName(), org.apache.logging.log4j.Level.OFF);
Configurator.setLevel(HikariDataSource.class.getName(), org.apache.logging.log4j.Level.OFF);
Configurator.setLevel(HikariPool.class.getName(), org.apache.logging.log4j.Level.OFF);
}
}

Expand Down Expand Up @@ -63,6 +74,8 @@ public static boolean checkEnvironment(@Nonnull Slimefun sf) {
public static void init(@Nonnull Slimefun sf) {
EnvironmentChecker.scheduleSlimeGlueCheck(sf);

EnvUtil.init();

checkDebug();

VaultIntegration.register(sf);
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/city/norain/slimefun4/api/menu/UniversalMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package city.norain.slimefun4.api.menu;

import java.util.UUID;
import javax.annotation.Nonnull;
import lombok.Getter;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;

/**
* This class represents a universal chest menu
* which a menu located by certain identify id instead of location.
*/
public class UniversalMenu extends DirtyChestMenu {
@Getter
private final UUID uuid;

public UniversalMenu(@Nonnull UniversalMenuPreset preset, @Nonnull UUID uuid) {
this(preset, uuid, (Location) null);
}

public UniversalMenu(@Nonnull UniversalMenuPreset preset, @Nonnull UUID uuid, Location lastPresent) {
super(preset);
this.uuid = uuid;

preset.clone(this, lastPresent);
this.getContents();
}

public UniversalMenu(
@Nonnull UniversalMenuPreset preset, @Nonnull UUID uuid, Location lastPresent, ItemStack[] contents) {
super(preset);
this.uuid = uuid;

for (int i = 0; i < contents.length; i++) {
var item = contents[i];
if (item == null || item.getType().isAir()) {
continue;
}
addItem(i, item);
}

preset.clone(this, lastPresent);
this.getContents();
}

public UniversalMenu(@Nonnull UniversalMenuPreset preset, @Nonnull UUID uuid, ItemStack[] contents) {
this(preset, uuid, null, contents);
}

public void update(@Nonnull Location lastPresent) {
((UniversalMenuPreset) preset).clone(this, lastPresent);
}

/**
* This method drops the contents of this {@link BlockMenu} on the ground at the given
* {@link Location}.
*
* @param l Where to drop these items
* @param slots The slots of items that should be dropped
*/
public void dropItems(Location l, int... slots) {
for (int slot : slots) {
ItemStack item = getItemInSlot(slot);

if (item != null) {
l.getWorld().dropItemNaturally(l, item);
replaceExistingItem(slot, null);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package city.norain.slimefun4.api.menu;

import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
import org.bukkit.Location;
import org.bukkit.block.Block;

public abstract class UniversalMenuPreset extends BlockMenuPreset {
/**
* Creates a new ChestMenu with the specified
* Title
*
* @param title The title of the Menu
*/
public UniversalMenuPreset(@Nonnull String id, @Nonnull String title) {
super(id, title);
}

public void newInstance(@Nonnull UniversalMenu menu, @Nonnull Block b) {
// This method can optionally be overridden by implementations
}

@Override
protected void clone(@Nonnull DirtyChestMenu menu) {
if (menu instanceof UniversalMenu universalMenu) {
var uniData = StorageCacheUtils.getUniversalBlock(universalMenu.getUuid());

if (uniData == null) {
return;
}

clone(universalMenu, uniData.getLastPresent().toLocation());
}
}

protected void clone(@Nonnull UniversalMenu menu, @Nonnull Location lastPresent) {
menu.setPlayerInventoryClickable(true);

for (int slot : occupiedSlots) {
menu.addItem(slot, getItemInSlot(slot));
}

if (getSize() > -1) {
menu.addItem(getSize() - 1, null);
}

newInstance(menu, lastPresent.getBlock());

for (int slot = 0; slot < 54; slot++) {
if (getMenuClickHandler(slot) != null) {
menu.addMenuClickHandler(slot, getMenuClickHandler(slot));
}
}

menu.addMenuOpeningHandler(getMenuOpeningHandler());
menu.addMenuCloseHandler(getMenuCloseHandler());
}

@Nullable public static UniversalMenuPreset getPreset(@Nullable String id) {
if (id == null) {
return null;
} else {
var preset = Slimefun.getRegistry().getMenuPresets().get(id);
if (preset instanceof UniversalMenuPreset uniPreset) {
return uniPreset;
} else {
return null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package city.norain.slimefun4.compatibillty;

import city.norain.slimefun4.SlimefunExtended;
import lombok.experimental.UtilityClass;
import org.bukkit.attribute.Attribute;

@UtilityClass
public class VersionedAttribute {
public static Attribute getMaxHealth() {
if (SlimefunExtended.getMinecraftVersion().isAtLeast(1, 21, 3)) {
return Attribute.valueOf("MAX_HEALTH");
} else {
return Attribute.valueOf("GENERIC_MAX_HEALTH");
}
}
}
Loading

0 comments on commit 63e484b

Please sign in to comment.