mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Merge pull request #47 from craftaro/development-v3-without-breaking-changes
Merges the original development-v3 branch and reverts commits that introduce breaking changes
This commit is contained in:
commit
2c1f8bbdf8
10
.github/FUNDING.yml
vendored
10
.github/FUNDING.yml
vendored
@ -1,12 +1,2 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
||||||
patreon: songoda
|
patreon: songoda
|
||||||
open_collective: # Replace with a single Open Collective username
|
|
||||||
ko_fi: # Replace with a single Ko-fi username
|
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
||||||
liberapay: # Replace with a single Liberapay username
|
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
|
||||||
otechie: # Replace with a single Otechie username
|
|
||||||
custom: [ 'https://songoda.com/songoda+' ]
|
custom: [ 'https://songoda.com/songoda+' ]
|
||||||
|
23
.github/actions/setup_project_workspace/action.yml
vendored
Normal file
23
.github/actions/setup_project_workspace/action.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
name: Prepare Workspace
|
||||||
|
description: Prepares the workspace for compilation
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
maven_username:
|
||||||
|
required: false
|
||||||
|
description: The username to use for the Maven server
|
||||||
|
maven_password:
|
||||||
|
required: false
|
||||||
|
description: The password to use for the Maven server
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: songoda/GH-Commons/.github/actions/setup_workspace@master
|
||||||
|
with:
|
||||||
|
maven_username: ${{ inputs.maven_username }}
|
||||||
|
maven_password: ${{ inputs.maven_password }}
|
||||||
|
|
||||||
|
- uses: SpraxDev/Action-SpigotMC@v4
|
||||||
|
with:
|
||||||
|
versions: 1.18.1, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4
|
||||||
|
remapped: true
|
13
.github/dependabot.yml
vendored
Normal file
13
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: maven
|
||||||
|
directory: /
|
||||||
|
target-branch: development
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
||||||
|
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
target-branch: development
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
93
.github/workflows/build.yml
vendored
Normal file
93
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master, development, development-v3 ]
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
types: [ opened, synchronize, reopened ]
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
env:
|
||||||
|
DEPLOYMENT_POM_PATH: ./Core/dependency-reduced-pom.xml
|
||||||
|
DEPLOYMENT_ARTIFACT_DIR: ./Core/target
|
||||||
|
DEPLOYMENT_ARTIFACT_SELECTOR: SongodaCore-*.jar
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Prepare Workspace
|
||||||
|
uses: ./.github/actions/setup_project_workspace
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: mvn -B clean test
|
||||||
|
|
||||||
|
Build:
|
||||||
|
name: Build + Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ Tests ]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Prepare Workspace
|
||||||
|
uses: ./.github/actions/setup_project_workspace
|
||||||
|
with:
|
||||||
|
maven_username: ${{ secrets.MAVEN_REPO_USERNAME }}
|
||||||
|
maven_password: ${{ secrets.MAVEN_REPO_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Set project version
|
||||||
|
uses: songoda/GH-Commons/.github/actions/maven_set_project_version@master
|
||||||
|
with:
|
||||||
|
append_snapshot: ${{ github.ref_type == 'tag' && 'false' || 'true' }}
|
||||||
|
version: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B -Duser.name="GitHub Actions on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" -DskipTests clean package
|
||||||
|
|
||||||
|
- name: Sign jar archives
|
||||||
|
uses: songoda/GH-Commons/.github/actions/sign_jars@master
|
||||||
|
with:
|
||||||
|
jar_file_selector: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}/${{ env.DEPLOYMENT_ARTIFACT_SELECTOR }}
|
||||||
|
keystore_gpg_encrypted: ${{ secrets.JARSIGNER_KEYSTORE_ENCRYPTED }}
|
||||||
|
keystore_gpg_password: ${{ secrets.JARSIGNER_KEYSTORE_ENCRYPTED_PASSWORD }}
|
||||||
|
keystore_password: ${{ secrets.JARSIGNER_KEYSTORE_PASSWORD }}
|
||||||
|
|
||||||
|
- name: 'Upload Build Artifacts'
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ github.event.repository.name }}
|
||||||
|
path: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}/${{ env.DEPLOYMENT_ARTIFACT_SELECTOR }}
|
||||||
|
|
||||||
|
- name: Deploy to Maven repo
|
||||||
|
uses: songoda/GH-Commons/.github/actions/maven_deploy@master
|
||||||
|
with:
|
||||||
|
repository_url: ${{ secrets.MAVEN_REPO_URL_RELEASES }}
|
||||||
|
repository_url_snapshots: ${{ secrets.MAVEN_REPO_URL_SNAPSHOTS }}
|
||||||
|
maven_pom_path: ${{ env.DEPLOYMENT_POM_PATH }}
|
||||||
|
maven_out_dir: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}
|
||||||
|
- name: Deploy parent pom.xml to Maven repo
|
||||||
|
uses: songoda/GH-Commons/.github/actions/maven_deploy@master
|
||||||
|
with:
|
||||||
|
repository_url: ${{ secrets.MAVEN_REPO_URL_RELEASES }}
|
||||||
|
repository_url_snapshots: ${{ secrets.MAVEN_REPO_URL_SNAPSHOTS }}
|
||||||
|
only_deploy_pom: true
|
||||||
|
maven_out_dir: ${{ env.DEPLOYMENT_ARTIFACT_DIR }}
|
||||||
|
|
||||||
|
discord_webhook:
|
||||||
|
name: Send Discord Webhook
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
needs: [ Tests, Build ]
|
||||||
|
if: ${{ always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development' || github.ref_type == 'tag') }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Notify Webhook
|
||||||
|
uses: songoda/GH-Commons/.github/actions/discord_send_job_results@master
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
webhook_url: ${{ secrets.DISCORD_BUILD_STATUS_WEBHOOK }}
|
36
.github/workflows/codeql.yml
vendored
Normal file
36
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: CodeQL
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master, development ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ master, development ]
|
||||||
|
schedule:
|
||||||
|
- cron: 30 18 * * 4
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Analyze:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: java
|
||||||
|
|
||||||
|
- name: Prepare Workspace
|
||||||
|
uses: ./.github/actions/setup_project_workspace
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B -DskipTests clean package
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
61
.github/workflows/maven.yml
vendored
61
.github/workflows/maven.yml
vendored
@ -1,61 +0,0 @@
|
|||||||
# This workflow will build a Java project with Maven
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
|
||||||
|
|
||||||
name: Build SongodaCore
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master, development ]
|
|
||||||
pull_request:
|
|
||||||
types: [ opened, synchronize, reopened ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Checkout project files
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
# Setup Java
|
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
with:
|
|
||||||
java-version: 17
|
|
||||||
distribution: adopt
|
|
||||||
cache: maven
|
|
||||||
|
|
||||||
# Build remapped Spigot versions
|
|
||||||
- uses: SpraxDev/Action-SpigotMC@v4
|
|
||||||
with:
|
|
||||||
versions: 1.18, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4
|
|
||||||
remapped: true
|
|
||||||
|
|
||||||
# Build project
|
|
||||||
- name: Build with Maven
|
|
||||||
run: 'mvn -B -Duser.name="GitHub Runner on $GITHUB_REPOSITORY (id=$GITHUB_RUN_ID)" clean package'
|
|
||||||
|
|
||||||
# Upload build artifacts
|
|
||||||
- name: 'Upload Build Artifact: SongodaCore-*.jar'
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: SongodaCore-artifacts
|
|
||||||
path: ./Core/target/SongodaCore-*.jar
|
|
||||||
|
|
||||||
##
|
|
||||||
# Discord Webhook
|
|
||||||
# TODO: Extract into external Action for better reusability (and readability)
|
|
||||||
##
|
|
||||||
- name: 'Discord Webhook (Success)'
|
|
||||||
if: ${{ success() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development') }}
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
curl -X POST --data "{\"content\":null,\"embeds\":[{\"title\":\"Build succeeded!\",\"description\":\"The build with the ID #$GITHUB_RUN_NUMBER has succeeded!\",\"url\":\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\",\"color\":5490477,\"fields\":[{\"name\":\"Branch\",\"value\":\"$GITHUB_REF\",\"inline\":true}],\"author\":{\"name\":\"$GITHUB_REPOSITORY\",\"url\":\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY\",\"icon_url\":\"$GITHUB_SERVER_URL/songoda.png\"},\"footer\":{\"text\":\"Initiated by $GITHUB_ACTOR\",\"icon_url\":\"$GITHUB_SERVER_URL/$GITHUB_ACTOR.png\"}}],\"username\":\"OctoAgent\",\"avatar_url\":\"https://github.githubassets.com/images/modules/logos_page/Octocat.png\"}" --header 'Content-Type: application/json' $DISCORD_WEBHOOK
|
|
||||||
env:
|
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_BUILD_STATUS_WEBHOOK }}
|
|
||||||
- name: 'Discord Webhook (Failure)'
|
|
||||||
if: ${{ failure() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development') }}
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
curl -X POST --data "{\"content\":null,\"embeds\":[{\"title\":\"Build failed!\",\"description\":\"The build with the ID #$GITHUB_RUN_NUMBER has failed!\",\"url\":\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\",\"color\":15611419,\"fields\":[{\"name\":\"Branch\",\"value\":\"$GITHUB_REF\",\"inline\":true}],\"author\":{\"name\":\"$GITHUB_REPOSITORY\",\"url\":\"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY\",\"icon_url\":\"$GITHUB_SERVER_URL/songoda.png\"},\"footer\":{\"text\":\"Initiated by $GITHUB_ACTOR\",\"icon_url\":\"$GITHUB_SERVER_URL/$GITHUB_ACTOR.png\"}}],\"username\":\"OctoAgent\",\"avatar_url\":\"https://github.githubassets.com/images/modules/logos_page/Octocat.png\"}" --header "Content-Type:application/json" $DISCORD_WEBHOOK
|
|
||||||
env:
|
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_BUILD_STATUS_WEBHOOK }}
|
|
44
.github/workflows/sonarcloud.yml
vendored
44
.github/workflows/sonarcloud.yml
vendored
@ -2,47 +2,43 @@ name: SonarCloud
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, development ]
|
branches: [ master, development, development-v3 ]
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [ opened, synchronize, reopened ]
|
types: [ opened, synchronize, reopened ]
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_PROJECT_KEY: songoda_SongodaCore
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
Analyze:
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
||||||
steps:
|
steps:
|
||||||
# Checkout project files
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/checkout@v2
|
|
||||||
if: ${{ env.SONAR_TOKEN != null }}
|
if: ${{ env.SONAR_TOKEN != null }}
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0
|
||||||
|
|
||||||
# Setup Java
|
- name: Prepare Workspace
|
||||||
- uses: actions/setup-java@v2
|
|
||||||
if: ${{ env.SONAR_TOKEN != null }}
|
if: ${{ env.SONAR_TOKEN != null }}
|
||||||
with:
|
uses: ./.github/actions/setup_project_workspace
|
||||||
java-version: 17
|
|
||||||
distribution: adopt
|
|
||||||
cache: maven
|
|
||||||
|
|
||||||
# Cache
|
|
||||||
- name: 'Cache: SonarCloud'
|
- name: 'Cache: SonarCloud'
|
||||||
if: ${{ env.SONAR_TOKEN != null }}
|
if: ${{ env.SONAR_TOKEN != null }}
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.sonar/cache
|
path: ~/.sonar/cache
|
||||||
key: ${{ runner.os }}-sonar
|
key: ${{ runner.os }}-sonar
|
||||||
|
|
||||||
# Build remapped Spigot versions
|
|
||||||
- uses: SpraxDev/Action-SpigotMC@v4
|
|
||||||
with:
|
|
||||||
versions: 1.18, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4
|
|
||||||
remapped: true
|
|
||||||
|
|
||||||
- name: Analyze project
|
- name: Analyze project
|
||||||
if: ${{ env.SONAR_TOKEN != null }}
|
if: ${{ env.SONAR_TOKEN != null }}
|
||||||
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=songoda_SongodaCore
|
run: >
|
||||||
|
mvn -B \
|
||||||
|
verify \
|
||||||
|
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
|
||||||
|
"-Dsonar.projectKey=$SONAR_PROJECT_KEY"
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
@ -10,15 +10,13 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.18-R0.1-SNAPSHOT</version>
|
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.songoda.core.compatibility;
|
package com.songoda.core.compatibility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Usage is highly discouraged – use NMSManager instead
|
* @deprecated Usage is highly discouraged – use com.songoda.core.nms.Nms#getImplementations() instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public enum ClassMapping {
|
public enum ClassMapping {
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -1548,6 +1549,7 @@ public enum CompatibleMaterial {
|
|||||||
*
|
*
|
||||||
* @return LegacyMaterial or null if none found
|
* @return LegacyMaterial or null if none found
|
||||||
*/
|
*/
|
||||||
|
@Contract("_, !null -> !null")
|
||||||
public static CompatibleMaterial getMaterial(String name, CompatibleMaterial def) {
|
public static CompatibleMaterial getMaterial(String name, CompatibleMaterial def) {
|
||||||
return name == null ? def : lookupMap.getOrDefault(name.toUpperCase(), def);
|
return name == null ? def : lookupMap.getOrDefault(name.toUpperCase(), def);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Usage is highly discouraged – use NMSManager instead
|
* @deprecated Usage is highly discouraged – use com.songoda.core.nms.Nms#getImplementations() instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public enum MethodMapping {
|
public enum MethodMapping {
|
||||||
|
@ -6,26 +6,27 @@ import org.bukkit.Bukkit;
|
|||||||
public enum ServerVersion {
|
public enum ServerVersion {
|
||||||
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21;
|
UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21;
|
||||||
|
|
||||||
private final static String serverPackagePath;
|
|
||||||
private final static String serverPackageVersion;
|
private final static String serverPackageVersion;
|
||||||
private final static String serverReleaseVersion;
|
private final static String serverReleaseVersion;
|
||||||
private final static ServerVersion serverVersion;
|
private final static ServerVersion serverVersion;
|
||||||
private final static boolean isMocked;
|
private final static boolean isMocked;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String srvPackage = Bukkit.getServer().getClass().getPackage().getName();
|
if (Bukkit.getServer() != null) {
|
||||||
isMocked = srvPackage.equals("be.seeseemelk.mockbukkit");
|
String srvPackage = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
isMocked = srvPackage.equals("be.seeseemelk.mockbukkit");
|
||||||
|
|
||||||
if (isMocked) {
|
if (isMocked) {
|
||||||
String packageVersionShard = "v" + Bukkit.getServer().getBukkitVersion().replace('.', '_') + "_R0";
|
serverPackageVersion = "v" + Bukkit.getServer().getBukkitVersion().replace('.', '_') + "_R0";
|
||||||
|
serverReleaseVersion = "0";
|
||||||
serverPackagePath = "org.bukkit.craftbukkit." + packageVersionShard;
|
} else {
|
||||||
serverPackageVersion = packageVersionShard;
|
serverPackageVersion = srvPackage.substring(srvPackage.lastIndexOf('.') + 1);
|
||||||
serverReleaseVersion = "0";
|
serverReleaseVersion = serverPackageVersion.indexOf('R') != -1 ? serverPackageVersion.substring(serverPackageVersion.indexOf('R') + 1) : "";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
serverPackagePath = srvPackage;
|
serverPackageVersion = "Bukkit-not-initialized";
|
||||||
serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
|
serverReleaseVersion = "Bukkit-not-initialized";
|
||||||
serverReleaseVersion = serverPackageVersion.indexOf('R') != -1 ? serverPackageVersion.substring(serverPackageVersion.indexOf('R') + 1) : "";
|
isMocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
serverVersion = getVersion();
|
serverVersion = getVersion();
|
||||||
@ -42,18 +43,34 @@ public enum ServerVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLessThan(ServerVersion other) {
|
public boolean isLessThan(ServerVersion other) {
|
||||||
|
if (serverVersion == UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.ordinal() < other.ordinal();
|
return this.ordinal() < other.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtOrBelow(ServerVersion other) {
|
public boolean isAtOrBelow(ServerVersion other) {
|
||||||
|
if (serverVersion == UNKNOWN && other != UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.ordinal() <= other.ordinal();
|
return this.ordinal() <= other.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGreaterThan(ServerVersion other) {
|
public boolean isGreaterThan(ServerVersion other) {
|
||||||
|
if (serverVersion == UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.ordinal() > other.ordinal();
|
return this.ordinal() > other.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(ServerVersion other) {
|
public boolean isAtLeast(ServerVersion other) {
|
||||||
|
if (serverVersion == UNKNOWN && other != UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.ordinal() >= other.ordinal();
|
return this.ordinal() >= other.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,18 +95,34 @@ public enum ServerVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServerVersionAbove(ServerVersion version) {
|
public static boolean isServerVersionAbove(ServerVersion version) {
|
||||||
|
if (serverVersion == UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return serverVersion.ordinal() > version.ordinal();
|
return serverVersion.ordinal() > version.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServerVersionAtLeast(ServerVersion version) {
|
public static boolean isServerVersionAtLeast(ServerVersion version) {
|
||||||
|
if (serverVersion == UNKNOWN && version != UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return serverVersion.ordinal() >= version.ordinal();
|
return serverVersion.ordinal() >= version.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServerVersionAtOrBelow(ServerVersion version) {
|
public static boolean isServerVersionAtOrBelow(ServerVersion version) {
|
||||||
|
if (serverVersion == UNKNOWN && version != UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return serverVersion.ordinal() <= version.ordinal();
|
return serverVersion.ordinal() <= version.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isServerVersionBelow(ServerVersion version) {
|
public static boolean isServerVersionBelow(ServerVersion version) {
|
||||||
|
if (serverVersion == UNKNOWN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return serverVersion.ordinal() < version.ordinal();
|
return serverVersion.ordinal() < version.ordinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.songoda.core.compatibility.bukkit;
|
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
|
||||||
import com.songoda.core.compatibility.CompatibleSound;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
|
|
||||||
class CompatibleSoundTest {
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
MockBukkit.mock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Disabled("CompatibleSound class needs some work beforehand")
|
|
||||||
void getSound() {
|
|
||||||
for (CompatibleSound compatibleSound : CompatibleSound.values()) {
|
|
||||||
assertNotNull(compatibleSound.getSound());
|
|
||||||
|
|
||||||
// compatibleSound.usesCompatibility()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
263
Core/pom.xml
263
Core/pom.xml
@ -10,24 +10,34 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore</artifactId>
|
<artifactId>SongodaCore</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>SongodaCore-${project.version}</finalName>
|
<finalName>SongodaCore-${project.version}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>de.m3y.maven</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>inject-maven-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>1.3</version>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
|
||||||
|
<goals>
|
||||||
|
<goal>inject</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<injections>
|
||||||
<target>${java.version}</target>
|
<injection>
|
||||||
|
<value>${project.version}</value>
|
||||||
<release>${java.release}</release>
|
<pointCut>com.songoda.core.SongodaCoreConstants.getCoreVersion</pointCut>
|
||||||
|
</injection>
|
||||||
|
</injections>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
@ -63,7 +73,19 @@
|
|||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
|
||||||
|
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>com.songoda:*</include>
|
||||||
|
<include>com.zaxxer:HikariCP</include>
|
||||||
|
<include>de.tr7zw:item-nbt-api</include>
|
||||||
|
<include>net.kyori:*</include>
|
||||||
|
<include>org.apache.commons:commons-lang3</include>
|
||||||
|
<include>org.apache.commons:commons-text</include>
|
||||||
|
<include>org.yaml:snakeyaml</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
@ -76,21 +98,30 @@
|
|||||||
<shadedPattern>com.songoda.core.third_party.de.tr7zw.nbtapi</shadedPattern>
|
<shadedPattern>com.songoda.core.third_party.de.tr7zw.nbtapi</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.kyori</pattern>
|
||||||
|
<shadedPattern>com.songoda.core.third_party.net.kyori</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.apache.commons</pattern>
|
<pattern>org.apache.commons</pattern>
|
||||||
<shadedPattern>com.songoda.core.third_party.org.apache.commons</shadedPattern>
|
<shadedPattern>com.songoda.core.third_party.org.apache.commons</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
|
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.yaml.snakeyaml</pattern>
|
||||||
|
<shadedPattern>com.songoda.core.third_party.org.yaml.snakeyaml</shadedPattern>
|
||||||
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
|
|
||||||
<artifactSet>
|
<filters>
|
||||||
<includes>
|
<filter>
|
||||||
<include>com.songoda:*</include>
|
<artifact>*:*</artifact>
|
||||||
<include>com.zaxxer:HikariCP</include>
|
<includes>
|
||||||
<include>org.apache.commons:commons-text</include>
|
<include>**/*.class</include>
|
||||||
<include>org.apache.commons:commons-lang3</include>
|
</includes>
|
||||||
<include>de.tr7zw:item-nbt-api</include>
|
</filter>
|
||||||
</includes>
|
</filters>
|
||||||
</artifactSet>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
@ -114,7 +145,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.17</version>
|
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -125,6 +156,13 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>SongodaCore-NMS</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
<artifactId>item-nbt-api</artifactId>
|
<artifactId>item-nbt-api</artifactId>
|
||||||
@ -132,148 +170,33 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Need to include all NMS modules here -->
|
|
||||||
<!-- Note when adding a new module: include the class in NmsManager -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>4.11.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>SongodaCore-NMS-v1_8_R1</artifactId>
|
<artifactId>adventure-platform-bukkit</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>4.1.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>com.zaxxer</groupId>
|
||||||
<artifactId>SongodaCore-NMS-v1_8_R2</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>3.2.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>SongodaCore-NMS-v1_8_R3</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>1.33</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_9_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_9_R2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_10_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_11_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_12_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_13_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_13_R2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_14_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_15_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R3</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_17_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_18_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_18_R2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_19_R1</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_19_R1v2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_19_R2</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>SongodaCore-NMS-v1_19_R3</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- End NMS -->
|
|
||||||
|
|
||||||
<!-- Start Plugin Hooks -->
|
<!-- Start Plugin Hooks -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -448,47 +371,5 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- End Plugin Hooks -->
|
<!-- End Plugin Hooks -->
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.googlecode.json-simple</groupId>
|
|
||||||
<artifactId>json-simple</artifactId>
|
|
||||||
<version>1.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.yaml</groupId>
|
|
||||||
<artifactId>snakeyaml</artifactId>
|
|
||||||
<version>1.26</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>1.7.25</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-nop</artifactId>
|
|
||||||
<version>1.7.25</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.zaxxer</groupId>
|
|
||||||
<artifactId>HikariCP</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
|
||||||
<artifactId>mariadb-java-client</artifactId>
|
|
||||||
<version>3.0.8</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.xerial</groupId>
|
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
|
||||||
<version>3.23.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -44,27 +44,36 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SongodaCore {
|
public class SongodaCore {
|
||||||
private final static Logger logger = Logger.getLogger("SongodaCore");
|
private static final Logger logger = Logger.getLogger(SongodaCoreConstants.getProjectName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whenever we make a major change to the core GUI, updater,
|
* Whenever we make a major change to the core GUI, updater,
|
||||||
* or other function used by the core, increment this number
|
* or other function used by the core, increment this number
|
||||||
|
*
|
||||||
|
* @deprecated The Core's version should be used instead as it uses Semantic Versioning
|
||||||
*/
|
*/
|
||||||
private final static int coreRevision = 9;
|
@Deprecated
|
||||||
|
private static final int coreRevision = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since coreRevision 6
|
* @since coreRevision 6
|
||||||
|
* @deprecated Is being replaced by {@link SongodaCoreConstants#getCoreVersion()} which is automatically kept up to date.
|
||||||
*/
|
*/
|
||||||
private final static String coreVersion = "2.6.21";
|
@Deprecated
|
||||||
|
private static final String coreVersion = SongodaCoreConstants.getCoreVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is specific to the website api
|
* This is specific to the website api
|
||||||
|
*
|
||||||
|
* @deprecated Seems useless and will probably be removed in the near future
|
||||||
*/
|
*/
|
||||||
private final static int updaterVersion = 1;
|
@Deprecated
|
||||||
|
private static final int updaterVersion = 1;
|
||||||
|
|
||||||
private final static Set<PluginInfo> registeredPlugins = new HashSet<>();
|
private static final Set<PluginInfo> registeredPlugins = new HashSet<>();
|
||||||
|
|
||||||
private static SongodaCore INSTANCE = null;
|
private static SongodaCore INSTANCE = null;
|
||||||
|
|
||||||
private JavaPlugin piggybackedPlugin;
|
private JavaPlugin piggybackedPlugin;
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
private EventListener loginListener;
|
private EventListener loginListener;
|
||||||
@ -76,7 +85,7 @@ public class SongodaCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPlugin(JavaPlugin plugin, int pluginID, CompatibleMaterial icon) {
|
public static void registerPlugin(JavaPlugin plugin, int pluginID, CompatibleMaterial icon) {
|
||||||
registerPlugin(plugin, pluginID, icon == null ? "STONE" : icon.name(), coreVersion);
|
registerPlugin(plugin, pluginID, icon == null ? "STONE" : icon.name(), SongodaCoreConstants.getCoreVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPlugin(JavaPlugin plugin, int pluginID, String icon) {
|
public static void registerPlugin(JavaPlugin plugin, int pluginID, String icon) {
|
||||||
@ -91,13 +100,23 @@ public class SongodaCore {
|
|||||||
try {
|
try {
|
||||||
// test to see if we're up-to-date
|
// test to see if we're up-to-date
|
||||||
int otherVersion;
|
int otherVersion;
|
||||||
|
int ownVersion;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
otherVersion = (int) clazz.getMethod("getCoreVersion").invoke(null);
|
otherVersion = (int) clazz.getMethod("getCoreMajorVersion").invoke(null);
|
||||||
|
ownVersion = getCoreMajorVersion();
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
otherVersion = -1;
|
try {
|
||||||
|
otherVersion = (int) clazz.getMethod("getCoreVersion").invoke(null);
|
||||||
|
} catch (Exception ignore2) {
|
||||||
|
otherVersion = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ownVersion = getCoreVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherVersion >= getCoreVersion()) {
|
|
||||||
|
if (otherVersion >= ownVersion) {
|
||||||
// use the active service
|
// use the active service
|
||||||
// assuming that the other is greater than R6 if we get here ;)
|
// assuming that the other is greater than R6 if we get here ;)
|
||||||
clazz.getMethod("registerPlugin", JavaPlugin.class, int.class, String.class, String.class).invoke(null, plugin, pluginID, icon, coreVersion);
|
clazz.getMethod("registerPlugin", JavaPlugin.class, int.class, String.class, String.class).invoke(null, plugin, pluginID, icon, coreVersion);
|
||||||
@ -221,6 +240,10 @@ public class SongodaCore {
|
|||||||
tasks.add(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> update(info), 60L));
|
tasks.add(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> update(info), 60L));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Seems useless and will probably be replaced in the near future
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
private void update(PluginInfo plugin) {
|
private void update(PluginInfo plugin) {
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://update.songoda.com/index.php?plugin=" + plugin.getSongodaId()
|
URL url = new URL("https://update.songoda.com/index.php?plugin=" + plugin.getSongodaId()
|
||||||
@ -266,20 +289,45 @@ public class SongodaCore {
|
|||||||
return new ArrayList<>(registeredPlugins);
|
return new ArrayList<>(registeredPlugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVersion() {
|
||||||
|
return SongodaCoreConstants.getCoreVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getCoreMajorVersion()} instead, but careful, coreRevision is at 9 while major version is at 2
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getCoreVersion() {
|
public static int getCoreVersion() {
|
||||||
return coreRevision;
|
return coreRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getVersion()} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static String getCoreLibraryVersion() {
|
public static String getCoreLibraryVersion() {
|
||||||
return coreVersion;
|
return SongodaCoreConstants.getCoreVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getCoreMajorVersion() {
|
||||||
|
String fullVersion = getVersion();
|
||||||
|
if (fullVersion.contains(".")) {
|
||||||
|
return Integer.parseInt(fullVersion.substring(0, fullVersion.indexOf(".")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Seems useless and will probably be removed in the near future
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static int getUpdaterVersion() {
|
public static int getUpdaterVersion() {
|
||||||
return updaterVersion;
|
return updaterVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrefix() {
|
public static String getPrefix() {
|
||||||
return "[SongodaCore] ";
|
return "[" + SongodaCoreConstants.getProjectName() + "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Logger getLogger() {
|
public static Logger getLogger() {
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.songoda.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some return values in this class are automatically replaced by a maven plugin after the project has been compiled.
|
||||||
|
* This allows for properties to be defined at one place without relying on a text file
|
||||||
|
* that needs to be inside the final jar (might get lost when this lib is shaded into other projects).
|
||||||
|
* <p>
|
||||||
|
* <b>!! Manually changing the values in this class has to be considered a breaking change. !!</b>
|
||||||
|
*/
|
||||||
|
public class SongodaCoreConstants {
|
||||||
|
private SongodaCoreConstants() {
|
||||||
|
throw new IllegalStateException("Utility class");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCoreVersion() {
|
||||||
|
return "UNKNOWN_VESION";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getProjectName() {
|
||||||
|
return "SongodaCore";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getGitHubProjectUrl() {
|
||||||
|
return "https://github.com/craftaro/SongodaCore";
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import com.songoda.core.utils.SongodaAuth;
|
|||||||
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
|
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -25,7 +25,6 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
protected Config config = new Config(this);
|
protected Config config = new Config(this);
|
||||||
protected long dataLoadDelay = 20L;
|
protected long dataLoadDelay = 20L;
|
||||||
|
|
||||||
protected ConsoleCommandSender console = Bukkit.getConsoleSender();
|
|
||||||
private boolean emergencyStop = false;
|
private boolean emergencyStop = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -91,6 +90,8 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandSender console = Bukkit.getConsoleSender();
|
||||||
|
|
||||||
// Check plugin access, don't load plugin if user don't have access
|
// Check plugin access, don't load plugin if user don't have access
|
||||||
if (!SongodaAuth.isAuthorized(true)) {
|
if (!SongodaAuth.isAuthorized(true)) {
|
||||||
String pluginName = getDescription().getName();
|
String pluginName = getDescription().getName();
|
||||||
@ -110,7 +111,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
ChatColor.YELLOW + "UUID: " + serverUuid + "\n" +
|
ChatColor.YELLOW + "UUID: " + serverUuid + "\n" +
|
||||||
ChatColor.YELLOW + "IP: " + externalIP + "\n" +
|
ChatColor.YELLOW + "IP: " + externalIP + "\n" +
|
||||||
ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
|
ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
|
||||||
this.console.sendMessage(message);
|
console.sendMessage(message);
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
emergencyStop();
|
emergencyStop();
|
||||||
@ -125,15 +126,19 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
ChatColor.GREEN, "Enabling", ChatColor.GRAY));
|
ChatColor.GREEN, "Enabling", ChatColor.GRAY));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
locale = Locale.loadDefaultLocale(this, "en_US");
|
this.locale = Locale.loadDefaultLocale(this, "en_US");
|
||||||
|
|
||||||
// plugin setup
|
// plugin setup
|
||||||
onPluginEnable();
|
onPluginEnable();
|
||||||
|
|
||||||
// Load Data.
|
if (this.emergencyStop) {
|
||||||
Bukkit.getScheduler().runTaskLater(this, this::onDataLoad, dataLoadDelay);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (emergencyStop) {
|
// Load Data.
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, this::onDataLoad, this.dataLoadDelay);
|
||||||
|
|
||||||
|
if (this.emergencyStop) {
|
||||||
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
console.sendMessage(ChatColor.RED + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||||
console.sendMessage(" ");
|
console.sendMessage(" ");
|
||||||
return;
|
return;
|
||||||
@ -156,10 +161,12 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onDisable() {
|
public final void onDisable() {
|
||||||
if (emergencyStop) {
|
if (this.emergencyStop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandSender console = Bukkit.getConsoleSender();
|
||||||
|
|
||||||
console.sendMessage(" "); // blank line to separate chatter
|
console.sendMessage(" "); // blank line to separate chatter
|
||||||
console.sendMessage(ChatColor.GREEN + "=============================");
|
console.sendMessage(ChatColor.GREEN + "=============================");
|
||||||
console.sendMessage(String.format("%s%s %s by %sCraftaro <3!", ChatColor.GRAY,
|
console.sendMessage(String.format("%s%s %s by %sCraftaro <3!", ChatColor.GRAY,
|
||||||
@ -173,12 +180,8 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
console.sendMessage(" "); // blank line to separate chatter
|
console.sendMessage(" "); // blank line to separate chatter
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsoleCommandSender getConsole() {
|
|
||||||
return console;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
return locale;
|
return this.locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,13 +194,13 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
* @return true if the locale exists and was loaded successfully
|
* @return true if the locale exists and was loaded successfully
|
||||||
*/
|
*/
|
||||||
public boolean setLocale(String localeName, boolean reload) {
|
public boolean setLocale(String localeName, boolean reload) {
|
||||||
if (locale != null && locale.getName().equals(localeName)) {
|
if (this.locale != null && this.locale.getName().equals(localeName)) {
|
||||||
return !reload || locale.reloadMessages();
|
return !reload || this.locale.reloadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale l = Locale.loadLocale(this, localeName);
|
Locale l = Locale.loadLocale(this, localeName);
|
||||||
if (l != null) {
|
if (l != null) {
|
||||||
locale = l;
|
this.locale = l;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +245,7 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void emergencyStop() {
|
protected void emergencyStop() {
|
||||||
emergencyStop = true;
|
this.emergencyStop = true;
|
||||||
|
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
@ -255,10 +258,10 @@ public abstract class SongodaPlugin extends JavaPlugin {
|
|||||||
protected void criticalErrorOnPluginStartup(Throwable th) {
|
protected void criticalErrorOnPluginStartup(Throwable th) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE,
|
Bukkit.getLogger().log(Level.SEVERE,
|
||||||
String.format(
|
String.format(
|
||||||
"Unexpected error while loading %s v%s c%s: Disabling plugin!",
|
"Unexpected error while loading %s v%s (core v%s): Disabling plugin!",
|
||||||
getDescription().getName(),
|
getDescription().getName(),
|
||||||
getDescription().getVersion(),
|
getDescription().getVersion(),
|
||||||
SongodaCore.getCoreLibraryVersion()
|
SongodaCore.getVersion()
|
||||||
), th);
|
), th);
|
||||||
|
|
||||||
emergencyStop();
|
emergencyStop();
|
||||||
|
@ -5,7 +5,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.songoda.core.compatibility.ClassMapping;
|
import com.songoda.core.compatibility.ClassMapping;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import com.songoda.core.utils.TextUtils;
|
import com.songoda.core.utils.TextUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -228,7 +227,7 @@ public class ChatMessage {
|
|||||||
Object packet;
|
Object packet;
|
||||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_19)) {
|
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_19)) {
|
||||||
packet = mc_PacketPlayOutChat_new.newInstance(mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)), mc_PacketPlayOutChat_new_1_19_0 ? 1 : false);
|
packet = mc_PacketPlayOutChat_new.newInstance(mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)), mc_PacketPlayOutChat_new_1_19_0 ? 1 : false);
|
||||||
}else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
|
||||||
packet = mc_PacketPlayOutChat_new.newInstance(
|
packet = mc_PacketPlayOutChat_new.newInstance(
|
||||||
mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)),
|
mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)),
|
||||||
mc_chatMessageType_Chat.get(null),
|
mc_chatMessageType_Chat.get(null),
|
||||||
@ -237,8 +236,8 @@ public class ChatMessage {
|
|||||||
packet = mc_PacketPlayOutChat_new.newInstance(mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)));
|
packet = mc_PacketPlayOutChat_new.newInstance(mc_IChatBaseComponent_ChatSerializer_a.invoke(null, gson.toJson(textList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
NmsManager.getPlayer().sendPacket((Player) sender, packet);
|
Nms.getImplementations().getPlayer().sendPacket((Player) sender, packet);
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
} catch (ReflectiveOperationException | IllegalArgumentException ex) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Problem preparing raw chat packets (disabling further packets)", ex);
|
Bukkit.getLogger().log(Level.WARNING, "Problem preparing raw chat packets (disabling further packets)", ex);
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package com.songoda.core.gui;
|
|||||||
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.core.gui.methods.Clickable;
|
import com.songoda.core.gui.methods.Clickable;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import com.songoda.core.nms.anvil.AnvilCore;
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
import com.songoda.core.nms.anvil.CustomAnvil;
|
import com.songoda.core.nms.anvil.CustomAnvil;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -125,7 +125,7 @@ public class AnvilGui extends Gui {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createInventory() {
|
protected void createInventory() {
|
||||||
AnvilCore nms = NmsManager.getAnvil();
|
AnvilCore nms = Nms.getImplementations().getAnvil();
|
||||||
|
|
||||||
if (nms != null) {
|
if (nms != null) {
|
||||||
anvil = nms.createAnvil(player, new GuiHolder(guiManager, this));
|
anvil = nms.createAnvil(player, new GuiHolder(guiManager, this));
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package com.songoda.core.hooks.protection;
|
package com.songoda.core.hooks.protection;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotAPI;
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class PlotSquaredProtection extends Protection {
|
public class PlotSquaredProtection extends Protection {
|
||||||
|
|
||||||
PlotSquared plotSquared;
|
|
||||||
|
|
||||||
public PlotSquaredProtection(Plugin plugin) {
|
public PlotSquaredProtection(Plugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
plotSquared = PlotSquared.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -23,21 +20,51 @@ public class PlotSquaredProtection extends Protection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return plotSquared != null;
|
return Bukkit.getPluginManager().isPluginEnabled("PlotSquared");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPlace(Player player, Location location) {
|
public boolean canPlace(Player player, Location location) {
|
||||||
return plotSquared.getPlotAreaManager().getApplicablePlotArea(com.plotsquared.core.location.Location.at(location.getWorld().getName(), (int) location.getX(), (int) location.getY(), (int) location.getZ())).getPlots().stream().anyMatch(p -> p.isAdded(player.getUniqueId()));
|
return isPlayerAddedAtPlotLocation(player, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBreak(Player player, Location location) {
|
public boolean canBreak(Player player, Location location) {
|
||||||
return plotSquared.getPlotAreaManager().getApplicablePlotArea(com.plotsquared.core.location.Location.at(location.getWorld().getName(), (int) location.getX(), (int) location.getY(), (int) location.getZ())).getPlots().stream().anyMatch(p -> p.isAdded(player.getUniqueId()));
|
return isPlayerAddedAtPlotLocation(player, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteract(Player player, Location location) {
|
public boolean canInteract(Player player, Location location) {
|
||||||
return plotSquared.getPlotAreaManager().getApplicablePlotArea(com.plotsquared.core.location.Location.at(location.getWorld().getName(), (int) location.getX(), (int) location.getY(), (int) location.getZ())).getPlots().stream().anyMatch(p -> p.isAdded(player.getUniqueId()));
|
return isPlayerAddedAtPlotLocation(player, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPlayerAddedAtPlotLocation(Player player, Location location) {
|
||||||
|
PlotArea plotArea = getApplicablePlotArea(location);
|
||||||
|
if (plotArea == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Plot p : plotArea.getPlots()) {
|
||||||
|
if (p.isAdded(player.getUniqueId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlotArea getApplicablePlotArea(Location location) {
|
||||||
|
return PlotSquared.get()
|
||||||
|
.getPlotAreaManager()
|
||||||
|
.getApplicablePlotArea(getPlotSquaredLocation(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
private com.plotsquared.core.location.Location getPlotSquaredLocation(Location location) {
|
||||||
|
return com.plotsquared.core.location.Location.at(
|
||||||
|
location.getWorld().getName(),
|
||||||
|
(int) location.getX(),
|
||||||
|
(int) location.getY(),
|
||||||
|
(int) location.getZ()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
Core/src/main/java/com/songoda/core/http/HttpClient.java
Normal file
9
Core/src/main/java/com/songoda/core/http/HttpClient.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface HttpClient {
|
||||||
|
@NotNull HttpResponse get(String url) throws IOException;
|
||||||
|
}
|
11
Core/src/main/java/com/songoda/core/http/HttpResponse.java
Normal file
11
Core/src/main/java/com/songoda/core/http/HttpResponse.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface HttpResponse {
|
||||||
|
int getResponseCode() throws IOException;
|
||||||
|
|
||||||
|
byte[] getBody() throws IOException;
|
||||||
|
|
||||||
|
String getBodyAsString() throws IOException;
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class HttpResponseImpl implements HttpResponse, AutoCloseable {
|
||||||
|
protected final HttpURLConnection connection;
|
||||||
|
|
||||||
|
protected byte[] body;
|
||||||
|
|
||||||
|
HttpResponseImpl(HttpURLConnection connection) throws IOException {
|
||||||
|
this.connection = connection;
|
||||||
|
|
||||||
|
this.connection.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResponseCode() throws IOException {
|
||||||
|
int statusCode = this.connection.getResponseCode();
|
||||||
|
|
||||||
|
if (statusCode == -1) {
|
||||||
|
throw new IOException("HTTP Status Code is -1");
|
||||||
|
}
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getBody() throws IOException {
|
||||||
|
if (this.body == null) {
|
||||||
|
try (InputStream in = this.connection.getInputStream();
|
||||||
|
InputStream err = this.connection.getErrorStream()) {
|
||||||
|
if (err != null) {
|
||||||
|
this.body = IOUtils.toByteArray(err);
|
||||||
|
} else {
|
||||||
|
this.body = IOUtils.toByteArray(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBodyAsString() throws IOException {
|
||||||
|
return new String(getBody(), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws Exception {
|
||||||
|
this.connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import com.songoda.core.SongodaCoreConstants;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class SimpleHttpClient implements HttpClient {
|
||||||
|
private static final String USER_AGENT = generateUserAgent();
|
||||||
|
|
||||||
|
public @NotNull HttpResponse get(String url) throws IOException {
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
|
connection.setInstanceFollowRedirects(true);
|
||||||
|
connection.setConnectTimeout(5000);
|
||||||
|
connection.setReadTimeout(5000);
|
||||||
|
|
||||||
|
connection.setRequestProperty("User-Agent", USER_AGENT);
|
||||||
|
|
||||||
|
return new HttpResponseImpl(connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String generateUserAgent() {
|
||||||
|
String projectName = SongodaCoreConstants.getProjectName();
|
||||||
|
String version = SongodaCoreConstants.getCoreVersion();
|
||||||
|
String projectUrl = SongodaCoreConstants.getGitHubProjectUrl();
|
||||||
|
|
||||||
|
return projectName + "/" + version + " (+" + projectUrl + ")";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class UnexpectedHttpStatusException extends IOException {
|
||||||
|
public final int responseCode;
|
||||||
|
public final String url;
|
||||||
|
|
||||||
|
public UnexpectedHttpStatusException(int responseCode, String url) {
|
||||||
|
super("Got HTTP Status Code " + responseCode + ": " + url);
|
||||||
|
|
||||||
|
this.responseCode = responseCode;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
@ -101,7 +101,10 @@ public class DropUtils {
|
|||||||
Bukkit.getScheduler().runTask(SongodaCore.getHijackedPlugin(), () -> {
|
Bukkit.getScheduler().runTask(SongodaCore.getHijackedPlugin(), () -> {
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
if (entity.getKiller() != null) {
|
if (entity.getKiller() != null) {
|
||||||
command = command.replace("%player%", entity.getKiller().getName().replace("%x%", String.valueOf((int)entity.getLocation().getX())).replace("%y%", String.valueOf((int)entity.getLocation().getY())).replace("%z%", String.valueOf((int)entity.getLocation().getZ())));
|
command = command.replace("%player%", entity.getKiller().getName()
|
||||||
|
.replace("%x%", String.valueOf((int) entity.getLocation().getX()))
|
||||||
|
.replace("%y%", String.valueOf((int) entity.getLocation().getY()))
|
||||||
|
.replace("%z%", String.valueOf((int) entity.getLocation().getZ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.contains("%player%")) {
|
if (!command.contains("%player%")) {
|
||||||
|
@ -12,10 +12,10 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -166,7 +166,7 @@ public class LootManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
JsonReader reader = new JsonReader(new FileReader(file.getPath()));
|
JsonReader reader = new JsonReader(Files.newBufferedReader(file.toPath()));
|
||||||
|
|
||||||
Lootable lootable = gson.fromJson(reader, Lootable.class);
|
Lootable lootable = gson.fromJson(reader, Lootable.class);
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ public class LootManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Writer writer = new FileWriter(file.getPath())) {
|
try (Writer writer = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) {
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
gson.toJson(lootable, writer);
|
gson.toJson(lootable, writer);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.songoda.core.math;
|
package com.songoda.core.math;
|
||||||
|
|
||||||
|
import com.songoda.core.SongodaCoreConstants;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -7,7 +9,7 @@ public class MathUtils {
|
|||||||
private static final Map<String, Double> cache = new HashMap<>();
|
private static final Map<String, Double> cache = new HashMap<>();
|
||||||
|
|
||||||
public static double eval(String toParse) {
|
public static double eval(String toParse) {
|
||||||
return eval(toParse, "SongodaCore Eval Engine");
|
return eval(toParse, SongodaCoreConstants.getProjectName() + " Eval Engine");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double eval(String toParse, String warningMessage) {
|
public static double eval(String toParse, String warningMessage) {
|
||||||
|
22
Core/src/main/java/com/songoda/core/nms/Nms.java
Normal file
22
Core/src/main/java/com/songoda/core/nms/Nms.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.songoda.core.nms;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
|
|
||||||
|
public class Nms {
|
||||||
|
protected static NmsImplementations impl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The implementations for the current server version
|
||||||
|
*/
|
||||||
|
public static NmsImplementations getImplementations() throws UnsupportedServerVersionException {
|
||||||
|
if (impl == null) {
|
||||||
|
try {
|
||||||
|
impl = (NmsImplementations) Class.forName("com.songoda.core.nms." + ServerVersion.getServerVersionString() + ".NmsImplementationsImpl").getConstructors()[0].newInstance();
|
||||||
|
} catch (ReflectiveOperationException ex) {
|
||||||
|
throw new UnsupportedServerVersionException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
}
|
@ -3,192 +3,51 @@ package com.songoda.core.nms;
|
|||||||
import com.songoda.core.nms.anvil.AnvilCore;
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
import com.songoda.core.nms.entity.NMSPlayer;
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
import com.songoda.core.nms.nbt.NBTCore;
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
import com.songoda.core.nms.world.WorldCore;
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link Nms} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public class NmsManager {
|
public class NmsManager {
|
||||||
private static final String serverPackagePath = Bukkit.getServer().getClass().getPackage().getName();
|
@Deprecated
|
||||||
private static final String serverPackageVersion = serverPackagePath.substring(serverPackagePath.lastIndexOf('.') + 1);
|
|
||||||
private static final String bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
|
||||||
private static final NMSPlayer player;
|
|
||||||
private static final AnvilCore anvil;
|
|
||||||
private static final NBTCore nbt;
|
|
||||||
private static final WorldCore world;
|
|
||||||
|
|
||||||
static {
|
|
||||||
switch (serverPackageVersion) {
|
|
||||||
case "v1_8_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_8_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_8_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_8_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_8_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_8_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_8_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_8_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_8_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_8_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_8_R3":
|
|
||||||
player = new com.songoda.core.nms.v1_8_R3.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_8_R3.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_8_R3.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_8_R3.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_9_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_9_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_9_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_9_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_9_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_9_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_9_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_9_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_9_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_9_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_10_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_10_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_10_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_10_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_10_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_11_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_11_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_11_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_11_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_11_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_12_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_12_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_12_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_12_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_12_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_13_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_13_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_13_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_13_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_13_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_13_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_13_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_13_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_13_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_13_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_14_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_14_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_14_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_14_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_14_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_15_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_15_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_15_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_15_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_15_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_16_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_16_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_16_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_16_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_16_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_16_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_16_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_16_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_16_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_16_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_16_R3":
|
|
||||||
player = new com.songoda.core.nms.v1_16_R3.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_16_R3.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_16_R3.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_16_R3.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_17_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_17_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_17_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_17_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_17_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_18_R1":
|
|
||||||
player = new com.songoda.core.nms.v1_18_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_18_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_18_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_18_R1.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_18_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_18_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_18_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_18_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_18_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_19_R1":
|
|
||||||
if (bukkitVersion.endsWith(".0") || bukkitVersion.equals("1.19")) {
|
|
||||||
player = new com.songoda.core.nms.v1_19_R1.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_19_R1.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_19_R1.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_19_R1.world.WorldCoreImpl();
|
|
||||||
} else {
|
|
||||||
player = new com.songoda.core.nms.v1_19_R1v2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_19_R1v2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_19_R1v2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_19_R1v2.world.WorldCoreImpl();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "v1_19_R2":
|
|
||||||
player = new com.songoda.core.nms.v1_19_R2.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_19_R2.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_19_R2.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_19_R2.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
case "v1_19_R3":
|
|
||||||
player = new com.songoda.core.nms.v1_19_R3.entity.NMSPlayerImpl();
|
|
||||||
anvil = new com.songoda.core.nms.v1_19_R3.anvil.AnvilCore();
|
|
||||||
nbt = new com.songoda.core.nms.v1_19_R3.nbt.NBTCoreImpl();
|
|
||||||
world = new com.songoda.core.nms.v1_19_R3.world.WorldCoreImpl();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Logger.getLogger(NmsManager.class.getName()).log(Level.SEVERE, "Failed to load NMS for this server version: version {0} not found", serverPackageVersion);
|
|
||||||
|
|
||||||
player = null;
|
|
||||||
anvil = null;
|
|
||||||
nbt = null;
|
|
||||||
world = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NMSPlayer getPlayer() {
|
public static NMSPlayer getPlayer() {
|
||||||
return player;
|
return Nms.getImplementations().getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static AnvilCore getAnvil() {
|
public static AnvilCore getAnvil() {
|
||||||
return anvil;
|
return Nms.getImplementations().getAnvil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean hasAnvil() {
|
public static boolean hasAnvil() {
|
||||||
return anvil != null;
|
return getAnvil() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static NBTCore getNbt() {
|
public static NBTCore getNbt() {
|
||||||
return nbt;
|
return Nms.getImplementations().getNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean hasNbt() {
|
public static boolean hasNbt() {
|
||||||
return nbt != null;
|
return getNbt() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static WorldCore getWorld() {
|
public static WorldCore getWorld() {
|
||||||
return world;
|
return Nms.getImplementations().getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean hasWorld() {
|
public static boolean hasWorld() {
|
||||||
return world != null;
|
return getWorld() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static NmsWorldBorder getWorldBorder() {
|
||||||
|
return Nms.getImplementations().getWorldBorder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.songoda.core.nms;
|
||||||
|
|
||||||
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
|
|
||||||
|
public class UnsupportedServerVersionException extends RuntimeException {
|
||||||
|
public UnsupportedServerVersionException() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsupportedServerVersionException(Throwable cause) {
|
||||||
|
this("Your sever version (" + ServerVersion.getServerVersionString() + "; " + ServerVersion.getServerVersion().name() + ") is not fully supported", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UnsupportedServerVersionException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import com.songoda.core.compatibility.ClassMapping;
|
|||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.core.compatibility.MethodMapping;
|
import com.songoda.core.compatibility.MethodMapping;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.nms.NmsManager;
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -343,7 +342,8 @@ public class BlockUtils {
|
|||||||
*
|
*
|
||||||
* @param loc The Location of the container
|
* @param loc The Location of the container
|
||||||
*
|
*
|
||||||
* @deprecated Broken in/since Spigot 1.19.4! Use {@link com.songoda.core.nms.world.WorldCore#updateAdjacentComparators(Block)} on {@link NmsManager#getWorld()} instead
|
* @deprecated Use {@link com.songoda.core.nms.world.WorldCore#updateAdjacentComparators(Block)}
|
||||||
|
* via {@link com.songoda.core.nms.Nms#getImplementations()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void updateAdjacentComparators(Location loc) {
|
public static void updateAdjacentComparators(Location loc) {
|
||||||
@ -406,7 +406,11 @@ public class BlockUtils {
|
|||||||
* <p>
|
* <p>
|
||||||
* The chunk must be loaded and players must relog if they have the
|
* The chunk must be loaded and players must relog if they have the
|
||||||
* chunk loaded in order to use this method.
|
* chunk loaded in order to use this method.
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link com.songoda.core.nms.world.SWorld#setBlockFast(int, int, int, Material)}
|
||||||
|
* via {@link com.songoda.core.nms.Nms#getImplementations()} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setBlockFast(World world, int x, int y, int z, Material material, byte data) {
|
public static void setBlockFast(World world, int x, int y, int z, Material material, byte data) {
|
||||||
try {
|
try {
|
||||||
// Cache reflection
|
// Cache reflection
|
||||||
@ -451,6 +455,11 @@ public class BlockUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link com.songoda.core.nms.world.SWorld#setBlockFast(int, int, int, Material)}
|
||||||
|
* via {@link com.songoda.core.nms.Nms#getImplementations()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void setBlockFast(World world, int x, int y, int z, CompatibleMaterial material, byte data) {
|
public static void setBlockFast(World world, int x, int y, int z, CompatibleMaterial material, byte data) {
|
||||||
setBlockFast(world, x, y, z, material.getBlockMaterial(), data);
|
setBlockFast(world, x, y, z, material.getBlockMaterial(), data);
|
||||||
}
|
}
|
||||||
@ -476,8 +485,7 @@ public class BlockUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return block.getData() >= (mat == CompatibleMaterial.BEETROOTS
|
return block.getData() >= (mat == CompatibleMaterial.BEETROOTS || mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
||||||
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -526,8 +534,7 @@ public class BlockUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (mat == CompatibleMaterial.BEETROOTS
|
return (mat == CompatibleMaterial.BEETROOTS || mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
||||||
|| mat == CompatibleMaterial.NETHER_WART ? 3 : 7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,7 @@ package com.songoda.core.world;
|
|||||||
import com.songoda.core.compatibility.CompatibleHand;
|
import com.songoda.core.compatibility.CompatibleHand;
|
||||||
import com.songoda.core.compatibility.CompatibleSound;
|
import com.songoda.core.compatibility.CompatibleSound;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,12 +18,12 @@ public class SItemStack {
|
|||||||
|
|
||||||
public SItemStack(ItemStack item) {
|
public SItemStack(ItemStack item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.sItem = NmsManager.getWorld().getItemStack(item);
|
this.sItem = Nms.getImplementations().getWorld().getItemStack(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SItemStack(CompatibleHand hand, Player player) {
|
public SItemStack(CompatibleHand hand, Player player) {
|
||||||
this.item = hand.getItem(player);
|
this.item = hand.getItem(player);
|
||||||
this.sItem = NmsManager.getWorld().getItemStack(item);
|
this.sItem = Nms.getImplementations().getWorld().getItemStack(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack addDamage(Player player, int damage) {
|
public ItemStack addDamage(Player player, int damage) {
|
||||||
@ -49,7 +49,7 @@ public class SItemStack {
|
|||||||
int durability;
|
int durability;
|
||||||
|
|
||||||
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11)
|
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_11)
|
||||||
? NmsManager.getNbt().of(item).has("Unbreakable")
|
? Nms.getImplementations().getNbt().of(item).has("Unbreakable")
|
||||||
: item.getItemMeta().isUnbreakable()) {
|
: item.getItemMeta().isUnbreakable()) {
|
||||||
return item;
|
return item;
|
||||||
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
} else if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
|
||||||
|
@ -2,7 +2,7 @@ package com.songoda.core.world;
|
|||||||
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.core.hooks.EntityStackerManager;
|
import com.songoda.core.hooks.EntityStackerManager;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import com.songoda.core.nms.world.SpawnedEntity;
|
import com.songoda.core.nms.world.SpawnedEntity;
|
||||||
import com.songoda.core.utils.EntityUtils;
|
import com.songoda.core.utils.EntityUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -20,7 +20,7 @@ public class SSpawner {
|
|||||||
|
|
||||||
public SSpawner(Location location) {
|
public SSpawner(Location location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.sSpawner = NmsManager.getWorld().getSpawner(location);
|
this.sSpawner = Nms.getImplementations().getWorld().getSpawner(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSpawner(CreatureSpawner spawner) {
|
public SSpawner(CreatureSpawner spawner) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.songoda.core.world;
|
package com.songoda.core.world;
|
||||||
|
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -15,7 +15,7 @@ public class SWorld {
|
|||||||
|
|
||||||
public SWorld(World world) {
|
public SWorld(World world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.sWorld = NmsManager.getWorld().getWorld(world);
|
this.sWorld = Nms.getImplementations().getWorld().getWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity[] getEntitiesFromChunk(int x, int z) {
|
public Entity[] getEntitiesFromChunk(int x, int z) {
|
||||||
|
@ -3,7 +3,7 @@ package com.songoda.core.world;
|
|||||||
import com.songoda.core.compatibility.ClassMapping;
|
import com.songoda.core.compatibility.ClassMapping;
|
||||||
import com.songoda.core.compatibility.MethodMapping;
|
import com.songoda.core.compatibility.MethodMapping;
|
||||||
import com.songoda.core.compatibility.ServerVersion;
|
import com.songoda.core.compatibility.ServerVersion;
|
||||||
import com.songoda.core.nms.NmsManager;
|
import com.songoda.core.nms.Nms;
|
||||||
import com.songoda.core.utils.NMSUtils;
|
import com.songoda.core.utils.NMSUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,6 +12,10 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link com.songoda.core.nms.world.NmsWorldBorder} via {@link Nms#getImplementations()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public class SWorldBorder {
|
public class SWorldBorder {
|
||||||
private static Class<?> packetPlayOutWorldBorderEnumClass;
|
private static Class<?> packetPlayOutWorldBorderEnumClass;
|
||||||
private static Class<?> worldBorderClass;
|
private static Class<?> worldBorderClass;
|
||||||
@ -81,18 +85,22 @@ public class SWorldBorder {
|
|||||||
|
|
||||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17)) {
|
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_17)) {
|
||||||
Object packet = clientboundInitializeBorderPacketConstructor.newInstance(worldBorder);
|
Object packet = clientboundInitializeBorderPacketConstructor.newInstance(worldBorder);
|
||||||
NmsManager.getPlayer().sendPacket(player, packet);
|
Nms.getImplementations().getPlayer().sendPacket(player, packet);
|
||||||
} else {
|
} else {
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
Object packet = packetPlayOutWorldBorderConstructor.newInstance(worldBorder,
|
Object packet = packetPlayOutWorldBorderConstructor.newInstance(worldBorder,
|
||||||
Enum.valueOf((Class<? extends Enum>) packetPlayOutWorldBorderEnumClass, "INITIALIZE"));
|
Enum.valueOf((Class<? extends Enum>) packetPlayOutWorldBorderEnumClass, "INITIALIZE"));
|
||||||
NmsManager.getPlayer().sendPacket(player, packet);
|
Nms.getImplementations().getPlayer().sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException ex) {
|
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link com.songoda.core.nms.world.NmsWorldBorder.BorderColor} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public enum Color {
|
public enum Color {
|
||||||
Blue, Green, Red
|
Blue, Green, Red
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.songoda.core;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.opentest4j.TestSkippedException;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
class SongodaCoreConstantsTest {
|
||||||
|
// Pattern is from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
||||||
|
private static final Pattern VERSION_PATTERN = Pattern.compile("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getCoreVersion() {
|
||||||
|
if (!Objects.equals(System.getenv("TESTS_RUN_WITH_MAVEN"), "true")) {
|
||||||
|
throw new TestSkippedException("Skipping test because it requires the TESTS_RUN_WITH_MAVEN environment variable to be set to true");
|
||||||
|
}
|
||||||
|
|
||||||
|
String coreVersion = SongodaCoreConstants.getCoreVersion();
|
||||||
|
|
||||||
|
assertTrue(VERSION_PATTERN.matcher(coreVersion).matches(), "Version string is not a valid semver string: " + coreVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getProjectName() {
|
||||||
|
assertFalse(SongodaCoreConstants.getProjectName().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getGitHubProjectUrl() {
|
||||||
|
assertFalse(SongodaCoreConstants.getGitHubProjectUrl().isEmpty());
|
||||||
|
}
|
||||||
|
}
|
@ -1,86 +0,0 @@
|
|||||||
package com.songoda.core.compatibility.material;
|
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
|
|
||||||
class CompatibleMaterialTest {
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
MockBukkit.mock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getMaterialForNull() {
|
|
||||||
assertNull(CompatibleMaterial.getMaterial((Material) null));
|
|
||||||
assertNull(CompatibleMaterial.getMaterial((ItemStack) null));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void getMaterialForAllBukkitMaterials() {
|
|
||||||
Map<CompatibleMaterial, Material> returnedMaterials = new HashMap<>(Material.values().length);
|
|
||||||
for (Material bukkitMaterial : Material.values()) {
|
|
||||||
CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(bukkitMaterial);
|
|
||||||
|
|
||||||
if (bukkitMaterial.name().startsWith("LEGACY_")) {
|
|
||||||
assertNull(compatibleMaterial);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
assertNotNull(compatibleMaterial, () -> "Could not get an CompatibleMaterial for Material." + bukkitMaterial.name());
|
|
||||||
assertEquals(bukkitMaterial, compatibleMaterial.getMaterial());
|
|
||||||
assertEquals(compatibleMaterial, CompatibleMaterial.getMaterial(bukkitMaterial.name()));
|
|
||||||
|
|
||||||
assertFalse(returnedMaterials.containsKey(compatibleMaterial),
|
|
||||||
() -> String.format("Assertion failed when converting Material.%s to CompatibleMaterial.%s: " +
|
|
||||||
"CompatibleMaterial.%1$s has already been returned for Material.%3$s previously",
|
|
||||||
bukkitMaterial.name(),
|
|
||||||
compatibleMaterial.name(),
|
|
||||||
returnedMaterials.get(compatibleMaterial).name()
|
|
||||||
));
|
|
||||||
|
|
||||||
assertEquals(bukkitMaterial.isAir(), compatibleMaterial.isAir(), getMaterialPropertyAssertionError(compatibleMaterial, "Air"));
|
|
||||||
assertEquals(bukkitMaterial.isBlock(), compatibleMaterial.isBlock(), getMaterialPropertyAssertionError(compatibleMaterial, "Block"));
|
|
||||||
assertEquals(bukkitMaterial.isBurnable(), compatibleMaterial.isBurnable(), getMaterialPropertyAssertionError(compatibleMaterial, "Burnable"));
|
|
||||||
assertEquals(bukkitMaterial.isEdible(), compatibleMaterial.isEdible(), getMaterialPropertyAssertionError(compatibleMaterial, "Edible"));
|
|
||||||
assertEquals(bukkitMaterial.isFlammable(), compatibleMaterial.isFlammable(), getMaterialPropertyAssertionError(compatibleMaterial, "Flammable"));
|
|
||||||
assertEquals(bukkitMaterial.isFuel(), compatibleMaterial.isFuel(), getMaterialPropertyAssertionError(compatibleMaterial, "Fuel"));
|
|
||||||
assertEquals(bukkitMaterial.isInteractable(), compatibleMaterial.isInteractable(), getMaterialPropertyAssertionError(compatibleMaterial, "Interactable"));
|
|
||||||
assertEquals(bukkitMaterial.isItem(), compatibleMaterial.isItem(), getMaterialPropertyAssertionError(compatibleMaterial, "Item"));
|
|
||||||
assertEquals(bukkitMaterial.isOccluding(), compatibleMaterial.isOccluding(), getMaterialPropertyAssertionError(compatibleMaterial, "Occluding"));
|
|
||||||
assertEquals(bukkitMaterial.isSolid(), compatibleMaterial.isSolid(), getMaterialPropertyAssertionError(compatibleMaterial, "Solid"));
|
|
||||||
assertEquals(bukkitMaterial.isTransparent(), compatibleMaterial.isTransparent(), getMaterialPropertyAssertionError(compatibleMaterial, "Transparent"));
|
|
||||||
|
|
||||||
assertFalse(compatibleMaterial.usesCompatibility());
|
|
||||||
assertFalse(compatibleMaterial.usesData());
|
|
||||||
assertEquals(-1, compatibleMaterial.getData());
|
|
||||||
|
|
||||||
ItemStack compatibleItem = compatibleMaterial.getItem();
|
|
||||||
assertEquals(bukkitMaterial, compatibleItem.getType());
|
|
||||||
assertEquals(compatibleMaterial, CompatibleMaterial.getMaterial(compatibleItem));
|
|
||||||
|
|
||||||
returnedMaterials.put(compatibleMaterial, bukkitMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Supplier<String> getMaterialPropertyAssertionError(CompatibleMaterial compatibleMaterial, String propertyName) {
|
|
||||||
return () -> String.format("Expected CompatibleMaterial.%s to be '%s'", compatibleMaterial.name(), propertyName);
|
|
||||||
}
|
|
||||||
}
|
|
22
Core/src/test/java/com/songoda/core/http/MockHttpClient.java
Normal file
22
Core/src/test/java/com/songoda/core/http/MockHttpClient.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MockHttpClient implements HttpClient {
|
||||||
|
public HttpResponse returnValue;
|
||||||
|
public List<String> callsOnGet = new LinkedList<>();
|
||||||
|
|
||||||
|
public MockHttpClient(HttpResponse returnValue) {
|
||||||
|
this.returnValue = returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HttpResponse get(String url) {
|
||||||
|
this.callsOnGet.add(url);
|
||||||
|
|
||||||
|
return this.returnValue;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.songoda.core.http;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class MockHttpResponse implements HttpResponse {
|
||||||
|
public int responseCode;
|
||||||
|
public byte[] body;
|
||||||
|
|
||||||
|
public MockHttpResponse(int responseCode, byte[] body) {
|
||||||
|
this.responseCode = responseCode;
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResponseCode() {
|
||||||
|
return this.responseCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getBody() {
|
||||||
|
return this.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBodyAsString() {
|
||||||
|
return new String(getBody(), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
@ -1,127 +0,0 @@
|
|||||||
package com.songoda.core.input;
|
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
|
||||||
import be.seeseemelk.mockbukkit.MockPlugin;
|
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
|
||||||
import be.seeseemelk.mockbukkit.entity.PlayerMock;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
@Disabled("BukkitMock seems to cause some troubles here, skipping for now")
|
|
||||||
class ChatPromptTest {
|
|
||||||
private final String inputMsg = "&eInput-Message";
|
|
||||||
|
|
||||||
private ServerMock server;
|
|
||||||
private MockPlugin plugin;
|
|
||||||
private PlayerMock player;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
this.server = MockBukkit.mock();
|
|
||||||
this.plugin = MockBukkit.createMockPlugin();
|
|
||||||
this.player = this.server.addPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void showPrompt() throws InterruptedException {
|
|
||||||
List<String> chatInputs = new ArrayList<>(1);
|
|
||||||
|
|
||||||
ChatPrompt.showPrompt(this.plugin, this.player, event -> {
|
|
||||||
assertEquals(this.player, event.getPlayer());
|
|
||||||
|
|
||||||
chatInputs.add(event.getMessage());
|
|
||||||
});
|
|
||||||
|
|
||||||
this.player.chat(this.inputMsg);
|
|
||||||
Thread.sleep(1000);
|
|
||||||
// this.server.getScheduler().waitAsyncTasksFinished() // does not wait for async events
|
|
||||||
|
|
||||||
String playerReceivedMsg = this.player.nextMessage();
|
|
||||||
|
|
||||||
assertNotNull(playerReceivedMsg);
|
|
||||||
assertTrue(playerReceivedMsg.endsWith(this.inputMsg));
|
|
||||||
|
|
||||||
assertEquals(1, chatInputs.size());
|
|
||||||
assertEquals(this.inputMsg, chatInputs.get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Something is still running in the background and prevents the test from finishing */
|
|
||||||
@Disabled("Scheduling mock seems bugged, skipping for now")
|
|
||||||
@Test
|
|
||||||
void showPromptWithTimeout() {
|
|
||||||
AtomicBoolean calledOnClose = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
ChatPrompt.showPrompt(this.plugin, this.player, event -> {
|
|
||||||
})
|
|
||||||
.setOnClose(() -> calledOnClose.set(true))
|
|
||||||
.setTimeOut(this.player, 40);
|
|
||||||
|
|
||||||
this.server.getScheduler().performTicks(40);
|
|
||||||
|
|
||||||
String playerReceivedMsg = this.player.nextMessage();
|
|
||||||
|
|
||||||
assertNotNull(playerReceivedMsg);
|
|
||||||
assertTrue(playerReceivedMsg.contains("timed out"));
|
|
||||||
|
|
||||||
this.server.getScheduler().performOneTick();
|
|
||||||
assertTrue(calledOnClose.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void cancelPrompt() {
|
|
||||||
AtomicBoolean calledOnCancel = new AtomicBoolean(false);
|
|
||||||
AtomicBoolean calledHandler = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
ChatPrompt prompt = ChatPrompt.showPrompt(plugin, player, (event) -> calledHandler.set(true));
|
|
||||||
prompt.setOnCancel(() -> calledOnCancel.set(true));
|
|
||||||
|
|
||||||
this.server.dispatchCommand(player, "cancel");
|
|
||||||
// this.player.chat("/cancel");
|
|
||||||
// Thread.sleep(1000);
|
|
||||||
// this.server.getScheduler().waitAsyncTasksFinished() // does not wait for async events
|
|
||||||
|
|
||||||
System.out.println(this.player.nextMessage());
|
|
||||||
|
|
||||||
// assertTrue(player.nextMessage().endsWith("/cancel"));
|
|
||||||
|
|
||||||
assertTrue(calledOnCancel.get());
|
|
||||||
assertFalse(calledHandler.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void isRegistered() {
|
|
||||||
assertFalse(ChatPrompt.isRegistered(this.player));
|
|
||||||
|
|
||||||
ChatPrompt.showPrompt(this.plugin, this.player, (event) -> {
|
|
||||||
});
|
|
||||||
|
|
||||||
assertTrue(ChatPrompt.isRegistered(this.player));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void unregister() {
|
|
||||||
assertFalse(ChatPrompt.unregister(this.player));
|
|
||||||
|
|
||||||
ChatPrompt.showPrompt(this.plugin, this.player, (event) -> {
|
|
||||||
});
|
|
||||||
|
|
||||||
assertTrue(ChatPrompt.unregister(this.player));
|
|
||||||
assertFalse(ChatPrompt.unregister(this.player));
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,16 +2,19 @@ package com.songoda.core.math;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
class MathUtilsTest {
|
class MathUtilsTest {
|
||||||
private final String warningMessage = "MathTest";
|
private final String warningMessage = "MathTest";
|
||||||
private final String warningMessageExpectedStart = warningMessage + " ";
|
private final String warningMessageExpectedStart = this.warningMessage + " ";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void eval() {
|
void eval() {
|
||||||
|
assertEquals(0, MathUtils.eval("0"));
|
||||||
|
assertEquals(10, MathUtils.eval("10"));
|
||||||
|
assertEquals(0.0, MathUtils.eval("0.0"));
|
||||||
|
assertEquals(10.5, MathUtils.eval("10.5"));
|
||||||
|
|
||||||
assertEquals(10.5 + 4, MathUtils.eval("10.5 + 4"));
|
assertEquals(10.5 + 4, MathUtils.eval("10.5 + 4"));
|
||||||
assertEquals(10.5 - 5, MathUtils.eval("10.5 - 5"));
|
assertEquals(10.5 - 5, MathUtils.eval("10.5 - 5"));
|
||||||
assertEquals(10 * 4, MathUtils.eval("10 * 4"));
|
assertEquals(10 * 4, MathUtils.eval("10 * 4"));
|
||||||
@ -33,28 +36,28 @@ class MathUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void evalWithCommaAsDecimalSeparator() {
|
void evalWithCommaAsDecimalSeparator() {
|
||||||
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("1,0", warningMessage));
|
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("1,0", this.warningMessage));
|
||||||
|
|
||||||
assertTrue(ex.getMessage().startsWith(warningMessageExpectedStart),
|
assertTrue(ex.getMessage().startsWith(this.warningMessageExpectedStart),
|
||||||
() -> "'" + ex.getMessage() + "' does not start with '" + warningMessageExpectedStart + "'");
|
() -> "'" + ex.getMessage() + "' does not start with '" + this.warningMessageExpectedStart + "'");
|
||||||
assertTrue(ex.getMessage().contains("Unexpected: "));
|
assertTrue(ex.getMessage().contains("Unexpected: "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void evalWithUnsupportedSyntax() {
|
void evalWithUnsupportedSyntax() {
|
||||||
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("!2", warningMessage));
|
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("!2", this.warningMessage));
|
||||||
|
|
||||||
assertTrue(ex.getMessage().startsWith(warningMessageExpectedStart),
|
assertTrue(ex.getMessage().startsWith(this.warningMessageExpectedStart),
|
||||||
() -> "'" + ex.getMessage() + "' does not start with '" + warningMessageExpectedStart + "'");
|
() -> "'" + ex.getMessage() + "' does not start with '" + this.warningMessageExpectedStart + "'");
|
||||||
assertTrue(ex.getMessage().contains("Unexpected: "));
|
assertTrue(ex.getMessage().contains("Unexpected: "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void evalWithUnsupportedFunction() {
|
void evalWithUnsupportedFunction() {
|
||||||
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("acos(90)", warningMessage));
|
Exception ex = assertThrowsExactly(RuntimeException.class, () -> MathUtils.eval("acos(90)", this.warningMessage));
|
||||||
|
|
||||||
assertTrue(ex.getMessage().startsWith(warningMessageExpectedStart),
|
assertTrue(ex.getMessage().startsWith(this.warningMessageExpectedStart),
|
||||||
() -> "'" + ex.getMessage() + "' does not start with '" + warningMessageExpectedStart + "'");
|
() -> "'" + ex.getMessage() + "' does not start with '" + this.warningMessageExpectedStart + "'");
|
||||||
assertTrue(ex.getMessage().contains("Unknown function: "));
|
assertTrue(ex.getMessage().contains("Unknown function: "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.songoda.core.utils;
|
package com.songoda.core.utils;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.WorldMock;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@ -13,12 +14,20 @@ class LocationUtilsTest {
|
|||||||
void isLocationMatching() {
|
void isLocationMatching() {
|
||||||
assertTrue(LocationUtils.isLocationMatching(
|
assertTrue(LocationUtils.isLocationMatching(
|
||||||
new Location(null, 10, 20, 30),
|
new Location(null, 10, 20, 30),
|
||||||
new Location(new WorldMock(), 10.25, 20.5, 30.75)
|
new Location(Mockito.mock(World.class), 10.25, 20.5, 30.75)
|
||||||
|
));
|
||||||
|
assertTrue(LocationUtils.isLocationMatching(
|
||||||
|
new Location(null, 10, 20, 30),
|
||||||
|
new Location(null, 10.25, 20.5, 30.75)
|
||||||
));
|
));
|
||||||
|
|
||||||
assertFalse(LocationUtils.isLocationMatching(
|
assertFalse(LocationUtils.isLocationMatching(
|
||||||
new Location(null, 10, 20, 30),
|
new Location(null, 10, 20, 30),
|
||||||
new Location(new WorldMock(), -10.25, 20.5, 30.75)
|
new Location(Mockito.mock(World.class), -10.25, 20.5, 30.75)
|
||||||
|
));
|
||||||
|
assertFalse(LocationUtils.isLocationMatching(
|
||||||
|
new Location(Mockito.mock(World.class), 10, 20, 30),
|
||||||
|
new Location(null, -10.25, 20.5, 30.75)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,134 +1,143 @@
|
|||||||
package com.songoda.core.utils;
|
package com.songoda.core.utils;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import org.bukkit.Bukkit;
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
import org.bukkit.World;
|
||||||
import be.seeseemelk.mockbukkit.entity.PlayerMock;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.InOrder;
|
||||||
|
import org.mockito.MockedStatic;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
class PlayerUtilsTest {
|
class PlayerUtilsTest {
|
||||||
private ServerMock server;
|
@Test
|
||||||
|
void sendMessages_Array() {
|
||||||
|
Player player = Mockito.mock(Player.class);
|
||||||
|
PlayerUtils.sendMessages(player, "First message", "Second message");
|
||||||
|
|
||||||
@BeforeEach
|
InOrder playerInOrder = Mockito.inOrder(player);
|
||||||
void setUp() {
|
playerInOrder.verify(player).sendMessage("First message");
|
||||||
this.server = MockBukkit.mock();
|
playerInOrder.verify(player).sendMessage("Second message");
|
||||||
}
|
playerInOrder.verify(player, Mockito.never()).sendMessage(Mockito.anyString());
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
this.server = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sendMessages() {
|
void sendMessages_List() {
|
||||||
String[] messages = new String[] {"First message", "Second message"};
|
Player player = Mockito.mock(Player.class);
|
||||||
|
PlayerUtils.sendMessages(player, Arrays.asList("First message", "Second message"));
|
||||||
|
|
||||||
PlayerMock player = this.server.addPlayer();
|
InOrder playerInOrder = Mockito.inOrder(player);
|
||||||
|
playerInOrder.verify(player).sendMessage("First message");
|
||||||
PlayerUtils.sendMessages(player, messages);
|
playerInOrder.verify(player).sendMessage("Second message");
|
||||||
PlayerUtils.sendMessages(player, Arrays.asList(messages));
|
playerInOrder.verify(player, Mockito.never()).sendMessage(Mockito.anyString());
|
||||||
|
|
||||||
for (int i = 0; i < 2; ++i) {
|
|
||||||
assertEquals(messages[0], player.nextMessage());
|
|
||||||
assertEquals(messages[1], player.nextMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNull(player.nextMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Player#hidePlayer can currently not be mocked")
|
|
||||||
@Test
|
@Test
|
||||||
void getVisiblePlayerNames() {
|
void getVisiblePlayerNames() {
|
||||||
PlayerMock player = this.server.addPlayer("BasePlayer");
|
Player player = createMockPlayer("BasePlayer");
|
||||||
PlayerMock visiblePlayer = this.server.addPlayer("VisiblePlayer");
|
Player visiblePlayer = createMockPlayer("VisiblePlayer");
|
||||||
PlayerMock hiddenPlayer = this.server.addPlayer("HiddenPlayer");
|
Player hiddenPlayer = createMockPlayer("HiddenPlayer");
|
||||||
|
|
||||||
player.hidePlayer(MockBukkit.createMockPlugin(), hiddenPlayer);
|
List<String> result;
|
||||||
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
|
server.when(Bukkit::getOnlinePlayers).thenReturn(Arrays.asList(player, visiblePlayer, hiddenPlayer));
|
||||||
|
|
||||||
List<String> result = PlayerUtils.getVisiblePlayerNames(player, null);
|
Mockito.when(player.canSee(hiddenPlayer)).thenReturn(false);
|
||||||
assertTrue(result.contains(visiblePlayer.getName()));
|
Mockito.when(player.canSee(visiblePlayer)).thenReturn(true);
|
||||||
assertFalse(result.contains(hiddenPlayer.getName()));
|
|
||||||
assertFalse(result.contains(player.getName()));
|
|
||||||
|
|
||||||
assertEquals(0, PlayerUtils.getVisiblePlayerNames(player, "_").size());
|
assertEquals(0, PlayerUtils.getVisiblePlayerNames(player, "_").size());
|
||||||
|
|
||||||
|
result = PlayerUtils.getVisiblePlayerNames(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(result.contains("VisiblePlayer"));
|
||||||
|
assertEquals(1, result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Player#hidePlayer can currently not be mocked")
|
|
||||||
@Test
|
@Test
|
||||||
void getVisiblePlayerDisplayNames() {
|
void getVisiblePlayerDisplayNames() {
|
||||||
PlayerMock player = this.server.addPlayer("BasePlayer");
|
Player player = createMockPlayer("BasePlayer");
|
||||||
PlayerMock visiblePlayer = this.server.addPlayer("VisiblePlayer");
|
Player visiblePlayer = createMockPlayer("VisiblePlayer", "VisibleDisplayName");
|
||||||
PlayerMock hiddenPlayer = this.server.addPlayer("HiddenPlayer");
|
Player hiddenPlayer = createMockPlayer("HiddenPlayer");
|
||||||
|
|
||||||
player.setDisplayName("Base");
|
List<String> result;
|
||||||
visiblePlayer.setDisplayName("Visible");
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
hiddenPlayer.setDisplayName("Hidden");
|
server.when(Bukkit::getOnlinePlayers).thenReturn(Arrays.asList(player, visiblePlayer, hiddenPlayer));
|
||||||
|
|
||||||
player.hidePlayer(MockBukkit.createMockPlugin(), hiddenPlayer);
|
Mockito.when(player.canSee(hiddenPlayer)).thenReturn(false);
|
||||||
|
Mockito.when(player.canSee(visiblePlayer)).thenReturn(true);
|
||||||
|
|
||||||
List<String> result = PlayerUtils.getVisiblePlayerDisplayNames(player, null);
|
assertEquals(0, PlayerUtils.getVisiblePlayerDisplayNames(player, "A").size());
|
||||||
assertTrue(result.contains(visiblePlayer.getDisplayName()));
|
|
||||||
assertFalse(result.contains(hiddenPlayer.getDisplayName()));
|
|
||||||
assertFalse(result.contains(player.getDisplayName()));
|
|
||||||
|
|
||||||
assertEquals(0, PlayerUtils.getVisiblePlayerDisplayNames(player, "_").size());
|
result = PlayerUtils.getVisiblePlayerDisplayNames(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(result.contains("VisibleDisplayName"));
|
||||||
|
assertEquals(1, result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Player#hidePlayer can currently not be mocked")
|
|
||||||
@Test
|
@Test
|
||||||
void getVisiblePlayers() {
|
void getVisiblePlayers() {
|
||||||
PlayerMock player = this.server.addPlayer("BasePlayer");
|
Player player = createMockPlayer("BasePlayer");
|
||||||
PlayerMock visiblePlayer = this.server.addPlayer("VisiblePlayer");
|
Player visiblePlayer = createMockPlayer("VisiblePlayer");
|
||||||
PlayerMock hiddenPlayer = this.server.addPlayer("HiddenPlayer");
|
Player hiddenPlayer = createMockPlayer("HiddenPlayer");
|
||||||
|
|
||||||
player.hidePlayer(MockBukkit.createMockPlugin(), hiddenPlayer);
|
Mockito.when(player.canSee(hiddenPlayer)).thenReturn(false);
|
||||||
|
Mockito.when(player.canSee(visiblePlayer)).thenReturn(true);
|
||||||
|
|
||||||
|
List<Player> result;
|
||||||
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
|
server.when(Bukkit::getOnlinePlayers).thenReturn(Arrays.asList(player, visiblePlayer, hiddenPlayer));
|
||||||
|
|
||||||
|
assertEquals(0, PlayerUtils.getVisiblePlayers(player, "_").size());
|
||||||
|
|
||||||
|
result = PlayerUtils.getVisiblePlayers(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
List<Player> result = PlayerUtils.getVisiblePlayers(player, null);
|
|
||||||
assertTrue(result.contains(visiblePlayer));
|
assertTrue(result.contains(visiblePlayer));
|
||||||
assertFalse(result.contains(hiddenPlayer));
|
assertEquals(1, result.size());
|
||||||
assertFalse(result.contains(player));
|
|
||||||
|
|
||||||
assertEquals(0, PlayerUtils.getVisiblePlayers(player, "_").size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAllPlayers() {
|
void getAllPlayers() {
|
||||||
PlayerMock basePlayer = this.server.addPlayer("BasePlayer");
|
Player basePlayer = createMockPlayer("BasePlayer");
|
||||||
this.server.addPlayer("Player_1");
|
Player player1 = createMockPlayer("Player_1");
|
||||||
this.server.addPlayer("Player_2");
|
Player player2 = createMockPlayer("Player_2");
|
||||||
this.server.addPlayer("Player3");
|
Player player3 = createMockPlayer("Player3");
|
||||||
|
|
||||||
List<String> result = PlayerUtils.getAllPlayers(basePlayer, "");
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
assertEquals(3, result.size());
|
server.when(Bukkit::getOnlinePlayers).thenReturn(Arrays.asList(basePlayer, player1, player2, player3));
|
||||||
assertFalse(result.contains(basePlayer.getName()));
|
|
||||||
|
|
||||||
assertTrue(PlayerUtils.getAllPlayers(basePlayer, "_").isEmpty());
|
assertEquals(0, PlayerUtils.getVisiblePlayers(basePlayer, "_").size());
|
||||||
assertEquals(0, PlayerUtils.getAllPlayers(basePlayer, "Player_").size());
|
|
||||||
|
List<String> result = PlayerUtils.getAllPlayers(basePlayer, "");
|
||||||
|
assertFalse(result.contains(basePlayer.getName()));
|
||||||
|
assertEquals(3, result.size());
|
||||||
|
|
||||||
|
assertEquals(0, PlayerUtils.getAllPlayers(basePlayer, "_").size());
|
||||||
|
assertEquals(0, PlayerUtils.getAllPlayers(basePlayer, "Player_").size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Disabled for now as the implementations seems to be faulty")
|
@Disabled("Disabled for now as the implementations seems to be faulty")
|
||||||
@Test
|
@Test
|
||||||
void getAllPlayersDisplay() {
|
void getAllPlayersDisplay() {
|
||||||
PlayerMock basePlayer = this.server.addPlayer("BasePlayer");
|
Player basePlayer = createMockPlayer("BasePlayer");
|
||||||
this.server.addPlayer("Player_1");
|
createMockPlayer("Player_1");
|
||||||
this.server.addPlayer("Player_2");
|
createMockPlayer("Player_2");
|
||||||
this.server.addPlayer("Player3");
|
createMockPlayer("Player3");
|
||||||
|
|
||||||
List<String> result = PlayerUtils.getAllPlayersDisplay(basePlayer, "");
|
List<String> result = PlayerUtils.getAllPlayersDisplay(basePlayer, "");
|
||||||
assertEquals(3, result.size());
|
assertEquals(3, result.size());
|
||||||
@ -141,13 +150,9 @@ class PlayerUtilsTest {
|
|||||||
@Disabled("Disabled for now as the implementations seems to be faulty")
|
@Disabled("Disabled for now as the implementations seems to be faulty")
|
||||||
@Test
|
@Test
|
||||||
void findPlayer() {
|
void findPlayer() {
|
||||||
Player p3 = this.server.addPlayer("Player");
|
Player p3 = createMockPlayer("Player", "p3");
|
||||||
Player p1 = this.server.addPlayer("Player_1");
|
Player p1 = createMockPlayer("Player_1", "p1");
|
||||||
Player p2 = this.server.addPlayer("_Player_2");
|
Player p2 = createMockPlayer("_Player_2", "p2");
|
||||||
|
|
||||||
p1.setDisplayName("p1");
|
|
||||||
p2.setDisplayName("p2");
|
|
||||||
p3.setDisplayName("p3");
|
|
||||||
|
|
||||||
assertEquals(p1, PlayerUtils.findPlayer("Player_"));
|
assertEquals(p1, PlayerUtils.findPlayer("Player_"));
|
||||||
assertEquals(p2, PlayerUtils.findPlayer("_Play"));
|
assertEquals(p2, PlayerUtils.findPlayer("_Play"));
|
||||||
@ -160,73 +165,185 @@ class PlayerUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getRandomPlayer() {
|
void getRandomPlayer_NoneOnline() {
|
||||||
assertNull(PlayerUtils.getRandomPlayer());
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
|
server.when(Bukkit::getOnlinePlayers).thenReturn(Collections.emptyList());
|
||||||
for (int i = 0; i < 10; ++i) {
|
assertNull(PlayerUtils.getRandomPlayer());
|
||||||
this.server.addPlayer(String.valueOf(i));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<Player> returnedPlayers = new HashSet<>();
|
@Test
|
||||||
for (int i = 0; i < 50; ++i) {
|
void getRandomPlayer() {
|
||||||
if (returnedPlayers.size() >= 5) {
|
try (MockedStatic<Bukkit> server = Mockito.mockStatic(Bukkit.class)) {
|
||||||
break;
|
List<Player> players = new ArrayList<>(10);
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
Player player = createMockPlayer("Player_" + i);
|
||||||
|
players.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnedPlayers.add(PlayerUtils.getRandomPlayer());
|
server.when(Bukkit::getOnlinePlayers).thenReturn(players);
|
||||||
}
|
|
||||||
|
|
||||||
assertTrue(returnedPlayers.size() >= 5);
|
Set<Player> returnedPlayers = new HashSet<>();
|
||||||
|
for (int i = 0; i < 50; ++i) {
|
||||||
|
if (returnedPlayers.size() >= 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
returnedPlayers.add(PlayerUtils.getRandomPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(returnedPlayers.size() >= 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void giveItem() {
|
void giveItem() {
|
||||||
Player player = this.server.addPlayer();
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
PlayerUtils.giveItem(player, new ItemStack(Material.STONE));
|
Player player = createMockPlayer("Player");
|
||||||
assertTrue(player.getInventory().contains(Material.STONE, 1));
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
PlayerUtils.giveItem(player, new ItemStack(Material.GRASS_BLOCK), new ItemStack(Material.GRASS_BLOCK));
|
ItemStack itemToAdd = Mockito.mock(ItemStack.class);
|
||||||
assertTrue(player.getInventory().contains(Material.GRASS_BLOCK, 2));
|
|
||||||
|
|
||||||
PlayerUtils.giveItem(player, Arrays.asList(new ItemStack(Material.WHEAT_SEEDS), new ItemStack(Material.WHEAT_SEEDS)));
|
PlayerUtils.giveItem(player, itemToAdd);
|
||||||
assertTrue(player.getInventory().contains(Material.WHEAT_SEEDS, 2));
|
inventoryInOrder.verify(inventory).addItem(itemToAdd);
|
||||||
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void giveItemOnFullInventory() {
|
void giveItem_Array() {
|
||||||
PlayerMock player = this.server.addPlayer();
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
fillInventory(player);
|
Player player = createMockPlayer("Player");
|
||||||
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
int entityCount = this.server.getEntities().size();
|
ItemStack[] itemsToAdd = new ItemStack[] {Mockito.mock(ItemStack.class), Mockito.mock(ItemStack.class)};
|
||||||
PlayerUtils.giveItem(player, new ItemStack(Material.STONE));
|
|
||||||
assertEquals(entityCount + 1, this.server.getEntities().size());
|
|
||||||
|
|
||||||
entityCount = this.server.getEntities().size();
|
PlayerUtils.giveItem(player, itemsToAdd);
|
||||||
PlayerUtils.giveItem(player, new ItemStack(Material.GRASS_BLOCK), new ItemStack(Material.GRASS_BLOCK));
|
inventoryInOrder.verify(inventory).addItem(itemsToAdd);
|
||||||
assertEquals(entityCount + 2, this.server.getEntities().size());
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
|
}
|
||||||
|
|
||||||
entityCount = this.server.getEntities().size();
|
@Test
|
||||||
PlayerUtils.giveItem(player, Arrays.asList(new ItemStack(Material.WHEAT_SEEDS), new ItemStack(Material.WHEAT_SEEDS), new ItemStack(Material.WHEAT_SEEDS)));
|
void giveItem_List() {
|
||||||
assertEquals(entityCount + 3, this.server.getEntities().size());
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
|
Player player = createMockPlayer("Player");
|
||||||
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
|
ItemStack[] itemsToAdd = new ItemStack[] {Mockito.mock(ItemStack.class), Mockito.mock(ItemStack.class)};
|
||||||
|
|
||||||
|
PlayerUtils.giveItem(player, Arrays.asList(itemsToAdd));
|
||||||
|
inventoryInOrder.verify(inventory).addItem(itemsToAdd);
|
||||||
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void giveItem_FullInventory() {
|
||||||
|
ItemStack itemToAdd = Mockito.mock(ItemStack.class);
|
||||||
|
|
||||||
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
Mockito.when(inventory.addItem(itemToAdd)).thenReturn(new HashMap<Integer, ItemStack>() {{
|
||||||
|
put(0, itemToAdd);
|
||||||
|
}});
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
|
Player player = createMockPlayer("Player");
|
||||||
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
|
World world = Mockito.mock(World.class);
|
||||||
|
InOrder worldInOrder = Mockito.inOrder(world);
|
||||||
|
Mockito.when(player.getWorld()).thenReturn(world);
|
||||||
|
|
||||||
|
PlayerUtils.giveItem(player, itemToAdd);
|
||||||
|
|
||||||
|
inventoryInOrder.verify(inventory).addItem(itemToAdd);
|
||||||
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
|
|
||||||
|
worldInOrder.verify(world).dropItemNaturally(Mockito.any(), Mockito.eq(itemToAdd));
|
||||||
|
worldInOrder.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void giveItem_FullInventory_Array() {
|
||||||
|
ItemStack[] itemsToAdd = new ItemStack[] {Mockito.mock(ItemStack.class), Mockito.mock(ItemStack.class)};
|
||||||
|
|
||||||
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
Mockito.when(inventory.addItem(Mockito.any())).thenReturn(new HashMap<Integer, ItemStack>() {{
|
||||||
|
put(0, itemsToAdd[0]);
|
||||||
|
put(1, itemsToAdd[1]);
|
||||||
|
}});
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
|
Player player = createMockPlayer("Player");
|
||||||
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
|
World world = Mockito.mock(World.class);
|
||||||
|
InOrder worldInOrder = Mockito.inOrder(world);
|
||||||
|
Mockito.when(player.getWorld()).thenReturn(world);
|
||||||
|
|
||||||
|
PlayerUtils.giveItem(player, itemsToAdd);
|
||||||
|
inventoryInOrder.verify(inventory).addItem(itemsToAdd);
|
||||||
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
|
|
||||||
|
worldInOrder.verify(world).dropItemNaturally(Mockito.any(), Mockito.eq(itemsToAdd[0]));
|
||||||
|
worldInOrder.verify(world).dropItemNaturally(Mockito.any(), Mockito.eq(itemsToAdd[1]));
|
||||||
|
worldInOrder.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void giveItem_FullInventory_List() {
|
||||||
|
ItemStack[] itemsToAdd = new ItemStack[] {Mockito.mock(ItemStack.class), Mockito.mock(ItemStack.class)};
|
||||||
|
|
||||||
|
PlayerInventory inventory = Mockito.mock(PlayerInventory.class);
|
||||||
|
Mockito.when(inventory.addItem(Mockito.any())).thenReturn(new HashMap<Integer, ItemStack>() {{
|
||||||
|
put(0, itemsToAdd[0]);
|
||||||
|
put(1, itemsToAdd[1]);
|
||||||
|
}});
|
||||||
|
InOrder inventoryInOrder = Mockito.inOrder(inventory);
|
||||||
|
|
||||||
|
Player player = createMockPlayer("Player");
|
||||||
|
Mockito.when(player.getInventory()).thenReturn(inventory);
|
||||||
|
Mockito.when(player.isOnline()).thenReturn(true);
|
||||||
|
|
||||||
|
World world = Mockito.mock(World.class);
|
||||||
|
InOrder worldInOrder = Mockito.inOrder(world);
|
||||||
|
Mockito.when(player.getWorld()).thenReturn(world);
|
||||||
|
|
||||||
|
PlayerUtils.giveItem(player, Arrays.asList(itemsToAdd));
|
||||||
|
inventoryInOrder.verify(inventory).addItem(itemsToAdd);
|
||||||
|
inventoryInOrder.verify(inventory, Mockito.never()).addItem(Mockito.any());
|
||||||
|
|
||||||
|
worldInOrder.verify(world).dropItemNaturally(Mockito.any(), Mockito.eq(itemsToAdd[0]));
|
||||||
|
worldInOrder.verify(world).dropItemNaturally(Mockito.any(), Mockito.eq(itemsToAdd[1]));
|
||||||
|
worldInOrder.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Test is incomplete")
|
@Disabled("Test is incomplete")
|
||||||
@Test
|
@Test
|
||||||
void getNumberFromPermission() {
|
void getNumberFromPermission() {
|
||||||
Player player = this.server.addPlayer();
|
Player player = createMockPlayer("Player");
|
||||||
|
|
||||||
assertEquals(-1, PlayerUtils.getNumberFromPermission(player, "example.plugin.feature", -1));
|
assertEquals(-1, PlayerUtils.getNumberFromPermission(player, "example.plugin.feature", -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillInventory(Player player) {
|
private Player createMockPlayer(String name) {
|
||||||
ItemStack[] contents = new ItemStack[player.getInventory().getContents().length];
|
return createMockPlayer(name, name);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < contents.length; ++i) {
|
private Player createMockPlayer(String name, String displayName) {
|
||||||
contents[i] = new ItemStack(Material.BARRIER);
|
Player player = Mockito.mock(Player.class);
|
||||||
}
|
Mockito.when(player.getName()).thenReturn(name);
|
||||||
|
Mockito.when(player.getDisplayName()).thenReturn(displayName);
|
||||||
|
|
||||||
player.getInventory().setContents(contents);
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,14 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!--suppress VulnerableLibrariesLocal -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.17</version>
|
<version>1.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -26,6 +25,7 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.songoda.core.nms;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface NmsImplementations {
|
||||||
|
@NotNull NMSPlayer getPlayer();
|
||||||
|
|
||||||
|
@NotNull WorldCore getWorld();
|
||||||
|
|
||||||
|
@NotNull NmsWorldBorder getWorldBorder();
|
||||||
|
|
||||||
|
@NotNull AnvilCore getAnvil();
|
||||||
|
|
||||||
|
@NotNull NBTCore getNbt();
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.songoda.core.nms.world;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface NmsWorldBorder {
|
||||||
|
void send(Player player, BorderColor color, double size, Location center);
|
||||||
|
|
||||||
|
enum BorderColor {
|
||||||
|
BLUE, GREEN, RED
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,20 @@
|
|||||||
package com.songoda.core.nms.world;
|
package com.songoda.core.nms.world;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SWorld {
|
public interface SWorld {
|
||||||
List<LivingEntity> getLivingEntities();
|
List<LivingEntity> getLivingEntities();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a block to a certain type by updating the block directly in the NMS chunk.
|
||||||
|
* <br>
|
||||||
|
* The chunk must be loaded and players must relog if they have the chunk loaded in order to use this method.
|
||||||
|
* (F3+A is not enough)
|
||||||
|
*/
|
||||||
|
// TODO: Check if FabledSkyBlock *really* needs this method and if it can be removed.
|
||||||
|
// Would make thinks less complicated and I kinda cannot imagine it being *that* much faster to be worth it?
|
||||||
|
void setBlockFast(int x, int y, int z, Material material);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,13 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public interface WorldCore {
|
public interface WorldCore {
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #getSpawner(Location)} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
SSpawner getSpawner(CreatureSpawner spawner);
|
SSpawner getSpawner(CreatureSpawner spawner);
|
||||||
|
|
||||||
SSpawner getSpawner(Location location);
|
SSpawner getSpawner(Location location);
|
||||||
@ -29,7 +34,7 @@ public interface WorldCore {
|
|||||||
*/
|
*/
|
||||||
void randomTickChunk(Chunk bukkitChunk, int tickAmount) throws ReflectiveOperationException;
|
void randomTickChunk(Chunk bukkitChunk, int tickAmount) throws ReflectiveOperationException;
|
||||||
|
|
||||||
void updateAdjacentComparators(Block bukkitBlock);
|
void updateAdjacentComparators(@NotNull Block bukkitBlock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ticks all inactive spawners in a specific chunk ignoring the minimum required players within a specific range.<br>
|
* Ticks all inactive spawners in a specific chunk ignoring the minimum required players within a specific range.<br>
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_10_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_10_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_10_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_10_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_10_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_10_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_10_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_10_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_10_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_10_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_10_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,35 @@
|
|||||||
package com.songoda.core.nms.v1_10_R1.world;
|
package com.songoda.core.nms.v1_10_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_10_R1.Block;
|
||||||
|
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_10_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
|
||||||
|
levelChunk.a(new BlockPosition(x & 0xF, y, z & 0xF), Block.getByCombinedId(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,11 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
|
||||||
|
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_10_R1.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_10_R1.util.CraftMagicNumbers;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +42,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,12 +91,12 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(org.bukkit.block.Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull org.bukkit.block.Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = ((CraftWorld) craftBlock.getWorld()).getHandle();
|
||||||
net.minecraft.server.v1_10_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
|
||||||
|
|
||||||
BlockPosition blockPosition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
BlockPosition blockPos = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
||||||
nmsWorld.updateAdjacentComparators(blockPosition, CraftMagicNumbers.getBlock(craftBlock));
|
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
|
||||||
|
serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_11_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_11_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_11_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_11_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_11_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_11_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_11_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_11_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_11_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_11_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_11_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,35 @@
|
|||||||
package com.songoda.core.nms.v1_11_R1.world;
|
package com.songoda.core.nms.v1_11_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_11_R1.Block;
|
||||||
|
import net.minecraft.server.v1_11_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_11_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
|
||||||
|
levelChunk.a(new BlockPosition(x & 0xF, y, z & 0xF), Block.getByCombinedId(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,11 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.craftbukkit.v1_11_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_11_R1.CraftChunk;
|
||||||
|
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_11_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_11_R1.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.v1_11_R1.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_11_R1.util.CraftMagicNumbers;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +42,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,12 +91,12 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(org.bukkit.block.Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull org.bukkit.block.Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = ((CraftWorld) craftBlock.getWorld()).getHandle();
|
||||||
net.minecraft.server.v1_11_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
|
||||||
|
|
||||||
BlockPosition blockPosition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
BlockPosition blockPos = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
||||||
nmsWorld.updateAdjacentComparators(blockPosition, CraftMagicNumbers.getBlock(craftBlock));
|
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
|
||||||
|
serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_12_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_12_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_12_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_12_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_12_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_12_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_12_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_12_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_12_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_12_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,35 @@
|
|||||||
package com.songoda.core.nms.v1_12_R1.world;
|
package com.songoda.core.nms.v1_12_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_12_R1.Block;
|
||||||
|
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_12_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_12_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
|
||||||
|
levelChunk.a(new BlockPosition(x & 0xF, y, z & 0xF), Block.getByCombinedId(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,11 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.util.CraftMagicNumbers;
|
import org.bukkit.craftbukkit.v1_12_R1.util.CraftMagicNumbers;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +42,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,12 +91,12 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(org.bukkit.block.Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull org.bukkit.block.Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = ((CraftWorld) craftBlock.getWorld()).getHandle();
|
||||||
net.minecraft.server.v1_12_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
|
||||||
|
|
||||||
BlockPosition blockPosition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
BlockPosition blockPos = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
|
||||||
nmsWorld.updateAdjacentComparators(blockPosition, CraftMagicNumbers.getBlock(craftBlock));
|
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
|
||||||
|
serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_13_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_13_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_13_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_13_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_13_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_13_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_13_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_13_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_13_R1.world;
|
package com.songoda.core.nms.v1_13_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_13_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_13_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_13_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_13_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.a(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_13_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_13_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +41,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,11 +94,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_13_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_13_R2</artifactId>
|
<artifactId>SongodaCore-NMS-v1_13_R2</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_13_R2;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_13_R2.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R2.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R2.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_13_R2.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_13_R2.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_13_R2.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_13_R2.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_13_R2.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_13_R2.world;
|
package com.songoda.core.nms.v1_13_R2.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_13_R2.Chunk;
|
||||||
|
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -40,7 +41,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,11 +101,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_13_R2.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_14_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_14_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_14_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_14_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_14_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_14_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_14_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_14_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_14_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_14_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_14_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_14_R1.world;
|
package com.songoda.core.nms.v1_14_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_14_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_14_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +43,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,11 +98,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_14_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,8 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_15_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_15_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +25,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_15_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_15_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_15_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_15_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_15_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_15_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_15_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_15_R1.world;
|
package com.songoda.core.nms.v1_15_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_15_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_15_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +43,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,11 +101,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_15_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R1</artifactId>
|
<artifactId>SongodaCore-NMS-v1_16_R1</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R1;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_16_R1.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R1.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R1.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R1.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_16_R1.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R1.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R1.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_16_R1.world;
|
package com.songoda.core.nms.v1_16_R1.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R1.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +43,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,11 +102,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_16_R1.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R2</artifactId>
|
<artifactId>SongodaCore-NMS-v1_16_R2</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R2;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_16_R2.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R2.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R2.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R2.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_16_R2.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R2.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R2.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_16_R2.world;
|
package com.songoda.core.nms.v1_16_R2.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R2.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R2.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +43,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,11 +102,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_16_R2.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_16_R3</artifactId>
|
<artifactId>SongodaCore-NMS-v1_16_R3</artifactId>
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -26,12 +24,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R3;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.NmsImplementations;
|
||||||
|
import com.songoda.core.nms.anvil.AnvilCore;
|
||||||
|
import com.songoda.core.nms.entity.NMSPlayer;
|
||||||
|
import com.songoda.core.nms.nbt.NBTCore;
|
||||||
|
import com.songoda.core.nms.v1_16_R3.entity.NMSPlayerImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R3.nbt.NBTCoreImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R3.world.NmsWorldBorderImpl;
|
||||||
|
import com.songoda.core.nms.v1_16_R3.world.WorldCoreImpl;
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import com.songoda.core.nms.world.WorldCore;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class NmsImplementationsImpl implements NmsImplementations {
|
||||||
|
private final NMSPlayer player;
|
||||||
|
private final WorldCore world;
|
||||||
|
private final NmsWorldBorder worldBorder;
|
||||||
|
private final AnvilCore anvil;
|
||||||
|
private final NBTCore nbt;
|
||||||
|
|
||||||
|
public NmsImplementationsImpl() {
|
||||||
|
this.player = new NMSPlayerImpl();
|
||||||
|
this.world = new WorldCoreImpl();
|
||||||
|
this.worldBorder = new NmsWorldBorderImpl();
|
||||||
|
this.anvil = new com.songoda.core.nms.v1_16_R3.anvil.AnvilCore();
|
||||||
|
this.nbt = new NBTCoreImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NMSPlayer getPlayer() {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull WorldCore getWorld() {
|
||||||
|
return this.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NmsWorldBorder getWorldBorder() {
|
||||||
|
return this.worldBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull AnvilCore getAnvil() {
|
||||||
|
return this.anvil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NBTCore getNbt() {
|
||||||
|
return this.nbt;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.songoda.core.nms.v1_16_R3.world;
|
||||||
|
|
||||||
|
import com.songoda.core.nms.world.NmsWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R3.PacketPlayOutWorldBorder;
|
||||||
|
import net.minecraft.server.v1_16_R3.WorldBorder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class NmsWorldBorderImpl implements NmsWorldBorder {
|
||||||
|
@Override
|
||||||
|
public void send(Player player, BorderColor color, double size, @NotNull Location center) {
|
||||||
|
Objects.requireNonNull(center.getWorld());
|
||||||
|
|
||||||
|
WorldBorder worldBorder = new WorldBorder();
|
||||||
|
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
|
||||||
|
|
||||||
|
worldBorder.setCenter(center.getX(), center.getZ());
|
||||||
|
worldBorder.setSize(size);
|
||||||
|
worldBorder.setWarningTime(0);
|
||||||
|
worldBorder.setWarningDistance(0);
|
||||||
|
|
||||||
|
if (color == BorderColor.GREEN) {
|
||||||
|
worldBorder.transitionSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
|
||||||
|
} else if (color == BorderColor.RED) {
|
||||||
|
worldBorder.transitionSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,37 @@
|
|||||||
package com.songoda.core.nms.v1_16_R3.world;
|
package com.songoda.core.nms.v1_16_R3.world;
|
||||||
|
|
||||||
import com.songoda.core.nms.world.SWorld;
|
import com.songoda.core.nms.world.SWorld;
|
||||||
|
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_16_R3.Chunk;
|
||||||
|
import net.minecraft.server.v1_16_R3.IBlockData;
|
||||||
|
import net.minecraft.server.v1_16_R3.WorldServer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SWorldImpl implements SWorld {
|
public class SWorldImpl implements SWorld {
|
||||||
public SWorldImpl() {
|
private final World world;
|
||||||
|
|
||||||
|
public SWorldImpl(World world) {
|
||||||
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LivingEntity> getLivingEntities() {
|
public List<LivingEntity> getLivingEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>(); // FIXME
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockFast(int x, int y, int z, Material material) {
|
||||||
|
WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
|
||||||
|
Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
|
||||||
|
IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
|
||||||
|
|
||||||
|
levelChunk.setType(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.bukkit.block.CreatureSpawner;
|
|||||||
import org.bukkit.craftbukkit.v1_16_R3.CraftChunk;
|
import org.bukkit.craftbukkit.v1_16_R3.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WorldCoreImpl implements WorldCore {
|
public class WorldCoreImpl implements WorldCore {
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +43,7 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SWorld getWorld(World world) {
|
public SWorld getWorld(World world) {
|
||||||
return new SWorldImpl();
|
return new SWorldImpl(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,11 +103,10 @@ public class WorldCoreImpl implements WorldCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAdjacentComparators(Block bukkitBlock) {
|
public void updateAdjacentComparators(@NotNull Block bukkitBlock) {
|
||||||
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
|
||||||
CraftChunk craftChunk = (CraftChunk) bukkitBlock.getChunk();
|
WorldServer serverLevel = craftBlock.getCraftWorld().getHandle();
|
||||||
|
|
||||||
net.minecraft.server.v1_16_R3.World nmsWorld = craftChunk.getHandle().getWorld();
|
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
||||||
nmsWorld.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,13 @@
|
|||||||
<version>2.6.21</version>
|
<version>2.6.21</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
<artifactId>SongodaCore-NMS-v1_17_R1</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>16</java.version>
|
<java.version>16</java.version>
|
||||||
<java.release>16</java.release>
|
<java.release>16</java.release>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<artifactId>SongodaCore-NMS-v1_17_R1</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
@ -31,12 +29,14 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-NMS-API</artifactId>
|
<artifactId>SongodaCore-NMS-API</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>SongodaCore-Compatibility</artifactId>
|
<artifactId>SongodaCore-Compatibility</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user