mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-11-28 08:44:07 +00:00
Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f446605249 | ||
|
|
f1fc931b3e | ||
|
|
a9e821497c | ||
|
|
c8c5a04a59 | ||
|
|
4697f06163 | ||
|
|
15fc3eba67 | ||
|
|
86b2e3508b | ||
|
|
1f16f943e8 | ||
|
|
3cf85f2ce6 | ||
|
|
a5400d18e5 | ||
|
|
f494297607 | ||
|
|
6e1bb098c9 | ||
|
|
ebd0bedb2d | ||
|
|
4c2dbae45a | ||
|
|
12125d258f | ||
|
|
35d5fac459 | ||
|
|
9f181605f1 | ||
|
|
9c21792669 | ||
|
|
c721cd7837 | ||
|
|
d18bd94b3a |
No files matched your search
@@ -0,0 +1,37 @@
|
|||||||
|
name: Publish editor schema
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
if: '!github.event.release.prerelease'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.release.tag_name }}
|
||||||
|
persist-credentials: false
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
- name: Prepare plugin-owned schemas
|
||||||
|
env:
|
||||||
|
SCHEMA_PATHS: BetterRTP-Core/src/main/resources/META-INF/editor-schema.json BetterRTPAddons/src/main/resources/META-INF/editor-schema.json
|
||||||
|
run: |
|
||||||
|
node --input-type=module <<'JS'
|
||||||
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||||
|
mkdirSync('editor-schemas');
|
||||||
|
for (const path of process.env.SCHEMA_PATHS.split(' ')) {
|
||||||
|
const bytes = readFileSync(path), meta = JSON.parse(bytes)['x-bettersync'];
|
||||||
|
if (meta?.format !== 1 || !/^[a-z0-9-]+$/.test(meta.plugin) || !/^[A-Za-z0-9._-]+$/.test(meta.schemaVersion)) throw new Error('Invalid schema identity');
|
||||||
|
writeFileSync(`editor-schemas/${meta.plugin}-${meta.schemaVersion}.schema.json`, bytes);
|
||||||
|
}
|
||||||
|
JS
|
||||||
|
- name: Attach schemas to this plugin release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
||||||
|
run: gh release upload "$RELEASE_TAG" editor-schemas/*.schema.json
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
name: Release BetterRTP Maven version
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
concurrency:
|
||||||
|
group: release-maven-version
|
||||||
|
cancel-in-progress: false
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '17'
|
||||||
|
cache: maven
|
||||||
|
- name: Read BetterRTP Maven version
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mvn -B -q -f BetterRTP-Core/pom.xml help:evaluate -Dexpression=project.version -Doutput="$RUNNER_TEMP/version-0"
|
||||||
|
version0=$(cat "$RUNNER_TEMP/version-0")
|
||||||
|
[[ "$version0" =~ ^[0-9][A-Za-z0-9._-]*$ ]] || { echo "Invalid Maven version"; exit 1; }
|
||||||
|
[[ "$version0" != *SNAPSHOT* ]] || { echo "Snapshot versions are not released"; exit 1; }
|
||||||
|
echo "version0=$version0" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=v$version0" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "title=BetterRTP $version0" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Check for an existing release
|
||||||
|
id: existing
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ steps.version.outputs.tag }}
|
||||||
|
run: |
|
||||||
|
# Listing errors fail the workflow; they are not mistaken for an absent release.
|
||||||
|
releases=$(gh api --paginate "repos/$GH_REPO/releases?per_page=100" --jq '.[].tag_name')
|
||||||
|
if printf '%s\n' "$releases" | grep -Fxq "$RELEASE_TAG"; then
|
||||||
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Release $RELEASE_TAG already exists; bump the Maven version for another release."
|
||||||
|
fi
|
||||||
|
- name: Build and test
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
run: |
|
||||||
|
mvn -B -pl :BetterRTP clean verify
|
||||||
|
mvn -B -f tests/editor/pom.xml verify
|
||||||
|
- name: Prepare BetterRTP JAR and editor schemas
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
env:
|
||||||
|
# The website still needs Addons field metadata; this does not build its JAR.
|
||||||
|
SCHEMA_PATHS: BetterRTP-Core/src/main/resources/META-INF/editor-schema.json BetterRTPAddons/src/main/resources/META-INF/editor-schema.json
|
||||||
|
run: |
|
||||||
|
mkdir release-assets
|
||||||
|
cp "dist/BetterRTP-${{ steps.version.outputs.version0 }}.jar" release-assets/
|
||||||
|
python3 - <<'PYTHON'
|
||||||
|
import json, os, pathlib, re
|
||||||
|
for path in os.environ['SCHEMA_PATHS'].split():
|
||||||
|
data = pathlib.Path(path).read_bytes()
|
||||||
|
meta = json.loads(data)['x-bettersync']
|
||||||
|
if meta['format'] != 1 or not re.fullmatch(r'[a-z0-9-]+', meta['plugin']) or not re.fullmatch(r'[A-Za-z0-9._-]+', meta['schemaVersion']):
|
||||||
|
raise ValueError('Invalid schema identity')
|
||||||
|
pathlib.Path('release-assets', f"{meta['plugin']}-{meta['schemaVersion']}.schema.json").write_bytes(data)
|
||||||
|
PYTHON
|
||||||
|
- name: Publish versioned release
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ steps.version.outputs.tag }}
|
||||||
|
RELEASE_TITLE: ${{ steps.version.outputs.title }}
|
||||||
|
run: |
|
||||||
|
gh release create "$RELEASE_TAG" release-assets/* \
|
||||||
|
--target "$GITHUB_SHA" --title "$RELEASE_TITLE" --generate-notes --latest
|
||||||
@@ -18,4 +18,6 @@ jobs:
|
|||||||
run: cp settings.xml $HOME/.m2/settings.xml
|
run: cp settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
- name: Build and test with Maven
|
- name: Build and test with Maven
|
||||||
run: mvn test
|
run: |
|
||||||
|
mvn -B -pl :BetterRTP verify
|
||||||
|
mvn -B -f tests/editor/pom.xml verify
|
||||||
@@ -10,3 +10,5 @@ BetterRTP.wiki/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode/
|
.vscode/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
/dist/
|
||||||
@@ -0,0 +1,434 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>me.SuperRonanCraft</groupId>
|
||||||
|
<artifactId>BetterRTP</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>3.6.16</version>
|
||||||
|
|
||||||
|
<!-- Upload patches to https://repo.ronanplugins.com/#/ -->
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bettersync.version>2.0.1</bettersync.version>
|
||||||
|
<maven.compiler.release>8</maven.compiler.release>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<editor.website>https://www.minecentral.net</editor.website>
|
||||||
|
<editor.buildSuffix></editor.buildSuffix>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>dev</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<!-- Local Server Building -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.basedir}/../../../Java/plugins</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<finalName>${project.artifactId}-${project.version}${editor.buildSuffix}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.basedir}/../dist</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>3.1.4</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!-- Shade PaperLib into project -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml
|
||||||
|
</dependencyReducedPomLocation>
|
||||||
|
<relocations>
|
||||||
|
<relocation><pattern>com.ronanplugins.bettersync</pattern><shadedPattern>me.SuperRonanCraft.BetterRTP.lib.bettersync</shadedPattern></relocation>
|
||||||
|
|
||||||
|
<relocation>
|
||||||
|
<pattern>io.papermc.lib</pattern>
|
||||||
|
<shadedPattern>me.SuperRonanCraft.BetterRTP.lib.paperlib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.tcoded.folialib</pattern>
|
||||||
|
<shadedPattern>me.SuperRonanCraft.BetterRTP.lib.folialib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.14.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!-- Remove only Shade's unbundled backup, after the final JAR is ready. -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<configuration>
|
||||||
|
<filesets>
|
||||||
|
<fileset>
|
||||||
|
<directory>${project.basedir}/../dist</directory>
|
||||||
|
<includes>
|
||||||
|
<include>${project.artifactId}-*.jar</include>
|
||||||
|
<include>original-${project.artifactId}-*.jar</include>
|
||||||
|
</includes>
|
||||||
|
<followSymlinks>false</followSymlinks>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>remove-unshaded-backup</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals><goal>clean</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<excludeDefaultDirectories>true</excludeDefaultDirectories>
|
||||||
|
<filesets combine.self="override">
|
||||||
|
<fileset>
|
||||||
|
<directory>${project.basedir}/../dist</directory>
|
||||||
|
<includes><include>original-${project.build.finalName}.jar</include></includes>
|
||||||
|
<followSymlinks>false</followSymlinks>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<!-- CAN BE UNCOMMENTED IF YOU HAVE ACCESS TO THE REPO -->
|
||||||
|
<!--<repository>
|
||||||
|
<id>ronanplugins-private</id>
|
||||||
|
<name>RonanPlugins Repository</name>
|
||||||
|
<url>https://repo.ronanplugins.com/private</url>
|
||||||
|
</repository>-->
|
||||||
|
<!-- GitHub based Repos -->
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
<!-- FoliaLib Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>tcoded-releases</id>
|
||||||
|
<url>https://repo.tcoded.com/releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Spigot Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- PaperMC Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Vault Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- WorldGuard Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- ProjectRed Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>redprotect-repo</id>
|
||||||
|
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- FactionsUUID Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>factions-uuid</id>
|
||||||
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- ProtocolLib Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- EssentialsX Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>essentials-releases</id>
|
||||||
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- PlaceholderAPI Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi</id>
|
||||||
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- MinePlots Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>minecodes-repository-releases</id>
|
||||||
|
<name>mineCodes Organization Repository</name>
|
||||||
|
<url>https://repository.minecodes.pl/releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Used by Husk plugins -->
|
||||||
|
<repository>
|
||||||
|
<id>william278-releases</id>
|
||||||
|
<url>https://repo.william278.net/releases</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Download the tagged GitHub library through JitPack; bundled by Shade. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.RonanPlugins</groupId>
|
||||||
|
<artifactId>BetterSync</artifactId>
|
||||||
|
<version>${bettersync.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!--Spigot API-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spigot Stuff -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Vault -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Paper Library for Async Chunk/Teleport -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- WorldGuard (https://dev.bukkit.org/projects/worldguard) -->
|
||||||
|
<dependency> <!-- Saber Factions screws up if updated -->
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>7.0.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- RedProtect (https://www.spigotmc.org/resources/redprotect.15841/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
|
<artifactId>RedProtect-Core</artifactId>
|
||||||
|
<version>7.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
|
<artifactId>RedProtect-Spigot-1.13</artifactId>
|
||||||
|
<version>7.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FactionsUUID (https://www.spigotmc.org/resources/factionsuuid.1035/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.massivecraft</groupId>
|
||||||
|
<artifactId>Factions</artifactId>
|
||||||
|
<version>1.6.9.5-U0.6.8</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Lands (https://www.spigotmc.org/resources/lands.53313/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.angeschossen</groupId>
|
||||||
|
<artifactId>LandsAPI</artifactId>
|
||||||
|
<version>6.28.11</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- ProtocolLib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>5.3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Towny (https://www.spigotmc.org/resources/towny.72694/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
|
<artifactId>Towny</artifactId>
|
||||||
|
<version>0.98.6.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- GriefPrevention (https://www.spigotmc.org/resources/griefprevention.1884/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TechFortress</groupId>
|
||||||
|
<artifactId>GriefPrevention</artifactId>
|
||||||
|
<version>17.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- KingdomsX (https://www.spigotmc.org/resources/kingdomsx.77670/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.cryptomorin</groupId>
|
||||||
|
<artifactId>kingdoms</artifactId>
|
||||||
|
<version>1.16.8.1.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- GriefDefender (https://www.spigotmc.org/resources/griefdefender.68900/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.bloodmc</groupId>
|
||||||
|
<artifactId>GriefDefenderApi</artifactId>
|
||||||
|
<version>920a610</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Peublos (https://www.spigotmc.org/resources/pueblos.91255/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.SuperRonanCraft</groupId>
|
||||||
|
<artifactId>Pueblos</artifactId>
|
||||||
|
<version>97b96c9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Particles Library
|
||||||
|
https://github.com/ByteZ1337/ParticleLib
|
||||||
|
(https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>xyz.xenondevs</groupId>
|
||||||
|
<artifactId>particle</artifactId>
|
||||||
|
<version>1.8.4</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Lombok Support (@Getter & @Setter)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.38</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- EssentialsX -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.essentialsx</groupId>
|
||||||
|
<artifactId>EssentialsX</artifactId>
|
||||||
|
<version>2.21.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- Saber Factions (https://www.spigotmc.org/resources/saberfactions.69771/) (Added in 3.4.5)-->
|
||||||
|
<dependency> <!-- WorldGuard screws up if updated -->
|
||||||
|
<groupId>com.github.SaberLLC</groupId>
|
||||||
|
<artifactId>Saber-Factions</artifactId>
|
||||||
|
<version>2.4.0-RC</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- PlaceholderAPI Support (Added in 3.4.5)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.11.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- HuskClaims (https://www.spigotmc.org/resources/huskclaims.114467/) (Added in 3.6.13)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.william278.huskclaims</groupId>
|
||||||
|
<artifactId>huskclaims-bukkit</artifactId>
|
||||||
|
<version>1.5.10</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Husktown (https://www.spigotmc.org/resources/husktowns.92672/) (Added in 3.4.5)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.william278.husktowns</groupId>
|
||||||
|
<artifactId>husktowns-bukkit</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- MinePlots (https://builtbybit.com/resources/mineplots.21646/) (Added in 3.6.6 ) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>pl.minecodes.plots</groupId>
|
||||||
|
<artifactId>plugin-api</artifactId>
|
||||||
|
<version>3.4.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FoliaLib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tcoded</groupId>
|
||||||
|
<artifactId>FoliaLib</artifactId>
|
||||||
|
<version>0.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FactionsBridge -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dansplugins.factionsystem</groupId>
|
||||||
|
<artifactId>FactionsBridge</artifactId>
|
||||||
|
<version>1.3.8</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/../lib/FactionsBridge-1.3.8.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.WhipDevelopment</groupId>
|
||||||
|
<artifactId>CrashClaim</artifactId>
|
||||||
|
<version>c697d3e9ef</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bekvon.bukkit.residence</groupId>
|
||||||
|
<artifactId>Residence</artifactId>
|
||||||
|
<version>5.1.4.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
<systemPath>${project.basedir}/../lib/Residence5.1.4.1.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
+16
@@ -1,5 +1,8 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP;
|
package me.SuperRonanCraft.BetterRTP;
|
||||||
|
|
||||||
|
import com.ronanplugins.bettersync.editor.EditorClient;
|
||||||
|
import com.ronanplugins.bettersync.editor.EditorSchema;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
||||||
@@ -47,12 +50,19 @@ public class BetterRTP extends JavaPlugin {
|
|||||||
@Getter private boolean PlaceholderAPI;
|
@Getter private boolean PlaceholderAPI;
|
||||||
@Getter private final RTPLogger rtpLogger = new RTPLogger();
|
@Getter private final RTPLogger rtpLogger = new RTPLogger();
|
||||||
@Getter private final FoliaHandler foliaHandler = new FoliaHandler();
|
@Getter private final FoliaHandler foliaHandler = new FoliaHandler();
|
||||||
|
@Getter private EditorClient editorBridge;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
registerDependencies();
|
registerDependencies();
|
||||||
loadAll();
|
loadAll();
|
||||||
|
editorBridge = new EditorClient(
|
||||||
|
this, EditorSchema.load(this, "META-INF/editor-schema.json"),
|
||||||
|
EditorClient.website(this, "META-INF/betterrtp-editor.properties"),
|
||||||
|
me.SuperRonanCraft.BetterRTP.versions.AsyncHandler::sync, this::reload,
|
||||||
|
me.SuperRonanCraft.BetterRTP.references.PermissionNode.EDITOR::check,
|
||||||
|
() -> me.SuperRonanCraft.BetterRTP.references.file.FileOther.FILETYPE.CONFIG.getConfig().saveToString());
|
||||||
new Updater(this);
|
new Updater(this);
|
||||||
new Metrics(this);
|
new Metrics(this);
|
||||||
listener.registerEvents(this);
|
listener.registerEvents(this);
|
||||||
@@ -66,6 +76,9 @@ public class BetterRTP extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
RTP.getOperations().clear();
|
||||||
|
playerDataManager.clear();
|
||||||
|
if (editorBridge != null) editorBridge.close();
|
||||||
invs.closeAll();
|
invs.closeAll();
|
||||||
queue.unload();
|
queue.unload();
|
||||||
rtpLogger.unload();
|
rtpLogger.unload();
|
||||||
@@ -99,8 +112,11 @@ public class BetterRTP extends JavaPlugin {
|
|||||||
|
|
||||||
//(Re)Load all plugin systems/files/cache
|
//(Re)Load all plugin systems/files/cache
|
||||||
private void loadAll() {
|
private void loadAll() {
|
||||||
|
RTP.getOperations().clear();
|
||||||
foliaHandler.load();
|
foliaHandler.load();
|
||||||
playerDataManager.clear();
|
playerDataManager.clear();
|
||||||
|
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
|
||||||
|
playerDataManager.startSession(player);
|
||||||
files.loadAll();
|
files.loadAll();
|
||||||
settings.load();
|
settings.load();
|
||||||
cooldowns.load();
|
cooldowns.load();
|
||||||
+3
-3
@@ -16,7 +16,7 @@ public class PlayerInfo {
|
|||||||
@Getter private final HashMap<Player, World> invWorld = new HashMap<>();
|
@Getter private final HashMap<Player, World> invWorld = new HashMap<>();
|
||||||
@Getter private final HashMap<Player, RTP_INV_SETTINGS> invNextInv = new HashMap<>();
|
@Getter private final HashMap<Player, RTP_INV_SETTINGS> invNextInv = new HashMap<>();
|
||||||
//private final HashMap<Player, CooldownData> cooldown = new HashMap<>();
|
//private final HashMap<Player, CooldownData> cooldown = new HashMap<>();
|
||||||
@Getter private final HashMap<Player, Boolean> rtping = new HashMap<>();
|
|
||||||
//private final HashMap<Player, List<Location>> previousLocations = new HashMap<>();
|
//private final HashMap<Player, List<Location>> previousLocations = new HashMap<>();
|
||||||
//private final HashMap<Player, RTP_TYPE> rtpType = new HashMap<>();
|
//private final HashMap<Player, RTP_TYPE> rtpType = new HashMap<>();
|
||||||
|
|
||||||
@@ -48,14 +48,14 @@ public class PlayerInfo {
|
|||||||
invWorld.clear();
|
invWorld.clear();
|
||||||
invNextInv.clear();
|
invNextInv.clear();
|
||||||
//cooldown.clear();
|
//cooldown.clear();
|
||||||
rtping.clear();
|
|
||||||
//previousLocations.clear();
|
//previousLocations.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unload(Player p) {
|
private void unload(Player p) {
|
||||||
clearInvs(p);
|
clearInvs(p);
|
||||||
//cooldown.remove(p);
|
//cooldown.remove(p);
|
||||||
rtping.remove(p);
|
|
||||||
//previousLocations.remove(p);
|
//previousLocations.remove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
+4
-1
@@ -43,7 +43,10 @@ public class Commands {
|
|||||||
//Command Event
|
//Command Event
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
BetterRTP.debug(sendi.getName() + " executed: /" + label + " " + String.join(" ", args));
|
boolean editorSync = args[0].equalsIgnoreCase("editorsync") ||
|
||||||
|
(args[0].equalsIgnoreCase("addons") && args.length > 1 && args[1].equalsIgnoreCase("editorsync"));
|
||||||
|
BetterRTP.debug(sendi.getName() + " executed: /" + label + " " +
|
||||||
|
(editorSync ? (args[0].equalsIgnoreCase("addons") ? "addons editorsync [redacted]" : "editorsync [redacted]") : String.join(" ", args)));
|
||||||
cmd.execute(sendi, label, args);
|
cmd.execute(sendi, label, args);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new RTP_CommandEvent_After(sendi, cmd));
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_CommandEvent_After(sendi, cmd));
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+2
@@ -5,6 +5,8 @@ import me.SuperRonanCraft.BetterRTP.player.commands.types.*;
|
|||||||
public enum RTPCommandType {
|
public enum RTPCommandType {
|
||||||
BIOME(new CmdBiome()),
|
BIOME(new CmdBiome()),
|
||||||
EDIT(new CmdEdit()),
|
EDIT(new CmdEdit()),
|
||||||
|
EDITOR(new CmdEditor()),
|
||||||
|
EDITOR_SYNC(new CmdEditorSync()),
|
||||||
HELP(new CmdHelp()),
|
HELP(new CmdHelp()),
|
||||||
INFO(new CmdInfo()),
|
INFO(new CmdInfo()),
|
||||||
LOCATION(new CmdLocation()),
|
LOCATION(new CmdLocation()),
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdEditor implements RTPCommand, RTPCommandHelpable {
|
||||||
|
public String getName() { return "editor"; }
|
||||||
|
public PermissionNode permission() { return PermissionNode.EDITOR; }
|
||||||
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
public void execute(CommandSender sender, String label, String[] args) {
|
||||||
|
if (args.length == 1) BetterRTP.getInstance().getEditorBridge().upload(sender);
|
||||||
|
else sender.sendMessage("Usage: /" + label + " editor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.EDITOR.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdEditorSync implements RTPCommand, RTPCommandHelpable {
|
||||||
|
public String getName() { return "editorsync"; }
|
||||||
|
public PermissionNode permission() { return PermissionNode.EDITOR; }
|
||||||
|
public List<String> tabComplete(CommandSender sender, String[] args) { return Collections.emptyList(); }
|
||||||
|
public void execute(CommandSender sender, String label, String[] args) {
|
||||||
|
if (args.length == 2) BetterRTP.getInstance().getEditorBridge().redeem(sender, args[1]);
|
||||||
|
else sender.sendMessage("Usage: /" + label + " editorsync <token>");
|
||||||
|
}
|
||||||
|
public String getHelp() { return MessagesHelp.EDITOR_SYNC.get(); }
|
||||||
|
}
|
||||||
File renamed without changes.
+6
-14
@@ -13,9 +13,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
@@ -147,27 +144,22 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
|||||||
if (!upload) {
|
if (!upload) {
|
||||||
sendi.sendMessage(list.toArray(new String[0]));
|
sendi.sendMessage(list.toArray(new String[0]));
|
||||||
if (sendi instanceof Player) {
|
if (sendi instanceof Player) {
|
||||||
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &flogs.ronanplugins.com"));
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &fmclo.gs"));
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
((Player) sendi).spigot().sendMessage(component);
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
} else {
|
} else {
|
||||||
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://logs.ronanplugins.com");
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://mclo.gs");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list.add(0, "Command: " + cmd);
|
list.add(0, "Command: " + cmd);
|
||||||
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
String key = LogUploader.post(list);
|
String url = LogUploader.post(list);
|
||||||
if (key == null) {
|
if (url == null) {
|
||||||
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cAn error occured attempting to upload log!")), null);
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
} else {
|
} else {
|
||||||
try {
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(key);
|
|
||||||
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6https://logs.ronanplugins.com/" + json.get("key")), null);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
File renamed without changes.
+6
-14
@@ -13,9 +13,6 @@ import net.md_5.bungee.api.chat.TextComponent;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -36,25 +33,20 @@ public class CmdLogger implements RTPCommand {
|
|||||||
String cmd = "/" + label + " " + String.join(" ", args);
|
String cmd = "/" + label + " " + String.join(" ", args);
|
||||||
if (!upload) {
|
if (!upload) {
|
||||||
if (sendi instanceof Player) {
|
if (sendi instanceof Player) {
|
||||||
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload log to &flogs.ronanplugins.com"));
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload log to &fmclo.gs"));
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
((Player) sendi).spigot().sendMessage(component);
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
} else {
|
} else {
|
||||||
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload log to https://logs.ronanplugins.com");
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload log to https://mclo.gs");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
String key = LogUploader.post(BetterRTP.getInstance().getRtpLogger().getFile());
|
String url = LogUploader.post(BetterRTP.getInstance().getRtpLogger().getFile());
|
||||||
if (key == null) {
|
if (url == null) {
|
||||||
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cAn error occured attempting to upload log!")), null);
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
} else {
|
} else {
|
||||||
try {
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(key);
|
|
||||||
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6https://logs.ronanplugins.com/" + json.get("key")), null);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+6
-14
@@ -22,9 +22,6 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -59,27 +56,22 @@ public class CmdQueue implements RTPCommand {
|
|||||||
if (!upload) {
|
if (!upload) {
|
||||||
sendi.sendMessage(list.toArray(new String[0]));
|
sendi.sendMessage(list.toArray(new String[0]));
|
||||||
if (sendi instanceof Player) {
|
if (sendi instanceof Player) {
|
||||||
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &flogs.ronanplugins.com"));
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &fmclo.gs"));
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
((Player) sendi).spigot().sendMessage(component);
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
} else {
|
} else {
|
||||||
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://logs.ronanplugins.com");
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://mclo.gs");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list.add(0, "Command: " + cmd);
|
list.add(0, "Command: " + cmd);
|
||||||
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
String key = LogUploader.post(list);
|
String url = LogUploader.post(list);
|
||||||
if (key == null) {
|
if (url == null) {
|
||||||
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cAn error occured attempting to upload log!")), null);
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
} else {
|
} else {
|
||||||
try {
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(key);
|
|
||||||
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6https://logs.ronanplugins.com/" + json.get("key")), null);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
@@ -21,6 +21,7 @@ public class Click {
|
|||||||
try {
|
try {
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
PlayerData data = HelperPlayer.getData(p);
|
PlayerData data = HelperPlayer.getData(p);
|
||||||
|
if (data == null) return;
|
||||||
RTPInventories menu = BetterRTP.getInstance().getInvs();
|
RTPInventories menu = BetterRTP.getInstance().getInvs();
|
||||||
menu.getInv(data.getMenu().getInvType()).clickEvent(e);
|
menu.getInv(data.getMenu().getInvType()).clickEvent(e);
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
@@ -38,6 +39,7 @@ public class Click {
|
|||||||
else if (e.getWhoClicked() instanceof Player) {
|
else if (e.getWhoClicked() instanceof Player) {
|
||||||
// Clicks the inventory
|
// Clicks the inventory
|
||||||
PlayerData data = HelperPlayer.getData((Player) e.getWhoClicked());
|
PlayerData data = HelperPlayer.getData((Player) e.getWhoClicked());
|
||||||
|
if (data == null) return false;
|
||||||
if (!e.getInventory().equals(data.getMenu().getInv()))
|
if (!e.getInventory().equals(data.getMenu().getInv()))
|
||||||
return false;
|
return false;
|
||||||
// Clicks their own inventory
|
// Clicks their own inventory
|
||||||
File renamed without changes.
+3
-1
@@ -1,6 +1,7 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@@ -11,7 +12,8 @@ public class Damage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean isInInvincibleMode(Player player) {
|
static boolean isInInvincibleMode(Player player) {
|
||||||
return HelperPlayer.getData(player).getInvincibleEndTime() > System.currentTimeMillis();
|
PlayerData data = HelperPlayer.getData(player);
|
||||||
|
return data != null && data.getInvincibleEndTime() > System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onEntityDamage(EntityDamageEvent event) {
|
static void onEntityDamage(EntityDamageEvent event) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-4
@@ -8,7 +8,6 @@ import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
|||||||
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@@ -19,10 +18,9 @@ public class Join {
|
|||||||
|
|
||||||
static void event(PlayerJoinEvent e) {
|
static void event(PlayerJoinEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
getPl().getPlayerDataManager().startSession(p);
|
||||||
updater(p);
|
updater(p);
|
||||||
AsyncHandler.async(() -> {
|
|
||||||
getPl().getCooldowns().loadPlayer(p);
|
getPl().getCooldowns().loadPlayer(p);
|
||||||
});
|
|
||||||
rtpOnFirstJoin(p);
|
rtpOnFirstJoin(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +40,7 @@ public class Join {
|
|||||||
//RTP on first join
|
//RTP on first join
|
||||||
private static void rtpOnFirstJoin(Player p) {
|
private static void rtpOnFirstJoin(Player p) {
|
||||||
if (getPl().getSettings().isRtpOnFirstJoin_Enabled() && !p.hasPlayedBefore())
|
if (getPl().getSettings().isRtpOnFirstJoin_Enabled() && !p.hasPlayedBefore())
|
||||||
HelperRTP.tp(p, Bukkit.getConsoleSender(), Bukkit.getWorld(getPl().getSettings().getRtpOnFirstJoin_World()), null, RTP_TYPE.JOIN); //Console is sender to override delays
|
HelperRTP.tp(p, Bukkit.getConsoleSender(), Bukkit.getWorld(getPl().getSettings().getRtpOnFirstJoin_World()), null, RTP_TYPE.JOIN, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BetterRTP getPl() {
|
private static BetterRTP getPl() {
|
||||||
+5
@@ -1,6 +1,7 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@@ -8,6 +9,10 @@ class Leave {
|
|||||||
|
|
||||||
static void event(PlayerQuitEvent e) {
|
static void event(PlayerQuitEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
try {
|
||||||
|
BetterRTP.getInstance().getRTP().getOperations().cancel(p.getUniqueId(), p);
|
||||||
|
} finally {
|
||||||
HelperPlayer.unload(p);
|
HelperPlayer.unload(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+10
-6
@@ -22,6 +22,7 @@ import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
|||||||
public class RTP {
|
public class RTP {
|
||||||
|
|
||||||
@Getter final RTPTeleport teleport = new RTPTeleport();
|
@Getter final RTPTeleport teleport = new RTPTeleport();
|
||||||
|
@Getter private final RTPOperationTracker operations = new RTPOperationTracker();
|
||||||
//Cache
|
//Cache
|
||||||
public final HashMap<String, String> overriden = new HashMap<>();
|
public final HashMap<String, String> overriden = new HashMap<>();
|
||||||
@Getter List<String> disabledWorlds, blockList;
|
@Getter List<String> disabledWorlds, blockList;
|
||||||
@@ -82,16 +83,19 @@ public class RTP {
|
|||||||
private void rtp(CommandSender sendi, WorldPlayer pWorld, RTP_TYPE type) {
|
private void rtp(CommandSender sendi, WorldPlayer pWorld, RTP_TYPE type) {
|
||||||
//Cooldown
|
//Cooldown
|
||||||
Player p = pWorld.getPlayer();
|
Player p = pWorld.getPlayer();
|
||||||
getPl().getPInfo().getRtping().put(p, true); //Cache player so they cant run '/rtp' again while rtp'ing
|
if (!p.isOnline()) return;
|
||||||
|
RTPOperationTracker.Operation operation = operations.start(p.getUniqueId(), p);
|
||||||
|
if (operation == null) return;
|
||||||
//Setup player rtp methods
|
//Setup player rtp methods
|
||||||
RTPPlayer rtpPlayer = new RTPPlayer(p, this, pWorld, type);
|
RTPPlayer rtpPlayer = new RTPPlayer(p, this, pWorld, type, operation);
|
||||||
// Delaying? Else, just go
|
rtpPlayer.runSafely(() -> {
|
||||||
if (pWorld.getPlayerInfo().applyDelay && HelperRTP_Check.applyDelay(pWorld.getPlayer())) {
|
if (pWorld.getPlayerInfo().applyDelay && HelperRTP_Check.applyDelay(p)) {
|
||||||
new RTPDelay(sendi, rtpPlayer, delayTime, cancelOnMove, cancelOnDamage);
|
new RTPDelay(sendi, rtpPlayer, delayTime, cancelOnMove, cancelOnDamage);
|
||||||
} else {
|
} else {
|
||||||
if (!teleport.beforeTeleportInstant(sendi, p))
|
rtpPlayer.afterPreEvent(teleport.beforeTeleportInstant(sendi, p),
|
||||||
rtpPlayer.randomlyTeleport(sendi);
|
() -> rtpPlayer.randomlyTeleport(sendi));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private BetterRTP getPl() {
|
private BetterRTP getPl() {
|
||||||
+24
-10
@@ -22,15 +22,17 @@ class RTPDelay implements Listener {
|
|||||||
this.cancelOnMove = cancelOnMove;
|
this.cancelOnMove = cancelOnMove;
|
||||||
this.cancelOnDamage = cancelOnDamage;
|
this.cancelOnDamage = cancelOnDamage;
|
||||||
this.rtp = rtp;
|
this.rtp = rtp;
|
||||||
|
rtp.getOperation().onFinish(this::dispose);
|
||||||
delay(sendi, delay);
|
delay(sendi, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delay(CommandSender sendi, int delay) {
|
private void delay(CommandSender sendi, int delay) {
|
||||||
if (!getPl().getRTP().getTeleport().beforeTeleportDelay(rtp.getPlayer(), delay)) {
|
rtp.afterPreEvent(getPl().getRTP().getTeleport().beforeTeleportDelay(rtp.getPlayer(), delay), () -> {
|
||||||
task = AsyncHandler.syncLater(run(sendi, this), delay * 20L);
|
task = AsyncHandler.syncLater(run(sendi, this), delay * 20L);
|
||||||
if (cancelOnMove || cancelOnDamage)
|
if (cancelOnMove || cancelOnDamage)
|
||||||
Bukkit.getPluginManager().registerEvents(this, BetterRTP.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, BetterRTP.getInstance());
|
||||||
}
|
if (!rtp.isActive()) dispose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -57,23 +59,35 @@ class RTPDelay implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dispose() {
|
||||||
|
dispose(task, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dispose(WrappedTask task, Listener listener) {
|
||||||
|
try {
|
||||||
|
if (task != null) task.cancel();
|
||||||
|
} finally {
|
||||||
|
HandlerList.unregisterAll(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void cancel() {
|
private void cancel() {
|
||||||
if (task != null)
|
rtp.runSafely(() -> {
|
||||||
task.cancel();
|
try {
|
||||||
HandlerList.unregisterAll(this);
|
|
||||||
getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer());
|
getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer());
|
||||||
//getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
|
|
||||||
getPl().getCooldowns().removeCooldown(rtp.getPlayer(), rtp.worldPlayer.getWorld());
|
getPl().getCooldowns().removeCooldown(rtp.getPlayer(), rtp.worldPlayer.getWorld());
|
||||||
getPl().getPInfo().getRtping().remove(rtp.getPlayer());
|
} finally {
|
||||||
|
rtp.getOperation().finish();
|
||||||
|
}
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new RTP_CancelledEvent(rtp.getPlayer()));
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_CancelledEvent(rtp.getPlayer()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable run(final CommandSender sendi, final RTPDelay cls) {
|
private Runnable run(final CommandSender sendi, final RTPDelay cls) {
|
||||||
return () -> {
|
return () -> rtp.runSafely(() -> {
|
||||||
HandlerList.unregisterAll(cls);
|
HandlerList.unregisterAll(cls);
|
||||||
if (getPl().getPInfo().getRtping().containsKey(rtp.getPlayer()))
|
|
||||||
rtp.randomlyTeleport(sendi);
|
rtp.randomlyTeleport(sendi);
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private BetterRTP getPl() {
|
private BetterRTP getPl() {
|
||||||
File renamed without changes.
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/** Owns active requests. Identity checks prevent old callbacks from ending a newer request. */
|
||||||
|
public final class RTPOperationTracker {
|
||||||
|
private final Map<UUID, Operation> active = new HashMap<>();
|
||||||
|
|
||||||
|
public synchronized Operation start(UUID uuid, Object session) {
|
||||||
|
if (active.containsKey(uuid)) return null;
|
||||||
|
Operation operation = new Operation(uuid, session);
|
||||||
|
active.put(uuid, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean contains(UUID uuid) { return active.containsKey(uuid); }
|
||||||
|
|
||||||
|
public void cancel(UUID uuid, Object session) {
|
||||||
|
Operation operation;
|
||||||
|
synchronized (this) { operation = active.get(uuid); }
|
||||||
|
if (operation != null && operation.session == session) operation.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
List<Operation> operations;
|
||||||
|
synchronized (this) {
|
||||||
|
operations = new ArrayList<>(active.values());
|
||||||
|
active.clear();
|
||||||
|
}
|
||||||
|
RuntimeException failure = null;
|
||||||
|
for (Operation operation : operations) {
|
||||||
|
try { operation.finish(); } catch (RuntimeException ex) { failure = ex; }
|
||||||
|
}
|
||||||
|
if (failure != null) throw failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Operation {
|
||||||
|
private final UUID uuid;
|
||||||
|
private final Object session;
|
||||||
|
private final List<Runnable> cleanup = new ArrayList<>();
|
||||||
|
private boolean finished;
|
||||||
|
|
||||||
|
private Operation(UUID uuid, Object session) { this.uuid = uuid; this.session = session; }
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
synchronized (RTPOperationTracker.this) { return active.get(uuid) == this; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFinish(Runnable action) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (!finished) { cleanup.add(action); return; }
|
||||||
|
}
|
||||||
|
action.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finish() {
|
||||||
|
List<Runnable> actions;
|
||||||
|
synchronized (this) {
|
||||||
|
if (finished) return;
|
||||||
|
finished = true;
|
||||||
|
actions = new ArrayList<>(cleanup);
|
||||||
|
cleanup.clear();
|
||||||
|
}
|
||||||
|
synchronized (RTPOperationTracker.this) { active.remove(uuid, this); }
|
||||||
|
RuntimeException failure = null;
|
||||||
|
for (Runnable action : actions) {
|
||||||
|
try { action.run(); } catch (RuntimeException ex) { failure = ex; }
|
||||||
|
}
|
||||||
|
if (failure != null) throw failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Terminal future: cleanup also runs when result handling throws. */
|
||||||
|
public void complete(CompletableFuture<Boolean> future, Runnable success, Runnable failure,
|
||||||
|
Consumer<Throwable> errors) {
|
||||||
|
future.whenComplete((result, error) -> {
|
||||||
|
try {
|
||||||
|
if (!isActive()) return;
|
||||||
|
if (error != null) errors.accept(error);
|
||||||
|
else if (Boolean.TRUE.equals(result)) success.run();
|
||||||
|
else failure.run();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
errors.accept(ex);
|
||||||
|
} finally {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
-15
@@ -23,20 +23,56 @@ import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
|||||||
public class RTPPlayer {
|
public class RTPPlayer {
|
||||||
|
|
||||||
@Getter private final Player player;
|
@Getter private final Player player;
|
||||||
|
@Getter private final RTPOperationTracker.Operation operation;
|
||||||
private final RTP settings;
|
private final RTP settings;
|
||||||
@Getter WorldPlayer worldPlayer;
|
@Getter WorldPlayer worldPlayer;
|
||||||
@Getter RTP_TYPE type;
|
@Getter RTP_TYPE type;
|
||||||
@Getter int attempts;
|
@Getter int attempts;
|
||||||
//List<Location> attemptedLocations = new ArrayList<>();
|
//List<Location> attemptedLocations = new ArrayList<>();
|
||||||
|
|
||||||
RTPPlayer(Player player, RTP settings, WorldPlayer worldPlayer, RTP_TYPE type) {
|
RTPPlayer(Player player, RTP settings, WorldPlayer worldPlayer, RTP_TYPE type, RTPOperationTracker.Operation operation) {
|
||||||
|
this.operation = operation;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.worldPlayer = worldPlayer;
|
this.worldPlayer = worldPlayer;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isActive() {
|
||||||
|
if (!player.isOnline()) operation.finish();
|
||||||
|
return operation.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void logError(Throwable error) {
|
||||||
|
getPl().getLogger().log(java.util.logging.Level.WARNING, "RTP operation failed for " + player.getUniqueId(), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void runSafely(Runnable action) {
|
||||||
|
try {
|
||||||
|
if (isActive()) action.run();
|
||||||
|
} catch (Throwable error) {
|
||||||
|
try { operation.finish(); } finally { logError(error); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void afterPreEvent(boolean cancelled, Runnable continuation) {
|
||||||
|
if (cancelled) operation.finish();
|
||||||
|
else runSafely(continuation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void awaitChunk(CompletableFuture<Chunk> chunk, Runnable continuation) {
|
||||||
|
chunk.whenComplete((result, error) -> runSafely(() -> {
|
||||||
|
if (error != null) {
|
||||||
|
try { operation.finish(); } finally { logError(error); }
|
||||||
|
} else continuation.run();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
void randomlyTeleport(CommandSender sendi) {
|
void randomlyTeleport(CommandSender sendi) {
|
||||||
|
runSafely(() -> search(sendi));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void search(CommandSender sendi) {
|
||||||
if (attempts >= settings.maxAttempts) //Cancel out, too many tries
|
if (attempts >= settings.maxAttempts) //Cancel out, too many tries
|
||||||
metMax(sendi, player);
|
metMax(sendi, player);
|
||||||
else { //Try again to find a safe location
|
else { //Try again to find a safe location
|
||||||
@@ -45,11 +81,11 @@ public class RTPPlayer {
|
|||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
//Async Location finder
|
//Async Location finder
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
randomlyTeleport(sendi);
|
|
||||||
attempts++;
|
attempts++;
|
||||||
|
AsyncHandler.sync(() -> randomlyTeleport(sendi));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AsyncHandler.async(() -> {
|
AsyncHandler.async(() -> runSafely(() -> {
|
||||||
Location loc;
|
Location loc;
|
||||||
if (event.getLocation() != null) // && WorldPlayer.checkIsValid(event.getLocation(), pWorld))
|
if (event.getLocation() != null) // && WorldPlayer.checkIsValid(event.getLocation(), pWorld))
|
||||||
loc = event.getLocation();
|
loc = event.getLocation();
|
||||||
@@ -63,25 +99,21 @@ public class RTPPlayer {
|
|||||||
}
|
}
|
||||||
attempts++; //Add an attempt
|
attempts++; //Add an attempt
|
||||||
//Load chunk and find out if safe location (asynchronously)
|
//Load chunk and find out if safe location (asynchronously)
|
||||||
AsyncHandler.sync(() -> {
|
AsyncHandler.sync(() -> runSafely(() -> {
|
||||||
try { //Prior to 1.12 this async chunk will NOT work
|
try { //Prior to 1.12 this async chunk will NOT work
|
||||||
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(loc);
|
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(loc);
|
||||||
chunk.thenAccept(result -> {
|
awaitChunk(chunk, () -> attempt(sendi, loc));
|
||||||
//BetterRTP.debug("Checking location for " + p.getName());
|
|
||||||
attempt(sendi, loc);
|
|
||||||
});
|
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
//Legacy non-async support
|
//Legacy non-async support
|
||||||
attempt(sendi, loc);
|
attempt(sendi, loc);
|
||||||
} catch (Throwable ignored) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attempt(CommandSender sendi, Location loc) {
|
private void attempt(CommandSender sendi, Location loc) {
|
||||||
|
if (!isActive()) return;
|
||||||
Location tpLoc;
|
Location tpLoc;
|
||||||
tpLoc = RandomLocation.getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
tpLoc = RandomLocation.getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
||||||
//attemptedLocations.add(loc);
|
//attemptedLocations.add(loc);
|
||||||
@@ -94,11 +126,11 @@ public class RTPPlayer {
|
|||||||
getPl().getCooldowns().add(player, worldPlayer.getWorld());
|
getPl().getCooldowns().add(player, worldPlayer.getWorld());
|
||||||
tpLoc.setYaw(player.getLocation().getYaw());
|
tpLoc.setYaw(player.getLocation().getYaw());
|
||||||
tpLoc.setPitch(player.getLocation().getPitch());
|
tpLoc.setPitch(player.getLocation().getPitch());
|
||||||
AsyncHandler.sync(() -> settings.teleport.sendPlayer(sendi, player, tpLoc, worldPlayer, attempts, type));
|
AsyncHandler.sync(() -> runSafely(() -> settings.teleport.sendPlayer(sendi, this, tpLoc)));
|
||||||
} else {
|
} else {
|
||||||
if (worldPlayer.getPlayerInfo().applyCooldown)
|
if (worldPlayer.getPlayerInfo().applyCooldown)
|
||||||
getPl().getCooldowns().removeCooldown(player, worldPlayer.getWorld());
|
getPl().getCooldowns().removeCooldown(player, worldPlayer.getWorld());
|
||||||
getPl().getPInfo().getRtping().remove(player);
|
operation.finish();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
randomlyTeleport(sendi);
|
randomlyTeleport(sendi);
|
||||||
@@ -110,7 +142,7 @@ public class RTPPlayer {
|
|||||||
private void metMax(CommandSender sendi, Player p) {
|
private void metMax(CommandSender sendi, Player p) {
|
||||||
settings.teleport.failedTeleport(p, sendi);
|
settings.teleport.failedTeleport(p, sendi);
|
||||||
getPl().getCooldowns().removeCooldown(p, worldPlayer.getWorld());
|
getPl().getCooldowns().removeCooldown(p, worldPlayer.getWorld());
|
||||||
getPl().getPInfo().getRtping().remove(p);
|
operation.finish();
|
||||||
//RTP Failed Event
|
//RTP Failed Event
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new RTP_FailedEvent(this));
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_FailedEvent(this));
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
+13
-26
@@ -5,7 +5,6 @@ import java.util.Arrays;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
@@ -38,37 +37,25 @@ public class RTPTeleport {
|
|||||||
// CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).cancel(true);
|
// CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).cancel(true);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void sendPlayer(final CommandSender sendi, final Player p, final Location location, final WorldPlayer wPlayer,
|
void sendPlayer(CommandSender sendi, RTPPlayer request, Location location) {
|
||||||
final int attempts, RTP_TYPE type) throws NullPointerException {
|
Player p = request.getPlayer();
|
||||||
|
WorldPlayer wPlayer = request.getWorldPlayer();
|
||||||
|
int attempts = request.getAttempts();
|
||||||
|
RTP_TYPE type = request.getType();
|
||||||
Location oldLoc = p.getLocation();
|
Location oldLoc = p.getLocation();
|
||||||
loadingTeleport(p, sendi); //Send loading message to player who requested
|
loadingTeleport(p, sendi);
|
||||||
//List<CompletableFuture<Chunk>> asyncChunks = getChunks(location); //Get a list of chunks
|
|
||||||
//playerLoads.put(p, asyncChunks);
|
|
||||||
/*CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
|
||||||
new BukkitRunnable() { //Run synchronously
|
|
||||||
@Override
|
|
||||||
public void run() {*/
|
|
||||||
try {
|
|
||||||
RTP_TeleportEvent event = new RTP_TeleportEvent(p, location, wPlayer.getWorldtype());
|
RTP_TeleportEvent event = new RTP_TeleportEvent(p, location, wPlayer.getWorldtype());
|
||||||
getPl().getServer().getPluginManager().callEvent(event);
|
getPl().getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!request.isActive()) return;
|
||||||
Location loc = event.getLocation();
|
Location loc = event.getLocation();
|
||||||
PaperLib.teleportAsync(p, loc).thenRun(new BukkitRunnable() { //Async teleport
|
request.getOperation().complete(PaperLib.teleportAsync(p, loc), () -> {
|
||||||
@Override
|
if (!request.isActive()) return;
|
||||||
public void run() {
|
|
||||||
afterTeleport(p, loc, wPlayer, attempts, oldLoc, type);
|
afterTeleport(p, loc, wPlayer, attempts, oldLoc, type);
|
||||||
if (sendi != p) //Tell player who requested that the player rtp'd
|
if (sendi != p)
|
||||||
sendSuccessMsg(sendi, p.getName(), loc, wPlayer, false, attempts);
|
sendSuccessMsg(sendi, p.getName(), loc, wPlayer, false, attempts);
|
||||||
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing
|
if (type == RTP_TYPE.JOIN && getPl().getSettings().isRtpOnFirstJoin_SetAsRespawn())
|
||||||
//Save respawn location if first join
|
p.setBedSpawnLocation(loc, true);
|
||||||
if (type == RTP_TYPE.JOIN) //RTP Type was Join
|
}, () -> failedTeleport(p, sendi), request::logError);
|
||||||
if (BetterRTP.getInstance().getSettings().isRtpOnFirstJoin_SetAsRespawn()) //Save as respawn is enabled
|
|
||||||
p.setBedSpawnLocation(loc, true); //True means to force a respawn even without a valid bed
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing (errored)
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effects
|
//Effects
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4
-1
@@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
|||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@@ -52,8 +53,10 @@ public class RTPEffect_Potions { //Potions AND Invincibility
|
|||||||
|
|
||||||
public void giveEffects(Player p) {
|
public void giveEffects(Player p) {
|
||||||
AsyncHandler.syncAtEntity(p, () -> {
|
AsyncHandler.syncAtEntity(p, () -> {
|
||||||
|
PlayerData data = HelperPlayer.getData(p);
|
||||||
|
if (data == null) return;
|
||||||
if (invincibleEnabled)
|
if (invincibleEnabled)
|
||||||
HelperPlayer.getData(p).setInvincibleEndTime(System.currentTimeMillis() + (invincibleTime * 1000L));
|
data.setInvincibleEndTime(System.currentTimeMillis() + (invincibleTime * 1000L));
|
||||||
if (potionEnabled) {
|
if (potionEnabled) {
|
||||||
List<PotionEffect> effects = new ArrayList<>();
|
List<PotionEffect> effects = new ArrayList<>();
|
||||||
for (PotionEffectType e : potionEffects.keySet()) {
|
for (PotionEffectType e : potionEffects.keySet()) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-11
@@ -6,8 +6,6 @@ import com.comphenix.protocol.events.PacketContainer;
|
|||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public abstract class AbstractPacket {
|
public abstract class AbstractPacket {
|
||||||
// The packet we will be modifying
|
// The packet we will be modifying
|
||||||
protected PacketContainer handle;
|
protected PacketContainer handle;
|
||||||
@@ -42,15 +40,9 @@ public abstract class AbstractPacket {
|
|||||||
* Send the current packet to the given receiver.
|
* Send the current packet to the given receiver.
|
||||||
*
|
*
|
||||||
* @param receiver - the receiver.
|
* @param receiver - the receiver.
|
||||||
* @throws RuntimeException If the packet cannot be sent.
|
|
||||||
*/
|
*/
|
||||||
public void sendPacket(Player receiver) {
|
public void sendPacket(Player receiver) {
|
||||||
try {
|
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver, getHandle());
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
|
|
||||||
getHandle());
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new RuntimeException("Cannot send packet.", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +63,7 @@ public abstract class AbstractPacket {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void recievePacket(Player sender) {
|
public void recievePacket(Player sender) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
|
ProtocolLibrary.getProtocolManager().receiveClientPacket(sender,
|
||||||
getHandle());
|
getHandle());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Cannot recieve packet.", e);
|
throw new RuntimeException("Cannot recieve packet.", e);
|
||||||
@@ -86,7 +78,7 @@ public abstract class AbstractPacket {
|
|||||||
*/
|
*/
|
||||||
public void receivePacket(Player sender) {
|
public void receivePacket(Player sender) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
|
ProtocolLibrary.getProtocolManager().receiveClientPacket(sender,
|
||||||
getHandle());
|
getHandle());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Cannot receive packet.", e);
|
throw new RuntimeException("Cannot receive packet.", e);
|
||||||
File renamed without changes.
+3
-2
@@ -49,9 +49,10 @@ public interface PermissionCheck {
|
|||||||
|
|
||||||
String getNode();
|
String getNode();
|
||||||
|
|
||||||
|
@Getter
|
||||||
class PermissionResult {
|
class PermissionResult {
|
||||||
@Getter private final boolean passed;
|
private final boolean passed;
|
||||||
@Getter private final String string;
|
private final String string;
|
||||||
PermissionResult(String string, boolean passed) {
|
PermissionResult(String string, boolean passed) {
|
||||||
this.passed = passed;
|
this.passed = passed;
|
||||||
this.string = string;
|
this.string = string;
|
||||||
+3
-1
@@ -2,6 +2,7 @@ package me.SuperRonanCraft.BetterRTP.references;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum PermissionNode implements PermissionCheck {
|
public enum PermissionNode implements PermissionCheck {
|
||||||
|
|
||||||
ADMIN("admin"),
|
ADMIN("admin"),
|
||||||
@@ -21,11 +22,12 @@ public enum PermissionNode implements PermissionCheck {
|
|||||||
SIGN_CREATE("sign"),
|
SIGN_CREATE("sign"),
|
||||||
VERSION("version"),
|
VERSION("version"),
|
||||||
EDIT("edit"),
|
EDIT("edit"),
|
||||||
|
EDITOR("editor"),
|
||||||
LOCATION("location"),
|
LOCATION("location"),
|
||||||
DEVELOPER("DEVELOPER_PERM"),
|
DEVELOPER("DEVELOPER_PERM"),
|
||||||
;
|
;
|
||||||
|
|
||||||
@Getter private final String node;
|
private final String node;
|
||||||
|
|
||||||
PermissionNode(String node) {
|
PermissionNode(String node) {
|
||||||
this.node = PermissionCheck.getPrefix() + node;
|
this.node = PermissionCheck.getPrefix() + node;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.DepPerms;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class Permissions {
|
||||||
|
|
||||||
|
private final DepPerms depPerms = new DepPerms();
|
||||||
|
|
||||||
|
public void register() {
|
||||||
|
depPerms.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkPerm(String str, CommandSender sendi) {
|
||||||
|
return depPerms.hasPerm(str, sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+108
@@ -0,0 +1,108 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
|
||||||
|
public class DatabasePlayers extends SQLite {
|
||||||
|
|
||||||
|
public DatabasePlayers() {
|
||||||
|
super(DATABASE_TYPE.PLAYERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("Players");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
UUID("uuid", "varchar(32) PRIMARY KEY"),
|
||||||
|
//COOLDOWN DATA
|
||||||
|
COUNT("count", "long"),
|
||||||
|
LAST_COOLDOWN_DATE("last_rtp_date", "long"),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Immutable persistence values; never retains a Bukkit player/session. */
|
||||||
|
public static final class Snapshot {
|
||||||
|
public final UUID uuid;
|
||||||
|
public final int count;
|
||||||
|
public final long cooldown;
|
||||||
|
|
||||||
|
public Snapshot(UUID uuid, int count, long cooldown) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.count = count;
|
||||||
|
this.cooldown = cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snapshot capture(PlayerData data) {
|
||||||
|
return new Snapshot(data.player.getUniqueId(), data.getRtpCount(), data.getGlobalCooldown());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Existing API: load into this session only while it is still current. */
|
||||||
|
public void setupData(PlayerData data) {
|
||||||
|
if (data == null) return;
|
||||||
|
Snapshot stored = loadData(data.player.getUniqueId());
|
||||||
|
if (stored != null)
|
||||||
|
BetterRTP.getInstance().getPlayerDataManager().applyIfCurrent(data, current -> {
|
||||||
|
current.setRtpCount(stored.count);
|
||||||
|
current.setGlobalCooldown(stored.cooldown);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snapshot loadData(UUID uuid) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
try (Connection conn = getSQLConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + tables.get(0) + " WHERE " + COLUMNS.UUID.name + " = ?")) {
|
||||||
|
ps.setString(1, uuid.toString());
|
||||||
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
if (rs.next())
|
||||||
|
return new Snapshot(uuid, Math.toIntExact(rs.getLong(COLUMNS.COUNT.name)),
|
||||||
|
rs.getLong(COLUMNS.LAST_COOLDOWN_DATE.name));
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compatibility entry point: capture before deferring database work. */
|
||||||
|
public void setData(PlayerData data) {
|
||||||
|
if (data != null) setData(Snapshot.capture(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Snapshot data) {
|
||||||
|
SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "INSERT OR REPLACE INTO " + tables.get(0) + " ("
|
||||||
|
+ COLUMNS.UUID.name + ", " + COLUMNS.COUNT.name + ", "
|
||||||
|
+ COLUMNS.LAST_COOLDOWN_DATE.name + ") VALUES(?, ?, ?)";
|
||||||
|
List<Object> params = java.util.Arrays.asList(data.uuid.toString(), data.count, data.cooldown);
|
||||||
|
sqlUpdate(sql, params);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+184
@@ -0,0 +1,184 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueGenerator;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class DatabaseQueue extends SQLite {
|
||||||
|
|
||||||
|
public DatabaseQueue() {
|
||||||
|
super(DATABASE_TYPE.QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("Queue");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
ID("id", "integer PRIMARY KEY AUTOINCREMENT"),
|
||||||
|
//Location Data
|
||||||
|
X("x", "long"),
|
||||||
|
Z("z", "long"),
|
||||||
|
WORLD("world", "varchar(32)"),
|
||||||
|
GENERATED("generated", "long")
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void load() {
|
||||||
|
if (QueueHandler.isEnabled())
|
||||||
|
super.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<QueueData> getInRange(QueueRangeData range) {
|
||||||
|
final List<QueueData> queueDataList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement("SELECT * FROM " + tables.get(0) + " WHERE "
|
||||||
|
+ COLUMNS.WORLD.name + " = '" + range.getWorld().getName() + "' AND "
|
||||||
|
+ COLUMNS.X.name + " BETWEEN " + range.getXLow() + " AND " + range.getXHigh()
|
||||||
|
+ " AND " + COLUMNS.Z.name + " BETWEEN " + range.getZLow() + " AND " + range.getZHigh()
|
||||||
|
+ " ORDER BY RANDOM() LIMIT " + (QueueGenerator.queueMax + 1)
|
||||||
|
);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
long x = rs.getLong(COLUMNS.X.name);
|
||||||
|
long z = rs.getLong(COLUMNS.Z.name);
|
||||||
|
String worldName = rs.getString(COLUMNS.WORLD.name);
|
||||||
|
int id = rs.getInt(COLUMNS.ID.name);
|
||||||
|
long generated = rs.getLong(COLUMNS.GENERATED.name);
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if (world != null) {
|
||||||
|
queueDataList.add(new QueueData(new Location(world, x, 69, z), generated, id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, rs, conn);
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return queueDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set a queue to save
|
||||||
|
public QueueData addQueue(Location loc) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "INSERT INTO " + tables.get(0) + " ("
|
||||||
|
+ COLUMNS.X.name + ", "
|
||||||
|
+ COLUMNS.Z.name + ", "
|
||||||
|
+ COLUMNS.WORLD.name + ", "
|
||||||
|
+ COLUMNS.GENERATED.name + ") VALUES(?, ?, ?, ?)";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(loc.getBlockX());
|
||||||
|
add(loc.getBlockZ());
|
||||||
|
add(loc.getWorld().getName());
|
||||||
|
add(System.currentTimeMillis());
|
||||||
|
}};
|
||||||
|
int database_id = createQueue(sql, params);
|
||||||
|
return database_id >= 0 ? new QueueData(loc, System.currentTimeMillis(), database_id) : null;
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int createQueue(String statement, @NonNull List<Object> params) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
Iterator<Object> it = params.iterator();
|
||||||
|
int paramIndex = 1;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ps.setObject(paramIndex, it.next());
|
||||||
|
paramIndex++;
|
||||||
|
}
|
||||||
|
ps.executeUpdate();
|
||||||
|
ResultSet rs = ps.getGeneratedKeys();
|
||||||
|
if (rs.next()) {
|
||||||
|
id = rs.getInt(1);
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, null, conn);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeLocation(Location loc) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "DELETE FROM " + tables.get(0) + " WHERE "
|
||||||
|
+ COLUMNS.X.name + " = ? AND "
|
||||||
|
+ COLUMNS.Z.name + " = ? AND "
|
||||||
|
+ COLUMNS.WORLD.name + " = ?";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(loc.getBlockX());
|
||||||
|
add(loc.getBlockZ());
|
||||||
|
add(loc.getWorld().getName());
|
||||||
|
}};
|
||||||
|
return sqlUpdate(sql, params);
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class QueueRangeData {
|
||||||
|
|
||||||
|
int xLow, xHigh;
|
||||||
|
int zLow, zHigh;
|
||||||
|
World world;
|
||||||
|
|
||||||
|
public QueueRangeData(RTPWorld rtpWorld) {
|
||||||
|
this.xLow = rtpWorld.getCenterX() - rtpWorld.getMaxRadius();
|
||||||
|
this.xHigh = rtpWorld.getCenterX() + rtpWorld.getMaxRadius();
|
||||||
|
this.zLow = rtpWorld.getCenterZ() - rtpWorld.getMaxRadius();
|
||||||
|
this.zHigh = rtpWorld.getCenterZ() + rtpWorld.getMaxRadius();
|
||||||
|
this.world = rtpWorld.getWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class SQLiteExecutor {
|
||||||
|
public static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
@@ -39,6 +39,7 @@ public class DepPlaceholderAPI extends PlaceholderExpansion {
|
|||||||
@Override
|
@Override
|
||||||
public String onPlaceholderRequest(Player player, String request) {
|
public String onPlaceholderRequest(Player player, String request) {
|
||||||
PlayerData data = HelperPlayer.getData(player);
|
PlayerData data = HelperPlayer.getData(player);
|
||||||
|
if (data == null) return null;
|
||||||
if (request.equalsIgnoreCase("count")) {
|
if (request.equalsIgnoreCase("count")) {
|
||||||
return String.valueOf(data.getRtpCount());
|
return String.valueOf(data.getRtpCount());
|
||||||
} else if (request.startsWith("cooldown")) {
|
} else if (request.startsWith("cooldown")) {
|
||||||
+5
-3
@@ -3,11 +3,13 @@ package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.settings.SoftDepends;
|
import me.SuperRonanCraft.BetterRTP.references.settings.SoftDepends;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum REGIONPLUGINS {
|
public enum REGIONPLUGINS {
|
||||||
FACTIONSUUID("FactionsUUID", "Factions", new RTP_FactionsUUID()),
|
FACTIONSUUID("FactionsUUID", "Factions", new RTP_FactionsUUID()),
|
||||||
GRIEFDEFENDER("GriefDefender", new RTP_GriefDefender()),
|
GRIEFDEFENDER("GriefDefender", new RTP_GriefDefender()),
|
||||||
GRIEFPREVENTION("GriefPrevention", new RTP_GriefPrevention()),
|
GRIEFPREVENTION("GriefPrevention", new RTP_GriefPrevention()),
|
||||||
HCLAIMS("hClaims", "hClaim", new RTP_hClaims()),
|
HCLAIMS("hClaims", "hClaim", new RTP_hClaims()),
|
||||||
|
HUSKCLAIMS("HuskClaims", new RTP_HuskClaims()),
|
||||||
HUSKTOWNS("HuskTowns", new RTP_HuskTowns()),
|
HUSKTOWNS("HuskTowns", new RTP_HuskTowns()),
|
||||||
KINGDOMSX("KingdomsX", "Kingdoms", new RTP_KingdomsX()),
|
KINGDOMSX("KingdomsX", "Kingdoms", new RTP_KingdomsX()),
|
||||||
LANDS("Lands", new RTP_Lands()),
|
LANDS("Lands", new RTP_Lands()),
|
||||||
@@ -22,9 +24,9 @@ public enum REGIONPLUGINS {
|
|||||||
FACTIONSBRIDGE("FactionsBridge", new RTP_FactionsBridge()),
|
FACTIONSBRIDGE("FactionsBridge", new RTP_FactionsBridge()),
|
||||||
CRASH_CLAIM("CrashClaim", new RTP_CrashClaim());
|
CRASH_CLAIM("CrashClaim", new RTP_CrashClaim());
|
||||||
|
|
||||||
@Getter private final SoftDepends.RegionPlugin plugin = new SoftDepends.RegionPlugin();
|
private final SoftDepends.RegionPlugin plugin = new SoftDepends.RegionPlugin();
|
||||||
@Getter private final String setting_name, pluginyml_name;
|
private final String setting_name, pluginyml_name;
|
||||||
@Getter private final RegionPluginCheck validator;
|
private final RegionPluginCheck validator;
|
||||||
|
|
||||||
REGIONPLUGINS(String all_name, RegionPluginCheck validator) {
|
REGIONPLUGINS(String all_name, RegionPluginCheck validator) {
|
||||||
this(all_name, all_name, validator);
|
this(all_name, all_name, validator);
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import net.william278.huskclaims.BukkitHuskClaims;
|
||||||
|
import net.william278.huskclaims.api.BukkitHuskClaimsAPI;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_HuskClaims implements RegionPluginCheck {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.HUSKCLAIMS.isEnabled()) {
|
||||||
|
try {
|
||||||
|
result = !BukkitHuskClaimsAPI.getInstance().getClaimAt(BukkitHuskClaims.Adapter.adapt(loc)).isPresent();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
-6
@@ -1,21 +1,20 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
import net.william278.husktowns.api.HuskTownsAPI;
|
import net.william278.husktowns.api.BukkitHuskTownsAPI;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class RTP_HuskTowns implements RegionPluginCheck {
|
public class RTP_HuskTowns implements RegionPluginCheck {
|
||||||
|
|
||||||
// NOT TESTED (3.4.5)
|
@Override
|
||||||
// HuskTowns (v1.8.1)
|
|
||||||
// https://www.spigotmc.org/resources/husktowns.92672/
|
|
||||||
public boolean check(Location loc) {
|
public boolean check(Location loc) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
if (REGIONPLUGINS.HUSKTOWNS.isEnabled())
|
if (REGIONPLUGINS.HUSKTOWNS.isEnabled()) {
|
||||||
try {
|
try {
|
||||||
result = !HuskTownsAPI.getInstance().getClaimAt(loc).isPresent();
|
result = !BukkitHuskTownsAPI.getInstance().getClaimAt(loc).isPresent();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 241 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user