Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f327bb130
|
||
|
|
0f4a7f10e2
|
||
|
|
e3ced84855 | ||
|
|
10cb872506 | ||
|
|
b0d5bb72fe | ||
|
|
7e38775ded | ||
|
|
2ed23b24e5 | ||
|
|
b6d61d4cc9 | ||
|
|
c3f7eaebf4 | ||
|
|
52c90e1cea | ||
|
|
d887ff8eae | ||
|
|
0d5fb6a0ef | ||
|
|
6f8a6e868a | ||
|
|
70c1ecfc09 | ||
|
|
176272a4b9 | ||
|
|
c102e6650e | ||
|
|
c8fee82291 | ||
|
|
0ae9982ce5 | ||
|
|
59d358d907 | ||
|
|
2621181c5d | ||
|
|
48d044af8c | ||
|
|
9a7623c209 | ||
|
|
78354fdf68 | ||
|
|
859179d1fc | ||
|
|
79f53e9086 | ||
|
|
c14d777519 | ||
|
|
1829babe69 | ||
|
|
5aa959f1ac | ||
|
|
bc7e13f245 | ||
|
|
73edebff54 | ||
|
|
faf1d387e9 | ||
|
|
deed277376 | ||
|
|
28fc5aea70 | ||
|
|
bfcf0233fa | ||
|
|
3cf1aae89b | ||
|
|
db62878681 | ||
|
|
21cd52c166 | ||
|
|
9d715b61c0 | ||
|
|
d636cdd839 | ||
|
|
1bebdb5602 | ||
|
|
57caf85500 | ||
|
|
922586c925 | ||
|
|
9ec7bebecb | ||
|
|
5a7d1399b5 | ||
|
|
cc7481fa9a | ||
|
|
70d20aceb6 | ||
|
|
ac52211ce4 | ||
|
|
6f2bdccc89 | ||
|
|
6f23ed2528 | ||
|
|
2d36249dbb | ||
|
|
2f370ad641 | ||
|
|
1233f587c5 | ||
|
|
23ebea405e | ||
|
|
1bde75f9b3 |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
.gitea/CODEOWNERS linguist-detectable=false
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Pull requests request review from the eligible staff team(s).
|
||||||
|
# One approval from either an Admin or Developer satisfies branch protection.
|
||||||
|
* @trueog/Admins @trueog/Developers
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
- package-ecosystem: "maven"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "monthly"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
name: Auto-merge Dependabot PRs
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: [ "OpenInv CI" ]
|
|
||||||
types: [ completed ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
merge-dependabot:
|
|
||||||
if: "github.actor == 'dependabot[bot]'
|
|
||||||
&& github.event.workflow_run.event == 'pull_request'
|
|
||||||
&& github.event.workflow_run.conclusion == 'success'"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Approve
|
|
||||||
uses: hmarr/auto-approve-action@v3.1.0
|
|
||||||
with:
|
|
||||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
pull-request-number: "${{ github.event.workflow_run.event.pull_request.id }}"
|
|
||||||
- name: Merge
|
|
||||||
uses: pascalgn/automerge-action@v0.15.6
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
MERGE_LABELS: "dependencies,java"
|
|
||||||
MERGE_METHOD: "squash"
|
|
||||||
PULL_REQUEST: "${{ github.event.workflow_run.event.pull_request.id }}"
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
name: OpenInv CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: '17'
|
|
||||||
cache: 'maven'
|
|
||||||
|
|
||||||
# Install Spigot dependencies if necessary.
|
|
||||||
- name: Install Spigot Dependencies
|
|
||||||
run: . scripts/install_spigot_dependencies.sh
|
|
||||||
|
|
||||||
- name: Build With Maven
|
|
||||||
run: mvn -e clean package -am -P all
|
|
||||||
|
|
||||||
# Upload artifacts
|
|
||||||
- name: Upload Distributable Jar
|
|
||||||
id: upload-final
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: ./target/OpenInv.jar
|
|
||||||
- name: Upload API Jar
|
|
||||||
id: upload-api
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: api
|
|
||||||
path: ./api/target/openinvapi*.jar
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
name: Draft Github Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: [ "OpenInv CI" ]
|
|
||||||
types: [ completed ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
draft_release:
|
|
||||||
if: "github.event.workflow_run.event == 'push'
|
|
||||||
&& github.event.workflow_run.conclusion == 'success'
|
|
||||||
&& startsWith(github.event.workflow_run.event.push.ref, 'refs/tags/')"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Fetch all history - used to assemble changelog.
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set Release Variables
|
|
||||||
run: bash ./scripts/set_release_env.sh
|
|
||||||
|
|
||||||
- name: Download Artifact
|
|
||||||
# Unfortunately actions/download-artifact cannot fetch from other workflow runs.
|
|
||||||
uses: dawidd6/action-download-artifact@v2.26.0
|
|
||||||
with:
|
|
||||||
name: dist
|
|
||||||
path: dist
|
|
||||||
run_id: "${{ github.event.workflow_run.id }}"
|
|
||||||
run_number: "${{ github.event.workflow_run.run_number }}"
|
|
||||||
# Searching for a specific run ID that we know was successful, unset 'success' default.
|
|
||||||
workflow_conclusion: ""
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
id: create-release
|
|
||||||
uses: softprops/action-gh-release@v0.1.15
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
name: ${{ env.VERSIONED_NAME }}
|
|
||||||
body: ${{ env.GENERATED_CHANGELOG }}
|
|
||||||
draft: true
|
|
||||||
prerelease: false
|
|
||||||
files: ./dist/OpenInv.jar
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
name: Release to CurseForge
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [ released ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
curseforge_release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Fetch Github Release Asset
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@1.1.0
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
version: ${{ github.event.release.id }}
|
|
||||||
file: OpenInv.jar
|
|
||||||
|
|
||||||
- name: Set CurseForge Variables
|
|
||||||
run: . scripts/set_curseforge_env.sh "${{ github.event.release.body }}"
|
|
||||||
|
|
||||||
- name: Create CurseForge Release
|
|
||||||
uses: itsmeow/curseforge-upload@v3
|
|
||||||
with:
|
|
||||||
token: "${{ secrets.CURSEFORGE_TOKEN }}"
|
|
||||||
project_id: 31432
|
|
||||||
game_endpoint: minecraft
|
|
||||||
file_path: ./OpenInv.jar
|
|
||||||
display_name: "${{ github.event.release.name }}"
|
|
||||||
game_versions: "${{ env.CURSEFORGE_MINECRAFT_VERSIONS }}"
|
|
||||||
release_type: release
|
|
||||||
changelog_type: markdown
|
|
||||||
changelog: "${{ env.CURSEFORGE_CHANGELOG }}"
|
|
||||||
@@ -4,7 +4,9 @@
|
|||||||
**/.idea/
|
**/.idea/
|
||||||
**.iml
|
**.iml
|
||||||
**/target/
|
**/target/
|
||||||
|
**/build/
|
||||||
**/bin/
|
**/bin/
|
||||||
**/out/
|
**/out/
|
||||||
|
**/.gradle/
|
||||||
**/dependency-reduced-pom.xml
|
**/dependency-reduced-pom.xml
|
||||||
**/pom.xml.versionsBackup
|
**/pom.xml.versionsBackup
|
||||||
@@ -124,16 +124,10 @@ The OpenInv API is available via [JitPack](https://jitpack.io/).
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Compilation
|
### Compilation
|
||||||
To compile, the relevant Spigot jars must be installed in the local repository.
|
OpenInv now builds with Gradle 8.14.3 using Paperweight userdev for Purpur `1.19.4` on Java 17 / GraalVM 17.
|
||||||
As OpenInv is compiled against Mojang's mappings, you must run BuildTools with the `--remapped` argument:
|
|
||||||
`java -jar BuildTools.jar --remapped --rev $serverVersion`
|
|
||||||
`$serverVersion` is the version of the server, i.e. `1.18.1`
|
|
||||||
|
|
||||||
To compile for a single version, specify the module you are targeting:
|
Build the plugin with:
|
||||||
`mvn -pl $moduleName -am clean install`
|
`./gradlew build`
|
||||||
`$moduleName` is the name of the module, i.e. `internal/v1_18_R1`.
|
|
||||||
|
|
||||||
To compile for a set of versions, use a profile. Select a profile using the `-P` argument:
|
The server-ready shaded jar is written to:
|
||||||
`mvn clean package -am -P all`
|
`build/libs/OpenInv-${version}.jar`
|
||||||
The only provided profile is `all`. The final file is `target/OpenInv.jar`
|
|
||||||
For more information, check out the [official Maven guide](http://maven.apache.org/guides/introduction/introduction-to-profiles.html).
|
|
||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2022 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<name>OpenInvAPI</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -161,6 +161,7 @@ public interface IOpenInv {
|
|||||||
* @return the identifier
|
* @return the identifier
|
||||||
* @throws IllegalStateException if the server version is unsupported
|
* @throws IllegalStateException if the server version is unsupported
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
default @NotNull String getPlayerID(@NotNull OfflinePlayer offline) {
|
default @NotNull String getPlayerID(@NotNull OfflinePlayer offline) {
|
||||||
return offline.getUniqueId().toString();
|
return offline.getUniqueId().toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.lishid.openinv.event;
|
||||||
|
|
||||||
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event fired before OpenInv saves a player's data.
|
||||||
|
*/
|
||||||
|
public class OpenPlayerSaveEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final ISpecialInventory inventory;
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public OpenPlayerSaveEvent(@NotNull Player player, @NotNull ISpecialInventory inventory) {
|
||||||
|
this.player = player;
|
||||||
|
this.inventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link Player} whose data is being saved.
|
||||||
|
*
|
||||||
|
* @return player the Player whose data is being saved
|
||||||
|
*/
|
||||||
|
public @NotNull Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link ISpecialInventory} that triggered the save by being closed.
|
||||||
|
*
|
||||||
|
* @return the special inventory
|
||||||
|
*/
|
||||||
|
public @NotNull ISpecialInventory getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether the event is cancelled.
|
||||||
|
*
|
||||||
|
* @return true if the event is cancelled
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the event is cancelled.
|
||||||
|
*
|
||||||
|
* @param cancel whether the event is cancelled
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.block.data.type.Chest;
|
import org.bukkit.block.data.type.Chest;
|
||||||
import org.bukkit.entity.Cat;
|
import org.bukkit.entity.Cat;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -157,10 +158,22 @@ public interface IAnySilentContainer {
|
|||||||
* @return true if the type is a supported container
|
* @return true if the type is a supported container
|
||||||
*/
|
*/
|
||||||
default boolean isAnySilentContainer(@NotNull BlockState blockState) {
|
default boolean isAnySilentContainer(@NotNull BlockState blockState) {
|
||||||
return blockState instanceof org.bukkit.block.EnderChest
|
return blockState instanceof InventoryHolder holder && isAnySilentContainer(holder)
|
||||||
|| blockState instanceof org.bukkit.block.Chest
|
|| blockState instanceof EnderChest;
|
||||||
|| blockState instanceof org.bukkit.block.ShulkerBox
|
}
|
||||||
|| blockState instanceof org.bukkit.block.Barrel;
|
|
||||||
|
/**
|
||||||
|
* Check if the given {@link InventoryHolder} is a container which can be unblocked or silenced.
|
||||||
|
*
|
||||||
|
* @param holder the potential container
|
||||||
|
* @return true if the type is a supported container
|
||||||
|
*/
|
||||||
|
default boolean isAnySilentContainer(@NotNull InventoryHolder holder) {
|
||||||
|
return holder instanceof org.bukkit.block.EnderChest
|
||||||
|
|| holder instanceof org.bukkit.block.Chest
|
||||||
|
|| holder instanceof org.bukkit.block.DoubleChest
|
||||||
|
|| holder instanceof org.bukkit.block.ShulkerBox
|
||||||
|
|| holder instanceof org.bukkit.block.Barrel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2022 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvassembly</artifactId>
|
|
||||||
<name>OpenInvAssembly</name>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<directory>../target</directory>
|
|
||||||
<finalName>OpenInv</finalName>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>reactor-uberjar</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>single</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
|
||||||
<descriptors>
|
|
||||||
<descriptor>src/assembly/reactor-uberjar.xml</descriptor>
|
|
||||||
</descriptors>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2021 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
|
|
||||||
|
|
||||||
<id>reactor-uberjar</id>
|
|
||||||
|
|
||||||
<formats>
|
|
||||||
<format>jar</format>
|
|
||||||
</formats>
|
|
||||||
|
|
||||||
<includeBaseDirectory>false</includeBaseDirectory>
|
|
||||||
|
|
||||||
<moduleSets>
|
|
||||||
<moduleSet>
|
|
||||||
|
|
||||||
<useAllReactorProjects>true</useAllReactorProjects>
|
|
||||||
|
|
||||||
<binaries>
|
|
||||||
<outputDirectory>/</outputDirectory>
|
|
||||||
<unpack>true</unpack>
|
|
||||||
<unpackOptions>
|
|
||||||
<excludes>
|
|
||||||
<!--
|
|
||||||
- Exclude existing meta - assembly will write its own manifest, and the rest is maven
|
|
||||||
- details that end users don't need. Ignoring it saves around 7KB after compression
|
|
||||||
- with a single internal module present.
|
|
||||||
-->
|
|
||||||
<exclude>META-INF/**</exclude>
|
|
||||||
</excludes>
|
|
||||||
</unpackOptions>
|
|
||||||
<!-- Exclude dependencies - shade plugin will handle their inclusion as necessary in individual jars. -->
|
|
||||||
<includeDependencies>false</includeDependencies>
|
|
||||||
</binaries>
|
|
||||||
|
|
||||||
</moduleSet>
|
|
||||||
</moduleSets>
|
|
||||||
|
|
||||||
</assembly>
|
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
|
||||||
|
import io.papermc.paperweight.tasks.RemapJar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
java
|
||||||
|
`java-library`
|
||||||
|
id("com.gradleup.shadow") version "8.3.9"
|
||||||
|
id("io.papermc.paperweight.userdev") version "2.0.0-beta.18"
|
||||||
|
eclipse
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "com.lishid"
|
||||||
|
version = "4.4.4-SNAPSHOT"
|
||||||
|
|
||||||
|
val apiVersion = "1.19"
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
vendor.set(JvmVendorSpec.GRAAL_VM)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
paperweight.reobfArtifactConfiguration = ReobfArtifactConfiguration.REOBF_PRODUCTION
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
maven("https://repo.purpurmc.org/snapshots")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||||
|
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java.setSrcDirs(
|
||||||
|
listOf(
|
||||||
|
"api/src/main/java",
|
||||||
|
"plugin/src/main/java",
|
||||||
|
"internal/v1_19_R3/src/main/java",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
resources.setSrcDirs(listOf("plugin/src/main/resources"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
options.release.set(17)
|
||||||
|
options.compilerArgs.add("-parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
archiveBaseName.set("OpenInv")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
val props = mapOf("version" to project.version, "apiVersion" to apiVersion)
|
||||||
|
inputs.properties(props)
|
||||||
|
filesMatching("plugin.yml") {
|
||||||
|
expand(props)
|
||||||
|
}
|
||||||
|
from("LICENSE.txt") {
|
||||||
|
into("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
archiveClassifier.set("dev")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<ShadowJar>().configureEach {
|
||||||
|
archiveClassifier.set("dev-all")
|
||||||
|
minimize()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("assemble") {
|
||||||
|
dependsOn(tasks.named("reobfJar"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("build") {
|
||||||
|
dependsOn(tasks.named("shadowJar"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<RemapJar>("reobfJar") {
|
||||||
|
outputJar.set(layout.buildDirectory.file("libs/OpenInv-${project.version}.jar"))
|
||||||
|
}
|
||||||
|
|
||||||
|
eclipse {
|
||||||
|
project {
|
||||||
|
name = rootProject.name
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+94
@@ -0,0 +1,94 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2022 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvadapter1_18_R2</artifactId>
|
|
||||||
<name>OpenInvAdapter1_18_R2</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<spigot.version>1.18.2-R0.1-SNAPSHOT</spigot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvplugincore</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_18_R2;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtIo;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.level.storage.PlayerDataStorage;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
|
|
||||||
public class OpenPlayer extends CraftPlayer {
|
|
||||||
|
|
||||||
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
|
||||||
super(server, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadData() {
|
|
||||||
// See CraftPlayer#loadData
|
|
||||||
CompoundTag loaded = this.server.getHandle().playerIo.load(this.getHandle());
|
|
||||||
if (loaded != null) {
|
|
||||||
getHandle().readAdditionalSaveData(loaded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveData() {
|
|
||||||
ServerPlayer player = this.getHandle();
|
|
||||||
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
|
||||||
try {
|
|
||||||
PlayerDataStorage worldNBTStorage = player.server.getPlayerList().playerIo;
|
|
||||||
|
|
||||||
CompoundTag playerData = player.saveWithoutId(new CompoundTag());
|
|
||||||
|
|
||||||
if (!isOnline()) {
|
|
||||||
// Special case: save old vehicle data
|
|
||||||
CompoundTag oldData = worldNBTStorage.load(player);
|
|
||||||
|
|
||||||
if (oldData != null && oldData.contains("RootVehicle", 10)) {
|
|
||||||
// See net.minecraft.server.PlayerList#a(NetworkManager, EntityPlayer) and net.minecraft.server.EntityPlayer#b(NBTTagCompound)
|
|
||||||
playerData.put("RootVehicle", oldData.getCompound("RootVehicle"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", worldNBTStorage.getPlayerDir());
|
|
||||||
NbtIo.writeCompressed(playerData, file);
|
|
||||||
File file1 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat");
|
|
||||||
File file2 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat_old");
|
|
||||||
Util.safeReplaceFile(file1, file, file2);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogManager.getLogger().warn("Failed to save player data for {}: {}", player.getScoreboardName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2022 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvadapter1_19_R2</artifactId>
|
|
||||||
<name>OpenInvAdapter1_19_R2</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvplugincore</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R2;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtIo;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.world.level.storage.PlayerDataStorage;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
|
||||||
|
|
||||||
public class OpenPlayer extends CraftPlayer {
|
|
||||||
|
|
||||||
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
|
||||||
super(server, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadData() {
|
|
||||||
// See CraftPlayer#loadData
|
|
||||||
CompoundTag loaded = this.server.getHandle().playerIo.load(this.getHandle());
|
|
||||||
if (loaded != null) {
|
|
||||||
getHandle().readAdditionalSaveData(loaded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveData() {
|
|
||||||
ServerPlayer player = this.getHandle();
|
|
||||||
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
|
||||||
try {
|
|
||||||
PlayerDataStorage worldNBTStorage = player.server.getPlayerList().playerIo;
|
|
||||||
|
|
||||||
CompoundTag playerData = player.saveWithoutId(new CompoundTag());
|
|
||||||
setExtraData(playerData);
|
|
||||||
|
|
||||||
if (!isOnline()) {
|
|
||||||
// Special case: save old vehicle data
|
|
||||||
CompoundTag oldData = worldNBTStorage.load(player);
|
|
||||||
|
|
||||||
if (oldData != null && oldData.contains("RootVehicle", 10)) {
|
|
||||||
// See net.minecraft.server.PlayerList#a(NetworkManager, EntityPlayer) and net.minecraft.server.EntityPlayer#b(NBTTagCompound)
|
|
||||||
playerData.put("RootVehicle", oldData.getCompound("RootVehicle"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", worldNBTStorage.getPlayerDir());
|
|
||||||
NbtIo.writeCompressed(playerData, file);
|
|
||||||
File file1 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat");
|
|
||||||
File file2 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat_old");
|
|
||||||
Util.safeReplaceFile(file1, file, file2);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogManager.getLogger().warn("Failed to save player data for {}: {}", player.getName().getString(), e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2023 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvadapter1_19_R3</artifactId>
|
|
||||||
<name>OpenInvAdapter1_19_R3</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<version>${spigot.version}</version>
|
|
||||||
<classifier>remapped-mojang</classifier>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvplugincore</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
+2
-26
@@ -20,7 +20,6 @@ import com.lishid.openinv.OpenInv;
|
|||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import com.lishid.openinv.util.ReflectionHelper;
|
import com.lishid.openinv.util.ReflectionHelper;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -28,7 +27,6 @@ import net.minecraft.network.chat.Component;
|
|||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.world.CompoundContainer;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraft.world.entity.monster.Shulker;
|
import net.minecraft.world.entity.monster.Shulker;
|
||||||
@@ -39,11 +37,9 @@ import net.minecraft.world.level.GameType;
|
|||||||
import net.minecraft.world.level.block.BarrelBlock;
|
import net.minecraft.world.level.block.BarrelBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
|
||||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||||
import net.minecraft.world.level.block.TrappedChestBlock;
|
import net.minecraft.world.level.block.TrappedChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||||
@@ -160,33 +156,13 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
if (block instanceof ChestBlock chestBlock) {
|
if (block instanceof ChestBlock chestBlock) {
|
||||||
|
|
||||||
// boolean flag: do not check if chest is blocked
|
// boolean flag: do not check if chest is blocked
|
||||||
Optional<MenuProvider> menuOptional = chestBlock.combine(blockState, level, blockPos, true).apply(
|
menuProvider = chestBlock.getMenuProvider(blockState, level, blockPos, true);
|
||||||
// Combiner is a copy of private ChestBlock.MENU_PROVIDER_COMBINER
|
|
||||||
new DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>>() {
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptDouble(ChestBlockEntity localChest1, ChestBlockEntity localChest2) {
|
|
||||||
CompoundContainer doubleChest = new CompoundContainer(localChest1, localChest2);
|
|
||||||
return Optional.of(new ChestBlock.DoubleInventory(localChest1, localChest2, doubleChest));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (menuProvider == null) {
|
||||||
public Optional<MenuProvider> acceptSingle(ChestBlockEntity localChest) {
|
|
||||||
return Optional.of(localChest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptNone() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (menuOptional.isEmpty()) {
|
|
||||||
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuProvider = menuOptional.get();
|
|
||||||
|
|
||||||
if (block instanceof TrappedChestBlock) {
|
if (block instanceof TrappedChestBlock) {
|
||||||
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+210
-13
@@ -16,18 +16,60 @@
|
|||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R3;
|
package com.lishid.openinv.internal.v1_19_R3;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtIo;
|
import net.minecraft.nbt.NbtIo;
|
||||||
|
import net.minecraft.nbt.NumericTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.level.storage.PlayerDataStorage;
|
import net.minecraft.world.level.storage.PlayerDataStorage;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class OpenPlayer extends CraftPlayer {
|
public class OpenPlayer extends CraftPlayer {
|
||||||
|
|
||||||
|
private static final Set<String> RESET_TAGS = Set.of(
|
||||||
|
// net.minecraft.world.Entity#saveWithoutId(CompoundTag)
|
||||||
|
"CustomName",
|
||||||
|
"CustomNameVisible",
|
||||||
|
"Silent",
|
||||||
|
"NoGravity",
|
||||||
|
"Glowing",
|
||||||
|
"TicksFrozen",
|
||||||
|
"HasVisualFire",
|
||||||
|
"Tags",
|
||||||
|
"Passengers",
|
||||||
|
// net.minecraft.server.level.ServerPlayer#addAdditionalSaveData(CompoundTag)
|
||||||
|
// Intentional omissions to prevent mount loss: Attach, Entity, and RootVehicle
|
||||||
|
"warden_spawn_tracker",
|
||||||
|
"enteredNetherPosition",
|
||||||
|
"SpawnX",
|
||||||
|
"SpawnY",
|
||||||
|
"SpawnZ",
|
||||||
|
"SpawnForced",
|
||||||
|
"SpawnAngle",
|
||||||
|
"SpawnDimension",
|
||||||
|
// net.minecraft.world.entity.player.Player#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ShoulderEntityLeft",
|
||||||
|
"ShoulderEntityRight",
|
||||||
|
"LastDeathLocation",
|
||||||
|
// net.minecraft.world.entity.LivingEntity#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ActiveEffects",
|
||||||
|
"SleepingX",
|
||||||
|
"SleepingY",
|
||||||
|
"SleepingZ",
|
||||||
|
"Brain"
|
||||||
|
);
|
||||||
|
|
||||||
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
}
|
}
|
||||||
@@ -35,32 +77,42 @@ public class OpenPlayer extends CraftPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public void loadData() {
|
public void loadData() {
|
||||||
// See CraftPlayer#loadData
|
// See CraftPlayer#loadData
|
||||||
CompoundTag loaded = this.server.getHandle().playerIo.load(this.getHandle());
|
ServerPlayer serverPlayer = getHandle();
|
||||||
|
// The server's own storage, never the hookable PlayerList.playerIo, so an offline edit always targets the main profile
|
||||||
|
CompoundTag loaded = this.server.getServer().playerDataStorage.load(serverPlayer);
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
getHandle().readAdditionalSaveData(loaded);
|
serverPlayer.readAdditionalSaveData(loaded);
|
||||||
|
serverPlayer.loadGameTypes(loaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
ServerPlayer player = this.getHandle();
|
ServerPlayer player = this.getHandle();
|
||||||
|
// An offline save is a read-modify-write of the stored profile: hold the Utilities-OG player lock that MyWorlds and
|
||||||
|
// DiamondBank hold for theirs, so the two never interleave (no lock without that plugin, nothing else writes then)
|
||||||
|
boolean offline = !isOnline();
|
||||||
|
if (offline) {
|
||||||
|
UtilitiesLock.lock(player.getUUID());
|
||||||
|
}
|
||||||
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
||||||
try {
|
try {
|
||||||
PlayerDataStorage worldNBTStorage = player.server.getPlayerList().playerIo;
|
PlayerDataStorage worldNBTStorage = player.server.playerDataStorage;
|
||||||
|
|
||||||
CompoundTag playerData = player.saveWithoutId(new CompoundTag());
|
// Read without applying: load(Player) would push the stored inventory back over the edit being saved
|
||||||
|
CompoundTag oldData = offline ? readStoredTag(worldNBTStorage, player) : null;
|
||||||
|
CompoundTag playerData = getWritableTag(oldData);
|
||||||
|
playerData = player.saveWithoutId(playerData);
|
||||||
setExtraData(playerData);
|
setExtraData(playerData);
|
||||||
|
|
||||||
if (!isOnline()) {
|
if (oldData != null) {
|
||||||
// Special case: save old vehicle data
|
// Revert certain special data values when offline.
|
||||||
CompoundTag oldData = worldNBTStorage.load(player);
|
revertSpecialValues(playerData, oldData);
|
||||||
|
|
||||||
if (oldData != null && oldData.contains("RootVehicle", 10)) {
|
|
||||||
// See net.minecraft.server.PlayerList#a(NetworkManager, EntityPlayer) and net.minecraft.server.EntityPlayer#b(NBTTagCompound)
|
|
||||||
playerData.put("RootVehicle", oldData.getCompound("RootVehicle"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saveThroughStorageApi(worldNBTStorage, player.getUUID(), playerData)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", worldNBTStorage.getPlayerDir());
|
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", worldNBTStorage.getPlayerDir());
|
||||||
NbtIo.writeCompressed(playerData, file);
|
NbtIo.writeCompressed(playerData, file);
|
||||||
File file1 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat");
|
File file1 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat");
|
||||||
@@ -68,6 +120,151 @@ public class OpenPlayer extends CraftPlayer {
|
|||||||
Util.safeReplaceFile(file1, file, file2);
|
Util.safeReplaceFile(file1, file, file2);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogManager.getLogger().warn("Failed to save player data for {}: {}", player.getScoreboardName(), e);
|
LogManager.getLogger().warn("Failed to save player data for {}: {}", player.getScoreboardName(), e);
|
||||||
|
} finally {
|
||||||
|
if (offline) {
|
||||||
|
UtilitiesLock.unlock(player.getUUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utilities-OG's per player lock, reached by reflection so OpenInv needs no compile dependency on it
|
||||||
|
private static final class UtilitiesLock {
|
||||||
|
private static final Method LOCK;
|
||||||
|
private static final Method UNLOCK;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Method lock = null;
|
||||||
|
Method unlock = null;
|
||||||
|
try {
|
||||||
|
Class<?> utilities = Class.forName("net.trueog.utilitiesog.UtilitiesOG", true, OpenPlayer.class.getClassLoader());
|
||||||
|
lock = utilities.getMethod("lockPlayerData", UUID.class);
|
||||||
|
unlock = utilities.getMethod("unlockPlayerData", UUID.class);
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
// Utilities-OG is not installed, offline edits are unsynchronized like on vanilla
|
||||||
|
}
|
||||||
|
LOCK = lock;
|
||||||
|
UNLOCK = unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lock(UUID uuid) {
|
||||||
|
invoke(LOCK, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unlock(UUID uuid) {
|
||||||
|
invoke(UNLOCK, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void invoke(@Nullable Method method, UUID uuid) {
|
||||||
|
if (method == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
method.invoke(null, uuid);
|
||||||
|
} catch (ReflectiveOperationException e) {
|
||||||
|
LogManager.getLogger().warn("Utilities-OG player data lock failed for {}", uuid, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A storage with saveCompoundTag(UUID, CompoundTag) keeps profiles in a database (TrueOG Purpur); its getPlayerData(UUID) never touches the entity
|
||||||
|
private static @Nullable Method storageSave(@NotNull PlayerDataStorage storage) {
|
||||||
|
try {
|
||||||
|
return storage.getClass().getMethod("saveCompoundTag", UUID.class, CompoundTag.class);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @Nullable CompoundTag readStoredTag(@NotNull PlayerDataStorage storage, @NotNull ServerPlayer player) throws ReflectiveOperationException {
|
||||||
|
if (storageSave(storage) != null) {
|
||||||
|
Method get = storage.getClass().getMethod("getPlayerData", UUID.class);
|
||||||
|
return (CompoundTag) get.invoke(storage, player.getUUID());
|
||||||
|
}
|
||||||
|
// CraftBukkit's file read, which does not apply the data to the entity
|
||||||
|
Method getPlayerData = storage.getClass().getMethod("getPlayerData", String.class);
|
||||||
|
return (CompoundTag) getPlayerData.invoke(storage, player.getStringUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
// True when the storage took the profile itself (it logs a failed write); false means the caller keeps the file layout
|
||||||
|
private static boolean saveThroughStorageApi(@NotNull PlayerDataStorage storage, @NotNull UUID uuid, @NotNull CompoundTag playerData) throws ReflectiveOperationException {
|
||||||
|
Method save = storageSave(storage);
|
||||||
|
if (save == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
save.invoke(storage, uuid, playerData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract("null -> new")
|
||||||
|
private @NotNull CompoundTag getWritableTag(@Nullable CompoundTag oldData) {
|
||||||
|
if (oldData == null) {
|
||||||
|
return new CompoundTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy old data. This is a deep clone, so operating on it should be safe.
|
||||||
|
oldData = oldData.copy();
|
||||||
|
|
||||||
|
// Remove vanilla/server data that is not written every time.
|
||||||
|
oldData.getAllKeys().removeIf(key -> RESET_TAGS.contains(key) || key.startsWith("Bukkit"));
|
||||||
|
|
||||||
|
return oldData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revertSpecialValues(@NotNull CompoundTag newData, @NotNull CompoundTag oldData) {
|
||||||
|
// Revert automatic updates to play timestamps.
|
||||||
|
copyValue(oldData, newData, "bukkit", "lastPlayed", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastSeen", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastLogin", NumericTag.class);
|
||||||
|
// The persistent data container was captured when the inventory was opened; other plugins (MyWorlds nests its
|
||||||
|
// per-world profiles there) may have changed the stored one since, and this edit never touches it
|
||||||
|
Tag storedValues = oldData.get("BukkitValues");
|
||||||
|
if (storedValues != null) {
|
||||||
|
newData.put("BukkitValues", storedValues.copy());
|
||||||
|
} else {
|
||||||
|
newData.remove("BukkitValues");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void copyValue(
|
||||||
|
@NotNull CompoundTag source,
|
||||||
|
@NotNull CompoundTag target,
|
||||||
|
@NotNull String container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> tagType) {
|
||||||
|
CompoundTag oldContainer = getTag(source, container, CompoundTag.class);
|
||||||
|
CompoundTag newContainer = getTag(target, container, CompoundTag.class);
|
||||||
|
|
||||||
|
// New container being null means the server implementation doesn't store this data.
|
||||||
|
if (newContainer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If old tag exists, copy it to new location, removing otherwise.
|
||||||
|
setTag(newContainer, key, getTag(oldContainer, key, tagType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> @Nullable T getTag(
|
||||||
|
@Nullable CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> dataType) {
|
||||||
|
if (container == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Tag value = container.get(key);
|
||||||
|
if (value == null || !dataType.isAssignableFrom(value.getClass())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return dataType.cast(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void setTag(
|
||||||
|
@NotNull CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@Nullable T data) {
|
||||||
|
if (data == null) {
|
||||||
|
container.remove(key);
|
||||||
|
} else {
|
||||||
|
container.put(key, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-4
@@ -21,9 +21,8 @@ import com.lishid.openinv.internal.IPlayerDataManager;
|
|||||||
import com.lishid.openinv.internal.ISpecialInventory;
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
import com.lishid.openinv.internal.OpenInventoryView;
|
import com.lishid.openinv.internal.OpenInventoryView;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -33,10 +32,12 @@ import net.minecraft.world.entity.Entity;
|
|||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_19_R3.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftContainer;
|
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftContainer;
|
||||||
@@ -45,6 +46,9 @@ import org.bukkit.inventory.InventoryView;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PlayerDataManager implements IPlayerDataManager {
|
public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
|
||||||
private @Nullable Field bukkitEntity;
|
private @Nullable Field bukkitEntity;
|
||||||
@@ -112,19 +116,40 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
|
|
||||||
// Load data. This also reads basic data into the player.
|
// Load data. This also reads basic data into the player.
|
||||||
// See CraftPlayer#loadData
|
// See CraftPlayer#loadData
|
||||||
CompoundTag loadedData = server.getPlayerList().playerIo.load(entity);
|
// The server's own storage, not PlayerList.playerIo: a world manager may hook that field and answer with a per-world profile, and an offline edit always means the main profile.
|
||||||
|
CompoundTag loadedData = server.playerDataStorage.load(entity);
|
||||||
|
|
||||||
if (loadedData == null) {
|
if (loadedData == null) {
|
||||||
// Exceptions with loading are logged by Mojang.
|
// Exceptions with loading are logged by Mojang.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// A stored tag without a position is no profile, only data other plugins keep for a player who never joined
|
||||||
|
// (a MyWorlds inventory group, for example); editing it would turn it into a profile placed at 0,0,0.
|
||||||
|
if (!loadedData.contains("Pos", Tag.TAG_LIST)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Also read "extra" data.
|
// Also read "extra" data.
|
||||||
entity.readAdditionalSaveData(loadedData);
|
entity.readAdditionalSaveData(loadedData);
|
||||||
|
entity.loadGameTypes(loadedData);
|
||||||
|
|
||||||
if (entity.level == null) {
|
if (entity.level == null) {
|
||||||
// Paper: Move player to spawn
|
// Paper: Move player to spawn
|
||||||
entity.spawnIn(null);
|
// SPIGOT-7340: Cannot call ServerPlayer#spawnIn with a null world
|
||||||
|
ServerLevel level = null;
|
||||||
|
Vec3 position = null;
|
||||||
|
if (entity.getRespawnDimension() != null) {
|
||||||
|
level = entity.server.getLevel(entity.getRespawnDimension());
|
||||||
|
if (level != null && entity.getRespawnPosition() != null) {
|
||||||
|
position = net.minecraft.world.entity.player.Player.findRespawnPositionAndUseSpawnBlock(level, entity.getRespawnPosition(), entity.getRespawnAngle(), false, false).orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (level == null || position == null) {
|
||||||
|
level = ((CraftWorld) server.server.getWorlds().get(0)).getHandle();
|
||||||
|
position = Vec3.atCenterOf(level.getSharedSpawnPos());
|
||||||
|
}
|
||||||
|
entity.level = level;
|
||||||
|
entity.setPos(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the Bukkit entity.
|
// Return the Bukkit entity.
|
||||||
|
|||||||
+18
-41
@@ -14,21 +14,18 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R2;
|
package com.lishid.openinv.internal.v1_20_R2;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import com.lishid.openinv.util.ReflectionHelper;
|
import com.lishid.openinv.util.ReflectionHelper;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.world.CompoundContainer;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraft.world.entity.monster.Shulker;
|
import net.minecraft.world.entity.monster.Shulker;
|
||||||
@@ -39,11 +36,9 @@ import net.minecraft.world.level.GameType;
|
|||||||
import net.minecraft.world.level.block.BarrelBlock;
|
import net.minecraft.world.level.block.BarrelBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
|
||||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||||
import net.minecraft.world.level.block.TrappedChestBlock;
|
import net.minecraft.world.level.block.TrappedChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||||
@@ -54,7 +49,7 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.block.ShulkerBox;
|
import org.bukkit.block.ShulkerBox;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -65,19 +60,21 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
public AnySilentContainer() {
|
public AnySilentContainer() {
|
||||||
try {
|
try {
|
||||||
this.serverPlayerGameModeGameType = ServerPlayerGameMode.class.getDeclaredField("b");
|
try {
|
||||||
this.serverPlayerGameModeGameType.setAccessible(true);
|
this.serverPlayerGameModeGameType = ServerPlayerGameMode.class.getDeclaredField("b");
|
||||||
} catch (NoSuchFieldException e) {
|
this.serverPlayerGameModeGameType.setAccessible(true);
|
||||||
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
} catch (NoSuchFieldException e) {
|
||||||
logger.warning("ServerPlayerGameMode#gameModeForPlayer's obfuscated name has changed!");
|
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
||||||
logger.warning("Please report this at https://github.com/Jikoo/OpenInv/issues");
|
logger.warning("ServerPlayerGameMode#gameModeForPlayer's obfuscated name has changed!");
|
||||||
logger.warning("Attempting to fall through using reflection. Please verify that SilentContainer does not fail.");
|
logger.warning("Please report this at https://github.com/Jikoo/OpenInv/issues");
|
||||||
// N.B. gameModeForPlayer is (for now) declared before previousGameModeForPlayer so silent shouldn't break.
|
logger.warning("Attempting to fall through using reflection. Please verify that SilentContainer does not fail.");
|
||||||
this.serverPlayerGameModeGameType = ReflectionHelper.grabFieldByType(ServerPlayerGameMode.class, GameType.class);
|
// N.B. gameModeForPlayer is (for now) declared before previousGameModeForPlayer so silent shouldn't break.
|
||||||
|
this.serverPlayerGameModeGameType = ReflectionHelper.grabFieldByType(ServerPlayerGameMode.class, GameType.class);
|
||||||
|
}
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
||||||
logger.warning("Unable to directly write player game mode! SilentContainer will fail.");
|
logger.warning("Unable to directly write player game mode! SilentContainer will fail.");
|
||||||
logger.log(Level.WARNING, "Error obtaining GameType field", e);
|
logger.log(java.util.logging.Level.WARNING, "Error obtaining GameType field", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
if (!(bukkitWorld instanceof CraftWorld craftWorld)) {
|
if (!(bukkitWorld instanceof CraftWorld craftWorld)) {
|
||||||
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
||||||
OpenInv.getPlugin(OpenInv.class).getLogger().log(Level.WARNING, exception.getMessage(), exception);
|
OpenInv.getPlugin(OpenInv.class).getLogger().log(java.util.logging.Level.WARNING, exception.getMessage(), exception);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +124,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
ServerPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
|
ServerPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
|
||||||
|
|
||||||
final ServerLevel level = player.getLevel();
|
final net.minecraft.world.level.Level level = player.level();
|
||||||
final BlockPos blockPos = new BlockPos(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
final BlockPos blockPos = new BlockPos(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
||||||
final BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
final BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
||||||
|
|
||||||
@@ -158,33 +155,13 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
if (block instanceof ChestBlock chestBlock) {
|
if (block instanceof ChestBlock chestBlock) {
|
||||||
|
|
||||||
// boolean flag: do not check if chest is blocked
|
// boolean flag: do not check if chest is blocked
|
||||||
Optional<MenuProvider> menuOptional = chestBlock.combine(blockState, level, blockPos, true).apply(
|
menuProvider = chestBlock.getMenuProvider(blockState, level, blockPos, true);
|
||||||
// Combiner is a copy of private ChestBlock.MENU_PROVIDER_COMBINER
|
|
||||||
new DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>>() {
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptDouble(ChestBlockEntity localChest1, ChestBlockEntity localChest2) {
|
|
||||||
CompoundContainer doubleChest = new CompoundContainer(localChest1, localChest2);
|
|
||||||
return Optional.of(new ChestBlock.DoubleInventory(localChest1, localChest2, doubleChest));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (menuProvider == null) {
|
||||||
public Optional<MenuProvider> acceptSingle(ChestBlockEntity localChest) {
|
|
||||||
return Optional.of(localChest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptNone() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (menuOptional.isEmpty()) {
|
|
||||||
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuProvider = menuOptional.get();
|
|
||||||
|
|
||||||
if (block instanceof TrappedChestBlock) {
|
if (block instanceof TrappedChestBlock) {
|
||||||
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
||||||
} else {
|
} else {
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.openinv.internal.v1_20_R2;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtIo;
|
||||||
|
import net.minecraft.nbt.NumericTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.level.storage.PlayerDataStorage;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class OpenPlayer extends CraftPlayer {
|
||||||
|
|
||||||
|
private static final Set<String> RESET_TAGS = Set.of(
|
||||||
|
// net.minecraft.world.Entity#saveWithoutId(CompoundTag)
|
||||||
|
"CustomName",
|
||||||
|
"CustomNameVisible",
|
||||||
|
"Silent",
|
||||||
|
"NoGravity",
|
||||||
|
"Glowing",
|
||||||
|
"TicksFrozen",
|
||||||
|
"HasVisualFire",
|
||||||
|
"Tags",
|
||||||
|
"Passengers",
|
||||||
|
// net.minecraft.server.level.ServerPlayer#addAdditionalSaveData(CompoundTag)
|
||||||
|
// Intentional omissions to prevent mount loss: Attach, Entity, and RootVehicle
|
||||||
|
"warden_spawn_tracker",
|
||||||
|
"enteredNetherPosition",
|
||||||
|
"SpawnX",
|
||||||
|
"SpawnY",
|
||||||
|
"SpawnZ",
|
||||||
|
"SpawnForced",
|
||||||
|
"SpawnAngle",
|
||||||
|
"SpawnDimension",
|
||||||
|
// net.minecraft.world.entity.player.Player#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ShoulderEntityLeft",
|
||||||
|
"ShoulderEntityRight",
|
||||||
|
"LastDeathLocation",
|
||||||
|
// net.minecraft.world.entity.LivingEntity#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ActiveEffects", // Backwards compat: Renamed from 1.19
|
||||||
|
"active_effects",
|
||||||
|
"SleepingX",
|
||||||
|
"SleepingY",
|
||||||
|
"SleepingZ",
|
||||||
|
"Brain"
|
||||||
|
);
|
||||||
|
|
||||||
|
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
||||||
|
super(server, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadData() {
|
||||||
|
PlayerDataManager.loadData(getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveData() {
|
||||||
|
ServerPlayer player = this.getHandle();
|
||||||
|
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
||||||
|
try {
|
||||||
|
PlayerDataStorage worldNBTStorage = player.server.getPlayerList().playerIo;
|
||||||
|
|
||||||
|
CompoundTag oldData = isOnline() ? null : worldNBTStorage.load(player);
|
||||||
|
CompoundTag playerData = getWritableTag(oldData);
|
||||||
|
playerData = player.saveWithoutId(playerData);
|
||||||
|
setExtraData(playerData);
|
||||||
|
|
||||||
|
if (oldData != null) {
|
||||||
|
// Revert certain special data values when offline.
|
||||||
|
revertSpecialValues(playerData, oldData);
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = File.createTempFile(player.getStringUUID() + "-", ".dat", worldNBTStorage.getPlayerDir());
|
||||||
|
NbtIo.writeCompressed(playerData, file);
|
||||||
|
File file1 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat");
|
||||||
|
File file2 = new File(worldNBTStorage.getPlayerDir(), player.getStringUUID() + ".dat_old");
|
||||||
|
Util.safeReplaceFile(file1, file, file2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.getLogger().warn("Failed to save player data for {}: {}", player.getScoreboardName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract("null -> new")
|
||||||
|
private @NotNull CompoundTag getWritableTag(@Nullable CompoundTag oldData) {
|
||||||
|
if (oldData == null) {
|
||||||
|
return new CompoundTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy old data. This is a deep clone, so operating on it should be safe.
|
||||||
|
oldData = oldData.copy();
|
||||||
|
|
||||||
|
// Remove vanilla/server data that is not written every time.
|
||||||
|
oldData.getAllKeys().removeIf(key -> RESET_TAGS.contains(key) || key.startsWith("Bukkit"));
|
||||||
|
|
||||||
|
return oldData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revertSpecialValues(@NotNull CompoundTag newData, @NotNull CompoundTag oldData) {
|
||||||
|
// Revert automatic updates to play timestamps.
|
||||||
|
copyValue(oldData, newData, "bukkit", "lastPlayed", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastSeen", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastLogin", NumericTag.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void copyValue(
|
||||||
|
@NotNull CompoundTag source,
|
||||||
|
@NotNull CompoundTag target,
|
||||||
|
@NotNull String container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> tagType) {
|
||||||
|
CompoundTag oldContainer = getTag(source, container, CompoundTag.class);
|
||||||
|
CompoundTag newContainer = getTag(target, container, CompoundTag.class);
|
||||||
|
|
||||||
|
// New container being null means the server implementation doesn't store this data.
|
||||||
|
if (newContainer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If old tag exists, copy it to new location, removing otherwise.
|
||||||
|
setTag(newContainer, key, getTag(oldContainer, key, tagType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> @Nullable T getTag(
|
||||||
|
@Nullable CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> dataType) {
|
||||||
|
if (container == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Tag value = container.get(key);
|
||||||
|
if (value == null || !dataType.isAssignableFrom(value.getClass())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return dataType.cast(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void setTag(
|
||||||
|
@NotNull CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@Nullable T data) {
|
||||||
|
if (data == null) {
|
||||||
|
container.remove(key);
|
||||||
|
} else {
|
||||||
|
container.put(key, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+118
-34
@@ -14,47 +14,68 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_18_R2;
|
package com.lishid.openinv.internal.v1_20_R2;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IPlayerDataManager;
|
import com.lishid.openinv.internal.IPlayerDataManager;
|
||||||
import com.lishid.openinv.internal.ISpecialInventory;
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
import com.lishid.openinv.internal.OpenInventoryView;
|
import com.lishid.openinv.internal.OpenInventoryView;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import java.lang.reflect.Field;
|
import com.mojang.serialization.Dynamic;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ClientInformation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftContainer;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftContainer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PlayerDataManager implements IPlayerDataManager {
|
public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
|
||||||
|
private static boolean paper;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.configuration.Configuration");
|
||||||
|
paper = true;
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
paper = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private @Nullable Field bukkitEntity;
|
private @Nullable Field bukkitEntity;
|
||||||
|
|
||||||
public PlayerDataManager() {
|
public PlayerDataManager() {
|
||||||
try {
|
try {
|
||||||
bukkitEntity = Entity.class.getDeclaredField("bukkitEntity");
|
bukkitEntity = Entity.class.getDeclaredField("bukkitEntity");
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
Logger logger = JavaPlugin.getPlugin(OpenInv.class).getLogger();
|
||||||
logger.warning("Unable to obtain field to inject custom save process - players' mounts may be deleted when loaded.");
|
logger.warning("Unable to obtain field to inject custom save process - certain player data may be lost when saving!");
|
||||||
logger.log(java.util.logging.Level.WARNING, e.getMessage(), e);
|
logger.log(java.util.logging.Level.WARNING, e.getMessage(), e);
|
||||||
bukkitEntity = null;
|
bukkitEntity = null;
|
||||||
}
|
}
|
||||||
@@ -74,7 +95,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
|
|
||||||
if (nmsPlayer == null) {
|
if (nmsPlayer == null) {
|
||||||
// Could use reflection to examine fields, but it's honestly not worth the bother.
|
// Could use reflection to examine fields, but it's honestly not worth the bother.
|
||||||
throw new RuntimeException("Unable to fetch EntityPlayer from provided Player implementation");
|
throw new RuntimeException("Unable to fetch EntityPlayer from Player implementation " + player.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nmsPlayer;
|
return nmsPlayer;
|
||||||
@@ -87,10 +108,6 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a profile and entity to load the player data
|
|
||||||
// See net.minecraft.server.PlayerList#attemptLogin
|
|
||||||
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
|
||||||
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
|
||||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
ServerLevel worldServer = server.getLevel(Level.OVERWORLD);
|
ServerLevel worldServer = server.getLevel(Level.OVERWORLD);
|
||||||
|
|
||||||
@@ -98,39 +115,105 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPlayer entity = new ServerPlayer(server, worldServer, profile);
|
// Create a new ServerPlayer.
|
||||||
|
ServerPlayer entity = createNewPlayer(server, worldServer, offline);
|
||||||
|
|
||||||
// Stop listening for advancement progression - if this is not cleaned up, loading causes a memory leak.
|
// Stop listening for advancement progression - if this is not cleaned up, loading causes a memory leak.
|
||||||
entity.getAdvancements().stopListening();
|
entity.getAdvancements().stopListening();
|
||||||
|
|
||||||
|
// Try to load the player's data.
|
||||||
|
if (loadData(entity)) {
|
||||||
|
// If data is loaded successfully, return the Bukkit entity.
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull ServerPlayer createNewPlayer(
|
||||||
|
@NotNull MinecraftServer server,
|
||||||
|
@NotNull ServerLevel worldServer,
|
||||||
|
@NotNull final OfflinePlayer offline) {
|
||||||
|
// See net.minecraft.server.players.PlayerList#canPlayerLogin(ServerLoginPacketListenerImpl, GameProfile)
|
||||||
|
// See net.minecraft.server.network.ServerLoginPacketListenerImpl#handleHello(ServerboundHelloPacket)
|
||||||
|
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
||||||
|
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
||||||
|
|
||||||
|
ClientInformation dummyInfo = new ClientInformation(
|
||||||
|
"en_us",
|
||||||
|
1, // Reduce distance just in case.
|
||||||
|
ChatVisiblity.HIDDEN, // Don't accept chat.
|
||||||
|
false,
|
||||||
|
ServerPlayer.DEFAULT_MODEL_CUSTOMIZATION,
|
||||||
|
ServerPlayer.DEFAULT_MAIN_HAND,
|
||||||
|
true,
|
||||||
|
false // Don't list in player list (not that this player is in the list anyway).
|
||||||
|
);
|
||||||
|
|
||||||
|
ServerPlayer entity = new ServerPlayer(server, worldServer, profile, dummyInfo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
injectPlayer(entity);
|
injectPlayer(entity);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
JavaPlugin.getPlugin(OpenInv.class).getLogger().log(
|
||||||
|
java.util.logging.Level.WARNING,
|
||||||
|
e,
|
||||||
|
() -> "Unable to inject ServerPlayer, certain player data may be lost when saving!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load data. This also reads basic data into the player.
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean loadData(@NotNull ServerPlayer player) {
|
||||||
// See CraftPlayer#loadData
|
// See CraftPlayer#loadData
|
||||||
CompoundTag loadedData = server.getPlayerList().playerIo.load(entity);
|
CompoundTag loadedData = player.server.getPlayerList().playerIo.load(player);
|
||||||
|
|
||||||
if (loadedData == null) {
|
if (loadedData == null) {
|
||||||
// Exceptions with loading are logged by Mojang.
|
// Exceptions with loading are logged by Mojang.
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read basic data into the player.
|
||||||
|
player.load(loadedData);
|
||||||
// Also read "extra" data.
|
// Also read "extra" data.
|
||||||
entity.readAdditionalSaveData(loadedData);
|
player.readAdditionalSaveData(loadedData);
|
||||||
|
// Game type settings are also loaded separately.
|
||||||
|
player.loadGameTypes(loadedData);
|
||||||
|
|
||||||
if (entity.level == null) {
|
if (paper) {
|
||||||
// Paper: Move player to spawn
|
// Paper: world is not loaded by ServerPlayer#load(CompoundTag).
|
||||||
entity.spawnIn(null);
|
parseWorld(player, loadedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the Bukkit entity.
|
return true;
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void injectPlayer(ServerPlayer player) throws IllegalAccessException {
|
private static void parseWorld(@NotNull ServerPlayer player, @NotNull CompoundTag loadedData) {
|
||||||
|
// See PlayerList#placeNewPlayer
|
||||||
|
World bukkitWorld;
|
||||||
|
if (loadedData.contains("WorldUUIDMost") && loadedData.contains("WorldUUIDLeast")) {
|
||||||
|
// Modern Bukkit world.
|
||||||
|
bukkitWorld = org.bukkit.Bukkit.getServer().getWorld(new UUID(loadedData.getLong("WorldUUIDMost"), loadedData.getLong("WorldUUIDLeast")));
|
||||||
|
} else if (loadedData.contains("world", net.minecraft.nbt.Tag.TAG_STRING)) {
|
||||||
|
// Legacy Bukkit world.
|
||||||
|
bukkitWorld = org.bukkit.Bukkit.getServer().getWorld(loadedData.getString("world"));
|
||||||
|
} else {
|
||||||
|
// Vanilla player data.
|
||||||
|
DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, loadedData.get("Dimension")))
|
||||||
|
.resultOrPartial(JavaPlugin.getPlugin(OpenInv.class).getLogger()::warning)
|
||||||
|
.map(player.server::getLevel)
|
||||||
|
// If ServerLevel exists, set, otherwise move to spawn.
|
||||||
|
.ifPresentOrElse(player::setServerLevel, () -> player.spawnIn(null));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (bukkitWorld == null) {
|
||||||
|
player.spawnIn(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.setServerLevel(((CraftWorld) bukkitWorld).getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectPlayer(ServerPlayer player) throws IllegalAccessException {
|
||||||
if (bukkitEntity == null) {
|
if (bukkitEntity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -140,9 +223,8 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
bukkitEntity.set(player, new OpenPlayer(player.server.server, player));
|
bukkitEntity.set(player, new OpenPlayer(player.server.server, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public Player inject(@NotNull Player player) {
|
public @NotNull Player inject(@NotNull Player player) {
|
||||||
try {
|
try {
|
||||||
ServerPlayer nmsPlayer = getHandle(player);
|
ServerPlayer nmsPlayer = getHandle(player);
|
||||||
if (nmsPlayer.getBukkitEntity() instanceof OpenPlayer openPlayer) {
|
if (nmsPlayer.getBukkitEntity() instanceof OpenPlayer openPlayer) {
|
||||||
@@ -151,14 +233,16 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
injectPlayer(nmsPlayer);
|
injectPlayer(nmsPlayer);
|
||||||
return nmsPlayer.getBukkitEntity();
|
return nmsPlayer.getBukkitEntity();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
JavaPlugin.getPlugin(OpenInv.class).getLogger().log(
|
||||||
|
java.util.logging.Level.WARNING,
|
||||||
|
e,
|
||||||
|
() -> "Unable to inject ServerPlayer, certain player data may be lost when saving!");
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
|
public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
|
||||||
|
|
||||||
ServerPlayer nmsPlayer = getHandle(player);
|
ServerPlayer nmsPlayer = getHandle(player);
|
||||||
|
|
||||||
@@ -179,7 +263,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
container.setTitle(new TextComponent(view.getTitle()));
|
container.setTitle(Component.literal(view.getTitle()));
|
||||||
container = CraftEventFactory.callInventoryOpenEvent(nmsPlayer, container);
|
container = CraftEventFactory.callInventoryOpenEvent(nmsPlayer, container);
|
||||||
|
|
||||||
if (container == null) {
|
if (container == null) {
|
||||||
@@ -187,7 +271,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nmsPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(),
|
nmsPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(),
|
||||||
new TextComponent(container.getBukkitView().getTitle())));
|
Component.literal(container.getBukkitView().getTitle())));
|
||||||
nmsPlayer.containerMenu = container;
|
nmsPlayer.containerMenu = container;
|
||||||
nmsPlayer.initMenu(container);
|
nmsPlayer.initMenu(container);
|
||||||
|
|
||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_18_R2;
|
package com.lishid.openinv.internal.v1_20_R2;
|
||||||
|
|
||||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -33,8 +33,8 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
+8
-7
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_18_R2;
|
package com.lishid.openinv.internal.v1_20_R2;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||||
@@ -33,6 +33,7 @@ import net.minecraft.nbt.ListTag;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.tags.DamageTypeTags;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.ContainerHelper;
|
import net.minecraft.world.ContainerHelper;
|
||||||
@@ -46,8 +47,8 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -473,7 +474,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
for (NonNullList<ItemStack> compartment : this.compartments) {
|
for (NonNullList<ItemStack> compartment : this.compartments) {
|
||||||
for (int i = 0; i < compartment.size(); ++i) {
|
for (int i = 0; i < compartment.size(); ++i) {
|
||||||
if (!compartment.get(i).isEmpty()) {
|
if (!compartment.get(i).isEmpty()) {
|
||||||
compartment.get(i).inventoryTick(this.player.level, this.player, i, this.selected == i);
|
compartment.get(i).inventoryTick(this.player.level(), this.player, i, this.selected == i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,7 +720,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
|
|
||||||
for (int index : armorIndices) {
|
for (int index : armorIndices) {
|
||||||
ItemStack itemstack = this.armor.get(index);
|
ItemStack itemstack = this.armor.get(index);
|
||||||
if ((!damagesource.isFire() || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
|
if ((!damagesource.is(DamageTypeTags.IS_FIRE) || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
|
||||||
itemstack.hurtAndBreak((int) damage, this.player, localPlayer -> localPlayer.broadcastBreakEvent(EquipmentSlot.byTypeAndIndex(EquipmentSlot.Type.ARMOR, index)));
|
itemstack.hurtAndBreak((int) damage, this.player, localPlayer -> localPlayer.broadcastBreakEvent(EquipmentSlot.byTypeAndIndex(EquipmentSlot.Type.ARMOR, index)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -756,7 +757,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ItemStack itemstack) {
|
public boolean contains(ItemStack itemstack) {
|
||||||
return contains(itemStack -> itemStack.isEmpty() && itemStack.sameItem(itemstack));
|
return contains(itemStack -> itemStack.isEmpty() && itemStack.is(itemstack.getItem()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+12
-38
@@ -14,21 +14,16 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_18_R2;
|
package com.lishid.openinv.internal.v1_20_R3;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import com.lishid.openinv.util.ReflectionHelper;
|
import com.lishid.openinv.util.ReflectionHelper;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.world.CompoundContainer;
|
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.SimpleMenuProvider;
|
import net.minecraft.world.SimpleMenuProvider;
|
||||||
import net.minecraft.world.entity.monster.Shulker;
|
import net.minecraft.world.entity.monster.Shulker;
|
||||||
@@ -39,11 +34,9 @@ import net.minecraft.world.level.GameType;
|
|||||||
import net.minecraft.world.level.block.BarrelBlock;
|
import net.minecraft.world.level.block.BarrelBlock;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
import net.minecraft.world.level.block.ChestBlock;
|
||||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
|
||||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||||
import net.minecraft.world.level.block.TrappedChestBlock;
|
import net.minecraft.world.level.block.TrappedChestBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||||
@@ -54,11 +47,14 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.block.ShulkerBox;
|
import org.bukkit.block.ShulkerBox;
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class AnySilentContainer implements IAnySilentContainer {
|
public class AnySilentContainer implements IAnySilentContainer {
|
||||||
|
|
||||||
private @Nullable Field serverPlayerGameModeGameType;
|
private @Nullable Field serverPlayerGameModeGameType;
|
||||||
@@ -66,8 +62,6 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
public AnySilentContainer() {
|
public AnySilentContainer() {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
// IDE warns about field not existing, but SpecialSource does not remap strings used in reflection.
|
|
||||||
// The warning is not suppressed as a reminder that it must manually be checked on updates.
|
|
||||||
this.serverPlayerGameModeGameType = ServerPlayerGameMode.class.getDeclaredField("b");
|
this.serverPlayerGameModeGameType = ServerPlayerGameMode.class.getDeclaredField("b");
|
||||||
this.serverPlayerGameModeGameType.setAccessible(true);
|
this.serverPlayerGameModeGameType.setAccessible(true);
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
@@ -81,7 +75,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
||||||
logger.warning("Unable to directly write player game mode! SilentContainer will fail.");
|
logger.warning("Unable to directly write player game mode! SilentContainer will fail.");
|
||||||
logger.log(Level.WARNING, "Error obtaining GameType field", e);
|
logger.log(java.util.logging.Level.WARNING, "Error obtaining GameType field", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +88,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
if (!(bukkitWorld instanceof CraftWorld craftWorld)) {
|
if (!(bukkitWorld instanceof CraftWorld craftWorld)) {
|
||||||
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
||||||
OpenInv.getPlugin(OpenInv.class).getLogger().log(Level.WARNING, exception.getMessage(), exception);
|
OpenInv.getPlugin(OpenInv.class).getLogger().log(java.util.logging.Level.WARNING, exception.getMessage(), exception);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +125,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
ServerPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
|
ServerPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
|
||||||
|
|
||||||
final ServerLevel level = player.getLevel();
|
final net.minecraft.world.level.Level level = player.level();
|
||||||
final BlockPos blockPos = new BlockPos(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
final BlockPos blockPos = new BlockPos(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
||||||
final BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
final BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
||||||
|
|
||||||
@@ -147,7 +141,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
MenuType<?> containers = PlayerDataManager.getContainers(enderChest.getContainerSize());
|
MenuType<?> containers = PlayerDataManager.getContainers(enderChest.getContainerSize());
|
||||||
int rows = enderChest.getContainerSize() / 9;
|
int rows = enderChest.getContainerSize() / 9;
|
||||||
return new ChestMenu(containers, containerCounter, playerInventory, enderChest, rows);
|
return new ChestMenu(containers, containerCounter, playerInventory, enderChest, rows);
|
||||||
}, new TranslatableComponent("container.enderchest")));
|
}, Component.translatable(("container.enderchest"))));
|
||||||
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
|
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -162,33 +156,13 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
if (block instanceof ChestBlock chestBlock) {
|
if (block instanceof ChestBlock chestBlock) {
|
||||||
|
|
||||||
// boolean flag: do not check if chest is blocked
|
// boolean flag: do not check if chest is blocked
|
||||||
Optional<MenuProvider> menuOptional = chestBlock.combine(blockState, level, blockPos, true).apply(
|
menuProvider = chestBlock.getMenuProvider(blockState, level, blockPos, true);
|
||||||
// Combiner is a copy of private ChestBlock.MENU_PROVIDER_COMBINER
|
|
||||||
new DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>>() {
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptDouble(ChestBlockEntity localChest1, ChestBlockEntity localChest2) {
|
|
||||||
CompoundContainer doubleChest = new CompoundContainer(localChest1, localChest2);
|
|
||||||
return Optional.of(new ChestBlock.DoubleInventory(localChest1, localChest2, doubleChest));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (menuProvider == null) {
|
||||||
public Optional<MenuProvider> acceptSingle(ChestBlockEntity localChest) {
|
|
||||||
return Optional.of(localChest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<MenuProvider> acceptNone() {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (menuOptional.isEmpty()) {
|
|
||||||
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
OpenInv.getPlugin(OpenInv.class).sendSystemMessage(bukkitPlayer, "messages.error.lootNotGenerated");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuProvider = menuOptional.get();
|
|
||||||
|
|
||||||
if (block instanceof TrappedChestBlock) {
|
if (block instanceof TrappedChestBlock) {
|
||||||
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
|
||||||
} else {
|
} else {
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.lishid.openinv.internal.v1_20_R3;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.Util;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtIo;
|
||||||
|
import net.minecraft.nbt.NumericTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.level.storage.PlayerDataStorage;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class OpenPlayer extends CraftPlayer {
|
||||||
|
|
||||||
|
private static final Set<String> RESET_TAGS = Set.of(
|
||||||
|
// net.minecraft.world.Entity#saveWithoutId(CompoundTag)
|
||||||
|
"CustomName",
|
||||||
|
"CustomNameVisible",
|
||||||
|
"Silent",
|
||||||
|
"NoGravity",
|
||||||
|
"Glowing",
|
||||||
|
"TicksFrozen",
|
||||||
|
"HasVisualFire",
|
||||||
|
"Tags",
|
||||||
|
"Passengers",
|
||||||
|
// net.minecraft.server.level.ServerPlayer#addAdditionalSaveData(CompoundTag)
|
||||||
|
// Intentional omissions to prevent mount loss: Attach, Entity, and RootVehicle
|
||||||
|
"warden_spawn_tracker",
|
||||||
|
"enteredNetherPosition",
|
||||||
|
"SpawnX",
|
||||||
|
"SpawnY",
|
||||||
|
"SpawnZ",
|
||||||
|
"SpawnForced",
|
||||||
|
"SpawnAngle",
|
||||||
|
"SpawnDimension",
|
||||||
|
// net.minecraft.world.entity.player.Player#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ShoulderEntityLeft",
|
||||||
|
"ShoulderEntityRight",
|
||||||
|
"LastDeathLocation",
|
||||||
|
// net.minecraft.world.entity.LivingEntity#addAdditionalSaveData(CompoundTag)
|
||||||
|
"ActiveEffects", // Backwards compat: Renamed from 1.19
|
||||||
|
"active_effects",
|
||||||
|
"SleepingX",
|
||||||
|
"SleepingY",
|
||||||
|
"SleepingZ",
|
||||||
|
"Brain"
|
||||||
|
);
|
||||||
|
|
||||||
|
public OpenPlayer(CraftServer server, ServerPlayer entity) {
|
||||||
|
super(server, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadData() {
|
||||||
|
PlayerDataManager.loadData(getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveData() {
|
||||||
|
ServerPlayer player = this.getHandle();
|
||||||
|
// See net.minecraft.world.level.storage.PlayerDataStorage#save(EntityHuman)
|
||||||
|
try {
|
||||||
|
PlayerDataStorage worldNBTStorage = player.server.getPlayerList().playerIo;
|
||||||
|
|
||||||
|
CompoundTag oldData = isOnline() ? null : worldNBTStorage.load(player);
|
||||||
|
CompoundTag playerData = getWritableTag(oldData);
|
||||||
|
playerData = player.saveWithoutId(playerData);
|
||||||
|
setExtraData(playerData);
|
||||||
|
|
||||||
|
if (oldData != null) {
|
||||||
|
// Revert certain special data values when offline.
|
||||||
|
revertSpecialValues(playerData, oldData);
|
||||||
|
}
|
||||||
|
|
||||||
|
Path playerDataDir = worldNBTStorage.getPlayerDir().toPath();
|
||||||
|
Path file = Files.createTempFile(playerDataDir, player.getStringUUID() + "-", ".dat");
|
||||||
|
NbtIo.writeCompressed(playerData, file);
|
||||||
|
Path dataFile = playerDataDir.resolve(player.getStringUUID() + ".dat");
|
||||||
|
Path backupFile = playerDataDir.resolve(player.getStringUUID() + ".dat_old");
|
||||||
|
Util.safeReplaceFile(dataFile, file, backupFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtils.getLogger().warn("Failed to save player data for {}: {}", player.getScoreboardName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Contract("null -> new")
|
||||||
|
private @NotNull CompoundTag getWritableTag(@Nullable CompoundTag oldData) {
|
||||||
|
if (oldData == null) {
|
||||||
|
return new CompoundTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy old data. This is a deep clone, so operating on it should be safe.
|
||||||
|
oldData = oldData.copy();
|
||||||
|
|
||||||
|
// Remove vanilla/server data that is not written every time.
|
||||||
|
oldData.getAllKeys()
|
||||||
|
.removeIf(key -> RESET_TAGS.contains(key) || key.startsWith("Bukkit"));
|
||||||
|
|
||||||
|
return oldData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revertSpecialValues(@NotNull CompoundTag newData, @NotNull CompoundTag oldData) {
|
||||||
|
// Revert automatic updates to play timestamps.
|
||||||
|
copyValue(oldData, newData, "bukkit", "lastPlayed", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastSeen", NumericTag.class);
|
||||||
|
copyValue(oldData, newData, "Paper", "LastLogin", NumericTag.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void copyValue(
|
||||||
|
@NotNull CompoundTag source,
|
||||||
|
@NotNull CompoundTag target,
|
||||||
|
@NotNull String container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> tagType) {
|
||||||
|
CompoundTag oldContainer = getTag(source, container, CompoundTag.class);
|
||||||
|
CompoundTag newContainer = getTag(target, container, CompoundTag.class);
|
||||||
|
|
||||||
|
// New container being null means the server implementation doesn't store this data.
|
||||||
|
if (newContainer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If old tag exists, copy it to new location, removing otherwise.
|
||||||
|
setTag(newContainer, key, getTag(oldContainer, key, tagType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> @Nullable T getTag(
|
||||||
|
@Nullable CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@NotNull Class<T> dataType) {
|
||||||
|
if (container == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Tag value = container.get(key);
|
||||||
|
if (value == null || !dataType.isAssignableFrom(value.getClass())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return dataType.cast(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Tag> void setTag(
|
||||||
|
@NotNull CompoundTag container,
|
||||||
|
@NotNull String key,
|
||||||
|
@Nullable T data) {
|
||||||
|
if (data == null) {
|
||||||
|
container.remove(key);
|
||||||
|
} else {
|
||||||
|
container.put(key, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+115
-32
@@ -14,47 +14,68 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R2;
|
package com.lishid.openinv.internal.v1_20_R3;
|
||||||
|
|
||||||
import com.lishid.openinv.OpenInv;
|
import com.lishid.openinv.OpenInv;
|
||||||
import com.lishid.openinv.internal.IPlayerDataManager;
|
import com.lishid.openinv.internal.IPlayerDataManager;
|
||||||
import com.lishid.openinv.internal.ISpecialInventory;
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
import com.lishid.openinv.internal.OpenInventoryView;
|
import com.lishid.openinv.internal.OpenInventoryView;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import java.lang.reflect.Field;
|
import com.mojang.serialization.Dynamic;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtOps;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ClientInformation;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.dimension.DimensionType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftContainer;
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.event.CraftEventFactory;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftContainer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class PlayerDataManager implements IPlayerDataManager {
|
public class PlayerDataManager implements IPlayerDataManager {
|
||||||
|
|
||||||
|
private static boolean paper;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.configuration.Configuration");
|
||||||
|
paper = true;
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
paper = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private @Nullable Field bukkitEntity;
|
private @Nullable Field bukkitEntity;
|
||||||
|
|
||||||
public PlayerDataManager() {
|
public PlayerDataManager() {
|
||||||
try {
|
try {
|
||||||
bukkitEntity = Entity.class.getDeclaredField("bukkitEntity");
|
bukkitEntity = Entity.class.getDeclaredField("bukkitEntity");
|
||||||
} catch (NoSuchFieldException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
Logger logger = OpenInv.getPlugin(OpenInv.class).getLogger();
|
Logger logger = JavaPlugin.getPlugin(OpenInv.class).getLogger();
|
||||||
logger.warning("Unable to obtain field to inject custom save process - players' mounts may be deleted when loaded.");
|
logger.warning("Unable to obtain field to inject custom save process - certain player data may be lost when saving!");
|
||||||
logger.log(java.util.logging.Level.WARNING, e.getMessage(), e);
|
logger.log(java.util.logging.Level.WARNING, e.getMessage(), e);
|
||||||
bukkitEntity = null;
|
bukkitEntity = null;
|
||||||
}
|
}
|
||||||
@@ -74,7 +95,7 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
|
|
||||||
if (nmsPlayer == null) {
|
if (nmsPlayer == null) {
|
||||||
// Could use reflection to examine fields, but it's honestly not worth the bother.
|
// Could use reflection to examine fields, but it's honestly not worth the bother.
|
||||||
throw new RuntimeException("Unable to fetch EntityPlayer from provided Player implementation");
|
throw new RuntimeException("Unable to fetch EntityPlayer from Player implementation " + player.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nmsPlayer;
|
return nmsPlayer;
|
||||||
@@ -87,11 +108,6 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a profile and entity to load the player data
|
|
||||||
// See net.minecraft.server.players.PlayerList#canPlayerLogin
|
|
||||||
// and net.minecraft.server.network.ServerLoginPacketListenerImpl#handleHello
|
|
||||||
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
|
||||||
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
|
||||||
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
ServerLevel worldServer = server.getLevel(Level.OVERWORLD);
|
ServerLevel worldServer = server.getLevel(Level.OVERWORLD);
|
||||||
|
|
||||||
@@ -99,39 +115,105 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPlayer entity = new ServerPlayer(server, worldServer, profile);
|
// Create a new ServerPlayer.
|
||||||
|
ServerPlayer entity = createNewPlayer(server, worldServer, offline);
|
||||||
|
|
||||||
// Stop listening for advancement progression - if this is not cleaned up, loading causes a memory leak.
|
// Stop listening for advancement progression - if this is not cleaned up, loading causes a memory leak.
|
||||||
entity.getAdvancements().stopListening();
|
entity.getAdvancements().stopListening();
|
||||||
|
|
||||||
|
// Try to load the player's data.
|
||||||
|
if (loadData(entity)) {
|
||||||
|
// If data is loaded successfully, return the Bukkit entity.
|
||||||
|
return entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private @NotNull ServerPlayer createNewPlayer(
|
||||||
|
@NotNull MinecraftServer server,
|
||||||
|
@NotNull ServerLevel worldServer,
|
||||||
|
@NotNull final OfflinePlayer offline) {
|
||||||
|
// See net.minecraft.server.players.PlayerList#canPlayerLogin(ServerLoginPacketListenerImpl, GameProfile)
|
||||||
|
// See net.minecraft.server.network.ServerLoginPacketListenerImpl#handleHello(ServerboundHelloPacket)
|
||||||
|
GameProfile profile = new GameProfile(offline.getUniqueId(),
|
||||||
|
offline.getName() != null ? offline.getName() : offline.getUniqueId().toString());
|
||||||
|
|
||||||
|
ClientInformation dummyInfo = new ClientInformation(
|
||||||
|
"en_us",
|
||||||
|
1, // Reduce distance just in case.
|
||||||
|
ChatVisiblity.HIDDEN, // Don't accept chat.
|
||||||
|
false,
|
||||||
|
ServerPlayer.DEFAULT_MODEL_CUSTOMIZATION,
|
||||||
|
ServerPlayer.DEFAULT_MAIN_HAND,
|
||||||
|
true,
|
||||||
|
false // Don't list in player list (not that this player is in the list anyway).
|
||||||
|
);
|
||||||
|
|
||||||
|
ServerPlayer entity = new ServerPlayer(server, worldServer, profile, dummyInfo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
injectPlayer(entity);
|
injectPlayer(entity);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
JavaPlugin.getPlugin(OpenInv.class).getLogger().log(
|
||||||
|
java.util.logging.Level.WARNING,
|
||||||
|
e,
|
||||||
|
() -> "Unable to inject ServerPlayer, certain player data may be lost when saving!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load data. This also reads basic data into the player.
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean loadData(@NotNull ServerPlayer player) {
|
||||||
// See CraftPlayer#loadData
|
// See CraftPlayer#loadData
|
||||||
CompoundTag loadedData = server.getPlayerList().playerIo.load(entity);
|
CompoundTag loadedData = player.server.getPlayerList().playerIo.load(player);
|
||||||
|
|
||||||
if (loadedData == null) {
|
if (loadedData == null) {
|
||||||
// Exceptions with loading are logged by Mojang.
|
// Exceptions with loading are logged by Mojang.
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read basic data into the player.
|
||||||
|
player.load(loadedData);
|
||||||
// Also read "extra" data.
|
// Also read "extra" data.
|
||||||
entity.readAdditionalSaveData(loadedData);
|
player.readAdditionalSaveData(loadedData);
|
||||||
|
// Game type settings are also loaded separately.
|
||||||
|
player.loadGameTypes(loadedData);
|
||||||
|
|
||||||
if (entity.level == null) {
|
if (paper) {
|
||||||
// Paper: Move player to spawn
|
// Paper: world is not loaded by ServerPlayer#load(CompoundTag).
|
||||||
entity.spawnIn(null);
|
parseWorld(player, loadedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the Bukkit entity.
|
return true;
|
||||||
return entity.getBukkitEntity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void injectPlayer(ServerPlayer player) throws IllegalAccessException {
|
private static void parseWorld(@NotNull ServerPlayer player, @NotNull CompoundTag loadedData) {
|
||||||
|
// See PlayerList#placeNewPlayer
|
||||||
|
World bukkitWorld;
|
||||||
|
if (loadedData.contains("WorldUUIDMost") && loadedData.contains("WorldUUIDLeast")) {
|
||||||
|
// Modern Bukkit world.
|
||||||
|
bukkitWorld = Bukkit.getServer().getWorld(new UUID(loadedData.getLong("WorldUUIDMost"), loadedData.getLong("WorldUUIDLeast")));
|
||||||
|
} else if (loadedData.contains("world", net.minecraft.nbt.Tag.TAG_STRING)) {
|
||||||
|
// Legacy Bukkit world.
|
||||||
|
bukkitWorld = Bukkit.getServer().getWorld(loadedData.getString("world"));
|
||||||
|
} else {
|
||||||
|
// Vanilla player data.
|
||||||
|
DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, loadedData.get("Dimension")))
|
||||||
|
.resultOrPartial(JavaPlugin.getPlugin(OpenInv.class).getLogger()::warning)
|
||||||
|
.map(player.server::getLevel)
|
||||||
|
// If ServerLevel exists, set, otherwise move to spawn.
|
||||||
|
.ifPresentOrElse(player::setServerLevel, () -> player.spawnIn(null));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (bukkitWorld == null) {
|
||||||
|
player.spawnIn(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.setServerLevel(((CraftWorld) bukkitWorld).getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectPlayer(ServerPlayer player) throws IllegalAccessException {
|
||||||
if (bukkitEntity == null) {
|
if (bukkitEntity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,9 +223,8 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
bukkitEntity.set(player, new OpenPlayer(player.server.server, player));
|
bukkitEntity.set(player, new OpenPlayer(player.server.server, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public Player inject(@NotNull Player player) {
|
public @NotNull Player inject(@NotNull Player player) {
|
||||||
try {
|
try {
|
||||||
ServerPlayer nmsPlayer = getHandle(player);
|
ServerPlayer nmsPlayer = getHandle(player);
|
||||||
if (nmsPlayer.getBukkitEntity() instanceof OpenPlayer openPlayer) {
|
if (nmsPlayer.getBukkitEntity() instanceof OpenPlayer openPlayer) {
|
||||||
@@ -152,14 +233,16 @@ public class PlayerDataManager implements IPlayerDataManager {
|
|||||||
injectPlayer(nmsPlayer);
|
injectPlayer(nmsPlayer);
|
||||||
return nmsPlayer.getBukkitEntity();
|
return nmsPlayer.getBukkitEntity();
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
JavaPlugin.getPlugin(OpenInv.class).getLogger().log(
|
||||||
|
java.util.logging.Level.WARNING,
|
||||||
|
e,
|
||||||
|
() -> "Unable to inject ServerPlayer, certain player data may be lost when saving!");
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
|
public @Nullable InventoryView openInventory(@NotNull Player player, @NotNull ISpecialInventory inventory) {
|
||||||
|
|
||||||
ServerPlayer nmsPlayer = getHandle(player);
|
ServerPlayer nmsPlayer = getHandle(player);
|
||||||
|
|
||||||
+30
-18
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,12 +14,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R2;
|
package com.lishid.openinv.internal.v1_20_R3;
|
||||||
|
|
||||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
@@ -33,13 +30,17 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
import net.minecraft.world.level.block.entity.EnderChestBlockEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SpecialEnderChest extends PlayerEnderChestContainer implements ISpecialEnderChest {
|
public class SpecialEnderChest extends PlayerEnderChestContainer implements ISpecialEnderChest {
|
||||||
|
|
||||||
private final CraftInventory inventory;
|
private final CraftInventory inventory;
|
||||||
@@ -67,18 +68,29 @@ public class SpecialEnderChest extends PlayerEnderChestContainer implements ISpe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerOnline(@NotNull final org.bukkit.entity.Player player) {
|
public void setPlayerOnline(@NotNull final org.bukkit.entity.Player player) {
|
||||||
if (!this.playerOnline) {
|
if (this.playerOnline) {
|
||||||
try {
|
return;
|
||||||
this.owner = PlayerDataManager.getHandle(player);
|
|
||||||
PlayerEnderChestContainer enderChest = owner.getEnderChestInventory();
|
|
||||||
for (int i = 0; i < enderChest.getContainerSize(); ++i) {
|
|
||||||
enderChest.setItem(i, this.items.get(i));
|
|
||||||
}
|
|
||||||
this.items = enderChest.items;
|
|
||||||
enderChest.transaction.addAll(this.transaction);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
this.playerOnline = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerPlayer offlinePlayer = this.owner;
|
||||||
|
ServerPlayer onlinePlayer = PlayerDataManager.getHandle(player);
|
||||||
|
|
||||||
|
// Set owner to new player.
|
||||||
|
this.owner = onlinePlayer;
|
||||||
|
|
||||||
|
// Set player's ender chest contents to our modified contents.
|
||||||
|
PlayerEnderChestContainer onlineEnderChest = onlinePlayer.getEnderChestInventory();
|
||||||
|
for (int i = 0; i < onlineEnderChest.getContainerSize(); ++i) {
|
||||||
|
onlineEnderChest.setItem(i, this.items.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set our item array to the new inventory's array.
|
||||||
|
this.items = onlineEnderChest.items;
|
||||||
|
|
||||||
|
// Add viewers to new inventory.
|
||||||
|
onlineEnderChest.transaction.addAll(offlinePlayer.getEnderChestInventory().transaction);
|
||||||
|
|
||||||
|
this.playerOnline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+45
-26
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2011-2022 lishid. All rights reserved.
|
* Copyright (C) 2011-2023 lishid. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,16 +14,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.lishid.openinv.internal.v1_19_R2;
|
package com.lishid.openinv.internal.v1_20_R3;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.minecraft.CrashReport;
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.CrashReportCategory;
|
import net.minecraft.CrashReportCategory;
|
||||||
import net.minecraft.ReportedException;
|
import net.minecraft.ReportedException;
|
||||||
@@ -33,6 +27,7 @@ import net.minecraft.nbt.ListTag;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.tags.DamageTypeTags;
|
||||||
import net.minecraft.tags.TagKey;
|
import net.minecraft.tags.TagKey;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.ContainerHelper;
|
import net.minecraft.world.ContainerHelper;
|
||||||
@@ -46,13 +41,20 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftHumanEntity;
|
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftHumanEntity;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftInventory;
|
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftInventory;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerInventory {
|
public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerInventory {
|
||||||
|
|
||||||
private final CraftInventory inventory;
|
private final CraftInventory inventory;
|
||||||
@@ -77,20 +79,37 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerOnline(@NotNull org.bukkit.entity.Player player) {
|
public void setPlayerOnline(@NotNull org.bukkit.entity.Player player) {
|
||||||
if (!this.playerOnline) {
|
if (this.playerOnline) {
|
||||||
Player entityPlayer = PlayerDataManager.getHandle(player);
|
return;
|
||||||
entityPlayer.getInventory().transaction.addAll(this.transaction);
|
|
||||||
this.player = entityPlayer;
|
|
||||||
for (int i = 0; i < getContainerSize(); ++i) {
|
|
||||||
this.player.getInventory().setItem(i, getRawItem(i));
|
|
||||||
}
|
|
||||||
this.player.getInventory().selected = this.selected;
|
|
||||||
this.items = this.player.getInventory().items;
|
|
||||||
this.armor = this.player.getInventory().armor;
|
|
||||||
this.offhand = this.player.getInventory().offhand;
|
|
||||||
this.compartments = ImmutableList.of(this.items, this.armor, this.offhand);
|
|
||||||
this.playerOnline = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player offlinePlayer = this.player;
|
||||||
|
Player onlinePlayer = PlayerDataManager.getHandle(player);
|
||||||
|
onlinePlayer.getInventory().transaction.addAll(this.transaction);
|
||||||
|
|
||||||
|
// Set owner to new player.
|
||||||
|
this.player = onlinePlayer;
|
||||||
|
|
||||||
|
// Set player's inventory contents to our modified contents.
|
||||||
|
Inventory onlineInventory = onlinePlayer.getInventory();
|
||||||
|
for (int i = 0; i < getContainerSize(); ++i) {
|
||||||
|
onlineInventory.setItem(i, getRawItem(i));
|
||||||
|
}
|
||||||
|
onlineInventory.selected = this.selected;
|
||||||
|
|
||||||
|
// Set our item arrays to the new inventory's arrays.
|
||||||
|
this.items = onlineInventory.items;
|
||||||
|
this.armor = onlineInventory.armor;
|
||||||
|
this.offhand = onlineInventory.offhand;
|
||||||
|
this.compartments = ImmutableList.of(this.items, this.armor, this.offhand);
|
||||||
|
|
||||||
|
// Add existing viewers to new viewer list.
|
||||||
|
Inventory offlineInventory = offlinePlayer.getInventory();
|
||||||
|
// Remove self from listing - player is always a viewer of their own inventory, prevent duplicates.
|
||||||
|
offlineInventory.transaction.remove(offlinePlayer.getBukkitEntity());
|
||||||
|
onlineInventory.transaction.addAll(offlineInventory.transaction);
|
||||||
|
|
||||||
|
this.playerOnline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -456,7 +475,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
for (NonNullList<ItemStack> compartment : this.compartments) {
|
for (NonNullList<ItemStack> compartment : this.compartments) {
|
||||||
for (int i = 0; i < compartment.size(); ++i) {
|
for (int i = 0; i < compartment.size(); ++i) {
|
||||||
if (!compartment.get(i).isEmpty()) {
|
if (!compartment.get(i).isEmpty()) {
|
||||||
compartment.get(i).inventoryTick(this.player.level, this.player, i, this.selected == i);
|
compartment.get(i).inventoryTick(this.player.level(), this.player, i, this.selected == i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,7 +721,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
|
|
||||||
for (int index : armorIndices) {
|
for (int index : armorIndices) {
|
||||||
ItemStack itemstack = this.armor.get(index);
|
ItemStack itemstack = this.armor.get(index);
|
||||||
if ((!damagesource.isFire() || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
|
if ((!damagesource.is(DamageTypeTags.IS_FIRE) || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
|
||||||
itemstack.hurtAndBreak((int) damage, this.player, localPlayer -> localPlayer.broadcastBreakEvent(EquipmentSlot.byTypeAndIndex(EquipmentSlot.Type.ARMOR, index)));
|
itemstack.hurtAndBreak((int) damage, this.player, localPlayer -> localPlayer.broadcastBreakEvent(EquipmentSlot.byTypeAndIndex(EquipmentSlot.Type.ARMOR, index)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,7 +758,7 @@ public class SpecialPlayerInventory extends Inventory implements ISpecialPlayerI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ItemStack itemstack) {
|
public boolean contains(ItemStack itemstack) {
|
||||||
return contains(itemStack -> itemStack.isEmpty() && itemStack.sameItem(itemstack));
|
return contains(itemStack -> itemStack.isEmpty() && itemStack.is(itemstack.getItem()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2022 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>openinvplugincore</artifactId>
|
|
||||||
<name>OpenInvPlugin</name>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -22,11 +22,12 @@ import com.lishid.openinv.internal.ISpecialEnderChest;
|
|||||||
import com.lishid.openinv.internal.ISpecialInventory;
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
import com.lishid.openinv.internal.ISpecialPlayerInventory;
|
||||||
import com.lishid.openinv.util.InventoryAccess;
|
import com.lishid.openinv.util.InventoryAccess;
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
class InternalAccessor {
|
class InternalAccessor {
|
||||||
|
|
||||||
private final @NotNull Plugin plugin;
|
private final @NotNull Plugin plugin;
|
||||||
@@ -65,6 +66,8 @@ class InternalAccessor {
|
|||||||
case "v1_16_R3" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.1.8";
|
case "v1_16_R3" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.1.8";
|
||||||
case "v1_17_R1", "v1_18_R1" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.1.10";
|
case "v1_17_R1", "v1_18_R1" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.1.10";
|
||||||
case "v1_19_R1" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.2.2";
|
case "v1_19_R1" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.2.2";
|
||||||
|
case "v1_18_R2", "v1_19_R2" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.3.0";
|
||||||
|
case "v1_20_R1" -> "https://github.com/Jikoo/OpenInv/releases/tag/4.4.1";
|
||||||
default -> "https://github.com/Jikoo/OpenInv/releases";
|
default -> "https://github.com/Jikoo/OpenInv/releases";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.block.Container;
|
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -36,6 +35,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
import org.bukkit.event.inventory.InventoryInteractEvent;
|
import org.bukkit.event.inventory.InventoryInteractEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -54,19 +54,20 @@ record InventoryListener(OpenInv plugin) implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InventoryHolder holder = event.getInventory().getHolder();
|
||||||
if (this.plugin.getSilentContainerStatus(player)
|
if (this.plugin.getSilentContainerStatus(player)
|
||||||
&& event.getInventory().getHolder() instanceof Container container
|
&& holder != null
|
||||||
&& this.plugin.getAnySilentContainer().isAnySilentContainer(container)) {
|
&& this.plugin.getAnySilentContainer().isAnySilentContainer(holder)) {
|
||||||
this.plugin.getAnySilentContainer().deactivateContainer(player);
|
this.plugin.getAnySilentContainer().deactivateContainer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISpecialInventory specialInventory = InventoryAccess.getEnderChest(event.getInventory());
|
ISpecialInventory specialInventory = InventoryAccess.getEnderChest(event.getInventory());
|
||||||
if (specialInventory != null) {
|
if (specialInventory != null) {
|
||||||
this.plugin.handleCloseInventory(event.getPlayer(), specialInventory);
|
this.plugin.handleCloseInventory(specialInventory);
|
||||||
} else {
|
} else {
|
||||||
specialInventory = InventoryAccess.getPlayerInventory(event.getInventory());
|
specialInventory = InventoryAccess.getPlayerInventory(event.getInventory());
|
||||||
if (specialInventory != null) {
|
if (specialInventory != null) {
|
||||||
this.plugin.handleCloseInventory(event.getPlayer(), specialInventory);
|
this.plugin.handleCloseInventory(specialInventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.lishid.openinv.commands.OpenInvCommand;
|
|||||||
import com.lishid.openinv.commands.SearchContainerCommand;
|
import com.lishid.openinv.commands.SearchContainerCommand;
|
||||||
import com.lishid.openinv.commands.SearchEnchantCommand;
|
import com.lishid.openinv.commands.SearchEnchantCommand;
|
||||||
import com.lishid.openinv.commands.SearchInvCommand;
|
import com.lishid.openinv.commands.SearchInvCommand;
|
||||||
|
import com.lishid.openinv.event.OpenPlayerSaveEvent;
|
||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||||
import com.lishid.openinv.internal.ISpecialInventory;
|
import com.lishid.openinv.internal.ISpecialInventory;
|
||||||
@@ -544,7 +545,7 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleCloseInventory(@NotNull HumanEntity exViewer, @NotNull ISpecialInventory inventory) {
|
void handleCloseInventory(@NotNull ISpecialInventory inventory) {
|
||||||
Map<UUID, ? extends ISpecialInventory> map = inventory instanceof ISpecialPlayerInventory ? inventories : enderChests;
|
Map<UUID, ? extends ISpecialInventory> map = inventory instanceof ISpecialPlayerInventory ? inventories : enderChests;
|
||||||
UUID key = inventory.getPlayer().getUniqueId();
|
UUID key = inventory.getPlayer().getUniqueId();
|
||||||
@Nullable ISpecialInventory loaded = map.get(key);
|
@Nullable ISpecialInventory loaded = map.get(key);
|
||||||
@@ -576,11 +577,18 @@ public class OpenInv extends JavaPlugin implements IOpenInv {
|
|||||||
// Re-fetch from map - prevents duplicate saves on multi-close.
|
// Re-fetch from map - prevents duplicate saves on multi-close.
|
||||||
ISpecialInventory current = map.remove(key);
|
ISpecialInventory current = map.remove(key);
|
||||||
|
|
||||||
if (!disableSaving()
|
if (disableSaving()
|
||||||
&& current != null
|
|| current == null
|
||||||
&& current.getPlayer() instanceof Player player
|
|| !(current.getPlayer() instanceof Player player)
|
||||||
&& !player.isOnline()) {
|
|| player.isOnline()) {
|
||||||
this.accessor.getPlayerDataManager().inject(player).saveData();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenPlayerSaveEvent event = new OpenPlayerSaveEvent(player, current);
|
||||||
|
getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
this.accessor.getPlayerDataManager().inject(player).saveData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,4 +81,14 @@ public class OpenInventoryView extends InventoryView {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getOriginalTitle() {
|
||||||
|
return getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTitle(@NotNull String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -89,7 +90,7 @@ public class LanguageManager {
|
|||||||
if (resourceStream == null) {
|
if (resourceStream == null) {
|
||||||
localeConfigDefaults = new YamlConfiguration();
|
localeConfigDefaults = new YamlConfiguration();
|
||||||
} else {
|
} else {
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(resourceStream, StandardCharsets.UTF_8))) {
|
||||||
localeConfigDefaults = YamlConfiguration.loadConfiguration(reader);
|
localeConfigDefaults = YamlConfiguration.loadConfiguration(reader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
plugin.getLogger().log(Level.WARNING, e, () -> "[LanguageManager] Unable to load resource " + locale + ".yml");
|
plugin.getLogger().log(Level.WARNING, e, () -> "[LanguageManager] Unable to load resource " + locale + ".yml");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ settings:
|
|||||||
open:
|
open:
|
||||||
no-args-opens-self: false
|
no-args-opens-self: false
|
||||||
searchcontainer:
|
searchcontainer:
|
||||||
max-radius: 10
|
max-radius: 30
|
||||||
disable-offline-access: false
|
disable-offline-access: false
|
||||||
disable-saving: false
|
disable-saving: false
|
||||||
locale: 'en_us'
|
locale: 'en_us'
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
messages:
|
messages:
|
||||||
error:
|
error:
|
||||||
consoleUnsupported: 'You cannot use this command from console.'
|
consoleUnsupported: You cannot use this command from console.
|
||||||
lootNotGenerated: '&cLoot not generated! Please disable &b/silentcontainer&c.'
|
lootNotGenerated: '&cLoot not generated! Please disable &b/silentcontainer&c.'
|
||||||
invalidMaterial: '&cInvalid material: "%target%"'
|
invalidMaterial: '&cInvalid material: "%target%"'
|
||||||
invalidNumber: '&cInvalid number: "%target%"'
|
invalidNumber: '&cInvalid number: "%target%"'
|
||||||
@@ -9,22 +9,24 @@ messages:
|
|||||||
permissionEnderAll: '&cYou''re not allowed to access other players'' ender chests.'
|
permissionEnderAll: '&cYou''re not allowed to access other players'' ender chests.'
|
||||||
permissionExempt: '&c%target%''s inventory is protected.'
|
permissionExempt: '&c%target%''s inventory is protected.'
|
||||||
permissionCrossWorld: '&c%target% is not in your world.'
|
permissionCrossWorld: '&c%target% is not in your world.'
|
||||||
permissionPlayerOnline: '&cYou''re not allowed to open the inventory of online players.'
|
permissionPlayerOnline: '&cYou''re not allowed to open the inventory of online
|
||||||
permissionPlayerOffline: '&cYou''re not allowed to open the inventory of offline players.'
|
players.'
|
||||||
|
permissionPlayerOffline: '&cYou''re not allowed to open the inventory of offline
|
||||||
|
players.'
|
||||||
commandException: '&cAn error occurred. Please check console for details.'
|
commandException: '&cAn error occurred. Please check console for details.'
|
||||||
info:
|
info:
|
||||||
containerBlocked: 'You are opening a blocked container.'
|
containerBlocked: You are opening a blocked container.
|
||||||
containerBlockedSilent: 'You are opening a blocked container silently.'
|
containerBlockedSilent: You are opening a blocked container silently.
|
||||||
containerSilent: 'You are opening a container silently.'
|
containerSilent: You are opening a container silently.
|
||||||
settingState: '%setting%: %state%'
|
settingState: '%setting%: %state%'
|
||||||
player:
|
player:
|
||||||
noMatches: 'No players found with %target%.'
|
noMatches: No players found with %target%.
|
||||||
matches: 'Players holding %target%: %detail%'
|
matches: 'Players holding %target%: %detail%'
|
||||||
container:
|
container:
|
||||||
noMatches: 'No containers found with %target%.'
|
noMatches: No containers found with %target%.
|
||||||
matches: 'Containers holding %target%: %detail%'
|
matches: 'Containers holding %target%: %detail%'
|
||||||
on: 'on'
|
'true': 'on'
|
||||||
off: 'off'
|
'false': 'off'
|
||||||
container:
|
container:
|
||||||
player: '%player%''s Inventory'
|
player: '%player%''s Inventory'
|
||||||
enderchest: '%player%''s Ender Chest'
|
enderchest: '%player%''s Ender Chest'
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
name: OpenInv
|
name: OpenInv
|
||||||
main: com.lishid.openinv.OpenInv
|
main: com.lishid.openinv.OpenInv
|
||||||
version: ${project.version}
|
version: ${version}
|
||||||
author: lishid
|
author: lishid
|
||||||
authors: [Jikoo, ShadowRanger]
|
authors: [Jikoo, ShadowRanger]
|
||||||
description: >
|
description: >
|
||||||
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
This plugin allows you to open a player's inventory as a chest and interact with it in real time.
|
||||||
api-version: "1.16"
|
api-version: "${apiVersion}"
|
||||||
|
softdepend: [Utilities-OG]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
OpenInv.any.default:
|
OpenInv.any.default:
|
||||||
|
|||||||
@@ -1,199 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2011-2023 lishid. All rights reserved.
|
|
||||||
~
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<artifactId>openinvparent</artifactId>
|
|
||||||
<name>OpenInv</name>
|
|
||||||
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<!-- Silence IDE warning - property is declared in individual internal modules. -->
|
|
||||||
<spigot.version>unknown</spigot.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>all</id>
|
|
||||||
<modules>
|
|
||||||
<module>api</module>
|
|
||||||
<module>plugin</module>
|
|
||||||
<module>internal/v1_18_R2</module>
|
|
||||||
<module>internal/v1_19_R2</module>
|
|
||||||
<module>internal/v1_19_R3</module>
|
|
||||||
<module>assembly</module>
|
|
||||||
</modules>
|
|
||||||
</profile>
|
|
||||||
|
|
||||||
<profile>
|
|
||||||
<id>default</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>true</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<modules>
|
|
||||||
<module>api</module>
|
|
||||||
<module>plugin</module>
|
|
||||||
<module>assembly</module>
|
|
||||||
</modules>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<version>24.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>openinvplugincore</artifactId>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.lishid</groupId>
|
|
||||||
<artifactId>openinvapi</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<!--
|
|
||||||
~ This plugin is used in scripts to determine if NMS dependencies need to be installed. This must be
|
|
||||||
~ declared so that we don't run into MDEP-204; the default SuperPOM declares version 2.8.0.
|
|
||||||
-->
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>3.5.0</version>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<!-- Always shade entirety of required modules. -->
|
|
||||||
<artifact>com.lishid:openinv*</artifact>
|
|
||||||
<includes>
|
|
||||||
<include>**</include>
|
|
||||||
</includes>
|
|
||||||
</filter>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<!-- Don't warn about file conflicts that'll be clobbered anyway. -->
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
<minimizeJar>true</minimizeJar>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>3.4.1</version>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>3.11.0</version>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>3.5.0</version>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-obf</id>
|
|
||||||
<configuration>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
|
||||||
<reverse>true</reverse>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
|
||||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
|
||||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-spigot</id>
|
|
||||||
<configuration>
|
|
||||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "OpenInv"
|
||||||
Reference in new issue
Block a user