66 Commits

Author SHA1 Message Date
Joseph Robinson
3fb74607bd Update SECURITY.md 2020-04-05 17:51:19 -07:00
Joseph Robinson
fa135a1a22 Update SECURITY.md 2020-04-05 17:46:12 -07:00
cakoyo
0822c65af8 Merge pull request #149 from tsao-chi-fork/tsao-chi-patch-1
fix url
2020-04-03 15:47:17 +07:00
ㄗㄠˋ ㄑㄧˊ
740e47df67 fix url 2020-04-03 16:18:50 +08:00
Joseph Robinson
4e6d4be087 Create SECURITY.md 2020-04-02 00:22:00 -07:00
Joseph Robinson
5aaa3815fd Merge pull request #125 from tsao-chi/patch-2
typo?
2020-04-01 10:54:48 -07:00
Joseph Robinson
3ffb622a36 Added spigot repo 2020-03-31 13:30:56 -07:00
Joseph Robinson
7f0d3d441c Update README.md - Linted 2020-03-29 10:41:25 -07:00
Joseph Robinson
818ec7912c Fixed distribution error 2020-03-29 10:28:19 -07:00
Joseph Robinson
8c4adc5eb5 Merge branch 'master' of https://github.com/Akarin-project/Akarin 2020-03-28 21:50:38 -07:00
Joseph Robinson
7be85efd51 Added gradlebuild.sh 2020-03-28 18:32:01 -07:00
Joseph Robinson
9313f9d557 Updated checksums? 2020-03-28 17:15:39 -07:00
Joseph Robinson
aeec043ef1 removed copy of build.sh 2020-03-28 17:15:27 -07:00
Joseph Robinson
86631090a7 updated gradle 2020-03-28 17:14:17 -07:00
ㄗㄠˋ ㄑㄧˊ
4c6947d949 typo? 2020-03-28 21:12:13 +08:00
Joseph Robinson
82d21e2156 Update README.md 2020-03-26 17:35:19 -07:00
Joseph Robinson
bd6a6a4af2 Update README.md 2020-03-26 17:29:29 -07:00
Joseph Robinson
f95d397ee1 Update README.md 2020-03-26 17:26:02 -07:00
Joseph Robinson
c47fa0e78c Merge pull request #121 from LegacyGamerHD/patch-5
update the link
2020-03-19 10:36:20 -07:00
LegacyGamerHD
a70eb4415c Update README.md 2020-03-19 18:35:47 +01:00
Joseph Robinson
21713af0a0 Update README.md 2020-03-19 10:33:39 -07:00
Joseph Robinson
5bb3faf096 Update README.md 2020-03-18 19:53:43 -07:00
Joseph Robinson
b8e12697cc Merge pull request #118 from tsao-chi/patch-1
Rebrand (fix #109)
2020-03-16 09:16:26 -07:00
ㄗㄠˋ ㄑㄧˊ
0917583727 net.minecraft.server.MinecraftServer: Rebrand 2020-03-16 16:27:28 +08:00
ㄗㄠˋ ㄑㄧˊ
74d7463012 org.bukkit.craftbukkit.CraftServer: Rebrand 2020-03-16 16:25:37 +08:00
Joseph Robinson
c50dd7660f updated gradle to 6.2.2 2020-03-06 22:04:16 -07:00
Joseph Robinson
2e6ed47fc3 Updated build.gradle 2020-03-06 22:02:37 -07:00
Joseph Robinson
ff11917fde Merge pull request #112 from Akarin-project/gradle
Gradle
2020-03-06 22:01:23 -07:00
Joseph Robinson
fb0fb08ca9 Merge pull request #116 from Akarin-project/master
Updated gradle branch with master
2020-03-06 22:01:08 -07:00
Joseph Robinson
d996e03194 Revert "Merge branch 'master' of https://github.com/Akarin-project/Akarin"
This reverts commit d21f1ae0f7.
2020-03-06 21:47:22 -07:00
Joseph Robinson
0fc67cb84b Revert "changes suggested by @liach"
This reverts commit d9c7c27de2.
2020-03-06 21:46:16 -07:00
Joseph Robinson
d9c7c27de2 changes suggested by @liach 2020-03-06 21:35:40 -07:00
Joseph Robinson
d21f1ae0f7 Merge branch 'master' of https://github.com/Akarin-project/Akarin 2020-03-06 21:32:41 -07:00
Joseph Robinson
cfedff9496 Merge pull request #115 from Akarin-project/master
Added new gitignore to gradle branch
2020-03-06 21:31:42 -07:00
Joseph Robinson
8ee8f1125a Merge pull request #113 from Akarin-project/gitignore-update
Update .gitignore
2020-03-06 21:30:08 -07:00
Joseph Robinson
77f5c39f45 Merge pull request #114 from josephworks/master
Updated Gradle to last ver of gradle 5
2020-03-06 14:23:56 -07:00
Joseph Robinson
dcda956eb9 Updated Gradle to last ver of gradle 5 2020-03-06 14:20:47 -07:00
Joseph Robinson
3eae763c37 Update .gitignore 2020-03-06 14:14:20 -07:00
Joseph Robinson
673af6e6ce Merge pull request #111 from josephworks/master
Added Gradle
2020-03-06 14:05:12 -07:00
Joseph Robinson
1773ae99c0 Added Gradle 2020-03-06 14:01:58 -07:00
Joseph Robinson
eedfeffb32 Merge branch 'master' of https://github.com/Akarin-project/Akarin 2020-03-01 13:22:16 -07:00
Joseph Robinson
9b0e0440fa double [] for scripts 2020-03-01 13:19:05 -07:00
Joseph Robinson
c462bfc444 Updated EULA.java 2020-03-01 13:18:10 -07:00
Joseph Robinson
a3e57ec664 Merge pull request #108 from josephworks/master
Update EULA.java
2020-03-01 13:15:44 -07:00
Joseph Robinson
f303f0429a Update EULA.java 2020-03-01 13:15:04 -07:00
Joseph Robinson
9001462a77 Updated donation text 2020-03-01 10:19:18 -07:00
cakoyo
603e6030f5 Merge pull request #105 from WhyDoWeWonder/hacky-build
Workaround to Make Akarin Build
2020-02-17 11:10:50 +07:00
WhyDoWeWonder
1a5e7ff422 Debugging code
Trying to get it to build properly, just some debugging code
2020-02-14 20:04:37 -05:00
WhyDoWeWonder
1e5930ff4f Workaround to Make Project Build
Quick and Dirty hacks to get Akarin to build on the rbuild server.
2020-02-14 19:30:45 -05:00
cakoyo
89d7ca75b2 Merge pull request #100 from Akarin-project/dependabot/maven/io.netty-netty-all-4.1.42.Final
Bump netty-all from 4.1.35.Final-SNAPSHOT to 4.1.42.Final
2020-02-01 06:05:17 +07:00
Mgazul
0c27784fc2 Merge pull request #102 from braddevans/patch-1
fix compile from fresh git clone
2019-12-21 07:26:52 +08:00
Mgazul
0f4d9dbcc6 Merge pull request #103 from braddevans/master
update campfire to the latest 1.14.4 version from craftbukkit
2019-12-21 07:26:29 +08:00
bradd evans
cf9ddb81d4 update ci build 2019-12-20 17:15:16 +00:00
braddevans
51703b3300 fix travis.yml build 2019-12-20 17:10:51 +00:00
bradd evans
5c9567e797 update campfire to the latest 1.14.4 version on craftbukkit
update pom.xml to use a repo with almost every single lib you would ever need since nallar has been down for a year
update maven command to fully skip tests propperly
update work/paper
2019-12-20 16:58:56 +00:00
braddevans
e75ae756d7 fix compile from fresh git clone
fix compile
2019-12-20 14:52:18 +00:00
Mgazul
d1569d7502 Merge pull request #101 from LegacyGamerHD/patch-2
fix circleci and travis starting
2019-11-29 13:42:29 +08:00
LegacyGamerHD
e39a36bd42 Update .travis.yml 2019-11-22 23:41:07 -08:00
LegacyGamerHD
f726349f27 fix travis 2019-11-22 23:31:25 -08:00
LegacyGamerHD
f13789ac6a fix circleci 2019-11-22 23:29:23 -08:00
Mgazul
80713fe0ac api 2019-11-22 23:06:18 +08:00
Mgazul
e24a0066a3 1.14.4 2019-11-22 22:45:47 +08:00
Mgazul
c08e6988a0 add Paper-1.14.4 2019-11-22 20:24:58 +08:00
Mgazul
e08e69fba1 Delete .gitmodules 2019-11-22 20:19:05 +08:00
Mgazul
e7bd70d7cf Delete Paper 2019-11-22 20:15:38 +08:00
dependabot[bot]
dc96116b8e Bump netty-all from 4.1.35.Final-SNAPSHOT to 4.1.42.Final
Bumps [netty-all](https://github.com/netty/netty) from 4.1.35.Final-SNAPSHOT to 4.1.42.Final.
- [Release notes](https://github.com/netty/netty/releases)
- [Commits](https://github.com/netty/netty/commits/netty-4.1.42.Final)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-02 10:06:16 +00:00
1505 changed files with 71516 additions and 60404 deletions

49
.circleci/config.yml Normal file
View File

@@ -0,0 +1,49 @@
version: 2
jobs:
build:
working_directory: ~/Akarin-project/Akarin
parallelism: 1
shell: /bin/bash --login
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
docker:
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
run: sudo service postgresql start
steps:
# Machine Setup
- checkout
# Prepare for artifact
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- run:
working_directory: ~/Akarin-project/Akarin
command: sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java; sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac; echo -e "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> $BASH_ENV
# Dependencies
# Restore the dependency cache
- restore_cache:
keys:
# This branch if available
- v1-dep-{{ .Branch }}-
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
- v1-dep-
- run: git config --global user.email "circle@circleci.com"
- run: git config --global user.name "CircleCI"
- run: chmod -Rv +x scripts/
- run: ./scripts/build.sh
- run: ./scripts/inst.sh --setup --remote
# Save dependency cache
- save_cache:
key: v1-dep-{{ .Branch }}-{{ epoch }}
paths:
- ~/.m2
# Test
- run: yes|cp -rf ./akarin-*.jar $CIRCLE_ARTIFACTS
# Teardown
# Save test results
- store_test_results:
path: /tmp/circleci-test-results
# Save artifacts
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results

2
.gitmodules vendored
View File

@@ -1,4 +1,4 @@
[submodule "work/Paper"]
path = work/Paper
url = https://github.com/PaperMC/Paper.git
branch = master
branch = ver/1.14

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,2 @@
#Sat Mar 28 16:11:26 MST 2020
gradle.version=6.2.2

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

25
.travis.yml Normal file
View File

@@ -0,0 +1,25 @@
language: java
dist: trusty
jdk:
- oraclejdk8
install: true
script:
- git config --global user.email "circle@circleci.com"
- git config --global user.name "CircleCI"
- chmod -Rv +x scripts/
- ./scripts/build.sh
- ./scripts/inst.sh --setup --remote
after_success:
- rm -rf push
- mkdir push
- cp ./target/*.jar ./push/
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: $Github_token
file:
- ./push/*
file_glob: true
on:
tags: true

24
Jenkinsfile vendored
View File

@@ -1,24 +0,0 @@
pipeline {
agent any
stages {
stage('Init Submodules') {
steps {
sh 'git submodule update --init --recursive'
}
}
stage('Build') {
steps {
sh 'bash ./scripts/build.sh'
sh 'bash ./scripts/inst.sh --setup --fast'
}
}
stage('Archive') {
steps {
archiveArtifacts(artifacts: '*.jar', fingerprint: true)
}
}
}
}

View File

@@ -1,14 +1,17 @@
# <img src="https://i.loli.net/2018/05/17/5afd869c443ef.png" alt="Akarin Face" align="right">Akarin
[![Powered by](https://img.shields.io/badge/Powered_by-Akarin_project-ee6aa7.svg?style=flat)](https://akarin.io)
[![Powered by](https://img.shields.io/badge/Powered_by-Akarin_project-ee6aa7.svg?style=flat)](https://akarin.app/)
[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/fw2pJAj)
[![bStats](https://img.shields.io/badge/bStats-Torch-0099ff.svg?style=flat)](https://bstats.org/plugin/bukkit/Torch)
![Jenkins](https://img.shields.io/jenkins/build?jobUrl=http%3A%2F%2Fci.josephworks.net%2Fjob%2FAkarin%2Fjob%2Fver%25252F1.13.2%2F)
[![Patreon](https://img.shields.io/badge/Patreon-donate_us-yellow.svg?style=flat)](https://www.patreon.com/akarinproject)
[![Build Status](http://josephworks.ddns.net:8080/job/Akarin-project/job/Akarin/badge/icon)](http://josephworks.ddns.net:8080/job/Akarin-project/job/Akarin/)
[![Patreon](https://img.shields.io/badge/Patreon-Donate-yellow.svg?style=flat)](https://www.patreon.com/akarinproject)
[![Circle CI](https://circleci.com/gh/Akarin-project/Akarin/tree/master.svg?style=svg)](https://circleci.com/gh/Akarin-project/Akarin)
Akarin is currently **under heavy development** and contributions are welcome!
Introduction
---
> Akarin is a powerful server software from the 'new dimension', formerly known as Torch.
As a [Paper](https://github.com/PaperMC/Paper) fork, it should support almost all plugins that work on [Spigot](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse).
@@ -16,44 +19,57 @@ As a [Paper](https://github.com/PaperMC/Paper) fork, it should support almost al
Our project has a few key goals:
* **Open Access** - Make more game mechanics configurable.
* **Bedrock** - Make the server more safe and stable.
* **Bedrock** - Make the server more safe and stable.
* **Fast** - Simplify the logic and implement multi-threaded computing.
*Issues and Pull Requests will be labeled accordingly*
Get Akarin
---
### Download
#### Recommended
+ [**JosephWorks Jenkins**](http://ci.josephworks.net/job/Akarin)
+ [**Circle CI**](https://circleci.com/gh/Akarin-project/Akarin/tree/ver/master) - Checkout the 'Artifacts' tab of the latest build *Login required*
+ [**JosephWorks Jenkins**](http://josephworks.ddns.net:8080/job/Akarin-project/job/Akarin/)
+ [**Melon Jenkins**](https://ci.melon.cat/job/Akarin/) - Offline
*Open an [Issue](https://github.com/Akarin-project/Akarin/issues) or a [Pull Request](https://github.com/Akarin-project/Akarin/pulls) if you want to add your website here*
### Build
#### Requirements
* Java (JDK) 8 or above
* Maven
#### Compile
```sh
chmod -Rv a+x scripts/
./scripts/build.sh
./scripts/inst.sh --setup --fast
```
**Notes**
* You must use `--setup` at least once to deploy necessary dependencies otherwise some imports cannot be organized.
* For non-modified projects, it is recommended to add the `--fast` option to skip any tests.
* If your machine has insufficient memory, you may want to add the `--remote` option to avoid decompiling locally.
Demo Servers
---
* [Fair Server](https://fairserver.ru)
* [LoyaltyMC](https://minecraft-mp.com/server-s212077)
* [LoyaltyMC](https://www.loyaltymc.net/)
* ~~`demo.akarin.io` (official)~~
*Open an [Issue](https://github.com/Akarin-project/Akarin/issues) or a [Pull Request](https://github.com/Akarin-project/Akarin/pulls) if you want to add your website here*
Contributing
---
* You can checkout the `src` folder to see more. Please follow the patch style to do any change, so we are able to update between different Minecraft versions.
* Add your name to the [LICENSE](https://github.com/Akarin-project/Akarin/blob/master/LICENSE.md) if you want to publish your code under the [MIT License](https://github.com/Akarin-project/Akarin/blob/master/licenses/MIT.md).
* If you want to join the [Akarin-project](https://github.com/Akarin-project) team, you can [send](mailto://kira@kira.moe) us an email with your experience and necessary information.

22
SECURITY.md Normal file
View File

@@ -0,0 +1,22 @@
# Security Policy
## Supported Versions
The checked versions below are supported by us.
| Version | Supported | Notes |
| ------- | ------------------ | -------------- |
| 1.15.2 | :white_check_mark: | Latest Build |
| 1.14.4 | :white_check_mark: | Newer Build* |
| 1.13.2 | :x: | No Support |
| 1.12.2 | :white_check_mark: | LTS Build only |
Newer Build - Up to 20 commits behind or 5 jenkins builds.
No Support - You will be prompted to upgrade to 1.14.4.
LTS Build only - Provided in the releases tab on GitHub.
## Reporting an Issue
Have a problem, feel free to [create an issue](https://github.com/Akarin-project/Akarin/issues) or [ask us on discord](https://discord.gg/dX8MMvP)!

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>akarin-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>

View File

@@ -1,17 +0,0 @@
package co.aikar.timings;
public class ThreadAssertion {
private static boolean mainThread;
public static boolean is() {
return mainThread;
}
static void start() {
mainThread = true;
}
public static void close() {
mainThread = false;
}
}

View File

@@ -23,8 +23,8 @@
*/
package co.aikar.timings;
import javax.annotation.Nonnull; // Akarin - javax.annotation
import javax.annotation.Nullable; // Akarin - javax.annotation
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Provides an ability to time sections of code within the Minecraft Server
@@ -35,10 +35,8 @@ public interface Timing extends AutoCloseable {
*
* @return Timing
*/
@Nonnull // Akarin - javax.annotation
@NotNull
Timing startTiming();
default Timing startTiming(boolean assertThread) { return startTiming(); }; // Akarin
default Timing startTimingUnsafe() { return startTiming(); }; // Akarin
/**
* <p>Stops timing and records the data. Propagates the data up to group handlers.</p>
@@ -46,7 +44,6 @@ public interface Timing extends AutoCloseable {
* Will automatically be called when this Timing is used with try-with-resources
*/
void stopTiming();
default void stopTimingUnsafe() { stopTiming(); }; // Akarin
/**
* Starts timing the execution until {@link #stopTiming()} is called.
@@ -55,9 +52,8 @@ public interface Timing extends AutoCloseable {
*
* @return Timing
*/
@Nonnull // Akarin - javax.annotation
@NotNull
Timing startTimingIfSync();
default Timing startTimingIfSync(boolean assertThread) { return startTimingIfSync(); }; // Akarin
/**
* <p>Stops timing and records the data. Propagates the data up to group handlers.</p>

View File

@@ -24,7 +24,6 @@
package co.aikar.timings;
import co.aikar.util.LoadingIntMap;
import io.akarin.server.core.AkarinGlobalConfig;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.ArrayDeque;
@@ -33,10 +32,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull; // Akarin - javax.annotation
import javax.annotation.Nullable; // Akarin - javax.annotation
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class TimingHandler implements Timing {
@@ -50,6 +48,7 @@ class TimingHandler implements Timing {
private final Int2ObjectOpenHashMap<TimingData> children = new LoadingIntMap<>(TimingData::new);
final TimingData record;
private TimingHandler startParent;
private final TimingHandler groupHandler;
private long start = 0;
@@ -58,7 +57,7 @@ class TimingHandler implements Timing {
private boolean timed;
private boolean enabled;
TimingHandler(@Nonnull TimingIdentifier id) { // Akarin - javax.annotation
TimingHandler(@NotNull TimingIdentifier id) {
this.identifier = id;
this.verbose = id.name.startsWith("##");
this.record = new TimingData(this.id);
@@ -85,17 +84,10 @@ class TimingHandler implements Timing {
}
}
@Nonnull // Akarin - javax.annotation
@NotNull
@Override
public Timing startTimingIfSync() {
// Akarin start
return startTiming(false);
}
@Nonnull // Akarin - javax.annotation
@Override
public Timing startTimingIfSync(boolean assertThread) {
startTiming(assertThread);
// Akarin end
startTiming();
return this;
}
@@ -104,70 +96,49 @@ class TimingHandler implements Timing {
stopTiming();
}
@Nonnull // Akarin - javax.annotation
@NotNull
public Timing startTiming() {
// Akarin start
return startTiming(false);
}
@Override
public Timing startTimingUnsafe() {
if (enabled && ++timingDepth == 1) {
ThreadAssertion.close();
// Akarin end
start = System.nanoTime();
TIMING_STACK.addLast(this);
if (!enabled || !Bukkit.isPrimaryThread()) {
return this;
}
if (++timingDepth == 1) {
startParent = TIMING_STACK.peekLast();
start = System.nanoTime();
}
TIMING_STACK.addLast(this);
return this;
}
// Akarin start
@Override
public Timing startTiming(boolean assertThread) {
if (enabled && (ThreadAssertion.is() || Bukkit.isPrimaryThread()) && ++timingDepth == 1) {
start = System.nanoTime();
TIMING_STACK.addLast(this);
if (assertThread && AkarinGlobalConfig.lazyThreadAssertion)
ThreadAssertion.start();
}
return this;
}
@Override
public void stopTimingUnsafe() {
if (enabled && timingDepth > 0 && --timingDepth == 0 && start != 0) {
TimingHandler last = TIMING_STACK.removeLast();
if (last != this) {
Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to Paper! ( " + this.identifier + ":" + last +")", new Throwable());
TIMING_STACK.addLast(last); // Add it back
}
addDiff(System.nanoTime() - start, TIMING_STACK.peekLast());
start = 0;
ThreadAssertion.close();
}
}
// Akarin end
public void stopTiming() {
if (enabled && timingDepth > 0 && (ThreadAssertion.is() || Bukkit.isPrimaryThread()) && --timingDepth == 0 && start != 0) { // Akarin
TimingHandler last;
while ((last = TIMING_STACK.removeLast()) != this) {
last.timingDepth = 0;
String reportTo;
if ("minecraft".equals(last.identifier.group)) {
reportTo = "Paper! This is a potential bug in Paper";
} else {
reportTo = "the plugin " + last.identifier.group + "(Look for errors above this in the logs)";
}
Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to " + reportTo + " (" + last.identifier +" did not stopTiming)", new Throwable());
}
addDiff(System.nanoTime() - start, TIMING_STACK.peekLast());
if (!enabled || timingDepth <= 0 || start == 0 || !Bukkit.isPrimaryThread()) {
return;
}
popTimingStack();
if (--timingDepth == 0) {
addDiff(System.nanoTime() - start, startParent);
startParent = null;
start = 0;
// Akarin start
if (AkarinGlobalConfig.lazyThreadAssertion)
ThreadAssertion.close();
// Akarin end
}
}
private void popTimingStack() {
TimingHandler last;
while ((last = TIMING_STACK.removeLast()) != this) {
last.timingDepth = 0;
String reportTo;
if ("Minecraft".equalsIgnoreCase(last.identifier.group)) {
reportTo = "Paper! This is a potential bug in Paper";
} else {
reportTo = "the plugin " + last.identifier.group + "(Look for errors above this in the logs)";
}
Logger.getGlobal().log(Level.SEVERE, "TIMING_STACK_CORRUPTION - Report this to " + reportTo + " (" + last.identifier + " did not stopTiming)", new Throwable());
boolean found = TIMING_STACK.contains(this);
if (!found) {
// We aren't even in the stack... Don't pop everything
TIMING_STACK.addLast(last);
break;
}
}
}
@@ -208,7 +179,7 @@ class TimingHandler implements Timing {
checkEnabled();
}
@Nonnull // Akarin - javax.annotation
@NotNull
@Override
public TimingHandler getTimingHandler() {
return this;
@@ -229,7 +200,7 @@ class TimingHandler implements Timing {
*/
@Override
public void close() {
if (ThreadAssertion.is()) stopTimingUnsafe(); else stopTimingIfSync(); // Akarin
stopTimingIfSync();
}
public boolean isSpecial() {
@@ -244,7 +215,7 @@ class TimingHandler implements Timing {
return enabled;
}
@Nonnull // Akarin - javax.annotation
@NotNull
TimingData[] cloneChildren() {
final TimingData[] clonedChildren = new TimingData[children.size()];
int i = 0;

View File

@@ -144,7 +144,7 @@ public class TimingHistory {
public JSONPair apply(Map.Entry<EntityType, Counter> entry) {
entityTypeSet.add(entry.getKey());
return pair(
String.valueOf(entry.getKey().getTypeId()),
String.valueOf(entry.getKey().ordinal()),
entry.getValue().count()
);
}
@@ -157,7 +157,7 @@ public class TimingHistory {
public JSONPair apply(Map.Entry<Material, Counter> entry) {
tileEntityTypeSet.add(entry.getKey());
return pair(
String.valueOf(entry.getKey().getId()),
String.valueOf(entry.getKey().ordinal()),
entry.getValue().count()
);
}

View File

@@ -111,7 +111,7 @@ class TimingsExport extends Thread {
);
if (!TimingsManager.privacy) {
appendObjectData(parent,
pair("server", Bukkit.getServerName()),
pair("server", Bukkit.getUnsafe().getTimingsServerName()),
pair("motd", Bukkit.getServer().getMotd()),
pair("online-mode", Bukkit.getServer().getOnlineMode()),
pair("icon", Bukkit.getServer().getServerIcon().getData())
@@ -184,9 +184,9 @@ class TimingsExport extends Thread {
pair("handlers", handlers),
pair("worlds", toObjectMapper(TimingHistory.worldMap.entrySet(), input -> pair(input.getValue(), input.getKey()))),
pair("tileentity",
toObjectMapper(tileEntityTypeSet, input -> pair(input.getId(), input.name()))),
toObjectMapper(tileEntityTypeSet, input -> pair(input.ordinal(), input.name()))),
pair("entity",
toObjectMapper(entityTypeSet, input -> pair(input.getTypeId(), input.name())))
toObjectMapper(entityTypeSet, input -> pair(input.ordinal(), input.name())))
));
// Information about loaded plugins
@@ -288,8 +288,8 @@ class TimingsExport extends Thread {
String hostName = "BrokenHost";
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch(Exception ignored) {}
con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getServerName() + "/" + hostName);
} catch (Exception ignored) {}
con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getUnsafe().getTimingsServerName() + "/" + hostName);
con.setRequestMethod("POST");
con.setInstanceFollowRedirects(false);

View File

@@ -0,0 +1,35 @@
package com.destroystokyo.paper;
import org.bukkit.World;
/**
* Enumeration of different heightmap types maintained by the server. Generally using these maps is much faster
* than using an iterative search for a block in a given x, z coordinate.
*/
public enum HeightmapType {
/**
* The highest block used for lighting in the world. Also the block returned by {@link World#getHighestBlockYAt(int, int)}}
*/
LIGHT_BLOCKING,
/**
* References the highest block in the world.
*/
ANY,
/**
* References the highest solid block in a world.
*/
SOLID,
/**
* References the highest solid or liquid block in a world.
*/
SOLID_OR_LIQUID,
/**
* References the highest solid or liquid block in a world, excluding leaves.
*/
SOLID_OR_LIQUID_NO_LEAVES;
}

View File

@@ -100,14 +100,6 @@ public class MaterialTags {
*/
public static final MaterialSetTag DYES = new MaterialSetTag(keyFor("dyes"))
.endsWith("_DYE")
.add(Material.BONE_MEAL,
Material.CACTUS_GREEN,
Material.COCOA_BEANS,
Material.DANDELION_YELLOW,
Material.INK_SAC,
Material.LAPIS_LAZULI,
Material.ROSE_RED
)
.ensureSize("DYES", 16);
/**
@@ -181,7 +173,7 @@ public class MaterialTags {
*/
public static final MaterialSetTag HORSE_ARMORS = new MaterialSetTag(keyFor("horse_armors"))
.endsWith("_HORSE_ARMOR")
.ensureSize("HORSE_ARMORS", 3);
.ensureSize("HORSE_ARMORS", 4);
/**
* Covers the 6 variants of infested blocks.
@@ -316,7 +308,7 @@ public class MaterialTags {
*/
public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs"))
.endsWith("_SPAWN_EGG")
.ensureSize("SPAWN_EGGS", 51);
.ensureSize("SPAWN_EGGS", 58);
/**
* Covers all 16 colors of stained glass.
@@ -364,8 +356,8 @@ public class MaterialTags {
.ensureSize("PURPUR", 4);
public static final MaterialSetTag SIGNS = new MaterialSetTag(keyFor("signs"))
.add(Material.SIGN, Material.WALL_SIGN)
.ensureSize("SIGNS", 2);
.endsWith("_SIGN")
.ensureSize("SIGNS", 12);
public static final MaterialSetTag TORCH = new MaterialSetTag(keyFor("torch"))
.add(Material.TORCH, Material.WALL_TORCH)

View File

@@ -0,0 +1,52 @@
package com.destroystokyo.paper.block;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.jetbrains.annotations.NotNull;
/**
* Represents the sounds that a {@link Block} makes in certain situations
* <p>
* The sound group includes break, step, place, hit, and fall sounds.
*/
public interface BlockSoundGroup {
/**
* Gets the sound that plays when breaking this block
*
* @return The break sound
*/
@NotNull
Sound getBreakSound();
/**
* Gets the sound that plays when stepping on this block
*
* @return The step sound
*/
@NotNull
Sound getStepSound();
/**
* Gets the sound that plays when placing this block
*
* @return The place sound
*/
@NotNull
Sound getPlaceSound();
/**
* Gets the sound that plays when hitting this block
*
* @return The hit sound
*/
@NotNull
Sound getHitSound();
/**
* Gets the sound that plays when this block falls
*
* @return The fall sound
*/
@NotNull
Sound getFallSound();
}

View File

@@ -36,6 +36,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
* @param cancelled if this event is enabled
*/
public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) {
super(true);
this.originalHandshake = originalHandshake;
this.cancelled = cancelled;
}

View File

@@ -27,6 +27,7 @@ public final class GS4QueryEvent extends Event {
private QueryResponse response;
public GS4QueryEvent(@NotNull QueryType queryType, @NotNull InetAddress querierAddress, @NotNull QueryResponse response) {
super(true); // should always be called async
this.queryType = Preconditions.checkNotNull(queryType, "queryType");
this.querierAddress = Preconditions.checkNotNull(querierAddress, "querierAddress");
this.response = Preconditions.checkNotNull(response, "response");

View File

@@ -2,6 +2,7 @@ package com.destroystokyo.paper.event.server;
import com.google.common.base.Preconditions;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.destroystokyo.paper.exception.ServerException;
@@ -15,6 +16,7 @@ public class ServerExceptionEvent extends Event {
@NotNull private ServerException exception;
public ServerExceptionEvent(@NotNull ServerException exception) {
super(!Bukkit.isPrimaryThread());
this.exception = Preconditions.checkNotNull(exception, "exception");
}

View File

@@ -0,0 +1,44 @@
package com.destroystokyo.paper.util;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
public interface VersionFetcher {
/**
* Amount of time to cache results for in milliseconds
* <p>
* Negative values will never cache.
*
* @return cache time
*/
long getCacheTime();
/**
* Gets the version message to cache and show to command senders. Multiple messages can be sent using newlines (\n)
* in the string. The string will be split on these newlines and sent as individual messages.
* <p>
* NOTE: This is run in a new thread separate from that of the command processing thread
*
* @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
* @return the message to show when requesting a version
*/
@NotNull
String getVersionMessage(@NotNull String serverVersion);
class DummyVersionFetcher implements VersionFetcher {
@Override
public long getCacheTime() {
return -1;
}
@NotNull
@Override
public String getVersionMessage(@NotNull String serverVersion) {
Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
new Throwable().printStackTrace();
return "Unable to check for updates. No version provider set.";
}
}
}

View File

@@ -1,10 +0,0 @@
package io.akarin.server.api.event;
import org.bukkit.entity.Player;
/**
* Represents event with a player attached
*/
public interface PlayerAttachedEvent {
public Player getPlayer();
}

View File

@@ -1,11 +0,0 @@
package io.akarin.server.api.event;
import org.bukkit.World;
import org.bukkit.entity.Player;
/**
* Represents event with a world attached
*/
public interface WorldAttachedEvent {
public World getWorld();
}

View File

@@ -1,7 +0,0 @@
package io.akarin.server.api.structure;
/**
* Represents a village structure
*/
public interface Village {
}

View File

@@ -1,227 +0,0 @@
package io.akarin.server.core;
import com.google.common.base.Throwables;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@SuppressWarnings({"UnusedIsStillUsed", "unused"})
public class AkarinGlobalConfig {
private final static Logger LOGGER = Logger.getLogger("Akarin");
private static File CONFIG_FILE;
private static final String HEADER = "This is the global configuration file for Akarin.\n"
+ "Some options may impact gameplay, so use with caution,\n"
+ "and make sure you know what each option does before configuring.\n"
+ "\n"
+ "Akarin website: https://akarin.io/ \n";
/*========================================================================*/
public static YamlConfiguration config;
static int version;
/*========================================================================*/
public static void init(File configFile) {
CONFIG_FILE = configFile;
config = new YamlConfiguration();
try {
config.load(CONFIG_FILE);
} catch (IOException ex) {
} catch (InvalidConfigurationException ex) {
LOGGER.log(Level.SEVERE, "Could not load akarin.yml, please correct your syntax errors");
ex.printStackTrace();
throw Throwables.propagate(ex);
}
config.options().header(HEADER);
config.options().copyDefaults(true);
version = getInt("config-version", 3);
set("config-version", 3);
readConfig(AkarinGlobalConfig.class, null);
}
static void readConfig(Class<?> clazz, Object instance) {
for (Method method : clazz.getDeclaredMethods()) {
if (Modifier.isPrivate(method.getModifiers())) {
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
try {
method.setAccessible(true);
method.invoke(instance);
} catch (InvocationTargetException ex) {
throw Throwables.propagate(ex.getCause());
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Error invoking " + method);
ex.printStackTrace();
}
}
}
}
try {
config.save(CONFIG_FILE);
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Could not save " + CONFIG_FILE);
ex.printStackTrace();
}
}
private static final Pattern SPACE = Pattern.compile(" ");
private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
public static int getSeconds(String str) {
str = SPACE.matcher(str).replaceAll("");
final char unit = str.charAt(str.length() - 1);
str = NOT_NUMERIC.matcher(str).replaceAll("");
double num;
try {
num = Double.parseDouble(str);
} catch (Exception e) {
num = 0D;
}
switch (unit) {
case 'd': num *= (double) 60*60*24; break;
case 'h': num *= (double) 60*60; break;
case 'm': num *= 60; break;
default: case 's': break;
}
return (int) num;
}
protected static String timeSummary(int seconds) {
String time = "";
if (seconds > 60 * 60 * 24) {
time += TimeUnit.SECONDS.toDays(seconds) + "d";
seconds %= 60 * 60 * 24;
}
if (seconds > 60 * 60) {
time += TimeUnit.SECONDS.toHours(seconds) + "h";
seconds %= 60 * 60;
}
if (seconds > 0) {
time += TimeUnit.SECONDS.toMinutes(seconds) + "m";
}
return time;
}
public static void set(String path, Object val) {
config.set(path, val);
}
private static boolean getBoolean(String path, boolean def) {
config.addDefault(path, def);
return config.getBoolean(path, config.getBoolean(path));
}
private static double getDouble(String path, double def) {
config.addDefault(path, def);
return config.getDouble(path, config.getDouble(path));
}
private static float getFloat(String path, float def) {
// TODO: Figure out why getFloat() always returns the default value.
return (float) getDouble(path, def);
}
private static int getInt(String path, int def) {
config.addDefault(path, def);
return config.getInt(path, config.getInt(path));
}
private static <T> List getList(String path, T def) {
config.addDefault(path, def);
return config.getList(path, config.getList(path));
}
private static String getString(String path, String def) {
config.addDefault(path, def);
return config.getString(path, config.getString(path));
}
/*========================================================================*/
public static boolean noResponseDoGC = true;
private static void noResponseDoGC() {
noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", noResponseDoGC);
}
public static String serverBrandName = "";
private static void serverBrandName() {
serverBrandName = getString("alternative.modified-server-brand-name", serverBrandName);
}
public static int fileIOThreads = 2;
private static void fileIOThreads() {
fileIOThreads = getInt("core.chunk-save-threads", fileIOThreads);
fileIOThreads = fileIOThreads < 1 ? 1 : fileIOThreads;
fileIOThreads = fileIOThreads > 8 ? 8 : fileIOThreads;
}
public static boolean fixPhysicsEventBehaviour = false;
private static void fixPhysicsEventBehavior() {
fixPhysicsEventBehaviour = getBoolean("alternative.fix-physics-event-behaviour", fixPhysicsEventBehaviour);
}
public static boolean lazyThreadAssertion = true;
private static void lazyThreadAssertion() {
lazyThreadAssertion = getBoolean("core.lazy-thread-assertion", lazyThreadAssertion);
}
public static double blockbreakAnimationVisibleDistance = 1024;
private static void blockbreakAnimationVisibleDistance() {
double def = 32.00;
if (version == 2)
def = getDouble("alternative.block-break-animation-visible-distance", def);
blockbreakAnimationVisibleDistance = Math.sqrt(getDouble("core.block-break-animation-visible-distance", def));
}
public static boolean enableAsyncLighting = true;
private static void enableAsyncLighting() {
enableAsyncLighting = getBoolean("core.async-lighting.enable", enableAsyncLighting);
}
public static String yggdrasilServerURL = "https://api.mojang.com/";
private static void yggdrasilServerURL() {
yggdrasilServerURL = getString("alternative.yggdrasil.url", yggdrasilServerURL);
}
public static boolean disallowBeforeLogin = false;
private static void disallowBeforeLogin() {
disallowBeforeLogin = getBoolean("alternative.disallow-before-login-event", disallowBeforeLogin);
}
public static boolean allowExcessiveSigns = false;
private static void allowExcessiveSigns() {
allowExcessiveSigns = getBoolean("alternative.allow-excessive-signs", allowExcessiveSigns);
}
public static boolean ignoreRayTraceForSeatableBlocks = false;
private static void ignoreRayTraceForSeatableBlocks() {
ignoreRayTraceForSeatableBlocks = getBoolean("alternative.ignore-ray-trace-for-seatable-blocks", ignoreRayTraceForSeatableBlocks);
}
public static boolean improvedMobSpawnMechanics = false;
private static void improvedMobSpawnMechanics() {
improvedMobSpawnMechanics = getBoolean("core.improved-mob-spawn-mechanics.enable", improvedMobSpawnMechanics);
}
public static int userCacheExpireDays = 30;
private static void enableModernUserCaches() {
userCacheExpireDays = getSeconds(getString("core.user-cache-expire-time", "30d"));
}
public static boolean spinningAwaitTicking = true;
private static void spinningAwaitTicking() {
spinningAwaitTicking = getBoolean("core.spinning-tick-await", spinningAwaitTicking);
}
}

View File

@@ -56,7 +56,7 @@ public enum Achievement {
/**
* Returns whether or not this achievement has a parent achievement.
*
*
* @return whether the achievement has a parent achievement
*/
public boolean hasParent() {
@@ -65,7 +65,7 @@ public enum Achievement {
/**
* Returns the parent achievement of this achievement, or null if none.
*
*
* @return the parent achievement or null
*/
@Nullable

View File

@@ -1,17 +1,15 @@
package org.bukkit;
import java.util.HashMap;
import org.apache.commons.lang.Validate;
import com.google.common.collect.Maps;
import java.util.HashMap;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents the art on a painting
*/
public enum Art {
public enum Art implements Keyed {
KEBAB(0, 1, 1),
AZTEC(1, 1, 1),
ALBAN(2, 1, 1),
@@ -39,7 +37,8 @@ public enum Art {
SKELETON(24, 4, 3),
DONKEY_KONG(25, 4, 3);
private int id, width, height;
private final int id, width, height;
private final NamespacedKey key;
private static final HashMap<String, Art> BY_NAME = Maps.newHashMap();
private static final HashMap<Integer, Art> BY_ID = Maps.newHashMap();
@@ -47,6 +46,7 @@ public enum Art {
this.id = id;
this.width = width;
this.height = height;
this.key = NamespacedKey.minecraft(name().toLowerCase(java.util.Locale.ENGLISH));
}
/**
@@ -78,6 +78,12 @@ public enum Art {
return id;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* Get a painting by its numeric ID
*

View File

@@ -1,10 +1,9 @@
package org.bukkit;
import java.util.Date;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Date;
/**
* A single entry from a ban list. This may represent either a player ban or
* an IP ban.

View File

@@ -1,10 +1,9 @@
package org.bukkit;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Date;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A ban list, containing bans of some {@link Type}.

View File

@@ -1,5 +1,6 @@
package org.bukkit;
import com.google.common.collect.ImmutableList;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.Serializable;
@@ -12,8 +13,8 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Logger;
import org.bukkit.Warning.WarningState;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
@@ -28,12 +29,15 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.help.HelpMap;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Merchant;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.loot.LootTable;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permissible;
@@ -43,13 +47,6 @@ import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.util.CachedServerIcon;
import com.google.common.collect.ImmutableList;
import org.bukkit.advancement.Advancement;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -192,31 +189,6 @@ public final class Bukkit {
return server.getIp();
}
/**
* Get the name of this server.
*
* @return the name of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public static String getServerName() {
return server.getServerName();
}
/**
* Get an ID of this server. The ID is a simple generally alphanumeric ID
* that can be used for uniquely identifying this server.
*
* @return the ID of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public static String getServerId() {
return server.getServerId();
}
/**
* Get world type (level-type setting) for default world.
*
@@ -981,11 +953,9 @@ public final class Bukkit {
}
/**
* Creates an empty inventory with the specified type and title. If the type
* Creates an empty inventory with the specified type. If the type
* is {@link InventoryType#CHEST}, the new inventory has a size of 27;
* otherwise the new inventory has the normal size for its type.<br>
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
* otherwise the new inventory has the normal size for its type.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
@@ -1260,12 +1230,12 @@ public final class Bukkit {
/**
* Create a ChunkData for use in a generator.
*
*
* See {@link ChunkGenerator#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}
*
*
* @param world the world to create the ChunkData for
* @return a new ChunkData for the world
*
*
*/
@NotNull
public static ChunkGenerator.ChunkData createChunkData(@NotNull World world) {
@@ -1533,9 +1503,7 @@ public final class Bukkit {
* no further guarantees are made.
* @throws IllegalArgumentException if the selector is malformed in any way
* or a parameter is null
* @deprecated draft API
*/
@Deprecated
@NotNull
public static List<Entity> selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException {
return server.selectEntities(sender, selector);
@@ -1631,6 +1599,10 @@ public final class Bukkit {
public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
return server.createProfile(uuid, name);
}
public static int getCurrentTick() {
return server.getCurrentTick();
}
// Paper end
@NotNull

View File

@@ -1,11 +1,9 @@
package org.bukkit;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang.Validate;
import com.google.common.collect.Maps;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* All supported color values for chat
*/
public enum ChatColor{
public enum ChatColor {
/**
* Represents black
*/
@@ -27,7 +25,7 @@ public enum ChatColor{
/**
* Represents dark blue
*/
DARK_BLUE('1', 0x1){
DARK_BLUE('1', 0x1) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -37,7 +35,7 @@ public enum ChatColor{
/**
* Represents dark green
*/
DARK_GREEN('2', 0x2){
DARK_GREEN('2', 0x2) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -47,7 +45,7 @@ public enum ChatColor{
/**
* Represents dark blue (aqua)
*/
DARK_AQUA('3', 0x3){
DARK_AQUA('3', 0x3) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -57,7 +55,7 @@ public enum ChatColor{
/**
* Represents dark red
*/
DARK_RED('4', 0x4){
DARK_RED('4', 0x4) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -67,7 +65,7 @@ public enum ChatColor{
/**
* Represents dark purple
*/
DARK_PURPLE('5', 0x5){
DARK_PURPLE('5', 0x5) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -77,7 +75,7 @@ public enum ChatColor{
/**
* Represents gold
*/
GOLD('6', 0x6){
GOLD('6', 0x6) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -87,7 +85,7 @@ public enum ChatColor{
/**
* Represents gray
*/
GRAY('7', 0x7){
GRAY('7', 0x7) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -97,7 +95,7 @@ public enum ChatColor{
/**
* Represents dark gray
*/
DARK_GRAY('8', 0x8){
DARK_GRAY('8', 0x8) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -107,7 +105,7 @@ public enum ChatColor{
/**
* Represents blue
*/
BLUE('9', 0x9){
BLUE('9', 0x9) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -117,7 +115,7 @@ public enum ChatColor{
/**
* Represents green
*/
GREEN('a', 0xA){
GREEN('a', 0xA) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -127,7 +125,7 @@ public enum ChatColor{
/**
* Represents aqua
*/
AQUA('b', 0xB){
AQUA('b', 0xB) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -137,7 +135,7 @@ public enum ChatColor{
/**
* Represents red
*/
RED('c', 0xC){
RED('c', 0xC) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -147,7 +145,7 @@ public enum ChatColor{
/**
* Represents light purple
*/
LIGHT_PURPLE('d', 0xD){
LIGHT_PURPLE('d', 0xD) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -157,7 +155,7 @@ public enum ChatColor{
/**
* Represents yellow
*/
YELLOW('e', 0xE){
YELLOW('e', 0xE) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -167,7 +165,7 @@ public enum ChatColor{
/**
* Represents white
*/
WHITE('f', 0xF){
WHITE('f', 0xF) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -177,7 +175,7 @@ public enum ChatColor{
/**
* Represents magical characters that change around randomly
*/
MAGIC('k', 0x10, true){
MAGIC('k', 0x10, true) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -187,7 +185,7 @@ public enum ChatColor{
/**
* Makes the text bold.
*/
BOLD('l', 0x11, true){
BOLD('l', 0x11, true) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -197,7 +195,7 @@ public enum ChatColor{
/**
* Makes a line appear through the text.
*/
STRIKETHROUGH('m', 0x12, true){
STRIKETHROUGH('m', 0x12, true) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -207,7 +205,7 @@ public enum ChatColor{
/**
* Makes the text appear underlined.
*/
UNDERLINE('n', 0x13, true){
UNDERLINE('n', 0x13, true) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -217,7 +215,7 @@ public enum ChatColor{
/**
* Makes the text italic.
*/
ITALIC('o', 0x14, true){
ITALIC('o', 0x14, true) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -227,7 +225,7 @@ public enum ChatColor{
/**
* Resets all previous chat colors or formats.
*/
RESET('r', 0x15){
RESET('r', 0x15) {
@NotNull
@Override
public net.md_5.bungee.api.ChatColor asBungee() {
@@ -246,8 +244,8 @@ public enum ChatColor{
private final char code;
private final boolean isFormat;
private final String toString;
private final static Map<Integer, ChatColor> BY_ID = Maps.newHashMap();
private final static Map<Character, ChatColor> BY_CHAR = Maps.newHashMap();
private static final Map<Integer, ChatColor> BY_ID = Maps.newHashMap();
private static final Map<Character, ChatColor> BY_CHAR = Maps.newHashMap();
private ChatColor(char code, int intCode) {
this(code, intCode, false);
@@ -282,7 +280,7 @@ public enum ChatColor{
/**
* Checks if this code is a format code as opposed to a color code.
*
*
* @return whether this ChatColor is a format code
*/
public boolean isFormat() {
@@ -291,7 +289,7 @@ public enum ChatColor{
/**
* Checks if this code is a color code as opposed to a format code.
*
*
* @return whether this ChatColor is a color code
*/
public boolean isColor() {
@@ -353,6 +351,8 @@ public enum ChatColor{
*/
@NotNull
public static String translateAlternateColorCodes(char altColorChar, @NotNull String textToTranslate) {
Validate.notNull(textToTranslate, "Cannot translate null text");
char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; i++) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
@@ -371,6 +371,8 @@ public enum ChatColor{
*/
@NotNull
public static String getLastColors(@NotNull String input) {
Validate.notNull(input, "Cannot get last colors from null text");
String result = "";
int length = input.length();

View File

@@ -1,8 +1,11 @@
package org.bukkit;
import java.util.Collection;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
/**
@@ -143,18 +146,6 @@ public interface Chunk {
*/
boolean load();
/**
* Unloads and optionally saves the Chunk
*
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are
* nearby
* @return true if the chunk has unloaded successfully, otherwise false
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
boolean unload(boolean save, boolean safe);
/**
* Unloads and optionally saves the Chunk
*
@@ -194,8 +185,81 @@ public interface Chunk {
* <p>
* A force loaded chunk will not be unloaded due to lack of player activity.
*
* @param forced
* @param forced force load status
* @see World#setChunkForceLoaded(int, int, boolean)
*/
void setForceLoaded(boolean forced);
/**
* Adds a plugin ticket for this chunk, loading this chunk if it is not
* already loaded.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param plugin Plugin which owns the ticket
* @return {@code true} if a plugin ticket was added, {@code false} if the
* ticket already exists for the plugin
* @throws IllegalStateException If the specified plugin is not enabled
* @see World#addPluginChunkTicket(int, int, Plugin)
*/
boolean addPluginChunkTicket(@NotNull Plugin plugin);
/**
* Removes the specified plugin's ticket for this chunk
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param plugin Plugin which owns the ticket
* @return {@code true} if the plugin ticket was removed, {@code false} if
* there is no plugin ticket for the chunk
* @see World#removePluginChunkTicket(int, int, Plugin)
*/
boolean removePluginChunkTicket(@NotNull Plugin plugin);
/**
* Retrieves a collection specifying which plugins have tickets for this
* chunk. This collection is not updated when plugin tickets are added or
* removed to this chunk.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @return unmodifiable collection containing which plugins have tickets for
* this chunk
* @see World#getPluginChunkTickets(int, int)
*/
@NotNull
Collection<Plugin> getPluginChunkTickets();
/**
* Gets the amount of time in ticks that this chunk has been inhabited.
*
* Note that the time is incremented once per tick per player in the chunk.
*
* @return inhabited time
*/
long getInhabitedTime();
/**
* Sets the amount of time in ticks that this chunk has been inhabited.
*
* @param ticks new inhabited time
*/
void setInhabitedTime(long ticks);
/**
* Tests if this chunk contains the specified block.
*
* @param block block to test
* @return if the block is contained within
*/
boolean contains(@NotNull BlockData block);
}

View File

@@ -131,4 +131,12 @@ public interface ChunkSnapshot {
* @return true if empty, false if not
*/
boolean isSectionEmpty(int sy);
/**
* Tests if this snapshot contains the specified block.
*
* @param block block to test
* @return if the block is contained within
*/
boolean contains(@NotNull BlockData block);
}

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -13,7 +12,7 @@ public enum CoalType {
CHARCOAL(0x1);
private final byte data;
private final static Map<Byte, CoalType> BY_DATA = Maps.newHashMap();
private static final Map<Byte, CoalType> BY_DATA = Maps.newHashMap();
private CoalType(final int data) {
this.data = (byte) data;

View File

@@ -1,12 +1,10 @@
package org.bukkit;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
/**
@@ -319,6 +317,7 @@ public final class Color implements ConfigurationSerializable {
return asRGB() ^ Color.class.hashCode();
}
@Override
@NotNull
public Map<String, Object> serialize() {
return ImmutableMap.<String, Object>of(

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -44,7 +43,7 @@ public enum CropState {
RIPE(0x7);
private final byte data;
private final static Map<Byte, CropState> BY_DATA = Maps.newHashMap();
private static final Map<Byte, CropState> BY_DATA = Maps.newHashMap();
private CropState(final int data) {
this.data = (byte) data;

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -35,7 +34,7 @@ public enum Difficulty {
HARD(3);
private final int value;
private final static Map<Integer, Difficulty> BY_ID = Maps.newHashMap();
private static final Map<Integer, Difficulty> BY_ID = Maps.newHashMap();
private Difficulty(final int value) {
this.value = value;

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -80,10 +79,10 @@ public enum DyeColor {
private final byte dyeData;
private final Color color;
private final Color firework;
private final static DyeColor[] BY_WOOL_DATA;
private final static DyeColor[] BY_DYE_DATA;
private final static Map<Color, DyeColor> BY_COLOR;
private final static Map<Color, DyeColor> BY_FIREWORK;
private static final DyeColor[] BY_WOOL_DATA;
private static final DyeColor[] BY_DYE_DATA;
private static final Map<Color, DyeColor> BY_COLOR;
private static final Map<Color, DyeColor> BY_FIREWORK;
private DyeColor(final int woolData, final int dyeData, /*@NotNull*/ Color color, /*@NotNull*/ Color firework) {
this.woolData = (byte) woolData;

View File

@@ -1,9 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.bukkit.block.BlockFace;
import org.bukkit.potion.Potion;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
@@ -153,7 +152,7 @@ public enum EntityEffect {
private final byte data;
private final Class<? extends Entity> applicable;
private final static Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();
private static final Map<Byte, EntityEffect> BY_DATA = Maps.newHashMap();
EntityEffect(final int data, /*@NotNull*/ Class<? extends Entity> clazz) {
this.data = (byte) data;

View File

@@ -1,14 +1,12 @@
package org.bukkit;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.NotNull;
/**

View File

@@ -1,10 +1,8 @@
package org.bukkit;
import java.util.Map;
import org.bukkit.entity.HumanEntity;
import com.google.common.collect.Maps;
import java.util.Map;
import org.bukkit.entity.HumanEntity;
import org.jetbrains.annotations.Nullable;
/**
@@ -29,14 +27,14 @@ public enum GameMode {
ADVENTURE(2),
/**
* Spectator mode cannot interact with the world in anyway and is
* invisible to normal players. This grants the player the
* Spectator mode cannot interact with the world in anyway and is
* invisible to normal players. This grants the player the
* ability to no-clip through the world.
*/
SPECTATOR(3);
private final int value;
private final static Map<Integer, GameMode> BY_ID = Maps.newHashMap();
private static final Map<Integer, GameMode> BY_ID = Maps.newHashMap();
private GameMode(final int value) {
this.value = value;

View File

@@ -1,11 +1,10 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* GameRules dictate certain behavior within Minecraft itself
@@ -117,6 +116,11 @@ public final class GameRule<T> {
*/
public static final GameRule<Boolean> SPECTATORS_GENERATE_CHUNKS = new GameRule<>("spectatorsGenerateChunks", Boolean.class);
/**
* Whether pillager raids are enabled or not.
*/
public static final GameRule<Boolean> DISABLE_RAIDS = new GameRule<>("disableRaids", Boolean.class);
// Numerical rules
/**
* How often a random block tick occurs (such as plant growth, leaf decay,

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -24,7 +23,7 @@ public enum GrassSpecies {
FERN_LIKE(0x2);
private final byte data;
private final static Map<Byte, GrassSpecies> BY_DATA = Maps.newHashMap();
private static final Map<Byte, GrassSpecies> BY_DATA = Maps.newHashMap();
private GrassSpecies(final int data) {
this.data = (byte) data;

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
public enum Instrument {
@@ -51,10 +50,34 @@ public enum Instrument {
/**
* Xylophone is normally played when a note block is on top of a bone block.
*/
XYLOPHONE(0x9);
XYLOPHONE(0x9),
/**
* Iron Xylophone is normally played when a note block is on top of a iron block.
*/
IRON_XYLOPHONE(0xA),
/**
* Cow Bell is normally played when a note block is on top of a soul sand block.
*/
COW_BELL(0xB),
/**
* Didgeridoo is normally played when a note block is on top of a pumpkin block.
*/
DIDGERIDOO(0xC),
/**
* Bit is normally played when a note block is on top of a emerald block.
*/
BIT(0xD),
/**
* Banjo is normally played when a note block is on top of a hay block.
*/
BANJO(0xE),
/**
* Pling is normally played when a note block is on top of a glowstone block.
*/
PLING(0xF);
private final byte type;
private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
private Instrument(final int type) {
this.type = (byte) type;

View File

@@ -1,9 +1,11 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import com.google.common.base.Preconditions; // Paper
import java.util.HashMap;
import java.util.Map;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Entity; // Paper
@@ -29,7 +31,7 @@ import org.bukkit.entity.Player;
* representation by the implementation.
*/
public class Location implements Cloneable, ConfigurationSerializable {
private World world;
private Reference<World> world;
private double x;
private double y;
private double z;
@@ -58,8 +60,11 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param yaw The absolute rotation on the x-plane, in degrees
* @param pitch The absolute rotation on the y-plane, in degrees
*/
public Location(@UndefinedNullability final World world, final double x, final double y, final double z, final float yaw, final float pitch) { // Paper
this.world = world;
public Location(@UndefinedNullability final World world, final double x, final double y, final double z, final float yaw, final float pitch) {
if (world != null) {
this.world = new WeakReference<>(world);
}
this.x = x;
this.y = y;
this.z = z;
@@ -73,16 +78,38 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @param world New world that this location resides in
*/
public void setWorld(@Nullable World world) {
this.world = world;
this.world = (world == null) ? null : new WeakReference<>(world);
}
/**
* Checks if world in this location is present and loaded.
*
* @return true if is loaded, otherwise false
*/
public boolean isWorldLoaded() {
if (this.world == null) {
return false;
}
World world = this.world.get();
return world != null && Bukkit.getWorld(world.getUID()) != null;
}
/**
* Gets the world that this location resides in
*
* @return World that contains this location
* @return World that contains this location, or {@code null} if it is not set
* @throws IllegalArgumentException when world is unloaded
* @see #isWorldLoaded()
*/
@UndefinedNullability
public World getWorld() {
if (this.world == null) {
return null;
}
World world = this.world.get();
Preconditions.checkArgument(world != null, "World unloaded");
return world;
}
@@ -93,7 +120,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
*/
@NotNull
public Chunk getChunk() {
return world.getChunkAt(this);
return getWorld().getChunkAt(this);
}
/**
@@ -103,7 +130,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
*/
@NotNull
public Block getBlock() {
return world.getBlockAt(this);
return getWorld().getBlockAt(this);
}
/**
@@ -285,7 +312,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
/**
* Sets the {@link #getYaw() yaw} and {@link #getPitch() pitch} to point
* in the direction of the vector.
*
*
* @param vector the direction vector
* @return the same location
*/
@@ -516,7 +543,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
return this;
}
public boolean isChunkLoaded() { return world.isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
public boolean isChunkLoaded() { return this.getWorld().isChunkLoaded(locToBlock(x) >> 4, locToBlock(z) >> 4); } // Paper
// Paper start
/**
@@ -525,6 +552,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return true if a chunk has been generated at this location
*/
public boolean isGenerated() {
World world = this.getWorld();
Preconditions.checkNotNull(world, "Location has no world!");
return world.isChunkGenerated(locToBlock(x) >> 4, locToBlock(z) >> 4);
}
@@ -610,6 +638,33 @@ public class Location implements Cloneable, ConfigurationSerializable {
return centerLoc;
}
// Paper start - Add heightmap api
/**
* Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ())
* @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ())
* @throws NullPointerException if {{@link #getWorld()}} is {@code null}
*/
@NotNull
public Location toHighestLocation() {
return this.toHighestLocation(com.destroystokyo.paper.HeightmapType.LIGHT_BLOCKING);
}
/**
* Returns a copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap)
* @param heightmap The heightmap to use for finding the highest y location.
* @return A copy of this location except with y = getWorld().getHighestBlockYAt(this.getBlockX(), this.getBlockZ(), heightmap)
* @throws NullPointerException if {{@link #getWorld()}} is {@code null}
* @throws UnsupportedOperationException if {@link World#getHighestBlockYAt(int, int, com.destroystokyo.paper.HeightmapType)} does not support the specified heightmap
*/
@NotNull
public Location toHighestLocation(@NotNull final com.destroystokyo.paper.HeightmapType heightmap) {
final Location ret = this.clone();
ret.setY(this.getWorld().getHighestBlockYAt(this, heightmap));
return ret;
}
// Paper end
/**
* Creates explosion at this location with given power
*
@@ -619,7 +674,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(float power) {
return world.createExplosion(this, power);
return this.getWorld().createExplosion(this, power);
}
/**
@@ -633,7 +688,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(float power, boolean setFire) {
return world.createExplosion(this, power, setFire);
return this.getWorld().createExplosion(this, power, setFire);
}
/**
@@ -646,7 +701,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(float power, boolean setFire, boolean breakBlocks) {
return world.createExplosion(this, power, setFire, breakBlocks);
return this.getWorld().createExplosion(this, power, setFire, breakBlocks);
}
/**
@@ -659,7 +714,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(@Nullable Entity source, float power) {
return world.createExplosion(source, this, power, true, true);
return this.getWorld().createExplosion(source, this, power, true, true);
}
/**
@@ -674,7 +729,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(@Nullable Entity source, float power, boolean setFire) {
return world.createExplosion(source, this, power, setFire, true);
return this.getWorld().createExplosion(source, this, power, setFire, true);
}
/**
@@ -688,7 +743,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(@NotNull Entity source, float power, boolean setFire, boolean breakBlocks) {
return world.createExplosion(source, source.getLocation(), power, setFire, breakBlocks);
return this.getWorld().createExplosion(source, source.getLocation(), power, setFire, breakBlocks);
}
/**
@@ -703,6 +758,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
*/
@NotNull
public Collection<Entity> getNearbyEntities(double x, double y, double z) {
World world = this.getWorld();
if (world == null) {
throw new IllegalArgumentException("Location has no world");
}
@@ -925,6 +981,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
*/
@NotNull
public <T extends Entity> Collection<T> getNearbyEntitiesByType(@Nullable Class<? extends Entity> clazz, double xRadius, double yRadius, double zRadius, @Nullable Predicate<T> predicate) {
World world = this.getWorld();
if (world == null) {
throw new IllegalArgumentException("Location has no world");
}
@@ -941,7 +998,9 @@ public class Location implements Cloneable, ConfigurationSerializable {
}
final Location other = (Location) obj;
if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
World world = (this.world == null) ? null : this.world.get();
World otherWorld = (other.world == null) ? null : other.world.get();
if (world != otherWorld && (world == null || !world.equals(otherWorld))) {
return false;
}
if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
@@ -966,7 +1025,8 @@ public class Location implements Cloneable, ConfigurationSerializable {
public int hashCode() {
int hash = 3;
hash = 19 * hash + (this.world != null ? this.world.hashCode() : 0);
World world = (this.world == null) ? null : this.world.get();
hash = 19 * hash + (world != null ? world.hashCode() : 0);
hash = 19 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
@@ -977,6 +1037,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
@Override
public String toString() {
World world = (this.world == null) ? null : this.world.get();
return "Location{" + "world=" + world + ",x=" + x + ",y=" + y + ",z=" + z + ",pitch=" + pitch + ",yaw=" + yaw + '}';
}
@@ -1025,11 +1086,15 @@ public class Location implements Cloneable, ConfigurationSerializable {
return NumberConversions.floor(loc);
}
@Override
@Utility
@NotNull
public Map<String, Object> serialize() {
Map<String, Object> data = new HashMap<String, Object>();
data.put("world", this.world.getName());
if (this.world != null) {
data.put("world", getWorld().getName());
}
data.put("x", this.x);
data.put("y", this.y);
@@ -1051,9 +1116,12 @@ public class Location implements Cloneable, ConfigurationSerializable {
*/
@NotNull
public static Location deserialize(@NotNull Map<String, Object> args) {
World world = Bukkit.getWorld((String) args.get("world"));
if (world == null) {
throw new IllegalArgumentException("unknown world");
World world = null;
if (args.containsKey("world")) {
world = Bukkit.getWorld((String) args.get("world"));
if (world == null) {
throw new IllegalArgumentException("unknown world");
}
}
return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch")));

File diff suppressed because it is too large Load Diff

View File

@@ -39,8 +39,8 @@ public final class NamespacedKey implements com.destroystokyo.paper.Namespaced {
/**
* Create a key in a specific namespace.
*
* @param namespace String representing a grouping of keys
* @param key Name for this specific key
* @param namespace namespace
* @param key key
* @deprecated should never be used by plugins, for internal use only!!
*/
@Deprecated
@@ -72,7 +72,7 @@ public final class NamespacedKey implements com.destroystokyo.paper.Namespaced {
Preconditions.checkArgument(key != null, "Key cannot be null");
this.namespace = plugin.getName().toLowerCase(Locale.ROOT);
this.key = key.toLowerCase().toLowerCase(Locale.ROOT);
this.key = key.toLowerCase(Locale.ROOT);
// Check validity after normalization
Preconditions.checkArgument(VALID_NAMESPACE.matcher(this.namespace).matches(), "Invalid namespace. Must be [a-z0-9._-]: %s", this.namespace);

View File

@@ -1,10 +1,8 @@
package org.bukkit;
import java.util.Map;
import org.apache.commons.lang.Validate;
import com.google.common.collect.Maps;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -1,7 +1,6 @@
package org.bukkit;
import java.util.UUID;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Player;
@@ -26,6 +25,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Player name or null if we have not seen a name for this player yet
*/
@Override
@Nullable
public String getName();
@@ -34,6 +34,7 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
*
* @return Player UUID
*/
@Override
@NotNull
public UUID getUniqueId();

View File

@@ -60,6 +60,14 @@ public enum Particle {
BUBBLE_COLUMN_UP,
NAUTILUS,
DOLPHIN,
SNEEZE,
CAMPFIRE_COSY_SMOKE,
CAMPFIRE_SIGNAL_SMOKE,
COMPOSTER,
FLASH,
FALLING_LAVA,
LANDING_LAVA,
FALLING_WATER,
// ----- Legacy Separator -----
LEGACY_BLOCK_CRACK(MaterialData.class),
LEGACY_BLOCK_DUST(MaterialData.class),

View File

@@ -0,0 +1,134 @@
package org.bukkit;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Raider;
import org.jetbrains.annotations.NotNull;
/**
* Represents a raid event.
*/
public interface Raid {
/**
* Get whether this raid started.
*
* @return whether raid is started
*/
boolean isStarted();
/**
* Gets the amount of ticks this raid has existed.
*
* @return active ticks
*/
long getActiveTicks();
/**
* Gets the Bad Omen level of this raid.
*
* @return Bad Omen level (between 0 and 5)
*/
int getBadOmenLevel();
/**
* Sets the Bad Omen level.
* <br>
* If the level is higher than 1, there will be an additional wave that as
* strong as the final wave.
*
* @param badOmenLevel new Bad Omen level (from 0-5)
* @throws IllegalArgumentException if invalid Bad Omen level
*/
void setBadOmenLevel(int badOmenLevel);
/**
* Gets the center location where the raid occurs.
*
* @return location
*/
@NotNull
Location getLocation();
/**
* Gets the current status of the raid.
* <br>
* Do not use this method to check if the raid has been started, call
* {@link #isStarted()} instead.
*
* @return Raids status
*/
@NotNull
RaidStatus getStatus();
/**
* Gets the number of raider groups which have spawned.
*
* @return total spawned groups
*/
int getSpawnedGroups();
/**
* Gets the number of raider groups which would spawn.
* <br>
* This also includes the group which spawns in the additional wave (if
* present).
*
* @return total groups
*/
int getTotalGroups();
/**
* Gets the number of waves in this raid (exclude the additional wave).
*
* @return number of waves
*/
int getTotalWaves();
/**
* Gets the sum of all raider's health.
*
* @return total raiders health
*/
float getTotalHealth();
/**
* Get the UUID of all heroes in this raid.
*
* @return a set of unique ids
*/
@NotNull
Set<UUID> getHeroes();
/**
* Gets all remaining {@link Raider} in the present wave.
*
* @return a list of current raiders
*/
@NotNull
List<Raider> getRaiders();
/**
* Represents the status of a {@link Raid}.
*/
public enum RaidStatus {
/**
* The raid is in progress.
*/
ONGOING,
/**
* The raid was beaten by heroes.
*/
VICTORY,
/**
* The village has fallen (i.e. all villagers died).
*/
LOSS,
/**
* The raid was terminated.
*/
STOPPED;
}
}

View File

@@ -0,0 +1,196 @@
package org.bukkit;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Predicate;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.Biome;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
import org.bukkit.entity.memory.MemoryKey;
import org.bukkit.loot.LootTables;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a registry of Bukkit objects that may be retrieved by
* {@link NamespacedKey}.
*
* @param <T> type of item in the registry
*/
public interface Registry<T extends Keyed> extends Iterable<T> {
/**
* Server advancements.
*
* @see Bukkit#getAdvancement(org.bukkit.NamespacedKey)
* @see Bukkit#advancementIterator()
*/
Registry<Advancement> ADVANCEMENT = new Registry<Advancement>() {
@Nullable
@Override
public Advancement get(@NotNull NamespacedKey key) {
return Bukkit.getAdvancement(key);
}
@NotNull
@Override
public Iterator<Advancement> iterator() {
return Bukkit.advancementIterator();
}
};
/**
* Server art.
*
* @see Art
*/
Registry<Art> ART = new SimpleRegistry<>(Art.class);
/**
* Server biomes.
*
* @see Biome
*/
Registry<Biome> BIOME = new SimpleRegistry<>(Biome.class);
/**
* Custom boss bars.
*
* @see Bukkit#getBossBar(org.bukkit.NamespacedKey)
* @see Bukkit#getBossBars()
*/
Registry<KeyedBossBar> BOSS_BARS = new Registry<KeyedBossBar>() {
@Nullable
@Override
public KeyedBossBar get(@NotNull NamespacedKey key) {
return Bukkit.getBossBar(key);
}
@NotNull
@Override
public Iterator<KeyedBossBar> iterator() {
return Bukkit.getBossBars();
}
};
/**
* Server enchantments.
*
* @see Enchantment#getByKey(org.bukkit.NamespacedKey)
*/
Registry<Enchantment> ENCHANTMENT = new Registry<Enchantment>() {
@Nullable
@Override
public Enchantment get(@NotNull NamespacedKey key) {
return Enchantment.getByKey(key);
}
@NotNull
@Override
public Iterator<Enchantment> iterator() {
return Arrays.asList(Enchantment.values()).iterator();
}
};
/**
* Server entity types.
*
* @see EntityType
*/
Registry<EntityType> ENTITY_TYPE = new SimpleRegistry<>(EntityType.class, (entity) -> entity != EntityType.UNKNOWN);
/**
* Default server loot tables.
*
* @see LootTables
*/
Registry<LootTables> LOOT_TABLES = new SimpleRegistry<>(LootTables.class);
/**
* Server materials.
*
* @see Material
*/
Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy());
/**
* Server statistics.
*
* @see Statistic
*/
Registry<Statistic> STATISTIC = new SimpleRegistry<>(Statistic.class);
/**
* Villager profession.
*
* @see Villager.Profession
*/
Registry<Villager.Profession> VILLAGER_PROFESSION = new SimpleRegistry<>(Villager.Profession.class);
/**
* Villager type.
*
* @see Villager.Type
*/
Registry<Villager.Type> VILLAGER_TYPE = new SimpleRegistry<>(Villager.Type.class);
/**
* Memory Keys.
*
* @see MemoryKey
*/
Registry<MemoryKey> MEMORY_MODULE_TYPE = new Registry<MemoryKey>() {
@NotNull
@Override
public Iterator iterator() {
return MemoryKey.values().iterator();
}
@Nullable
@Override
public MemoryKey get(@NotNull NamespacedKey key) {
return MemoryKey.getByKey(key);
}
};
/**
* Get the object by its key.
*
* @param key non-null key
* @return item or null if does not exist
*/
@Nullable
T get(@NotNull NamespacedKey key);
static final class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {
private final Map<NamespacedKey, T> map;
protected SimpleRegistry(@NotNull Class<T> type) {
this(type, Predicates.<T>alwaysTrue());
}
protected SimpleRegistry(@NotNull Class<T> type, @NotNull Predicate<T> predicate) {
ImmutableMap.Builder<NamespacedKey, T> builder = ImmutableMap.builder();
for (T entry : type.getEnumConstants()) {
if (predicate.test(entry)) {
builder.put(entry.getKey(), entry);
}
}
map = builder.build();
}
@Nullable
@Override
public T get(@NotNull NamespacedKey key) {
return map.get(key);
}
@NotNull
@Override
public Iterator<T> iterator() {
return map.values().iterator();
}
}
}

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -14,7 +13,7 @@ public enum SandstoneType {
SMOOTH(0x2);
private final byte data;
private final static Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
private static final Map<Byte, SandstoneType> BY_DATA = Maps.newHashMap();
private SandstoneType(final int data) {
this.data = (byte) data;

View File

@@ -1,5 +1,6 @@
package org.bukkit;
import com.google.common.collect.ImmutableList;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.Serializable;
@@ -12,8 +13,8 @@ import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.logging.Logger;
import org.bukkit.Warning.WarningState;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
@@ -28,12 +29,15 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.help.HelpMap;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Merchant;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.loot.LootTable;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permissible;
@@ -44,13 +48,6 @@ import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.util.CachedServerIcon;
import com.google.common.collect.ImmutableList;
import org.bukkit.advancement.Advancement;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -161,27 +158,6 @@ public interface Server extends PluginMessageRecipient {
@NotNull
public String getIp();
/**
* Get the name of this server.
*
* @return the name of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public String getServerName();
/**
* Get an ID of this server. The ID is a simple generally alphanumeric ID
* that can be used for uniquely identifying this server.
*
* @return the ID of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public String getServerId();
/**
* Get world type (level-type setting) for default world.
*
@@ -814,11 +790,9 @@ public interface Server extends PluginMessageRecipient {
public HelpMap getHelpMap();
/**
* Creates an empty inventory with the specified type and title. If the type
* Creates an empty inventory with the specified type. If the type
* is {@link InventoryType#CHEST}, the new inventory has a size of 27;
* otherwise the new inventory has the normal size for its type.<br>
* It should be noted that some inventory types do not support titles and
* may not render with said titles on the Minecraft client.
* otherwise the new inventory has the normal size for its type.
* <br>
* {@link InventoryType#WORKBENCH} will not process crafting recipes if
* created with this method. Use
@@ -1053,12 +1027,12 @@ public interface Server extends PluginMessageRecipient {
/**
* Create a ChunkData for use in a generator.
*
*
* See {@link ChunkGenerator#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}
*
*
* @param world the world to create the ChunkData for
* @return a new ChunkData for the world
*
*
*/
@NotNull
public ChunkGenerator.ChunkData createChunkData(@NotNull World world);
@@ -1305,9 +1279,7 @@ public interface Server extends PluginMessageRecipient {
* no further guarantees are made.
* @throws IllegalArgumentException if the selector is malformed in any way
* or a parameter is null
* @deprecated draft API
*/
@Deprecated
@NotNull
List<Entity> selectEntities(@NotNull CommandSender sender, @NotNull String selector) throws IllegalArgumentException;
@@ -1426,5 +1398,12 @@ public interface Server extends PluginMessageRecipient {
*/
@NotNull
com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name);
/**
* Get the current internal server tick
*
* @return Current tick
*/
int getCurrentTick();
// Paper end
}

View File

@@ -24,22 +24,40 @@ public enum Sound {
BLOCK_ANVIL_PLACE,
BLOCK_ANVIL_STEP,
BLOCK_ANVIL_USE,
BLOCK_BAMBOO_BREAK,
BLOCK_BAMBOO_FALL,
BLOCK_BAMBOO_HIT,
BLOCK_BAMBOO_PLACE,
BLOCK_BAMBOO_SAPLING_BREAK,
BLOCK_BAMBOO_SAPLING_HIT,
BLOCK_BAMBOO_SAPLING_PLACE,
BLOCK_BAMBOO_STEP,
BLOCK_BARREL_CLOSE,
BLOCK_BARREL_OPEN,
BLOCK_BEACON_ACTIVATE,
BLOCK_BEACON_AMBIENT,
BLOCK_BEACON_DEACTIVATE,
BLOCK_BEACON_POWER_SELECT,
BLOCK_BELL_RESONATE,
BLOCK_BELL_USE,
BLOCK_BLASTFURNACE_FIRE_CRACKLE,
BLOCK_BREWING_STAND_BREW,
BLOCK_BUBBLE_COLUMN_BUBBLE_POP,
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT,
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE,
BLOCK_CAMPFIRE_CRACKLE,
BLOCK_CHEST_CLOSE,
BLOCK_CHEST_LOCKED,
BLOCK_CHEST_OPEN,
BLOCK_CHORUS_FLOWER_DEATH,
BLOCK_CHORUS_FLOWER_GROW,
BLOCK_COMPARATOR_CLICK,
BLOCK_COMPOSTER_EMPTY,
BLOCK_COMPOSTER_FILL,
BLOCK_COMPOSTER_FILL_SUCCESS,
BLOCK_COMPOSTER_READY,
BLOCK_CONDUIT_ACTIVATE,
BLOCK_CONDUIT_AMBIENT,
BLOCK_CONDUIT_AMBIENT_SHORT,
@@ -50,6 +68,7 @@ public enum Sound {
BLOCK_CORAL_BLOCK_HIT,
BLOCK_CORAL_BLOCK_PLACE,
BLOCK_CORAL_BLOCK_STEP,
BLOCK_CROP_BREAK,
BLOCK_DISPENSER_DISPENSE,
BLOCK_DISPENSER_FAIL,
BLOCK_DISPENSER_LAUNCH,
@@ -79,6 +98,7 @@ public enum Sound {
BLOCK_GRAVEL_HIT,
BLOCK_GRAVEL_PLACE,
BLOCK_GRAVEL_STEP,
BLOCK_GRINDSTONE_USE,
BLOCK_IRON_DOOR_CLOSE,
BLOCK_IRON_DOOR_OPEN,
BLOCK_IRON_TRAPDOOR_CLOSE,
@@ -88,6 +108,11 @@ public enum Sound {
BLOCK_LADDER_HIT,
BLOCK_LADDER_PLACE,
BLOCK_LADDER_STEP,
BLOCK_LANTERN_BREAK,
BLOCK_LANTERN_FALL,
BLOCK_LANTERN_HIT,
BLOCK_LANTERN_PLACE,
BLOCK_LANTERN_STEP,
BLOCK_LAVA_AMBIENT,
BLOCK_LAVA_EXTINGUISH,
BLOCK_LAVA_POP,
@@ -100,14 +125,20 @@ public enum Sound {
BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF,
BLOCK_METAL_PRESSURE_PLATE_CLICK_ON,
BLOCK_METAL_STEP,
BLOCK_NETHER_WART_BREAK,
BLOCK_NOTE_BLOCK_BANJO,
BLOCK_NOTE_BLOCK_BASEDRUM,
BLOCK_NOTE_BLOCK_BASS,
BLOCK_NOTE_BLOCK_BELL,
BLOCK_NOTE_BLOCK_BIT,
BLOCK_NOTE_BLOCK_CHIME,
BLOCK_NOTE_BLOCK_COW_BELL,
BLOCK_NOTE_BLOCK_DIDGERIDOO,
BLOCK_NOTE_BLOCK_FLUTE,
BLOCK_NOTE_BLOCK_GUITAR,
BLOCK_NOTE_BLOCK_HARP,
BLOCK_NOTE_BLOCK_HAT,
BLOCK_NOTE_BLOCK_IRON_XYLOPHONE,
BLOCK_NOTE_BLOCK_PLING,
BLOCK_NOTE_BLOCK_SNARE,
BLOCK_NOTE_BLOCK_XYLOPHONE,
@@ -123,6 +154,11 @@ public enum Sound {
BLOCK_SAND_HIT,
BLOCK_SAND_PLACE,
BLOCK_SAND_STEP,
BLOCK_SCAFFOLDING_BREAK,
BLOCK_SCAFFOLDING_FALL,
BLOCK_SCAFFOLDING_HIT,
BLOCK_SCAFFOLDING_PLACE,
BLOCK_SCAFFOLDING_STEP,
BLOCK_SHULKER_BOX_CLOSE,
BLOCK_SHULKER_BOX_OPEN,
BLOCK_SLIME_BLOCK_BREAK,
@@ -130,6 +166,7 @@ public enum Sound {
BLOCK_SLIME_BLOCK_HIT,
BLOCK_SLIME_BLOCK_PLACE,
BLOCK_SLIME_BLOCK_STEP,
BLOCK_SMOKER_SMOKE,
BLOCK_SNOW_BREAK,
BLOCK_SNOW_FALL,
BLOCK_SNOW_HIT,
@@ -144,6 +181,8 @@ public enum Sound {
BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF,
BLOCK_STONE_PRESSURE_PLATE_CLICK_ON,
BLOCK_STONE_STEP,
BLOCK_SWEET_BERRY_BUSH_BREAK,
BLOCK_SWEET_BERRY_BUSH_PLACE,
BLOCK_TRIPWIRE_ATTACH,
BLOCK_TRIPWIRE_CLICK_OFF,
BLOCK_TRIPWIRE_CLICK_ON,
@@ -193,11 +232,14 @@ public enum Sound {
ENTITY_BOAT_PADDLE_LAND,
ENTITY_BOAT_PADDLE_WATER,
ENTITY_CAT_AMBIENT,
ENTITY_CAT_BEG_FOR_FOOD,
ENTITY_CAT_DEATH,
ENTITY_CAT_EAT,
ENTITY_CAT_HISS,
ENTITY_CAT_HURT,
ENTITY_CAT_PURR,
ENTITY_CAT_PURREOW,
ENTITY_CAT_STRAY_AMBIENT,
ENTITY_CHICKEN_AMBIENT,
ENTITY_CHICKEN_DEATH,
ENTITY_CHICKEN_EGG,
@@ -270,6 +312,7 @@ public enum Sound {
ENTITY_ENDER_PEARL_THROW,
ENTITY_EVOKER_AMBIENT,
ENTITY_EVOKER_CAST_SPELL,
ENTITY_EVOKER_CELEBRATE,
ENTITY_EVOKER_DEATH,
ENTITY_EVOKER_FANGS_ATTACK,
ENTITY_EVOKER_HURT,
@@ -290,6 +333,16 @@ public enum Sound {
ENTITY_FISHING_BOBBER_SPLASH,
ENTITY_FISHING_BOBBER_THROW,
ENTITY_FISH_SWIM,
ENTITY_FOX_AGGRO,
ENTITY_FOX_AMBIENT,
ENTITY_FOX_BITE,
ENTITY_FOX_DEATH,
ENTITY_FOX_EAT,
ENTITY_FOX_HURT,
ENTITY_FOX_SCREECH,
ENTITY_FOX_SLEEP,
ENTITY_FOX_SNIFF,
ENTITY_FOX_SPIT,
ENTITY_GENERIC_BIG_FALL,
ENTITY_GENERIC_BURN,
ENTITY_GENERIC_DEATH,
@@ -380,13 +433,31 @@ public enum Sound {
ENTITY_MAGMA_CUBE_SQUISH_SMALL,
ENTITY_MINECART_INSIDE,
ENTITY_MINECART_RIDING,
ENTITY_MOOSHROOM_CONVERT,
ENTITY_MOOSHROOM_EAT,
ENTITY_MOOSHROOM_MILK,
ENTITY_MOOSHROOM_SHEAR,
ENTITY_MOOSHROOM_SUSPICIOUS_MILK,
ENTITY_MULE_AMBIENT,
ENTITY_MULE_CHEST,
ENTITY_MULE_DEATH,
ENTITY_MULE_HURT,
ENTITY_OCELOT_AMBIENT,
ENTITY_OCELOT_DEATH,
ENTITY_OCELOT_HURT,
ENTITY_PAINTING_BREAK,
ENTITY_PAINTING_PLACE,
ENTITY_PANDA_AGGRESSIVE_AMBIENT,
ENTITY_PANDA_AMBIENT,
ENTITY_PANDA_BITE,
ENTITY_PANDA_CANT_BREED,
ENTITY_PANDA_DEATH,
ENTITY_PANDA_EAT,
ENTITY_PANDA_HURT,
ENTITY_PANDA_PRE_SNEEZE,
ENTITY_PANDA_SNEEZE,
ENTITY_PANDA_STEP,
ENTITY_PANDA_WORRIED_AMBIENT,
ENTITY_PARROT_AMBIENT,
ENTITY_PARROT_DEATH,
ENTITY_PARROT_EAT,
@@ -401,11 +472,15 @@ public enum Sound {
ENTITY_PARROT_IMITATE_ENDER_DRAGON,
ENTITY_PARROT_IMITATE_EVOKER,
ENTITY_PARROT_IMITATE_GHAST,
ENTITY_PARROT_IMITATE_GUARDIAN,
ENTITY_PARROT_IMITATE_HUSK,
ENTITY_PARROT_IMITATE_ILLUSIONER,
ENTITY_PARROT_IMITATE_MAGMA_CUBE,
ENTITY_PARROT_IMITATE_PANDA,
ENTITY_PARROT_IMITATE_PHANTOM,
ENTITY_PARROT_IMITATE_PILLAGER,
ENTITY_PARROT_IMITATE_POLAR_BEAR,
ENTITY_PARROT_IMITATE_RAVAGER,
ENTITY_PARROT_IMITATE_SHULKER,
ENTITY_PARROT_IMITATE_SILVERFISH,
ENTITY_PARROT_IMITATE_SKELETON,
@@ -433,6 +508,10 @@ public enum Sound {
ENTITY_PIG_HURT,
ENTITY_PIG_SADDLE,
ENTITY_PIG_STEP,
ENTITY_PILLAGER_AMBIENT,
ENTITY_PILLAGER_CELEBRATE,
ENTITY_PILLAGER_DEATH,
ENTITY_PILLAGER_HURT,
ENTITY_PLAYER_ATTACK_CRIT,
ENTITY_PLAYER_ATTACK_KNOCKBACK,
ENTITY_PLAYER_ATTACK_NODAMAGE,
@@ -446,6 +525,7 @@ public enum Sound {
ENTITY_PLAYER_HURT,
ENTITY_PLAYER_HURT_DROWN,
ENTITY_PLAYER_HURT_ON_FIRE,
ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH,
ENTITY_PLAYER_LEVELUP,
ENTITY_PLAYER_SMALL_FALL,
ENTITY_PLAYER_SPLASH,
@@ -469,6 +549,14 @@ public enum Sound {
ENTITY_RABBIT_DEATH,
ENTITY_RABBIT_HURT,
ENTITY_RABBIT_JUMP,
ENTITY_RAVAGER_AMBIENT,
ENTITY_RAVAGER_ATTACK,
ENTITY_RAVAGER_CELEBRATE,
ENTITY_RAVAGER_DEATH,
ENTITY_RAVAGER_HURT,
ENTITY_RAVAGER_ROAR,
ENTITY_RAVAGER_STEP,
ENTITY_RAVAGER_STUNNED,
ENTITY_SALMON_AMBIENT,
ENTITY_SALMON_DEATH,
ENTITY_SALMON_FLOP,
@@ -555,15 +643,41 @@ public enum Sound {
ENTITY_VEX_DEATH,
ENTITY_VEX_HURT,
ENTITY_VILLAGER_AMBIENT,
ENTITY_VILLAGER_CELEBRATE,
ENTITY_VILLAGER_DEATH,
ENTITY_VILLAGER_HURT,
ENTITY_VILLAGER_NO,
ENTITY_VILLAGER_TRADE,
ENTITY_VILLAGER_WORK_ARMORER,
ENTITY_VILLAGER_WORK_BUTCHER,
ENTITY_VILLAGER_WORK_CARTOGRAPHER,
ENTITY_VILLAGER_WORK_CLERIC,
ENTITY_VILLAGER_WORK_FARMER,
ENTITY_VILLAGER_WORK_FISHERMAN,
ENTITY_VILLAGER_WORK_FLETCHER,
ENTITY_VILLAGER_WORK_LEATHERWORKER,
ENTITY_VILLAGER_WORK_LIBRARIAN,
ENTITY_VILLAGER_WORK_MASON,
ENTITY_VILLAGER_WORK_SHEPHERD,
ENTITY_VILLAGER_WORK_TOOLSMITH,
ENTITY_VILLAGER_WORK_WEAPONSMITH,
ENTITY_VILLAGER_YES,
ENTITY_VINDICATOR_AMBIENT,
ENTITY_VINDICATOR_CELEBRATE,
ENTITY_VINDICATOR_DEATH,
ENTITY_VINDICATOR_HURT,
ENTITY_WANDERING_TRADER_AMBIENT,
ENTITY_WANDERING_TRADER_DEATH,
ENTITY_WANDERING_TRADER_DISAPPEARED,
ENTITY_WANDERING_TRADER_DRINK_MILK,
ENTITY_WANDERING_TRADER_DRINK_POTION,
ENTITY_WANDERING_TRADER_HURT,
ENTITY_WANDERING_TRADER_NO,
ENTITY_WANDERING_TRADER_REAPPEARED,
ENTITY_WANDERING_TRADER_TRADE,
ENTITY_WANDERING_TRADER_YES,
ENTITY_WITCH_AMBIENT,
ENTITY_WITCH_CELEBRATE,
ENTITY_WITCH_DEATH,
ENTITY_WITCH_DRINK,
ENTITY_WITCH_HURT,
@@ -610,6 +724,7 @@ public enum Sound {
ENTITY_ZOMBIE_VILLAGER_DEATH,
ENTITY_ZOMBIE_VILLAGER_HURT,
ENTITY_ZOMBIE_VILLAGER_STEP,
EVENT_RAID_HORN,
ITEM_ARMOR_EQUIP_CHAIN,
ITEM_ARMOR_EQUIP_DIAMOND,
ITEM_ARMOR_EQUIP_ELYTRA,
@@ -619,6 +734,8 @@ public enum Sound {
ITEM_ARMOR_EQUIP_LEATHER,
ITEM_ARMOR_EQUIP_TURTLE,
ITEM_AXE_STRIP,
ITEM_BOOK_PAGE_TURN,
ITEM_BOOK_PUT,
ITEM_BOTTLE_EMPTY,
ITEM_BOTTLE_FILL,
ITEM_BOTTLE_FILL_DRAGONBREATH,
@@ -629,13 +746,24 @@ public enum Sound {
ITEM_BUCKET_FILL_FISH,
ITEM_BUCKET_FILL_LAVA,
ITEM_CHORUS_FRUIT_TELEPORT,
ITEM_CROP_PLANT,
ITEM_CROSSBOW_HIT,
ITEM_CROSSBOW_LOADING_END,
ITEM_CROSSBOW_LOADING_MIDDLE,
ITEM_CROSSBOW_LOADING_START,
ITEM_CROSSBOW_QUICK_CHARGE_1,
ITEM_CROSSBOW_QUICK_CHARGE_2,
ITEM_CROSSBOW_QUICK_CHARGE_3,
ITEM_CROSSBOW_SHOOT,
ITEM_ELYTRA_FLYING,
ITEM_FIRECHARGE_USE,
ITEM_FLINTANDSTEEL_USE,
ITEM_HOE_TILL,
ITEM_NETHER_WART_PLANT,
ITEM_SHIELD_BLOCK,
ITEM_SHIELD_BREAK,
ITEM_SHOVEL_FLATTEN,
ITEM_SWEET_BERRIES_PICK_FROM_BUSH,
ITEM_TOTEM_USE,
ITEM_TRIDENT_HIT,
ITEM_TRIDENT_HIT_GROUND,
@@ -666,6 +794,11 @@ public enum Sound {
MUSIC_NETHER,
MUSIC_UNDER_WATER,
UI_BUTTON_CLICK,
UI_CARTOGRAPHY_TABLE_TAKE_RESULT,
UI_LOOM_SELECT_PATTERN,
UI_LOOM_TAKE_RESULT,
UI_STONECUTTER_SELECT_RECIPE,
UI_STONECUTTER_TAKE_RESULT,
UI_TOAST_CHALLENGE_COMPLETE,
UI_TOAST_IN,
UI_TOAST_OUT,

View File

@@ -1,11 +1,12 @@
package org.bukkit;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
/**
* Represents a countable statistic, which is tracked by the server.
*/
public enum Statistic {
public enum Statistic implements Keyed {
DAMAGE_DEALT,
DAMAGE_TAKEN,
DEATHS,
@@ -74,9 +75,21 @@ public enum Statistic {
DAMAGE_BLOCKED_BY_SHIELD,
DAMAGE_ABSORBED,
DAMAGE_RESISTED,
CLEAN_SHULKER_BOX;
CLEAN_SHULKER_BOX,
OPEN_BARREL,
INTERACT_WITH_BLAST_FURNACE,
INTERACT_WITH_SMOKER,
INTERACT_WITH_LECTERN,
INTERACT_WITH_CAMPFIRE,
INTERACT_WITH_CARTOGRAPHY_TABLE,
INTERACT_WITH_LOOM,
INTERACT_WITH_STONECUTTER,
BELL_RING,
RAID_TRIGGER,
RAID_WIN;
private final Type type;
private final NamespacedKey key;
private Statistic() {
this(Type.UNTYPED);
@@ -84,6 +97,7 @@ public enum Statistic {
private Statistic(/*@NotNull*/ Type type) {
this.type = type;
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
/**
@@ -123,6 +137,12 @@ public enum Statistic {
return type == Type.BLOCK;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* The type of statistic.
*

View File

@@ -2,15 +2,14 @@ package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang.Validate;
import org.bukkit.map.MapCursor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* This class handles the creation and storage of all structure types for
* Bukkit. Structure Types are the different kinds of structures that can be
@@ -20,7 +19,7 @@ import java.util.Objects;
* The registration of new {@link StructureType}s is case-sensitive.
*/
// Order is retrieved from WorldGenFactory
public class StructureType {
public final class StructureType {
private static final Map<String, StructureType> structureTypeMap = new HashMap<>();
@@ -31,7 +30,7 @@ public class StructureType {
* They are the only place where cave spider spawners and minecarts with
* chests can be found naturally.
*/
public static final StructureType MINESHAFT = register(new StructureType("Mineshaft", MapCursor.Type.RED_X));
public static final StructureType MINESHAFT = register(new StructureType("mineshaft", MapCursor.Type.RED_X));
/**
* Villages are naturally generating structures that form above ground.
@@ -39,7 +38,7 @@ public class StructureType {
* They are usually generated in desert, plains, taiga, and savanna biomes
* and are a site for villager spawns, with whom the player can trade.
*/
public static final StructureType VILLAGE = register(new StructureType("Village", MapCursor.Type.MANSION));
public static final StructureType VILLAGE = register(new StructureType("village", MapCursor.Type.MANSION));
/**
* Nether fortresses are very large complexes that mainly consist of
@@ -48,7 +47,7 @@ public class StructureType {
* They contain blaze spawners, nether wart farms, and loot chests. They are
* only generated in the nether dimension.
*/
public static final StructureType NETHER_FORTRESS = register(new StructureType("Fortress", MapCursor.Type.RED_X));
public static final StructureType NETHER_FORTRESS = register(new StructureType("fortress", MapCursor.Type.RED_X));
/**
* Strongholds are underground structures that consist of many rooms,
@@ -56,7 +55,7 @@ public class StructureType {
* <br>
* They can be found using an {@link Material#ENDER_EYE}.
*/
public static final StructureType STRONGHOLD = register(new StructureType("Stronghold", MapCursor.Type.MANSION));
public static final StructureType STRONGHOLD = register(new StructureType("stronghold", MapCursor.Type.MANSION));
/**
* Jungle pyramids (also known as jungle temples) are found in jungles.
@@ -65,7 +64,7 @@ public class StructureType {
* consist of three floors, with the bottom floor containing treasure
* chests.
*/
public static final StructureType JUNGLE_PYRAMID = register(new StructureType("Jungle_Pyramid", MapCursor.Type.RED_X));
public static final StructureType JUNGLE_PYRAMID = register(new StructureType("jungle_pyramid", MapCursor.Type.RED_X));
/**
* Ocean ruins are clusters of many different blocks that generate
@@ -74,27 +73,27 @@ public class StructureType {
* They come in my different variations. The cold variants consist primarily
* of stone brick, and the warm variants consist of sandstone.
*/
public static final StructureType OCEAN_RUIN = register(new StructureType("Ocean_Ruin", MapCursor.Type.TEMPLE));
public static final StructureType OCEAN_RUIN = register(new StructureType("ocean_ruin", MapCursor.Type.TEMPLE));
/**
* Desert pyramids (also known as desert temples) are found in deserts.
* <br>
* They are usually composed of sandstone and stained terracotta.
*/
public static final StructureType DESERT_PYRAMID = register(new StructureType("Desert_Pyramid", MapCursor.Type.RED_X));
public static final StructureType DESERT_PYRAMID = register(new StructureType("desert_pyramid", MapCursor.Type.RED_X));
/**
* Igloos are structures that generate in snowy biomes.
* <br>
* They consist of the house, as well as a basement.
*/
public static final StructureType IGLOO = register(new StructureType("Igloo", MapCursor.Type.RED_X));
public static final StructureType IGLOO = register(new StructureType("igloo", MapCursor.Type.RED_X));
/**
* Swamp huts (also known as witch huts) generate in swamp biomes and have
* the ability to spawn witches.
*/
public static final StructureType SWAMP_HUT = register(new StructureType("Swamp_Hut", MapCursor.Type.RED_X));
public static final StructureType SWAMP_HUT = register(new StructureType("swamp_hut", MapCursor.Type.RED_X));
/**
* Ocean monuments are underwater structures.
@@ -103,7 +102,7 @@ public class StructureType {
* lanterns. They are the only place guardians and elder guardians spawn
* naturally.
*/
public static final StructureType OCEAN_MONUMENT = register(new StructureType("Monument", MapCursor.Type.TEMPLE));
public static final StructureType OCEAN_MONUMENT = register(new StructureType("monument", MapCursor.Type.TEMPLE));
/**
* End Cities are tall castle-like structures that generate in the outer
@@ -112,7 +111,7 @@ public class StructureType {
* They consist primarily of end stone bricks, purpur blocks, and end rods.
* They are the only place where shulkers can be found.
*/
public static final StructureType END_CITY = register(new StructureType("EndCity", MapCursor.Type.RED_X));
public static final StructureType END_CITY = register(new StructureType("endcity", MapCursor.Type.RED_X));
/**
* Mansions (also known as woodland mansions) are massive house structures
@@ -121,13 +120,13 @@ public class StructureType {
* They are the only place where evokers, vindicators, and vexes spawn
* naturally (but only once)
*/
public static final StructureType WOODLAND_MANSION = register(new StructureType("Mansion", MapCursor.Type.MANSION));
public static final StructureType WOODLAND_MANSION = register(new StructureType("mansion", MapCursor.Type.MANSION));
/**
* Buried treasure consists of a single chest buried in the beach sand or
* gravel, with random loot in it.
*/
public static final StructureType BURIED_TREASURE = register(new StructureType("Buried_Treasure", MapCursor.Type.RED_X));
public static final StructureType BURIED_TREASURE = register(new StructureType("buried_treasure", MapCursor.Type.RED_X));
/**
* Shipwrecks are structures that generate on the floor of oceans or
@@ -136,7 +135,12 @@ public class StructureType {
* They are made up of wood materials, and contain 1-3 loot chests. They can
* generate sideways, upside-down, or upright.
*/
public static final StructureType SHIPWRECK = register(new StructureType("Shipwreck", MapCursor.Type.RED_X));
public static final StructureType SHIPWRECK = register(new StructureType("shipwreck", MapCursor.Type.RED_X));
/**
* Pillager outposts may contain crossbows.
*/
public static final StructureType PILLAGER_OUTPOST = register(new StructureType("pillager_outpost", MapCursor.Type.RED_X));
/* ****************
* STRUCTURE TYPES REGISTERED ABOVE THIS

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
/**
* Represents a tag that may be defined by the server or a resource pack to
@@ -57,6 +56,10 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all wooden slabs.
*/
Tag<Material> WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class);
/**
* Vanilla block tag representing all wooden fences.
*/
Tag<Material> WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class);
/**
* Vanilla block tag representing all wooden pressure plates.
*/
@@ -118,6 +121,10 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all slabs.
*/
Tag<Material> SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class);
/**
* Vanilla block tag representing all walls.
*/
Tag<Material> WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class);
/**
* Vanilla block tag representing all damaged and undamaged anvils.
*/
@@ -139,6 +146,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all empty and filled flower pots.
*/
Tag<Material> FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class);
/**
* Vanilla block tag representing all small flowers.
*/
Tag<Material> SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class);
/**
* Vanilla block tag representing all beds.
*/
Tag<Material> BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class);
/**
* Vanilla block tag representing all fences.
*/
Tag<Material> FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class);
/**
* Vanilla block tag denoting blocks that enderman may pick up and hold.
*/
@@ -175,6 +194,26 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all coral.
*/
Tag<Material> CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class);
/**
* Vanilla block tag denoting all blocks bamboo may be planted on.
*/
Tag<Material> BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class);
/**
* Vanilla block tag denoting dirt like blocks.
*/
Tag<Material> DIRT_LIKE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt_like"), Material.class);
/**
* Vanilla block tag representing all standing signs.
*/
Tag<Material> STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class);
/**
* Vanilla block tag representing all wall signs.
*/
Tag<Material> WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class);
/**
* Vanilla block tag representing all signs.
*/
Tag<Material> SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class);
/**
* Key for the built in item registry.
*/
@@ -191,6 +230,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla item tag representing all fish items.
*/
Tag<Material> ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class);
/**
* Vanilla item tag representing all music disc items.
*/
Tag<Material> ITEMS_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("music_discs"), Material.class);
/**
* Vanilla item tag representing all coal items.
*/
Tag<Material> ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class);
/**
* Vanilla item tag representing all arrow items.
*/
Tag<Material> ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class);
/**
* Returns whether or not this tag has an entry for the specified item.

View File

@@ -1,100 +0,0 @@
package org.bukkit;
import org.jetbrains.annotations.NotNull;
/**
* The Travel Agent handles the creation and the research of Nether and End
* portals when Entities try to use one.
* <p>
* It is used in {@link org.bukkit.event.entity.EntityPortalEvent} and in
* {@link org.bukkit.event.player.PlayerPortalEvent} to help developers
* reproduce and/or modify Vanilla behaviour.
*/
public interface TravelAgent {
/**
* Set the Block radius to search in for available portals.
*
* @param radius the radius in which to search for a portal from the
* location
* @return this travel agent
*/
@NotNull
public TravelAgent setSearchRadius(int radius);
/**
* Gets the search radius value for finding an available portal.
*
* @return the currently set search radius
*/
public int getSearchRadius();
/**
* Sets the maximum radius from the given location to create a portal.
*
* @param radius the radius in which to create a portal from the location
* @return this travel agent
*/
@NotNull
public TravelAgent setCreationRadius(int radius);
/**
* Gets the maximum radius from the given location to create a portal.
*
* @return the currently set creation radius
*/
public int getCreationRadius();
/**
* Returns whether the TravelAgent will attempt to create a destination
* portal or not.
*
* @return whether the TravelAgent should create a destination portal or
* not
*/
public boolean getCanCreatePortal();
/**
* Sets whether the TravelAgent should attempt to create a destination
* portal or not.
*
* @param create Sets whether the TravelAgent should create a destination
* portal or not
*/
public void setCanCreatePortal(boolean create);
/**
* Attempt to find a portal near the given location, if a portal is not
* found it will attempt to create one.
*
* @param location the location where the search for a portal should begin
* @return the location of a portal which has been found or returns the
* location passed to the method if unsuccessful
* @see #createPortal(Location)
*/
@NotNull
public Location findOrCreate(@NotNull Location location);
/**
* Attempt to find a portal near the given location.
*
* @param location the desired location of the portal
* @return the location of the nearest portal to the location
*/
@NotNull
public Location findPortal(@NotNull Location location);
/**
* Attempt to create a portal near the given location.
* <p>
* In the case of a Nether portal teleportation, this will attempt to
* create a Nether portal.
* <p>
* In the case of an Ender portal teleportation, this will (re-)create the
* obsidian platform and clean blocks above it.
*
* @param location the desired location of the portal
* @return true if a portal was successfully created
*/
public boolean createPortal(@NotNull Location location);
}

View File

@@ -1,8 +1,7 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
/**
@@ -37,7 +36,7 @@ public enum TreeSpecies {
;
private final byte data;
private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
private static final Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();
private TreeSpecies(final int data) {
this.data = (byte) data;

View File

@@ -28,6 +28,8 @@ public interface UnsafeValues {
BlockData fromLegacy(Material material, byte data);
Material getMaterial(String material, int version);
int getDataVersion();
ItemStack modifyItemStack(ItemStack stack, String arguments);
@@ -68,9 +70,22 @@ public interface UnsafeValues {
*/
boolean removeAdvancement(NamespacedKey key);
// Paper start - Add legacy check util
// Paper start
/**
* Server name to report to timings v2
* @return name
*/
String getTimingsServerName();
/**
* Called once by the version command on first use, then cached.
*/
default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
}
static boolean isLegacyPlugin(org.bukkit.plugin.Plugin plugin) {
return !("1.13".equals(plugin.getDescription().getAPIVersion()));
return !"1.13".equals(plugin.getDescription().getAPIVersion()) && !"1.14".equals(plugin.getDescription().getAPIVersion());
}
// Paper end
}

View File

@@ -1,12 +1,11 @@
package org.bukkit;
import com.google.common.collect.ImmutableMap;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -10,15 +10,24 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.Predicate;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.*;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.Metadatable;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Consumer;
@@ -33,22 +42,6 @@ import org.jetbrains.annotations.Nullable;
*/
public interface World extends PluginMessageRecipient, Metadatable {
// Akarin start
/**
* Get the nearest village of the location in range.
*
* @return The nearest village, null if there is no village in range.
*/
public io.akarin.server.api.structure.Village getNearestVillage(@NotNull Location location, double xRadius, double yRadius, double zRadius);
/**
* Get villages which are near by the location in range.
*
* @return All the villages in range, an empty list if there is no village in range.
*/
public List<io.akarin.server.api.structure.Village> getVillagesInRange(@NotNull Location location, double xRadius, double yRadius, double zRadius);
// Akarin end
// Paper start
/**
* @return The amount of Entities in this world
@@ -169,6 +162,79 @@ public interface World extends PluginMessageRecipient, Metadatable {
@NotNull
public Block getHighestBlockAt(@NotNull Location location);
// Paper start - Add heightmap API
/**
* Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions.
* <p>
* <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
* throwing an {@code UnsupportedOperationException}.
* </p>
*
* @param x The block's x-coordinate.
* @param z The block's z-coordinate.
* @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
* @return The highest block's y-coordinate at (x, z) that matches the specified heightmap's conditions.
* @throws UnsupportedOperationException If the heightmap type is not supported.
*
* @see com.destroystokyo.paper.HeightmapType
*/
public int getHighestBlockYAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException;
/**
* Returns the highest block's y-coordinate at the specified block coordinates that match the specified heightmap's conditions.
* Note that the y-coordinate of the specified location is ignored.
* <p>
* <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
* throwing an {@code UnsupportedOperationException}.
* </p>
*
* @param location The specified block coordinates.
* @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
* @return The highest block's y-coordinate at {@code location} that matches the specified heightmap's conditions.
* @throws UnsupportedOperationException If the heightmap type is not supported.
* @see com.destroystokyo.paper.HeightmapType
*/
default int getHighestBlockYAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
return this.getHighestBlockYAt(location.getBlockX(), location.getBlockZ(), heightmap);
}
/**
* Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions.
* <p>
* <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
* throwing an {@code UnsupportedOperationException}.
* </p>
* @param x The block's x-coordinate.
* @param z The block's z-coordinate.
* @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
* @return The highest {@link Block} at (x, z) that matches the specified heightmap's conditions.
* @throws UnsupportedOperationException If the heightmap type is not supported.
* @see com.destroystokyo.paper.HeightmapType
*/
@NotNull
default Block getHighestBlockAt(int x, int z, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
return this.getBlockAt(x, this.getHighestBlockYAt(x, z, heightmap), z);
}
/**
* Returns the highest {@link Block} at the specified block coordinates that match the specified heightmap's conditions.
* Note that the y-coordinate of the specified location is ignored.
* <p>
* <b>implNote:</b> Implementations are recommended to use an iterative search as a fallback before resorting to
* throwing an {@code UnsupportedOperationException}.
* </p>
* @param location The specified block coordinates.
* @param heightmap The specified heightmap to use. See {@link com.destroystokyo.paper.HeightmapType}
* @return The highest {@link Block} at {@code location} that matches the specified heightmap's conditions.
* @throws UnsupportedOperationException If the heightmap type is not supported.
* @see com.destroystokyo.paper.HeightmapType
*/
@NotNull
default Block getHighestBlockAt(@NotNull Location location, @NotNull com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException {
return this.getHighestBlockAt(location.getBlockX(), location.getBlockZ(), heightmap);
}
// Paper end
/**
* Gets the {@link Chunk} at the given coordinates
*
@@ -593,7 +659,11 @@ public interface World extends PluginMessageRecipient, Metadatable {
public Chunk[] getLoadedChunks();
/**
* Loads the specified {@link Chunk}
* Loads the specified {@link Chunk}.
* <p>
* <b>This method will keep the specified chunk loaded until one of the
* unload methods is manually called. Callers are advised to instead use
* getChunkAt which will only temporarily load the requested chunk.</b>
*
* @param chunk The chunk to load
*/
@@ -625,11 +695,19 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return true if the chunk is loaded and in use by one or more players,
* otherwise false
* @deprecated This method was added to facilitate chunk garbage collection.
* As of the current Minecraft version chunks are now strictly managed and
* will not be loaded for more than 1 tick unless they are in use.
*/
@Deprecated
public boolean isChunkInUse(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
* Loads the {@link Chunk} at the specified coordinates.
* <p>
* <b>This method will keep the specified chunk loaded until one of the
* unload methods is manually called. Callers are advised to instead use
* getChunkAt which will only temporarily load the requested chunk.</b>
* <p>
* If the chunk does not exist, it will be generated.
* <p>
@@ -642,7 +720,11 @@ public interface World extends PluginMessageRecipient, Metadatable {
public void loadChunk(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
* Loads the {@link Chunk} at the specified coordinates.
* <p>
* <b>This method will keep the specified chunk loaded until one of the
* unload methods is manually called. Callers are advised to instead use
* getChunkAt which will only temporarily load the requested chunk.</b>
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@@ -655,8 +737,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where safe and save is true
* This method is analogous to {@link #unloadChunk(int, int, boolean)}
* where save is true.
*
* @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false
@@ -666,8 +748,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where safe and saveis true
* This method is analogous to {@link #unloadChunk(int, int, boolean)}
* where save is true.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@@ -677,10 +759,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and optionally saves the {@link Chunk} at the specified
* coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where save is true
* coordinates.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@@ -689,27 +768,9 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean unloadChunk(int x, int z, boolean save);
/**
* Unloads and optionally saves the {@link Chunk} at the specified
* coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are
* nearby
* @return true if the chunk has unloaded successfully, otherwise false
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
public boolean unloadChunk(int x, int z, boolean save, boolean safe);
/**
* Safely queues the {@link Chunk} at the specified coordinates for
* unloading
* <p>
* This method is analogous to {@link #unloadChunkRequest(int, int,
* boolean)} where safe is true
* unloading.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@@ -717,18 +778,6 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean unloadChunkRequest(int x, int z);
/**
* Queues the {@link Chunk} at the specified coordinates for unloading
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
public boolean unloadChunkRequest(int x, int z, boolean safe);
/**
* Regenerates the {@link Chunk} at the specified coordinates
*
@@ -749,7 +798,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually refreshed
*
*
* @deprecated This method is not guaranteed to work suitably across all client implementations.
*/
@Deprecated
@@ -775,7 +824,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param forced
* @param forced force load status
*/
public void setChunkForceLoaded(int x, int z, boolean forced);
@@ -789,6 +838,94 @@ public interface World extends PluginMessageRecipient, Metadatable {
@NotNull
public Collection<Chunk> getForceLoadedChunks();
/**
* Adds a plugin ticket for the specified chunk, loading the chunk if it is
* not already loaded.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param plugin Plugin which owns the ticket
* @return {@code true} if a plugin ticket was added, {@code false} if the
* ticket already exists for the plugin
* @throws IllegalStateException If the specified plugin is not enabled
* @see #removePluginChunkTicket(int, int, Plugin)
*/
public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin);
/**
* Removes the specified plugin's ticket for the specified chunk
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param plugin Plugin which owns the ticket
* @return {@code true} if the plugin ticket was removed, {@code false} if
* there is no plugin ticket for the chunk
* @see #addPluginChunkTicket(int, int, Plugin)
*/
public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin);
/**
* Removes all plugin tickets for the specified plugin
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param plugin Specified plugin
* @see #addPluginChunkTicket(int, int, Plugin)
* @see #removePluginChunkTicket(int, int, Plugin)
*/
public void removePluginChunkTickets(@NotNull Plugin plugin);
/**
* Retrieves a collection specifying which plugins have tickets for the
* specified chunk. This collection is not updated when plugin tickets are
* added or removed to the chunk.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return unmodifiable collection containing which plugins have tickets for
* the chunk
* @see #addPluginChunkTicket(int, int, Plugin)
* @see #removePluginChunkTicket(int, int, Plugin)
*/
@NotNull
public Collection<Plugin> getPluginChunkTickets(int x, int z);
/**
* Returns a map of which plugins have tickets for what chunks. The returned
* map is not updated when plugin tickets are added or removed to chunks. If
* a plugin has no tickets, it will be absent from the map.
* <p>
* A plugin ticket will prevent a chunk from unloading until it is
* explicitly removed. A plugin instance may only have one ticket per chunk,
* but each chunk can have multiple plugin tickets.
* </p>
*
* @return unmodifiable map containing which plugins have tickets for what
* chunks
* @see #addPluginChunkTicket(int, int, Plugin)
* @see #removePluginChunkTicket(int, int, Plugin)
*/
@NotNull
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets();
/**
* Drops an item at the specified {@link Location}
*
@@ -834,7 +971,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @return Arrow entity spawned as a result of this method
*/
@NotNull
public <T extends Arrow> T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz);
public <T extends AbstractArrow> T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz);
/**
* Creates a tree at the given {@link Location}
@@ -916,7 +1053,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Get a collection of all entities in this World matching the given
* class/interface
*
*
* @param <T> an entity subclass
* @param cls The class representing the type of entity to match
* @return A List of all Entities currently residing in this world that
@@ -1638,6 +1775,21 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks);
/**
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire or breaking blocks.
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @param breakBlocks Whether or not to have blocks be destroyed
* @param source the source entity, used for tracking damage
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source);
/**
* Creates explosion at given coordinates with given power
*
@@ -1738,9 +1890,10 @@ public interface World extends PluginMessageRecipient, Metadatable {
public default boolean createExplosion(@NotNull Entity source, float power) {
return createExplosion(source, source.getLocation(), power, true, true);
}
// Paper end
/**
* Creates explosion at given location with given power and optionally
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire or breaking blocks.
*
* @param loc Location to blow up
@@ -1749,10 +1902,20 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param breakBlocks Whether or not to have blocks be destroyed
* @return false if explosion was canceled, otherwise true
*/
public default boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) {
return createExplosion(loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks);
}
// Paper end
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks);
/**
* Creates explosion at given coordinates with given power and optionally
* setting blocks on fire or breaking blocks.
*
* @param loc Location to blow up
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @param breakBlocks Whether or not to have blocks be destroyed
* @param source the source entity, used for tracking damage
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, @Nullable Entity source);
/**
* Gets the {@link Environment} type of this world
@@ -2230,7 +2393,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* <p>
* <b>Note:</b> If set to a negative number the world will use the
* server-wide spawn limit instead.
*
*
* @param limit the new mob limit
*/
void setMonsterSpawnLimit(int limit);
@@ -2249,7 +2412,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* <p>
* <b>Note:</b> If set to a negative number the world will use the
* server-wide spawn limit instead.
*
*
* @param limit the new mob limit
*/
void setAnimalSpawnLimit(int limit);
@@ -2268,7 +2431,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* <p>
* <b>Note:</b> If set to a negative number the world will use the
* server-wide spawn limit instead.
*
*
* @param limit the new mob limit
*/
void setWaterAnimalSpawnLimit(int limit);
@@ -2287,7 +2450,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* <p>
* <b>Note:</b> If set to a negative number the world will use the
* server-wide spawn limit instead.
*
*
* @param limit the new mob limit
*/
void setAmbientSpawnLimit(int limit);
@@ -2457,6 +2620,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* Spawns the particle (the number of times specified by count)
* at the target location.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param location the location to spawn at
* @param count the number of particles
@@ -2471,6 +2635,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* Spawns the particle (the number of times specified by count)
* at the target location.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param x the position on the x axis to spawn at
* @param y the position on the y axis to spawn at
@@ -2520,6 +2685,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param location the location to spawn at
* @param count the number of particles
@@ -2538,6 +2704,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param x the position on the x axis to spawn at
* @param y the position on the y axis to spawn at
@@ -2594,6 +2761,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param location the location to spawn at
* @param count the number of particles
@@ -2614,6 +2782,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param x the position on the x axis to spawn at
* @param y the position on the y axis to spawn at
@@ -2686,6 +2855,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param location the location to spawn at
* @param count the number of particles
@@ -2709,6 +2879,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
* randomized positively and negatively by the offset parameters
* on each axis.
*
* @param <T> type of particle data (see {@link Particle#getDataType()}
* @param particle the particle to spawn
* @param x the position on the x axis to spawn at
* @param y the position on the y axis to spawn at
@@ -2755,6 +2926,15 @@ public interface World extends PluginMessageRecipient, Metadatable {
@Nullable
public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored);
// Spigot start
/**
* Returns the view distance used for this world.
*
* @return the view distance used for this world
*/
int getViewDistance();
// Spigot end
// Spigot start
public class Spigot
{
@@ -2790,6 +2970,24 @@ public interface World extends PluginMessageRecipient, Metadatable {
Spigot spigot();
// Spigot end
/**
* Finds the nearest raid close to the given location.
*
* @param location the origin location
* @param radius the radius
* @return the closest {@link Raid}, or null if no raids were found
*/
@Nullable
public Raid locateNearestRaid(@NotNull Location location, int radius);
/**
* Gets all raids that are going on over this world.
*
* @return the list of all active raids
*/
@NotNull
public List<Raid> getRaids();
/**
* Represents various map environment types that a world may be
*/

View File

@@ -48,6 +48,8 @@ public class WorldCreator {
seed = world.getSeed();
environment = world.getEnvironment();
generator = world.getGenerator();
type = world.getWorldType();
generateStructures = world.canGenerateStructures();
return this;
}
@@ -67,6 +69,9 @@ public class WorldCreator {
seed = creator.seed();
environment = creator.environment();
generator = creator.generator();
type = creator.type();
generateStructures = creator.generateStructures();
generatorSettings = creator.generatorSettings();
return this;
}

View File

@@ -1,11 +1,10 @@
package org.bukkit;
import com.google.common.collect.Maps;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
/**
* Represents various types of worlds that may exist
*/
@@ -18,7 +17,7 @@ public enum WorldType {
CUSTOMIZED("CUSTOMIZED"),
BUFFET("BUFFET");
private final static Map<String, WorldType> BY_NAME = Maps.newHashMap();
private static final Map<String, WorldType> BY_NAME = Maps.newHashMap();
private final String name;
private WorldType(/*@NotNull*/ String name) {

View File

@@ -1,10 +1,9 @@
package org.bukkit.advancement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Date;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* The individual status of an advancement for a player. This class is not

View File

@@ -1,8 +1,7 @@
package org.bukkit.attribute;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import org.jetbrains.annotations.NotNull;
/**
* Represents a mutable instance of an attribute and its associated modifiers

View File

@@ -1,15 +1,14 @@
package org.bukkit.block;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.block.banner.Pattern;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Represents a captured state of a banner.
*/
public interface Banner extends BlockState {
public interface Banner extends TileState {
/**
* Returns the base color for this banner

View File

@@ -0,0 +1,8 @@
package org.bukkit.block;
import org.bukkit.loot.Lootable;
/**
* Represents a captured state of a Barrel.
*/
public interface Barrel extends Container, Lootable { }

View File

@@ -3,7 +3,6 @@ package org.bukkit.block;
import java.util.Collection;
import org.bukkit.Nameable;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
@@ -12,15 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a beacon.
*/
public interface Beacon extends Container, Nameable {
@NotNull
@Override
BeaconInventory getInventory();
@NotNull
@Override
BeaconInventory getSnapshotInventory();
public interface Beacon extends TileState, Lockable, Nameable {
/**
* Returns the list of players within the beacon's range of effect.

View File

@@ -7,4 +7,4 @@ import org.bukkit.material.Colorable;
* @deprecated does not provide useful information beyond the material itself
*/
@Deprecated
public interface Bed extends BlockState, Colorable { }
public interface Bed extends TileState, Colorable { }

View File

@@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of Bell.
*/
public interface Bell extends TileState { }

View File

@@ -1,9 +1,14 @@
package org.bukkit.block;
import java.util.Locale;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Holds all accepted Biomes in the default server
*/
public enum Biome {
public enum Biome implements Keyed {
OCEAN,
PLAINS,
DESERT,
@@ -76,5 +81,19 @@ public enum Biome {
SHATTERED_SAVANNA_PLATEAU,
ERODED_BADLANDS,
MODIFIED_WOODED_BADLANDS_PLATEAU,
MODIFIED_BADLANDS_PLATEAU
MODIFIED_BADLANDS_PLATEAU,
BAMBOO_JUNGLE,
BAMBOO_JUNGLE_HILLS;
private final NamespacedKey key;
private Biome() {
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
}

View File

@@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of a blast furnace.
*/
public interface BlastFurnace extends Furnace { }

View File

@@ -170,20 +170,16 @@ public interface Block extends Metadatable {
* The return value can be computed as follows:
* <br>
* {@code long value = ((long)x & 0x7FFFFFF) | (((long)z & 0x7FFFFFF) << 27) | ((long)y << 54);}
* </br>
* </p>
*
* <p>
* And may be unpacked as follows:
* <br>
* {@code int x = (int) ((packed << 37) >> 37);}
* </br>
* <br>
* {@code int y = (int) (packed >>> 54);}
* </br>
* <br>
* {@code int z = (int) ((packed << 10) >> 37);}
* </br>
* </p>
*
* @return This block's x, y, and z coordinates packed into a long value
@@ -311,7 +307,7 @@ public interface Block extends Metadatable {
/**
* Gets the face relation of this block compared to the given block.
* <p>
* For example:
* For example:
* <pre>{@code
* Block current = world.getBlockAt(100, 100, 100);
* Block target = world.getBlockAt(100, 101, 100);
@@ -532,4 +528,16 @@ public interface Block extends Metadatable {
*/
@NotNull
BoundingBox getBoundingBox();
// Paper start
/**
* Gets the {@link com.destroystokyo.paper.block.BlockSoundGroup} for this block.
* <p>
* This object contains the block, step, place, hit, and fall sounds.
*
* @return the sound group for this block
*/
@NotNull
com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup();
// Paper end
}

View File

@@ -1,13 +1,12 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.BrewerInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a brewing stand.
*/
public interface BrewingStand extends Container, Nameable {
public interface BrewingStand extends Container {
/**
* How much time is left in the brewing cycle.

View File

@@ -0,0 +1,75 @@
package org.bukkit.block;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a campfire.
*/
public interface Campfire extends TileState {
/**
* @see Inventory#getSize()
*
* @return The size of the inventory
*/
int getSize();
/**
* @see Inventory#getItem(int)
*
* @param index The index of the Slot's ItemStack to return
* @return The ItemStack in the slot
*/
@Nullable
ItemStack getItem(int index);
/**
* @see Inventory#setItem(int, org.bukkit.inventory.ItemStack)
*
* @param index The index where to put the ItemStack
* @param item The ItemStack to set
*/
void setItem(int index, @Nullable ItemStack item);
/**
* Get cook time.
*
* This is the amount of time the item has been cooking for.
*
* @param index item slot index
* @return Cook time
*/
int getCookTime(int index);
/**
* Set cook time.
*
* This is the amount of time the item has been cooking for.
*
* @param index item slot index
* @param cookTime Cook time
*/
void setCookTime(int index, int cookTime);
/**
* Get cook time total.
*
* This is the amount of time the item is required to cook for.
*
* @param index item slot index
* @return Cook time total
*/
int getCookTimeTotal(int index);
/**
* Set cook time.
*
* This is the amount of time the item is required to cook for.
*
* @param index item slot index
* @param cookTimeTotal Cook time total
*/
void setCookTimeTotal(int index, int cookTimeTotal);
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.block;
import com.destroystokyo.paper.loottable.LootableBlockInventory;
import org.bukkit.Nameable;
import com.destroystokyo.paper.loottable.LootableBlockInventory; // Paper
import org.bukkit.Nameable; // Paper
import org.bukkit.inventory.Inventory;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.NotNull;
@@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a chest.
*/
public interface Chest extends Container, Nameable, LootableBlockInventory { // Paper
public interface Chest extends Container, LootableBlockInventory { // Paper
/**
* Gets the inventory of the chest block represented by this block state.

View File

@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a command block.
*/
public interface CommandBlock extends BlockState {
public interface CommandBlock extends TileState {
/**
* Gets the command that this CommandBlock will run when powered.

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of an on / off comparator.
*/
public interface Comparator extends BlockState { }
public interface Comparator extends TileState { }

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of a conduit.
*/
public interface Conduit extends BlockState { }
public interface Conduit extends TileState { }

View File

@@ -1,13 +1,14 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a container block.
*/
public interface Container extends BlockState, InventoryHolder, Lockable {
public interface Container extends TileState, BlockInventoryHolder, Lockable, Nameable {
/**
* Gets the inventory of the block represented by this block state.

View File

@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a creature spawner.
*/
public interface CreatureSpawner extends BlockState {
public interface CreatureSpawner extends TileState {
/**
* Get the spawner's creature type.
@@ -199,4 +199,18 @@ public interface CreatureSpawner extends BlockState {
* @param spawnRange the new spawn range
*/
public void setSpawnRange(int spawnRange);
// Paper start
/**
* Check if spawner is activated (a player is close enough)
*
* @return True if a player is close enough to activate it
*/
public boolean isActivated();
/**
* Resets the spawn delay timer within the min/max range
*/
public void resetTimer();
// Paper end
}

View File

@@ -3,4 +3,4 @@ package org.bukkit.block;
/**
* Represents a captured state of a (possibly inverted) daylight detector.
*/
public interface DaylightDetector extends BlockState { }
public interface DaylightDetector extends TileState { }

View File

@@ -18,6 +18,7 @@ public class DoubleChest implements InventoryHolder {
inventory = chest;
}
@Override
@NotNull
public Inventory getInventory() {
return inventory;

View File

@@ -1,13 +1,12 @@
package org.bukkit.block;
import com.destroystokyo.paper.loottable.LootableBlockInventory;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
/**
* Represents a captured state of a dropper.
*/
public interface Dropper extends Container, Nameable, LootableBlockInventory { // Paper
public interface Dropper extends Container, LootableBlockInventory { // Paper
/**
* Tries to drop a randomly selected item from the dropper's inventory,
@@ -16,7 +15,7 @@ public interface Dropper extends Container, Nameable, LootableBlockInventory { /
* Normal behavior of a dropper is as follows:
* <p>
* If the block that the dropper is facing is an InventoryHolder,
* the randomly selected ItemStack is placed within that
* the randomly selected ItemStack is placed within that
* Inventory in the first slot that's available, starting with 0 and
* counting up. If the inventory is full, nothing happens.
* <p>
@@ -26,7 +25,7 @@ public interface Dropper extends Container, Nameable, LootableBlockInventory { /
* <p>
* If the block represented by this state is no longer a dropper, this will
* do nothing.
*
*
* @throws IllegalStateException if this block state is not placed
*/
public void drop();

View File

@@ -5,4 +5,4 @@ import org.bukkit.Nameable;
/**
* Represents a captured state of an enchanting table.
*/
public interface EnchantingTable extends BlockState, Nameable { }
public interface EnchantingTable extends TileState, Nameable { }

View File

@@ -6,14 +6,14 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of an end gateway.
*/
public interface EndGateway extends BlockState {
public interface EndGateway extends TileState {
/**
* Gets the location that entities are teleported to when
* Gets the location that entities are teleported to when
* entering the gateway portal.
* <p>
* If this block state is not placed the location's world will be null.
*
*
* @return the gateway exit location
*/
@Nullable
@@ -24,7 +24,7 @@ public interface EndGateway extends BlockState {
* they enter the gateway portal.
* <p>
* If this block state is not placed the location's world has to be null.
*
*
* @param location the new exit location
* @throws IllegalArgumentException for differing worlds
*/
@@ -33,7 +33,7 @@ public interface EndGateway extends BlockState {
/**
* Gets whether this gateway will teleport entities directly to
* the exit location instead of finding a nearby location.
*
*
* @return true if the gateway is teleporting to the exact location
*/
boolean isExactTeleport();
@@ -41,7 +41,7 @@ public interface EndGateway extends BlockState {
/**
* Sets whether this gateway will teleport entities directly to
* the exit location instead of finding a nearby location.
*
*
* @param exact whether to teleport to the exact location
*/
void setExactTeleport(boolean exact);

Some files were not shown because too many files have changed in this diff Show More