Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 11:00:05 +01:00
Merge pull request #89 from IntellectualSites/new-vector-system
New vector system
Dieser Commit ist enthalten in:
Commit
c3a54c167d
18
.travis.yml
18
.travis.yml
@ -1,18 +0,0 @@
|
||||
language: java
|
||||
notifications:
|
||||
email: false
|
||||
before_install: chmod +x gradlew
|
||||
install: ./gradlew setupCIWorkspace -s
|
||||
script: ./gradlew build -s
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
# Caching for Gradle files, prevents hitting Maven too much.
|
||||
before_cache:
|
||||
- find $HOME/.gradle/ -name '*.lock' -print -exec rm -f {} \;
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.gradle/caches/
|
||||
- $HOME/.gradle/wrapper/
|
||||
|
||||
# Faster builds without sudo.
|
||||
sudo: false
|
50
COMPILING.md
50
COMPILING.md
@ -1,50 +0,0 @@
|
||||
Compiling
|
||||
=========
|
||||
|
||||
You can compile WorldEdit as long as you have the [Java Development Kit (JDK)](http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html) for Java 8 or newer.
|
||||
You only need one version of the JDK installed.
|
||||
|
||||
The build process uses Gradle, which you do *not* need to download. WorldEdit is a multi-module project with four modules:
|
||||
|
||||
* `worldedit-core` contains the WorldEdit API
|
||||
* `worldedit-bukkit` is the Bukkit plugin
|
||||
* `worldedit-sponge` is the Sponge plugin
|
||||
* `worldedit-forge` is the Forge mod
|
||||
|
||||
## To compile...
|
||||
|
||||
### On Windows
|
||||
|
||||
1. Shift + right click the folder with WorldEdit's files and click "Open command prompt".
|
||||
2. `gradlew clean setupDecompWorkspace`
|
||||
3. `gradlew build`
|
||||
|
||||
### On Linux, BSD, or Mac OS X
|
||||
|
||||
1. In your terminal, navigate to the folder with WorldEdit's files (`cd /folder/of/worldedit/files`)
|
||||
2. `./gradlew clean setupDecompWorkspace`
|
||||
3. `./gradlew build`
|
||||
|
||||
## Then you will find...
|
||||
|
||||
You will find:
|
||||
|
||||
* The core WorldEdit API in **worldedit-core/build/libs**
|
||||
* WorldEdit for Bukkit in **worldedit-bukkit/build/libs**
|
||||
* WorldEdit for Sponge in **worldedit-sponge/build/libs**
|
||||
* WorldEdit for Forge in **worldedit-forge/build/libs**
|
||||
|
||||
If you want to use WorldEdit, use the `-dist` version.
|
||||
|
||||
(The -dist version includes WorldEdit + necessary libraries.)
|
||||
|
||||
### Note regarding `setupDecompWorkspace`
|
||||
`setupDecompWorkspace` requires more memory than is usually given to Gradle by default.
|
||||
If it fails, you should put `org.gradle.jvmargs=-Xmx3G` in `gradle.properties`.
|
||||
Please don't commit this change!
|
||||
|
||||
## Other commands
|
||||
|
||||
* `gradlew idea` will generate an [IntelliJ IDEA](http://www.jetbrains.com/idea/) module for each folder.
|
||||
* `gradlew eclipse` will generate an [Eclipse](https://www.eclipse.org/downloads/) project for each folder.
|
||||
* Use `setupCIWorkspace` instead of `setupDecompWorkspace` if you are doing this on a CI server.
|
@ -15,17 +15,18 @@ FAWE is a fork of WorldEdit that has huge speed and memory improvements and cons
|
||||
|
||||
## Downloads
|
||||
### 1.13+
|
||||
* [Download](https://empcraft.com/fawe/download/?bukkit113)
|
||||
* [Jenkins](https://ci.athion.net/job/FAWE-1.13/)
|
||||
* [Download](https://incendo.org/download/)
|
||||
* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit-1.13/)
|
||||
|
||||
### <1.12.2
|
||||
* [Download](https://empcraft.com/fawe/download/?bukkit)
|
||||
### < 1.12.2
|
||||
* [Download](https://incendo.org/download/)
|
||||
* [Jenkins](https://ci.athion.net/job/FastAsyncWorldEdit/)
|
||||
* [Repository](https://github.com/boy0001/FastAsyncWorldedit)
|
||||
|
||||
|
||||
## Building
|
||||
FAWE uses gradle to build
|
||||
You can safely ignore `gradlew setupDecompWorkspace` if you are not planning to work on the forge side of FAWE.
|
||||
|
||||
```
|
||||
$ gradlew setupDecompWorkspace
|
||||
|
@ -27,7 +27,11 @@ plugins {
|
||||
apply plugin: 'java'
|
||||
clean { delete "target" }
|
||||
|
||||
print new File('splash.txt').text
|
||||
|
||||
def splashFile = new File('splash.txt')
|
||||
if (splashFile.exists()) {
|
||||
print splashFile.text
|
||||
}
|
||||
|
||||
group = 'com.boydti.fawe'
|
||||
|
||||
@ -78,11 +82,10 @@ subprojects {
|
||||
maven { url "http://maven.sk89q.com/repo/" }
|
||||
maven { url "http://repo.maven.apache.org/maven2" }
|
||||
// Fawe
|
||||
maven {url "http://ci.athion.net/job/FAWE-WorldGuard-1.13/ws/mvn/"}
|
||||
maven {url "https://mvnrepository.com/artifact/"}
|
||||
maven {url "http://repo.dmulloy2.net/content/groups/public/"}
|
||||
maven {url "https://repo.destroystokyo.com/repository/maven-public//"}
|
||||
maven {url "http://ci.athion.net/job/PlotSquared-Legacy/ws/mvn/"}
|
||||
maven {url "http://ci.athion.net/job/PlotSquared-Breaking/ws/mvn/"}
|
||||
mavenLocal()
|
||||
maven {url "http://empcraft.com/maven2"}
|
||||
maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"}
|
||||
|
@ -14,6 +14,7 @@
|
||||
<allow pkg="gnu.trove"/>
|
||||
<allow pkg="com.google.gson"/>
|
||||
<allow pkg="net.royawesome.jlibnoise"/>
|
||||
<allow pkg="org.json.simple" />
|
||||
|
||||
<subpackage name="util.yaml">
|
||||
<allow pkg="org.yaml.snakeyaml"/>
|
||||
@ -30,6 +31,7 @@
|
||||
<allow pkg="com.nijiko"/>
|
||||
<allow pkg="com.nijikokun"/>
|
||||
<allow pkg="ru.tehkode"/>
|
||||
<allow pkg="net.milkbowl"/>
|
||||
</subpackage>
|
||||
|
||||
<subpackage name="worldedit">
|
||||
|
@ -2,7 +2,7 @@ CraftScripts are script files for WorldEdit that let you write world
|
||||
editing scripts with JavaScript easily.
|
||||
|
||||
Example usage:
|
||||
/cs maze.js lightstone 10 10
|
||||
/cs maze.js glowstone 10 10
|
||||
|
||||
You may or may not install these scripts -- it is optional. If you are, however,
|
||||
place the entire craftscripts/ folder into the respective directory for the platform
|
||||
|
@ -7,4 +7,4 @@ Note: Legally you should not release things to the public domain as not
|
||||
all countries have the concept of public domain in their copyright law.
|
||||
|
||||
You can also post your scripts here:
|
||||
http://forum.sk89q.com/forums/craftscripts.6/
|
||||
https://discord.gg/YKbmj7V or http://forum.sk89q.com/forums/craftscripts.6/
|
@ -43,8 +43,26 @@ var clothColors = [
|
||||
makeColor(100, 60, 0), // Brown
|
||||
makeColor(48, 80, 0), // Cactus green
|
||||
makeColor(255, 0, 0), // Red
|
||||
makeColor(0, 0, 0), // Black
|
||||
]
|
||||
makeColor(0, 0, 0) // Black
|
||||
];
|
||||
var clothBlocks = [
|
||||
context.getBlock("white_wool"),
|
||||
context.getBlock("orange_wool"),
|
||||
context.getBlock("magenta_wool"),
|
||||
context.getBlock("light_blue_wool"),
|
||||
context.getBlock("yellow_wool"),
|
||||
context.getBlock("lime_wool"),
|
||||
context.getBlock("pink_wool"),
|
||||
context.getBlock("gray_wool"),
|
||||
context.getBlock("light_gray_wool"),
|
||||
context.getBlock("cyan_wool"),
|
||||
context.getBlock("purple_wool"),
|
||||
context.getBlock("blue_wool"),
|
||||
context.getBlock("brown_wool"),
|
||||
context.getBlock("green_wool"),
|
||||
context.getBlock("red_wool"),
|
||||
context.getBlock("black_wool")
|
||||
];
|
||||
var clothColorsOpt = [
|
||||
makeColor(178, 178, 178), // White
|
||||
makeColor(187, 102, 44), // Orange
|
||||
@ -61,8 +79,8 @@ var clothColorsOpt = [
|
||||
makeColor(68, 41, 22), // Brown
|
||||
makeColor(44, 61, 19), // Cactus green
|
||||
makeColor(131, 36, 32), // Red
|
||||
makeColor(21, 18, 18), // Black
|
||||
]
|
||||
makeColor(21, 18, 18) // Black
|
||||
];
|
||||
var clothColorsOptHD = [
|
||||
makeColor(168, 168, 168), // White
|
||||
makeColor(143, 59, 0), // Orange
|
||||
@ -79,8 +97,8 @@ var clothColorsOptHD = [
|
||||
makeColor(52, 25, 0), // Brown
|
||||
makeColor(10, 76, 10), // Cactus green
|
||||
makeColor(127, 9, 9), // Red
|
||||
makeColor(17, 17, 17), // Black
|
||||
]
|
||||
makeColor(17, 17, 17) // Black
|
||||
];
|
||||
|
||||
// http://stackoverflow.com/questions/2103368/color-logic-algorithm/2103608#2103608
|
||||
function colorDistance(c1, c2) {
|
||||
@ -90,7 +108,7 @@ function colorDistance(c1, c2) {
|
||||
var b = c1.getBlue() - c2.getBlue();
|
||||
var weightR = 2 + rmean/256;
|
||||
var weightG = 4.0;
|
||||
var weightB = 2 + (255-rmean)/256
|
||||
var weightB = 2 + (255-rmean)/256;
|
||||
return Math.sqrt(weightR*r*r + weightG*g*g + weightB*b*b);
|
||||
}
|
||||
|
||||
@ -113,14 +131,14 @@ function findClosestWoolColor(col, clothColors) {
|
||||
|
||||
context.checkArgs(1, 3, "<image> <orientation> <palette>");
|
||||
|
||||
var f = context.getSafeFile("drawings", argv[1]);
|
||||
var f = context.getSafeOpenFile("drawings", argv[1], "png", ["png", "jpg", "jpeg", "bmp"]);
|
||||
var sess = context.remember();
|
||||
var upright = argv[2] == "v";
|
||||
var upright = argv[2] === "v";
|
||||
var colors = clothColors;
|
||||
if(argv[3] == "opt") {
|
||||
if(argv[3] === "opt") {
|
||||
colors = clothColorsOpt;
|
||||
player.print("Using optimized palette");
|
||||
} else if(argv[3] == "optHD") {
|
||||
} else if(argv[3] === "optHD") {
|
||||
colors = clothColorsOptHD;
|
||||
player.print("Using optimized HD palette");
|
||||
}
|
||||
@ -132,7 +150,7 @@ if (!f.exists()) {
|
||||
var width = img.getWidth();
|
||||
var height = img.getHeight();
|
||||
|
||||
var origin = player.getBlockIn();
|
||||
var origin = player.getBlockIn().toVector().toBlockPoint();
|
||||
|
||||
for (var x = 0; x < width; x++) {
|
||||
for (var y = 0; y < height; y++) {
|
||||
@ -141,9 +159,9 @@ if (!f.exists()) {
|
||||
// Added this to enable the user to create images upright
|
||||
// rather than flat on the ground
|
||||
if (!upright) {
|
||||
sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data));
|
||||
sess.setBlock(origin.add(x, 0, y), clothBlocks[data]);
|
||||
} else {
|
||||
sess.setBlock(origin.add(x, height - y, 0), new BaseBlock(35, data));
|
||||
sess.setBlock(origin.add(x, height - y, 0), clothBlocks[data]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
importPackage(Packages.com.sk89q.worldedit);
|
||||
importPackage(Packages.com.sk89q.worldedit.blocks);
|
||||
importPackage(Packages.com.sk89q.worldedit.math);
|
||||
|
||||
usage = "<block> [width] [length] [height] [size] [thickness] flags\n";
|
||||
usage += "\n";
|
||||
@ -40,10 +41,15 @@ usage += "• b places blue wool if unvisited";
|
||||
context.checkArgs(1, -1, usage);
|
||||
|
||||
sess = context.remember();
|
||||
origin = player.getBlockIn();
|
||||
origin = player.getBlockIn().toVector().toBlockPoint();
|
||||
|
||||
// This may throw an exception that is caught by the script processor
|
||||
block = context.getBlock(argv[1]);
|
||||
airBlock = context.getBlock("air");
|
||||
glassBlock = context.getBlock("glass");
|
||||
limeWoolBlock = context.getBlock("lime_wool");
|
||||
redWoolBlock = context.getBlock("red_wool");
|
||||
blueWoolBlock = context.getBlock("blue_wool");
|
||||
|
||||
if (argv.length > 7) flags = String(argv[7]);
|
||||
else flags = false;
|
||||
@ -74,20 +80,20 @@ if (argv.length > 2) {
|
||||
} else w = 5;
|
||||
|
||||
if (flags) {
|
||||
ee = flags.search("i") != -1 ? true : false;
|
||||
r = flags.search("y") != -1 ? true : false;
|
||||
ee = flags.search("i") != -1;
|
||||
r = flags.search("y") != -1;
|
||||
if (r) ee = true;
|
||||
f = flags.search("f") != -1 ? true : false;
|
||||
c = flags.search("c") != -1 ? true : false;
|
||||
e = flags.search("e") != -1 ? true : false;
|
||||
ao = flags.search("a") != -1 ? true : false;
|
||||
f = flags.search("f") != -1;
|
||||
c = flags.search("c") != -1;
|
||||
e = flags.search("e") != -1;
|
||||
ao = flags.search("a") != -1;
|
||||
if (ao) f = c = false, e = true;
|
||||
v = flags.search("v") != -1 ? true : false;
|
||||
so = flags.search("s") != -1 ? true : false;
|
||||
v = flags.search("v") != -1;
|
||||
so = flags.search("s") != -1;
|
||||
if (so) ee = true;
|
||||
g = flags.search("g") != -1 ? true : false;
|
||||
re = flags.search("r") != -1 ? true : false;
|
||||
bl = flags.search("b") != -1 ? true : false;
|
||||
g = flags.search("g") != -1;
|
||||
re = flags.search("r") != -1;
|
||||
bl = flags.search("b") != -1;
|
||||
if (g || re || bl) so = ee = true;
|
||||
} else ee = r = f = c = e = ao = v = so = g = re = bl = false;
|
||||
|
||||
@ -208,8 +214,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
|
||||
}
|
||||
} else if (e && cell != id(x, l)) {
|
||||
for (z = 0; z < h; z++) for (yi = 0; yi < s; yi++) for (xi = 1; xi <= wa; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(0));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(0));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), airBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), airBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,8 +228,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
|
||||
}
|
||||
} else if (e && cell != id(w, y)) {
|
||||
for (z = 0; z < h; z++) for (yi = 1; yi <= wa; yi++) for (xi = 0; xi < s; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(0));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(0));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), airBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), airBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,8 +242,8 @@ for (y = 0; y <= l; y++) for (x = 0; x <= w; x++) {
|
||||
|
||||
if (e && cell != id(x, l) && cell != id(w, y)) {
|
||||
for (z = 0; z < h; z++) for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) + yi), BaseBlock(0));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, -z), BaseBlock(0));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) + yi), airBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, -z), airBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,51 +287,51 @@ if (so) {
|
||||
|
||||
if (visited[cell] && !wrong[cell]) {
|
||||
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 5));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 5));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), limeWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), limeWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((visited[cell] && !wrong[cell] && visited[id(x - 1, y)] && !wrong[id(x - 1, y)] && noWallLeft[cell]) || cell == start || id(x - 1, y) == end) {
|
||||
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 5));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 5));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), limeWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), limeWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if (visited[cell] && !wrong[cell] && visited[id(x, y - 1)] && !wrong[id(x, y - 1)] && noWallAbove[cell]) {
|
||||
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 5));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 5));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), limeWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), limeWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if (g) {
|
||||
if (visited[cell] && !wrong[cell] && (!visited[id(x - 1, y)] || wrong[id(x - 1, y)]) && noWallLeft[cell] && cell != start) {
|
||||
for (z = 0; z < h; z++) for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(20));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(20));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), glassBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), glassBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!visited[cell] || wrong[cell]) && visited[id(x - 1, y)] && !wrong[id(x - 1, y)] && noWallLeft[cell] && id(x - 1, y) != end) {
|
||||
for (z = 0; z < h; z++) for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), BaseBlock(20));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), BaseBlock(20));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, z, y * (s + wa) + yi), glassBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, -z), glassBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if (visited[cell] && !wrong[cell] && (!visited[id(x, y - 1)] || wrong[id(x, y - 1)]) && noWallAbove[cell]) {
|
||||
for (z = 0; z < h; z++) for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(20));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(20));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), glassBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), glassBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!visited[cell] || wrong[cell]) && visited[id(x, y - 1)] && !wrong[id(x, y - 1)] && noWallAbove[cell]) {
|
||||
for (z = 0; z < h; z++) for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), BaseBlock(20));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), BaseBlock(20));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, z, y * (s + wa) - yi), glassBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, -z), glassBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -333,22 +339,22 @@ if (so) {
|
||||
if (re) {
|
||||
if (wrong[cell]) {
|
||||
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 14));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 14));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), redWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), redWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((wrong[cell] || wrong[id(x - 1, y)]) && noWallLeft[cell]) {
|
||||
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 14));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 14));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), redWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), redWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((wrong[cell] || wrong[id(x, y - 1)]) && noWallAbove[cell]) {
|
||||
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 14));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 14));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), redWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), redWoolBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -356,22 +362,22 @@ if (so) {
|
||||
if (bl) {
|
||||
if (!visited[cell] && y < l && x < w) {
|
||||
for (yi = 0; yi < s; yi++) for (xi = 0; xi < s; xi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), BaseBlock(35, 11));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), BaseBlock(35, 11));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) + yi), blueWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) + yi, +1), blueWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!visited[cell] || !visited[id(x - 1, y)]) && noWallLeft[cell] && x > 0 && x < w) {
|
||||
for (xi = 1; xi <= wa; xi++) for (yi = 0; yi < s; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), BaseBlock(35, 11));
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), BaseBlock(35, 11));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) - xi, -1, y * (s + wa) + yi), blueWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) - xi, y * (s + wa) + yi, +1), blueWoolBlock);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!visited[cell] || !visited[id(x, y - 1)]) && noWallAbove[cell]) {
|
||||
for (xi = 0; xi < s; xi++) for (yi = 1; yi <= wa; yi++) {
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), BaseBlock(35, 11));
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), BaseBlock(35, 11));
|
||||
if (!v) sess.setBlock(origin.add(x * (s + wa) + xi, -1, y * (s + wa) - yi), blueWoolBlock);
|
||||
else sess.setBlock(origin.add(x * (s + wa) + xi, y * (s + wa) - yi, +1), blueWoolBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@
|
||||
importPackage(Packages.com.sk89q.worldedit);
|
||||
importPackage(Packages.com.sk89q.worldedit.blocks);
|
||||
|
||||
var torchDirs = {}
|
||||
torchDirs[PlayerDirection.NORTH] = [2, 4];
|
||||
torchDirs[PlayerDirection.SOUTH] = [1, 3];
|
||||
torchDirs[PlayerDirection.WEST] = [3, 2];
|
||||
torchDirs[PlayerDirection.EAST] = [4, 1];
|
||||
var torchDirs = {};
|
||||
torchDirs[Direction.NORTH] = [2, 4];
|
||||
torchDirs[Direction.SOUTH] = [1, 3];
|
||||
torchDirs[Direction.WEST] = [3, 2];
|
||||
torchDirs[Direction.EAST] = [4, 1];
|
||||
|
||||
var pitches = {
|
||||
"f#": 0,
|
||||
|
@ -16,20 +16,20 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
importPackage(Packages.java.io);
|
||||
importPackage(Packages.java.awt);
|
||||
importPackage(Packages.com.sk89q.worldedit);
|
||||
importPackage(Packages.com.sk89q.worldedit.math);
|
||||
importPackage(Packages.com.sk89q.worldedit.blocks);
|
||||
|
||||
var blocks = context.remember();
|
||||
var session = context.getSession();
|
||||
var region = session.getRegion();
|
||||
var player = context.getPlayer();
|
||||
var region = session.getRegionSelector(player.getWorld()).getRegion();
|
||||
|
||||
context.checkArgs(1, 1, "<type>");
|
||||
|
||||
var blocktype = context.getBlock(argv[1]);
|
||||
|
||||
var cycles = region.getLength()
|
||||
var cycles = region.getLength();
|
||||
|
||||
if (region.getWidth() > cycles){
|
||||
cycles = region.getWidth();
|
||||
@ -40,8 +40,8 @@ cycles = cycles / 2;
|
||||
for (var c = 0; c < cycles; c++) {
|
||||
for (var w = 0; w < region.getWidth() - (c * 2); w++) {
|
||||
for (var l = 0; l < region.getLength() - (c * 2); l++) {
|
||||
if (w == 0 || w == (region.getWidth() - (c * 2)) - 1 || l == 0 || l == (region.getLength() - (c * 2)) - 1) {
|
||||
var vec = new Vector(
|
||||
if (w === 0 || w === (region.getWidth() - (c * 2)) - 1 || l === 0 || l === (region.getLength() - (c * 2)) - 1) {
|
||||
var vec = BlockVector3.at(
|
||||
region.getMinimumPoint().getX() + (w + c),
|
||||
region.getMaximumPoint().getY() + c,
|
||||
region.getMinimumPoint().getZ() + (l + c));
|
||||
|
@ -1,3 +1,6 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven'
|
||||
|
||||
repositories {
|
||||
maven {url "https://ci.athion.net/job/FAWE-WorldGuard-1.13/lastSuccessfulBuild/artifact/mvn"}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class Brushes
|
||||
*/
|
||||
public Set<String> getSniperBrushHandles(Class<? extends IBrush> clazz)
|
||||
{
|
||||
return new HashSet<String>(brushes.get(clazz));
|
||||
return new HashSet<>(brushes.get(clazz));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,12 +158,9 @@ public class Message
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder returnValueBuilder = new StringBuilder();
|
||||
returnValueBuilder.append(ChatColor.DARK_GREEN);
|
||||
returnValueBuilder.append("Block Types Selected: ");
|
||||
returnValueBuilder.append(ChatColor.AQUA);
|
||||
returnValueBuilder.append(snipeData.getVoxelList());
|
||||
snipeData.sendMessage(returnValueBuilder.toString());
|
||||
String returnValueBuilder = ChatColor.DARK_GREEN + "Block Types Selected: " + ChatColor.AQUA
|
||||
+ snipeData.getVoxelList();
|
||||
snipeData.sendMessage(returnValueBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ public final class PaintingWrapper
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void paint(final Player p, final boolean auto, final boolean back, final int choice)
|
||||
{
|
||||
Location targetLocation = p.getTargetBlock((Set<Material>) null, 4).getLocation();
|
||||
Chunk paintingChunk = p.getTargetBlock((Set<Material>) null, 4).getLocation().getChunk();
|
||||
Location targetLocation = p.getTargetBlock(null, 4).getLocation();
|
||||
Chunk paintingChunk = p.getTargetBlock(null, 4).getLocation().getChunk();
|
||||
|
||||
Double bestDistanceMatch = 50D;
|
||||
Painting bestMatch = null;
|
||||
@ -66,7 +66,7 @@ public final class PaintingWrapper
|
||||
{
|
||||
try
|
||||
{
|
||||
final int i = bestMatch.getArt().getId() + (back ? -1 : 1) + Art.values().length % Art.values().length;
|
||||
final int i = bestMatch.getArt().getId() + (back ? -1 : 1);
|
||||
Art art = Art.getById(i);
|
||||
|
||||
if (art == null)
|
||||
|
@ -77,7 +77,7 @@ public class SnipeData {
|
||||
*/
|
||||
private int voxelHeight = SnipeData.DEFAULT_VOXEL_HEIGHT;
|
||||
/**
|
||||
* Voxel centroid -- set Cylynder center /vc #.
|
||||
* Voxel centroid -- set Cylinder center /vc #.
|
||||
*/
|
||||
private int cCen = SnipeData.DEFAULT_CYLINDER_CENTER;
|
||||
private int range = 0;
|
||||
@ -272,7 +272,7 @@ public class SnipeData {
|
||||
* @param voxelId the voxelId to set
|
||||
*/
|
||||
public final void setVoxelId(final int voxelId) {
|
||||
if (WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(voxelId)) {
|
||||
if (WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(BlockTypes.getFromStateId(voxelId).getId())) {
|
||||
if (owner != null) {
|
||||
Player plr = owner.getPlayer();
|
||||
if (plr != null) {
|
||||
|
@ -94,7 +94,7 @@ public class Sniper {
|
||||
}
|
||||
|
||||
public String getCurrentToolId() {
|
||||
return getToolId((getPlayer().getItemInHand() != null) ? getPlayer().getItemInHand().getType() : null);
|
||||
return getToolId((getPlayer().getInventory().getItemInMainHand() != null) ? getPlayer().getInventory().getItemInMainHand().getType() : null);
|
||||
}
|
||||
|
||||
public String getToolId(Material itemInHand) {
|
||||
@ -169,18 +169,11 @@ public class Sniper {
|
||||
try {
|
||||
Player player = getPlayer();
|
||||
final FawePlayer<Player> fp = FawePlayer.wrap(player);
|
||||
TaskManager.IMP.taskNow(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
snipeOnCurrentThread(fp, action, itemInHand, clickedBlock, clickedFace, sniperTool, toolId);
|
||||
}
|
||||
}, false, true)) {
|
||||
TaskManager.IMP.taskNow(() -> {
|
||||
if (!fp.runAction(
|
||||
() -> snipeOnCurrentThread(fp, action, itemInHand, clickedBlock, clickedFace, sniperTool, toolId), false, true)) {
|
||||
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
|
||||
}
|
||||
}
|
||||
}, Fawe.isMainThread());
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
@ -660,9 +653,7 @@ public class Sniper {
|
||||
private IBrush instantiateBrush(Class<? extends IBrush> brush) {
|
||||
try {
|
||||
return brush.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
return null;
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,10 @@ package com.thevoxelbox.voxelsniper;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
/**
|
||||
* Holds {@link org.bukkit.block.BlockState}s that can be later on used to reset those block
|
||||
* Holds {@link BlockState}s that can be later on used to reset those block
|
||||
* locations back to the recorded states.
|
||||
*/
|
||||
public class Undo {
|
||||
|
@ -169,6 +169,7 @@ public class VoxelSniper extends JavaPlugin
|
||||
brushManager.registerSniperBrush(EntityRemovalBrush.class, "er", "entityremoval");
|
||||
brushManager.registerSniperBrush(EraserBrush.class, "erase", "eraser");
|
||||
brushManager.registerSniperBrush(ErodeBrush.class, "e", "erode");
|
||||
brushManager.registerSniperBrush(ErodeBlendBrush.class, "eb", "erodeblend", "erodeblendball");
|
||||
brushManager.registerSniperBrush(ExtrudeBrush.class, "ex", "extrude");
|
||||
brushManager.registerSniperBrush(FillDownBrush.class, "fd", "filldown");
|
||||
brushManager.registerSniperBrush(FlatOceanBrush.class, "fo", "flatocean");
|
||||
@ -218,6 +219,7 @@ public class VoxelSniper extends JavaPlugin
|
||||
brushManager.registerSniperBrush(VoxelDiscBrush.class, "vd", "voxeldisc");
|
||||
brushManager.registerSniperBrush(VoxelDiscFaceBrush.class, "vdf", "voxeldiscface");
|
||||
brushManager.registerSniperBrush(WarpBrush.class, "w", "warp");
|
||||
brushManager.registerSniperBrush(WallSider.class, "wallsider", "sider");
|
||||
}
|
||||
|
||||
public void setupCommand(final String label, final FaweCommand cmd) {
|
||||
|
@ -26,7 +26,7 @@ public class VoxelSniperListener implements Listener
|
||||
|
||||
private static final String SNIPER_PERMISSION = "voxelsniper.sniper";
|
||||
private final VoxelSniper plugin;
|
||||
private Map<String, VoxelCommand> commands = new HashMap<String, VoxelCommand>();
|
||||
private Map<String, VoxelCommand> commands = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
@ -79,9 +79,7 @@ public class VoxelSniperListener implements Listener
|
||||
}
|
||||
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
if (!fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!fp.runAction(() -> {
|
||||
ExceptionConverter exceptionConverter = CommandManager.getInstance().getExceptionConverter();
|
||||
try {
|
||||
try {
|
||||
@ -107,7 +105,6 @@ public class VoxelSniperListener implements Listener
|
||||
e.printStackTrace();
|
||||
}
|
||||
fp.sendMessage("An unknown FAWE error has occurred! Please see console.");
|
||||
}
|
||||
}, false, true)) {
|
||||
BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
|
||||
}
|
||||
|
@ -82,17 +82,18 @@ public class BiomeBrush extends Brush
|
||||
if (args[1].equalsIgnoreCase("info"))
|
||||
{
|
||||
v.sendMessage(ChatColor.GOLD + "Biome Brush Parameters:");
|
||||
String availableBiomes = "";
|
||||
StringBuilder availableBiomes = new StringBuilder();
|
||||
|
||||
for (final Biome biome : Biome.values())
|
||||
{
|
||||
if (availableBiomes.isEmpty())
|
||||
if (availableBiomes.length() == 0)
|
||||
{
|
||||
availableBiomes = ChatColor.DARK_GREEN + biome.name();
|
||||
availableBiomes = new StringBuilder(ChatColor.DARK_GREEN + biome.name());
|
||||
continue;
|
||||
}
|
||||
|
||||
availableBiomes += ChatColor.RED + ", " + ChatColor.DARK_GREEN + biome.name();
|
||||
availableBiomes.append(ChatColor.RED + ", " + ChatColor.DARK_GREEN)
|
||||
.append(biome.name());
|
||||
|
||||
}
|
||||
v.sendMessage(ChatColor.DARK_BLUE + "Available biomes: " + availableBiomes);
|
||||
@ -100,15 +101,15 @@ public class BiomeBrush extends Brush
|
||||
else
|
||||
{
|
||||
// allows biome names with spaces in their name
|
||||
String biomeName = args[1];
|
||||
StringBuilder biomeName = new StringBuilder(args[1]);
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
biomeName += " " + args[i];
|
||||
biomeName.append(" ").append(args[i]);
|
||||
}
|
||||
|
||||
for (final Biome biome : Biome.values())
|
||||
{
|
||||
if (biome.name().equalsIgnoreCase(biomeName))
|
||||
if (biome.name().equalsIgnoreCase(biomeName.toString()))
|
||||
{
|
||||
this.selectedBiome = biome;
|
||||
break;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Undo;
|
||||
@ -48,10 +49,8 @@ public class BlendBallBrush extends BlendBrushBase
|
||||
{
|
||||
for (int y = 0; y <= brushSizeDoubled; y++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeDoubled; z++)
|
||||
{
|
||||
newMaterials[x][y][z] = oldMaterials[x + 1][y + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
|
||||
brushSizeDoubled + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ public class BlendBallBrush extends BlendBrushBase
|
||||
}
|
||||
|
||||
// Find most common neighboring material.
|
||||
for (BlockTypes type : BlockTypes.values)
|
||||
for (BlockType type : BlockTypes.values)
|
||||
{
|
||||
int i = type.getInternalId();
|
||||
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
@ -94,7 +93,7 @@ public class BlendBallBrush extends BlendBrushBase
|
||||
// Make sure there'world not a tie for most common
|
||||
for (int i = 0; i < modeMatId; i++)
|
||||
{
|
||||
BlockTypes type = BlockTypes.get(i);
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
{
|
||||
tiecheck = false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Undo;
|
||||
@ -41,10 +42,7 @@ public class BlendDiscBrush extends BlendBrushBase
|
||||
// Log current materials into newmats
|
||||
for (int x = 0; x <= brushSizeDoubled; x++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeDoubled; z++)
|
||||
{
|
||||
newMaterials[x][z] = oldMaterials[x + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1);
|
||||
}
|
||||
|
||||
// Blend materials
|
||||
@ -69,7 +67,7 @@ public class BlendDiscBrush extends BlendBrushBase
|
||||
}
|
||||
|
||||
// Find most common neighboring material.
|
||||
for (BlockTypes type : BlockTypes.values)
|
||||
for (BlockType type : BlockTypes.values)
|
||||
{
|
||||
int i = type.getInternalId();
|
||||
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
@ -81,7 +79,7 @@ public class BlendDiscBrush extends BlendBrushBase
|
||||
// Make sure there'world not a tie for most common
|
||||
for (int i = 0; i < modeMatId; i++)
|
||||
{
|
||||
BlockTypes type = BlockTypes.get(i);
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
{
|
||||
tiecheck = false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Undo;
|
||||
@ -48,10 +49,8 @@ public class BlendVoxelBrush extends BlendBrushBase
|
||||
{
|
||||
for (int y = 0; y <= brushSizeDoubled; y++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeDoubled; z++)
|
||||
{
|
||||
newMaterials[x][y][z] = oldMaterials[x + 1][y + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
|
||||
brushSizeDoubled + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +81,7 @@ public class BlendVoxelBrush extends BlendBrushBase
|
||||
}
|
||||
|
||||
// Find most common neighboring material.
|
||||
for (BlockTypes type : BlockTypes.values)
|
||||
for (BlockType type : BlockTypes.values)
|
||||
{
|
||||
int i = type.getInternalId();
|
||||
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
@ -94,7 +93,7 @@ public class BlendVoxelBrush extends BlendBrushBase
|
||||
// Make sure there'world not a tie for most common
|
||||
for (int i = 0; i < modeMatId; i++)
|
||||
{
|
||||
BlockTypes type = BlockTypes.get(i);
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
{
|
||||
tiecheck = false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.Undo;
|
||||
@ -41,10 +42,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
|
||||
// Log current materials into newmats
|
||||
for (int x = 0; x <= brushSizeDoubled; x++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeDoubled; z++)
|
||||
{
|
||||
newMaterials[x][z] = oldMaterials[x + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1], 1, newMaterials[x], 0, brushSizeDoubled + 1);
|
||||
}
|
||||
|
||||
// Blend materials
|
||||
@ -69,7 +67,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
|
||||
}
|
||||
|
||||
// Find most common neighboring material.
|
||||
for (BlockTypes type : BlockTypes.values)
|
||||
for (BlockType type : BlockTypes.values)
|
||||
{
|
||||
int i = type.getInternalId();
|
||||
if (materialFrequency[i] > modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
@ -81,7 +79,7 @@ public class BlendVoxelDiscBrush extends BlendBrushBase
|
||||
// Make sure there'world not a tie for most common
|
||||
for (int i = 0; i < modeMatId; i++)
|
||||
{
|
||||
BlockTypes type = BlockTypes.get(i);
|
||||
BlockType type = BlockTypes.get(i);
|
||||
if (materialFrequency[i] == modeMatCount && !(this.excludeAir && type.getMaterial().isAir()) && !(this.excludeWater && (type == BlockTypes.WATER)))
|
||||
{
|
||||
tiecheck = false;
|
||||
|
@ -120,10 +120,7 @@ public class BlobBrush extends PerformBrush
|
||||
{
|
||||
for (int y = brushSizeDoubled; y >= 0; y--)
|
||||
{
|
||||
for (int z = brushSizeDoubled; z >= 0; z--)
|
||||
{
|
||||
splat[x][y][z] = tempSplat[x][y][z];
|
||||
}
|
||||
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,10 +215,7 @@ public class BlobBrush extends PerformBrush
|
||||
{
|
||||
for (int y = brushSizeDoubled; y >= 0; y--)
|
||||
{
|
||||
for (int z = brushSizeDoubled; z >= 0; z--)
|
||||
{
|
||||
splat[x][y][z] = tempSplat[x][y][z];
|
||||
}
|
||||
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0, brushSizeDoubled + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.block.Block;
|
||||
*/
|
||||
public class BlockResetBrush extends Brush
|
||||
{
|
||||
private static final ArrayList<Material> DENIED_UPDATES = new ArrayList<Material>();
|
||||
private static final ArrayList<Material> DENIED_UPDATES = new ArrayList<>();
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class DomeBrush extends Brush
|
||||
final int absoluteHeight = Math.abs(v.getVoxelHeight());
|
||||
final boolean negative = v.getVoxelHeight() < 0;
|
||||
|
||||
final Set<Vector> changeablePositions = new HashSet<Vector>();
|
||||
final Set<Vector> changeablePositions = new HashSet<>();
|
||||
|
||||
final Undo undo = new Undo();
|
||||
|
||||
|
@ -16,7 +16,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
*/
|
||||
public class EntityRemovalBrush extends Brush
|
||||
{
|
||||
private final List<String> exemptions = new ArrayList<String>(3);
|
||||
private final List<String> exemptions = new ArrayList<>(3);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -82,7 +82,7 @@ public class EntityRemovalBrush extends Brush
|
||||
private boolean isClassInExemptionList(Class<? extends Entity> entityClass) throws PatternSyntaxException
|
||||
{
|
||||
// Create a list of superclasses and interfaces implemented by the current entity type
|
||||
final List<String> entityClassHierarchy = new ArrayList<String>();
|
||||
final List<String> entityClassHierarchy = new ArrayList<>();
|
||||
|
||||
Class<?> currentClass = entityClass;
|
||||
while (currentClass != null && !currentClass.equals(Object.class))
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
|
||||
public class ErodeBlendBrush extends Brush{
|
||||
|
||||
private BlendBallBrush blendBall;
|
||||
private ErodeBrush erode;
|
||||
|
||||
public ErodeBlendBrush() {
|
||||
this.blendBall = new BlendBallBrush();
|
||||
this.erode = new ErodeBrush();
|
||||
this.setName("Erode BlendBall");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void arrow(final SnipeData v) {
|
||||
this.blendBall.excludeAir = false;
|
||||
this.blendBall.setTargetBlock(this.getTargetBlock());
|
||||
this.blendBall.arrow(v);
|
||||
this.erode.setTargetBlock(this.getTargetBlock());
|
||||
this.erode.arrow(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void powder(final SnipeData v) {
|
||||
this.blendBall.excludeAir = false;
|
||||
this.blendBall.setTargetBlock(this.getTargetBlock());
|
||||
this.blendBall.arrow(v);
|
||||
this.erode.setTargetBlock(this.getTargetBlock());
|
||||
this.erode.powder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void parameters(final String[] par, final SnipeData v) {
|
||||
this.blendBall.parameters(par, v);
|
||||
this.erode.parameters(par, v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "voxelsniper.brush.erodeblend";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Message vm) {
|
||||
this.erode.info(vm);
|
||||
this.blendBall.info(vm);
|
||||
}
|
||||
|
||||
}
|
@ -133,7 +133,7 @@ public class ErodeBrush extends Brush
|
||||
|
||||
int count = 0;
|
||||
|
||||
final Map<BlockWrapper, Integer> blockCount = new HashMap<BlockWrapper, Integer>();
|
||||
final Map<BlockWrapper, Integer> blockCount = new HashMap<>();
|
||||
|
||||
for (final Vector vector : ErodeBrush.FACES_TO_CHECK)
|
||||
{
|
||||
@ -363,8 +363,8 @@ public class ErodeBrush extends Brush
|
||||
|
||||
public BlockChangeTracker(final AsyncWorld world)
|
||||
{
|
||||
this.blockChanges = new HashMap<Integer, Map<Vector, BlockWrapper>>();
|
||||
this.flatChanges = new HashMap<Vector, BlockWrapper>();
|
||||
this.blockChanges = new HashMap<>();
|
||||
this.flatChanges = new HashMap<>();
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ public class ErodeBrush extends Brush
|
||||
{
|
||||
if (!this.blockChanges.containsKey(iteration))
|
||||
{
|
||||
this.blockChanges.put(iteration, new HashMap<Vector, BlockWrapper>());
|
||||
this.blockChanges.put(iteration, new HashMap<>());
|
||||
}
|
||||
|
||||
this.blockChanges.get(iteration).put(position, changedBlock);
|
||||
|
@ -24,7 +24,7 @@ public class GenerateTreeBrush extends Brush
|
||||
{
|
||||
// Tree Variables.
|
||||
private Random randGenerator = new Random();
|
||||
private ArrayList<Block> branchBlocks = new ArrayList<Block>();
|
||||
private ArrayList<Block> branchBlocks = new ArrayList<>();
|
||||
private Undo undo;
|
||||
// If these default values are edited. Remember to change default values in the default preset.
|
||||
private Material leafType = Material.OAK_LEAVES;
|
||||
|
@ -44,7 +44,7 @@ public class HeatRayBrush extends Brush
|
||||
private static final double REQUIRED_FIRE_DENSITY = -0.25;
|
||||
private static final double REQUIRED_AIR_DENSITY = 0;
|
||||
|
||||
private static final ArrayList<Material> FLAMABLE_BLOCKS = new ArrayList<Material>();
|
||||
private static final ArrayList<Material> FLAMABLE_BLOCKS = new ArrayList<>();
|
||||
|
||||
private int octaves = 5;
|
||||
private double frequency = 1;
|
||||
|
@ -83,11 +83,11 @@ public class JockeyBrush extends Brush
|
||||
{
|
||||
if (jockeyType == JockeyType.INVERSE_PLAYER_ONLY || jockeyType == JockeyType.INVERSE_ALL_ENTITIES)
|
||||
{
|
||||
player.setPassenger(closest);
|
||||
player.addPassenger(closest);
|
||||
}
|
||||
else
|
||||
{
|
||||
closest.setPassenger(player);
|
||||
closest.addPassenger(player);
|
||||
jockeyedEntity = closest;
|
||||
}
|
||||
v.sendMessage(ChatColor.GREEN + "You are now saddles on entity: " + closest.getEntityId());
|
||||
@ -113,7 +113,7 @@ public class JockeyBrush extends Brush
|
||||
{
|
||||
if (jockeyType == JockeyType.STACK_ALL_ENTITIES)
|
||||
{
|
||||
lastEntity.setPassenger(entity);
|
||||
lastEntity.addPassenger(entity);
|
||||
lastEntity = entity;
|
||||
stackHeight++;
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class JockeyBrush extends Brush
|
||||
{
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
lastEntity.setPassenger(entity);
|
||||
lastEntity.addPassenger(entity);
|
||||
lastEntity = entity;
|
||||
stackHeight++;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class MoveBrush extends Brush
|
||||
final AsyncWorld world = selection.getBlockStates().get(0).getWorld();
|
||||
|
||||
final Undo undo = new Undo();
|
||||
final HashSet<Block> undoSet = new HashSet<Block>();
|
||||
final HashSet<Block> undoSet = new HashSet<>();
|
||||
|
||||
final Selection newSelection = new Selection();
|
||||
final Location movedLocation1 = selection.getLocation1();
|
||||
@ -214,7 +214,7 @@ public class MoveBrush extends Brush
|
||||
/**
|
||||
* Calculated BlockStates of the selection.
|
||||
*/
|
||||
private final ArrayList<AsyncBlockState> blockStates = new ArrayList<AsyncBlockState>();
|
||||
private final ArrayList<AsyncBlockState> blockStates = new ArrayList<>();
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
|
||||
@ -13,8 +15,7 @@ import org.bukkit.Material;
|
||||
*
|
||||
* @author Gavjenks
|
||||
*/
|
||||
public class OverlayBrush extends PerformBrush
|
||||
{
|
||||
public class OverlayBrush extends PerformBrush {
|
||||
private static final int DEFAULT_DEPTH = 3;
|
||||
private int depth = DEFAULT_DEPTH;
|
||||
private boolean allBlocks = false;
|
||||
@ -22,40 +23,38 @@ public class OverlayBrush extends PerformBrush
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OverlayBrush()
|
||||
{
|
||||
public OverlayBrush() {
|
||||
this.setName("Overlay (Topsoil Filling)");
|
||||
}
|
||||
|
||||
private void overlay(final SnipeData v)
|
||||
{
|
||||
private void overlay(final SnipeData v) {
|
||||
final int brushSize = v.getBrushSize();
|
||||
final double brushSizeSquared = Math.pow(brushSize + 0.5, 2);
|
||||
|
||||
|
||||
for (int z = brushSize; z >= -brushSize; z--)
|
||||
{
|
||||
for (int x = brushSize; x >= -brushSize; x--)
|
||||
{
|
||||
for (int z = brushSize; z >= -brushSize; z--) {
|
||||
for (int x = brushSize; x >= -brushSize; x--) {
|
||||
// check if column is valid
|
||||
// column is valid if it has no solid block right above the clicked layer
|
||||
final int materialId = this.getBlockIdAt(this.getTargetBlock().getX() + x, this.getTargetBlock().getY() + 1, this.getTargetBlock().getZ() + z);
|
||||
if (isIgnoredBlock(materialId))
|
||||
{
|
||||
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared)
|
||||
{
|
||||
for (int y = this.getTargetBlock().getY(); y > 0; y--)
|
||||
{
|
||||
final int materialId = this.getBlockIdAt(this.getTargetBlock().getX() + x,
|
||||
this.getTargetBlock().getY() + 1, this.getTargetBlock().getZ() + z);
|
||||
if (isIgnoredBlock(materialId)) {
|
||||
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared) {
|
||||
for (int y = this.getTargetBlock().getY(); y > 0; y--) {
|
||||
// check for surface
|
||||
final int layerBlockId = this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z);
|
||||
if (!isIgnoredBlock(layerBlockId))
|
||||
{
|
||||
for (int currentDepth = y; y - currentDepth < depth; currentDepth--)
|
||||
{
|
||||
final int currentBlockId = this.getBlockIdAt(this.getTargetBlock().getX() + x, currentDepth, this.getTargetBlock().getZ() + z);
|
||||
if (isOverrideableMaterial(currentBlockId))
|
||||
{
|
||||
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, currentDepth, this.getTargetBlock().getZ() + z));
|
||||
final int layerBlockId =
|
||||
this.getBlockIdAt(this.getTargetBlock().getX() + x, y,
|
||||
this.getTargetBlock().getZ() + z);
|
||||
if (!isIgnoredBlock(layerBlockId)) {
|
||||
for (int currentDepth = y;
|
||||
y - currentDepth < depth; currentDepth--) {
|
||||
final int currentBlockId =
|
||||
this.getBlockIdAt(this.getTargetBlock().getX() + x,
|
||||
currentDepth, this.getTargetBlock().getZ() + z);
|
||||
if (isOverrideableMaterial(currentBlockId)) {
|
||||
this.current.perform(
|
||||
this.clampY(this.getTargetBlock().getX() + x,
|
||||
currentDepth, this.getTargetBlock().getZ() + z));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -69,82 +68,75 @@ public class OverlayBrush extends PerformBrush
|
||||
v.owner().storeUndo(this.current.getUndo());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isIgnoredBlock(int materialId)
|
||||
{
|
||||
BlockTypes type = BlockTypes.get(materialId);
|
||||
switch (type) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
case CACTUS:
|
||||
@SuppressWarnings("deprecation") private boolean isIgnoredBlock(int materialId) {
|
||||
BlockType type = BlockTypes.get(materialId);
|
||||
String s = type.getResource().toUpperCase();
|
||||
if (type == BlockTypes.WATER || type == BlockTypes.LAVA || type == BlockTypes.CACTUS) {
|
||||
return true;
|
||||
}
|
||||
BlockMaterial mat = type.getMaterial();
|
||||
return mat.isTranslucent();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean isOverrideableMaterial(int materialId)
|
||||
{
|
||||
@SuppressWarnings("deprecation") private boolean isOverrideableMaterial(int materialId) {
|
||||
BlockMaterial mat = BlockTypes.get(materialId).getMaterial();
|
||||
if (allBlocks && !(mat.isAir()))
|
||||
{
|
||||
if (allBlocks && !(mat.isAir())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mat.isFragileWhenPushed() && mat.isFullCube()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !mat.isFragileWhenPushed() && mat.isFullCube();
|
||||
}
|
||||
|
||||
private void overlayTwo(final SnipeData v)
|
||||
{
|
||||
private void overlayTwo(final SnipeData v) {
|
||||
final int brushSize = v.getBrushSize();
|
||||
final double brushSizeSquared = Math.pow(brushSize + 0.5, 2);
|
||||
final int[][] memory = new int[brushSize * 2 + 1][brushSize * 2 + 1];
|
||||
|
||||
for (int z = brushSize; z >= -brushSize; z--)
|
||||
{
|
||||
for (int x = brushSize; x >= -brushSize; x--)
|
||||
{
|
||||
for (int z = brushSize; z >= -brushSize; z--) {
|
||||
for (int x = brushSize; x >= -brushSize; x--) {
|
||||
boolean surfaceFound = false;
|
||||
for (int y = this.getTargetBlock().getY(); y > 0 && !surfaceFound; y--)
|
||||
{ // start scanning from the height you clicked at
|
||||
if (memory[x + brushSize][z + brushSize] != 1)
|
||||
{ // if haven't already found the surface in this column
|
||||
if ((Math.pow(x, 2) + Math.pow(z, 2)) <= brushSizeSquared)
|
||||
{ // if inside of the column...
|
||||
if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1, this.getTargetBlock().getZ() + z).isEmpty())
|
||||
{ // if not a floating block (like one of Notch'world pools)
|
||||
if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1, this.getTargetBlock().getZ() + z).isEmpty())
|
||||
{ // must start at surface... this prevents it filling stuff in if
|
||||
for (int y = this.getTargetBlock().getY();
|
||||
y > 0 && !surfaceFound; y--) { // start scanning from the height you clicked at
|
||||
if (memory[x + brushSize][z + brushSize]
|
||||
!= 1) { // if haven't already found the surface in this column
|
||||
if ((Math.pow(x, 2) + Math.pow(z, 2))
|
||||
<= brushSizeSquared) { // if inside of the column...
|
||||
if (!this.getBlockAt(this.getTargetBlock().getX() + x, y - 1,
|
||||
this.getTargetBlock().getZ() + z)
|
||||
.isEmpty()) { // if not a floating block (like one of Notch'world pools)
|
||||
if (this.getBlockAt(this.getTargetBlock().getX() + x, y + 1,
|
||||
this.getTargetBlock().getZ() + z)
|
||||
.isEmpty()) { // must start at surface... this prevents it filling stuff in if
|
||||
// you click in a wall and it starts out below surface.
|
||||
if (!this.allBlocks)
|
||||
{ // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
|
||||
if (!this.allBlocks) { // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
|
||||
|
||||
BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
|
||||
BlockType type = BukkitAdapter.asBlockType((this
|
||||
.getBlockType(this.getTargetBlock().getX() + x, y,
|
||||
this.getTargetBlock().getZ() + z)));
|
||||
BlockMaterial mat = type.getMaterial();
|
||||
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) {
|
||||
if (mat.isSolid() && mat.isFullCube() && !mat
|
||||
.hasContainer()) {
|
||||
for (int d = 1; (d < this.depth + 1); d++) {
|
||||
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify
|
||||
this.current.perform(
|
||||
this.clampY(this.getTargetBlock().getX() + x,
|
||||
y + d, this.getTargetBlock().getZ()
|
||||
+ z)); // fills down as many layers as you specify
|
||||
// in parameters
|
||||
memory[x + brushSize][z + brushSize] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
|
||||
memory[x + brushSize][z + brushSize] =
|
||||
1; // stop it from checking any other blocks in this vertical 1x1 column.
|
||||
}
|
||||
surfaceFound = true;
|
||||
continue;
|
||||
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int d = 1; (d < this.depth + 1); d++)
|
||||
{
|
||||
this.current.perform(this.clampY(this.getTargetBlock().getX() + x, y + d, this.getTargetBlock().getZ() + z)); // fills down as many layers as you specify in
|
||||
for (int d = 1; (d < this.depth + 1); d++) {
|
||||
this.current.perform(
|
||||
this.clampY(this.getTargetBlock().getX() + x, y + d,
|
||||
this.getTargetBlock().getZ()
|
||||
+ z)); // fills down as many layers as you specify in
|
||||
// parameters
|
||||
memory[x + brushSize][z + brushSize] = 1; // stop it from checking any other blocks in this vertical 1x1 column.
|
||||
memory[x + brushSize][z + brushSize] =
|
||||
1; // stop it from checking any other blocks in this vertical 1x1 column.
|
||||
}
|
||||
surfaceFound = true;
|
||||
}
|
||||
@ -160,46 +152,36 @@ public class OverlayBrush extends PerformBrush
|
||||
v.owner().storeUndo(this.current.getUndo());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void arrow(final SnipeData v)
|
||||
{
|
||||
@Override protected final void arrow(final SnipeData v) {
|
||||
this.overlay(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void powder(final SnipeData v)
|
||||
{
|
||||
@Override protected final void powder(final SnipeData v) {
|
||||
this.overlayTwo(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void info(final Message vm)
|
||||
{
|
||||
@Override public final void info(final Message vm) {
|
||||
vm.brushName(this.getName());
|
||||
vm.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void parameters(final String[] par, final SnipeData v)
|
||||
{
|
||||
for (int i = 1; i < par.length; i++)
|
||||
{
|
||||
@Override public final void parameters(final String[] par, final SnipeData v) {
|
||||
for (int i = 1; i < par.length; i++) {
|
||||
final String parameter = par[i];
|
||||
|
||||
if (parameter.equalsIgnoreCase("info"))
|
||||
{
|
||||
if (parameter.equalsIgnoreCase("info")) {
|
||||
v.sendMessage(ChatColor.GOLD + "Overlay brush parameters:");
|
||||
v.sendMessage(ChatColor.AQUA + "d[number] (ex: d3) How many blocks deep you want to replace from the surface.");
|
||||
v.sendMessage(ChatColor.BLUE + "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default.");
|
||||
v.sendMessage(ChatColor.AQUA
|
||||
+ "d[number] (ex: d3) How many blocks deep you want to replace from the surface.");
|
||||
v.sendMessage(ChatColor.BLUE
|
||||
+ "all (ex: /b over all) Sets the brush to overlay over ALL materials, not just natural surface ones (will no longer ignore trees and buildings). The parameter /some will set it back to default.");
|
||||
return;
|
||||
}
|
||||
if (parameter.startsWith("d"))
|
||||
{
|
||||
if (parameter.startsWith("d")) {
|
||||
try {
|
||||
this.depth = Integer.parseInt(parameter.replace("d", ""));
|
||||
|
||||
if (this.depth < 1)
|
||||
{
|
||||
if (this.depth < 1) {
|
||||
this.depth = 1;
|
||||
}
|
||||
|
||||
@ -207,27 +189,21 @@ public class OverlayBrush extends PerformBrush
|
||||
} catch (NumberFormatException e) {
|
||||
v.sendMessage(ChatColor.RED + "Depth isn't a number.");
|
||||
}
|
||||
}
|
||||
else if (parameter.startsWith("all"))
|
||||
{
|
||||
} else if (parameter.startsWith("all")) {
|
||||
this.allBlocks = true;
|
||||
v.sendMessage(ChatColor.BLUE + "Will overlay over any block." + this.depth);
|
||||
}
|
||||
else if (parameter.startsWith("some"))
|
||||
{
|
||||
} else if (parameter.startsWith("some")) {
|
||||
this.allBlocks = false;
|
||||
v.sendMessage(ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
v.sendMessage(ChatColor.RED + "Invalid brush parameters! use the info parameter to display parameter info.");
|
||||
v.sendMessage(
|
||||
ChatColor.BLUE + "Will overlay only natural block types." + this.depth);
|
||||
} else {
|
||||
v.sendMessage(ChatColor.RED
|
||||
+ "Invalid brush parameters! use the info parameter to display parameter info.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode()
|
||||
{
|
||||
@Override public String getPermissionNode() {
|
||||
return "voxelsniper.brush.overlay";
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.HashSet;
|
||||
*/
|
||||
public class PullBrush extends Brush
|
||||
{
|
||||
private final HashSet<BlockWrapper> surface = new HashSet<BlockWrapper>();
|
||||
private final HashSet<BlockWrapper> surface = new HashSet<>();
|
||||
private int vh;
|
||||
private double c1 = 1;
|
||||
private double c2 = 0;
|
||||
|
@ -163,16 +163,11 @@ public class Rot2DBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,16 +176,11 @@ public class Rot2DBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,16 +164,11 @@ public class Rot2DvertBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,16 +177,11 @@ public class Rot2DvertBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,16 +248,11 @@ public class Rot3DBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,16 +261,11 @@ public class Rot3DBrush extends Brush
|
||||
{
|
||||
this.bSize = v.getBrushSize();
|
||||
|
||||
switch (this.mode)
|
||||
{
|
||||
case 0:
|
||||
if (this.mode == 0) {
|
||||
this.getMatrix();
|
||||
this.rotate(v);
|
||||
break;
|
||||
|
||||
default:
|
||||
} else {
|
||||
v.owner().getPlayer().sendMessage(ChatColor.RED + "Something went wrong.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,8 @@ public class ShellBallBrush extends Brush
|
||||
{
|
||||
for (int y = 0; y <= brushSizeDoubled; y++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeDoubled; z++)
|
||||
{
|
||||
newMaterials[x][y][z] = oldMaterials[x + 1][y + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
|
||||
brushSizeDoubled + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,8 @@ public class ShellSetBrush extends Brush
|
||||
}
|
||||
else
|
||||
{
|
||||
final ArrayList<AsyncBlock> blocks = new ArrayList<AsyncBlock>(((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2));
|
||||
final ArrayList<AsyncBlock> blocks = new ArrayList<>(
|
||||
((Math.abs(highX - lowX) * Math.abs(highZ - lowZ) * Math.abs(highY - lowY)) / 2));
|
||||
for (int y = lowY; y <= highY; y++)
|
||||
{
|
||||
for (int x = lowX; x <= highX; x++)
|
||||
|
@ -49,10 +49,8 @@ public class ShellVoxelBrush extends Brush
|
||||
{
|
||||
for (int y = 0; y <= brushSizeSquared; y++)
|
||||
{
|
||||
for (int z = 0; z <= brushSizeSquared; z++)
|
||||
{
|
||||
newMaterials[x][y][z] = oldMaterials[x + 1][y + 1][z + 1];
|
||||
}
|
||||
System.arraycopy(oldMaterials[x + 1][y + 1], 1, newMaterials[x][y], 0,
|
||||
brushSizeSquared + 1);
|
||||
}
|
||||
}
|
||||
int temp;
|
||||
|
@ -2,6 +2,7 @@ package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
@ -95,19 +96,15 @@ public class SnowConeBrush extends Brush
|
||||
|
||||
if (snowData > snowconeData[x][z])
|
||||
{
|
||||
switch (BlockTypes.get(snowcone[x][z]))
|
||||
{
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
BlockType blockType =
|
||||
BlockTypes.get(snowcone[x][z]);
|
||||
if (blockType.getMaterial().isAir()) {
|
||||
snowconeData[x][z] = snowData;
|
||||
snowcone[x][z] = BlockTypes.SNOW.getInternalId();
|
||||
case SNOW_BLOCK:
|
||||
snowconeData[x][z] = snowData;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
snowconeData[x][z] = snowData;
|
||||
} else if (blockType == BlockTypes.SNOW_BLOCK) {
|
||||
snowconeData[x][z] = snowData;
|
||||
}
|
||||
}
|
||||
else if (yOffset[x][z] > 0 && snowcone[x][z] == BlockTypes.SNOW.getInternalId())
|
||||
@ -152,22 +149,17 @@ public class SnowConeBrush extends Brush
|
||||
@Override
|
||||
protected final void powder(final SnipeData v)
|
||||
{
|
||||
switch (getTargetBlock().getType())
|
||||
{
|
||||
case SNOW:
|
||||
if (getTargetBlock().getType() == Material.SNOW) {
|
||||
this.addSnow(v, this.getTargetBlock());
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
Block blockAbove = getTargetBlock().getRelative(BlockFace.UP);
|
||||
if (blockAbove != null && BukkitAdapter.adapt(blockAbove.getType()).getMaterial().isAir())
|
||||
{
|
||||
if (blockAbove != null && BukkitAdapter.adapt(blockAbove.getType()).getMaterial()
|
||||
.isAir()) {
|
||||
addSnow(v, blockAbove);
|
||||
} else {
|
||||
v.owner().getPlayer()
|
||||
.sendMessage(ChatColor.RED + "Error: Center block neither snow nor air.");
|
||||
}
|
||||
else
|
||||
{
|
||||
v.owner().getPlayer().sendMessage(ChatColor.RED + "Error: Center block neither snow nor air.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
@ -724,14 +725,12 @@ public class SpiralStaircaseBrush extends Brush
|
||||
// step/slab
|
||||
|
||||
try {
|
||||
BlockTypes type = BlockTypes.parse(par[i]);
|
||||
BlockType type = BlockTypes.parse(par[i]);
|
||||
this.stairtype = par[i].toLowerCase().intern();
|
||||
v.sendMessage(ChatColor.BLUE + "Staircase type: " + this.stairtype);
|
||||
return;
|
||||
} catch (InputParseException ignore) {}
|
||||
switch (par[i].toLowerCase()) {
|
||||
case "block":
|
||||
|
||||
if ("block".equals(par[i].toLowerCase())) {
|
||||
}
|
||||
if (par[i].equalsIgnoreCase("block") || par[i].equalsIgnoreCase("step") || par[i].equalsIgnoreCase("woodstair") || par[i].equalsIgnoreCase("cobblestair"))
|
||||
{
|
||||
|
@ -130,10 +130,9 @@ public class SplatterBallBrush extends PerformBrush
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
|
||||
{
|
||||
splat[x][y][z] = tempSplat[x][y][z];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
|
||||
2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +115,8 @@ public class SplatterDiscBrush extends PerformBrush
|
||||
// integrate tempsplat back into splat at end of iteration
|
||||
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
splat[x][y] = tempSplat[x][y];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
this.growPercent = gref;
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
|
||||
@ -103,10 +104,8 @@ public class SplatterOverlayBrush extends PerformBrush
|
||||
// integrate tempsplat back into splat at end of iteration
|
||||
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
splat[x][y] = tempSplat[x][y];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
this.growPercent = gref;
|
||||
@ -135,7 +134,7 @@ public class SplatterOverlayBrush extends PerformBrush
|
||||
if (!this.allBlocks)
|
||||
{
|
||||
// if the override parameter has not been activated, go to the switch that filters out manmade stuff.
|
||||
BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
|
||||
BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
|
||||
BlockMaterial mat = type.getMaterial();
|
||||
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer()) {
|
||||
final int depth = randomizeHeight ? generator.nextInt(this.depth) : this.depth;
|
||||
@ -239,10 +238,8 @@ public class SplatterOverlayBrush extends PerformBrush
|
||||
// integrate tempsplat back into splat at end of iteration
|
||||
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
splat[x][y] = tempsplat[x][y];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempsplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
this.growPercent = gref;
|
||||
@ -268,7 +265,7 @@ public class SplatterOverlayBrush extends PerformBrush
|
||||
if (!this.allBlocks)
|
||||
{ // if the override parameter has not been activated, go to the switch that filters out manmade stuff.
|
||||
|
||||
BlockTypes type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
|
||||
BlockType type = BlockTypes.get(this.getBlockIdAt(this.getTargetBlock().getX() + x, y, this.getTargetBlock().getZ() + z));
|
||||
BlockMaterial mat = type.getMaterial();
|
||||
if (mat.isSolid() && mat.isFullCube() && !mat.hasContainer())
|
||||
{
|
||||
|
@ -130,10 +130,9 @@ public class SplatterVoxelBrush extends PerformBrush
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
for (int z = 2 * v.getBrushSize(); z >= 0; z--)
|
||||
{
|
||||
splat[x][y][z] = tempSplat[x][y][z];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempSplat[x][y], 0, splat[x][y], 0,
|
||||
2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,10 +111,8 @@ public class SplatterVoxelDiscBrush extends PerformBrush
|
||||
// integrate tempsplat back into splat at end of iteration
|
||||
for (int x = 2 * v.getBrushSize(); x >= 0; x--)
|
||||
{
|
||||
for (int y = 2 * v.getBrushSize(); y >= 0; y--)
|
||||
{
|
||||
splat[x][y] = tempSplat[x][y];
|
||||
}
|
||||
if (2 * v.getBrushSize() + 1 >= 0)
|
||||
System.arraycopy(tempSplat[x], 0, splat[x], 0, 2 * v.getBrushSize() + 1);
|
||||
}
|
||||
}
|
||||
this.growPercent = gref;
|
||||
|
@ -16,9 +16,9 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class SplineBrush extends PerformBrush
|
||||
{
|
||||
private final ArrayList<Block> endPts = new ArrayList<Block>();
|
||||
private final ArrayList<Block> ctrlPts = new ArrayList<Block>();
|
||||
protected ArrayList<Point> spline = new ArrayList<Point>();
|
||||
private final ArrayList<Block> endPts = new ArrayList<>();
|
||||
private final ArrayList<Block> ctrlPts = new ArrayList<>();
|
||||
protected ArrayList<Point> spline = new ArrayList<>();
|
||||
protected boolean set;
|
||||
protected boolean ctrl;
|
||||
protected String[] sparams = {"ss", "sc", "clear"};
|
||||
|
@ -52,10 +52,10 @@ public class StampBrush extends Brush
|
||||
NO_AIR, FILL, DEFAULT
|
||||
}
|
||||
|
||||
protected HashSet<BlockWrapper> clone = new HashSet<BlockWrapper>();
|
||||
protected HashSet<BlockWrapper> fall = new HashSet<BlockWrapper>();
|
||||
protected HashSet<BlockWrapper> drop = new HashSet<BlockWrapper>();
|
||||
protected HashSet<BlockWrapper> solid = new HashSet<BlockWrapper>();
|
||||
protected HashSet<BlockWrapper> clone = new HashSet<>();
|
||||
protected HashSet<BlockWrapper> fall = new HashSet<>();
|
||||
protected HashSet<BlockWrapper> drop = new HashSet<>();
|
||||
protected HashSet<BlockWrapper> solid = new HashSet<>();
|
||||
protected Undo undo;
|
||||
protected boolean sorted = false;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class StencilListBrush extends Brush
|
||||
private short zRef;
|
||||
private short yRef;
|
||||
private byte pasteParam = 0;
|
||||
private HashMap<Integer, String> stencilList = new HashMap<Integer, String>();
|
||||
private HashMap<Integer, String> stencilList = new HashMap<>();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import com.thevoxelbox.voxelsniper.brush.perform.PerformBrush;
|
||||
|
139
favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java
Normale Datei
139
favs/src/main/java/com/thevoxelbox/voxelsniper/brush/WallSider.java
Normale Datei
@ -0,0 +1,139 @@
|
||||
package com.thevoxelbox.voxelsniper.brush;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
|
||||
public class WallSider extends Brush{
|
||||
|
||||
private static String[] facings = new String[] { "north", "east", "south", "west", "relative to player" };
|
||||
private short c;
|
||||
private short d;
|
||||
private double e;
|
||||
private boolean f;
|
||||
private boolean g;
|
||||
private boolean h;
|
||||
|
||||
public WallSider() {
|
||||
this.c = 4;
|
||||
this.d = 1;
|
||||
this.e = 0.0;
|
||||
this.setName("WallSider");
|
||||
}
|
||||
|
||||
private void a(final SnipeData snipeData, final Block block, final boolean b) {
|
||||
final double n = (snipeData.getBrushSize() + this.e) * (snipeData.getBrushSize() + this.e);
|
||||
final Vector vector;
|
||||
final Vector clone = (vector = block.getLocation().toVector()).clone();
|
||||
int c;
|
||||
if (this.c == 4) {
|
||||
double n2;
|
||||
if ((n2 = (snipeData.owner().getPlayer().getLocation().getYaw() - 90.0f) % 360.0f) < 0.0) {
|
||||
n2 += 360.0;
|
||||
}
|
||||
c = ((0.0 >= n2 && n2 < 45.0) ? 2 : ((45.0 >= n2 && n2 < 135.0) ? 3 : ((135.0 >= n2 && n2 < 225.0) ? 0 : ((225.0 >= n2 && n2 < 315.0) ? 1 : ((315.0 >= n2 && n2 < 360.0) ? 2 : -1)))));
|
||||
}
|
||||
else {
|
||||
c = this.c;
|
||||
}
|
||||
int n3 = c;
|
||||
if (b) {
|
||||
n3 = (short)((n3 + 2) % 4);
|
||||
}
|
||||
int n4 = 98;
|
||||
if (n3 == 0 || n3 == 2) {
|
||||
n4 = 97;
|
||||
}
|
||||
for (int i = -snipeData.getBrushSize(); i <= snipeData.getBrushSize(); ++i) {
|
||||
if (n4 == 97) {
|
||||
clone.setX(vector.getX() + i);
|
||||
}
|
||||
else {
|
||||
clone.setZ(vector.getZ() + i);
|
||||
}
|
||||
for (int j = -snipeData.getBrushSize(); j <= snipeData.getBrushSize(); ++j) {
|
||||
clone.setY(vector.getY() + j);
|
||||
if (vector.distanceSquared(clone) <= n) {
|
||||
for (short n5 = 0; n5 < this.d; ++n5) {
|
||||
if (n4 == 97) {
|
||||
clone.setZ(vector.getZ() + ((n3 == 2) ? n5 : (-n5)));
|
||||
}
|
||||
else {
|
||||
clone.setX(vector.getX() + ((n3 == 1) ? n5 : (-n5)));
|
||||
}
|
||||
final AsyncBlock block2 = this.getWorld().getBlockAt(clone.getBlockX(), clone.getBlockY(), clone.getBlockZ());
|
||||
if ((this.f && block2.getTypeId() == snipeData.getReplaceId()) || (!this.f && (block2.getTypeId() != 0 || this.g))) {
|
||||
block2.setTypeId(snipeData.getVoxelId());
|
||||
}
|
||||
}
|
||||
if (n4 == 97) {
|
||||
clone.setZ(vector.getZ());
|
||||
}
|
||||
else {
|
||||
clone.setX(vector.getX());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void arrow(final SnipeData snipeData) {
|
||||
this.a(snipeData, this.getTargetBlock(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void powder(final SnipeData snipeData) {
|
||||
this.a(snipeData, this.getTargetBlock(), true);
|
||||
}
|
||||
|
||||
public final void parameters(final String[] array, final SnipeData snipeData) {
|
||||
for (int i = 1; i < array.length; ++i) {
|
||||
final String lowerCase;
|
||||
if ((lowerCase = array[i].toLowerCase()).startsWith("d")) {
|
||||
this.d = (short)Integer.parseInt(lowerCase.replace("d", ""));
|
||||
snipeData.sendMessage(ChatColor.AQUA + "Depth set to " + this.d + " blocks");
|
||||
}
|
||||
else if (lowerCase.startsWith("s")) {
|
||||
this.c = (short)Integer.parseInt(lowerCase.replace("s", ""));
|
||||
if (this.c > 4 || this.c < 0) {
|
||||
this.c = 4;
|
||||
}
|
||||
snipeData.sendMessage(ChatColor.AQUA + "Orientation set to " + facings[this.c]);
|
||||
}
|
||||
else if (lowerCase.startsWith("true")) {
|
||||
this.e = 0.5;
|
||||
snipeData.sendMessage(ChatColor.AQUA + "True circle mode ON.");
|
||||
}
|
||||
else if (lowerCase.startsWith("false")) {
|
||||
this.e = 0.0;
|
||||
snipeData.sendMessage(ChatColor.AQUA + "True circle mode OFF.");
|
||||
}
|
||||
else if (lowerCase.startsWith("air")) {
|
||||
this.g = true;
|
||||
snipeData.sendMessage(ChatColor.AQUA + "Including air.");
|
||||
}
|
||||
else if (lowerCase.startsWith("mm")) {
|
||||
this.f = true;
|
||||
snipeData.sendMessage(ChatColor.AQUA + "Replacing block.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "voxelsniper.brush.wallsider";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Message vm) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,10 +2,10 @@ package com.thevoxelbox.voxelsniper.brush.perform;
|
||||
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import com.boydti.fawe.object.pattern.PatternTraverser;
|
||||
import com.sk89q.worldedit.MutableBlockVector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.thevoxelbox.voxelsniper.Message;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
import org.bukkit.block.Block;
|
||||
@ -14,7 +14,6 @@ public class PatternPerformer extends vPerformer {
|
||||
private String info;
|
||||
private Pattern pattern;
|
||||
private Extent extent;
|
||||
private MutableBlockVector mutable = new MutableBlockVector();
|
||||
|
||||
@Override
|
||||
public void info(Message vm) {
|
||||
@ -33,9 +32,9 @@ public class PatternPerformer extends vPerformer {
|
||||
|
||||
@Override
|
||||
public void perform(AsyncBlock block) {
|
||||
mutable.setComponents(block.getX(), block.getY(), block.getZ());
|
||||
BlockVector3 bv = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||
try {
|
||||
pattern.apply(extent, mutable, mutable);
|
||||
pattern.apply(extent, bv, bv);
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.thevoxelbox.voxelsniper.Message;
|
||||
public interface Performer
|
||||
{
|
||||
|
||||
public void parse(String[] args, com.thevoxelbox.voxelsniper.SnipeData v);
|
||||
void parse(String[] args, com.thevoxelbox.voxelsniper.SnipeData v);
|
||||
|
||||
public void showInfo(Message vm);
|
||||
void showInfo(Message vm);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public enum PerformerE
|
||||
public static String performer_list_short = "";
|
||||
public static String performer_list_long = "";
|
||||
|
||||
private PerformerE(Class<? extends vPerformer> c, String s, String l)
|
||||
PerformerE(Class<? extends vPerformer> c, String s, String l)
|
||||
{
|
||||
pclass = c;
|
||||
short_name = s;
|
||||
@ -116,28 +116,12 @@ public enum PerformerE
|
||||
p = pclass.getConstructor().newInstance();
|
||||
return p;
|
||||
}
|
||||
catch (InstantiationException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IllegalAccessException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (InvocationTargetException ex)
|
||||
catch (InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
catch (NoSuchMethodException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (SecurityException ex)
|
||||
catch (NoSuchMethodException | SecurityException ex)
|
||||
{
|
||||
Logger.getLogger(PerformerE.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@ -163,8 +147,8 @@ public enum PerformerE
|
||||
|
||||
static
|
||||
{
|
||||
performers = new TreeMap<String, vPerformer>();
|
||||
long_names = new TreeMap<String, String>();
|
||||
performers = new TreeMap<>();
|
||||
long_names = new TreeMap<>();
|
||||
|
||||
for (PerformerE pe : values())
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ package com.thevoxelbox.voxelsniper.command;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.material;
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
@ -39,7 +40,7 @@ public class VoxelReplaceCommand extends VoxelCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockTypes weType = BlockTypes.parse(args[0]);
|
||||
BlockType weType = BlockTypes.parse(args[0]);
|
||||
if (weType != null)
|
||||
{
|
||||
snipeData.setReplaceId(weType.getInternalId());
|
||||
|
@ -29,6 +29,7 @@ import com.bekvon.bukkit.residence.commands.material;
|
||||
import com.boydti.fawe.bukkit.favs.PatternUtil;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.thevoxelbox.voxelsniper.RangeBlockHelper;
|
||||
import com.thevoxelbox.voxelsniper.SnipeData;
|
||||
@ -53,8 +54,8 @@ public class VoxelVoxelCommand extends VoxelCommand {
|
||||
Block block = (new RangeBlockHelper(player, sniper.getWorld())).getTargetBlock();
|
||||
Material blockType = block.getType();
|
||||
|
||||
BlockTypes weType = BukkitAdapter.adapt(blockType);
|
||||
if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType)) {
|
||||
BlockType weType = BukkitAdapter.adapt(blockType);
|
||||
if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType.getId())) {
|
||||
player.sendMessage("You are not allowed to use " + blockType.name() + ". (WorldEdit config.yml)");
|
||||
return true;
|
||||
}
|
||||
@ -65,9 +66,9 @@ public class VoxelVoxelCommand extends VoxelCommand {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
BlockTypes weType = BlockTypes.parse(args[0]);
|
||||
BlockType weType = BlockTypes.parse(args[0]);
|
||||
if(weType != null) {
|
||||
if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType)) {
|
||||
if(!player.hasPermission("voxelsniper.ignorelimitations") && WorldEdit.getInstance().getConfiguration().disallowedBlocks.contains(weType.getId())) {
|
||||
player.sendMessage("You are not allowed to use " + weType + ".");
|
||||
return true;
|
||||
} else {
|
||||
|
@ -165,7 +165,7 @@ public class HelpJSAP extends JSAP
|
||||
{
|
||||
if (!(jsapResult.success()) || jsapResult.getBoolean("help"))
|
||||
{
|
||||
List<String> returnValue = new LinkedList<String>();
|
||||
List<String> returnValue = new LinkedList<>();
|
||||
// To avoid spurious missing argument errors we never print errors if help is required.
|
||||
if (!jsapResult.getBoolean("help"))
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.thevoxelbox.voxelsniper.util;
|
||||
|
||||
import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
@ -10,6 +11,7 @@ public class BlockWrapper
|
||||
{
|
||||
|
||||
private int id;
|
||||
private Material type;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
@ -38,6 +40,10 @@ public class BlockWrapper
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@ -131,4 +137,9 @@ public class BlockWrapper
|
||||
{
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public void setType(Material type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ load: STARTUP
|
||||
database: false
|
||||
depend: [WorldEdit]
|
||||
api-version: 1.13
|
||||
#softdepend: [WorldGuard, PlotSquared, MCore, Factions, GriefPrevention, Residence, Towny, PlotMe, PreciousStones]
|
||||
#softdepend: [WorldGuard, PlotSquared, MCore, Factions, GriefPrevention, Residence, Towny, PreciousStones]
|
||||
commands:
|
||||
'/p':
|
||||
description: VoxelSniper perform command
|
||||
@ -146,6 +146,7 @@ permissions:
|
||||
voxelsniper.brush.ellipsoid: true
|
||||
voxelsniper.brush.eraser: true
|
||||
voxelsniper.brush.erode: true
|
||||
voxelsniper.brush.erodeblend: true
|
||||
voxelsniper.brush.extrude: true
|
||||
voxelsniper.brush.filldown: true
|
||||
voxelsniper.brush.flatocean: true
|
||||
@ -190,6 +191,7 @@ permissions:
|
||||
voxelsniper.brush.voxeldisc: true
|
||||
voxelsniper.brush.voxeldiscface: true
|
||||
voxelsniper.brush.warp: true
|
||||
voxelsniper.brush.wallsider: true
|
||||
voxelsniper.goto: true
|
||||
voxelsniper.sniper: true
|
||||
voxelsniper.sniper:
|
||||
@ -228,6 +230,7 @@ permissions:
|
||||
voxelsniper.brush.entityremoval: true
|
||||
voxelsniper.brush.eraser: true
|
||||
voxelsniper.brush.erode: true
|
||||
voxelsniper.brush.erodeblend: true
|
||||
voxelsniper.brush.extrude: true
|
||||
voxelsniper.brush.filldown: true
|
||||
voxelsniper.brush.flatocean: true
|
||||
@ -279,6 +282,7 @@ permissions:
|
||||
voxelsniper.brush.voxeldisc: true
|
||||
voxelsniper.brush.voxeldiscface: true
|
||||
voxelsniper.brush.warp: true
|
||||
voxelsniper.brush.wallsider: true
|
||||
voxelsniper.brush.ball:
|
||||
default: op
|
||||
voxelsniper.brush.biome:
|
||||
@ -333,6 +337,8 @@ permissions:
|
||||
default: op
|
||||
voxelsniper.brush.erode:
|
||||
default: op
|
||||
voxelsniper.brush.erodeblend:
|
||||
default: op
|
||||
voxelsniper.brush.extrude:
|
||||
default: op
|
||||
voxelsniper.brush.filldown:
|
||||
@ -433,5 +439,7 @@ permissions:
|
||||
default: op
|
||||
voxelsniper.brush.voxeldiscface:
|
||||
default: op
|
||||
voxelsniper.brush.wallsider:
|
||||
default: op
|
||||
voxelsniper.brush.warp:
|
||||
default: op
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
#Mon Mar 25 18:59:14 EDT 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
||||
|
@ -10,7 +10,6 @@
|
||||
======= By Empire92 and WorldEdit team =======
|
||||
|
||||
If you encounter trouble:
|
||||
- Read COMPILING.md if you haven't yet
|
||||
- Run `build` in a separate Gradle run
|
||||
- Use gradlew and not gradle
|
||||
- Ask us!
|
||||
|
@ -4,16 +4,15 @@ apply plugin: 'maven'
|
||||
|
||||
repositories {
|
||||
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
|
||||
maven { url "https://ci.athion.net/job/FAWE-WorldGuard-1.13/lastSuccessfulBuild/artifact/mvn" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':worldedit-core')
|
||||
compile 'com.sk89q:dummypermscompat:1.8'
|
||||
compile 'com.destroystokyo.paper:paper-api:1.13-R0.1-SNAPSHOT'
|
||||
compile 'net.milkbowl.vault:VaultAPI:1.7'
|
||||
compile 'com.sk89q:dummypermscompat:1.10'
|
||||
compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
|
||||
compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
|
||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||
compile 'net.milkbowl.vault:VaultAPI:1.5.6'
|
||||
compile 'com.massivecraft:factions:2.8.0'
|
||||
compile 'com.drtshock:factions:1.6.9.5'
|
||||
compile 'com.factionsone:FactionsOne:1.2.2'
|
||||
@ -23,12 +22,11 @@ dependencies {
|
||||
compile 'net.jzx7:regios:5.9.9'
|
||||
compile 'com.bekvon.bukkit.residence:Residence:4.5._13.1'
|
||||
compile 'com.palmergames.bukkit:towny:0.84.0.9'
|
||||
compile 'com.worldcretornica:plotme_core:0.16.3'
|
||||
compile 'com.thevoxelbox.voxelsniper:voxelsniper:5.171.0'
|
||||
compile 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
|
||||
compile 'com.wasteofplastic:askyblock:3.0.8.2'
|
||||
compile 'com.sk89q:worldguard-core:latest'
|
||||
compile 'com.sk89q:worldguard-legacy:latest'
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39'
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
704
worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BStats.java
Normale Datei
704
worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BStats.java
Normale Datei
@ -0,0 +1,704 @@
|
||||
package org.bstats.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"}) public class BStats {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test environment
|
||||
if (System.getProperty("bstats.relocatecheck") == null || !System
|
||||
.getProperty("bstats.relocatecheck").equals("false")) {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(
|
||||
new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k',
|
||||
'k', 'i', 't'});
|
||||
final String examplePackage =
|
||||
new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class
|
||||
.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException(
|
||||
"bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private boolean enabled;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// Should the sent data be logged?
|
||||
private static boolean logSentData;
|
||||
|
||||
// Should the response text be logged?
|
||||
private static boolean logResponseStatusText;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final Plugin plugin;
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
*/
|
||||
public BStats(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
// Should the sent data be logged?
|
||||
config.addDefault("logSentData", false);
|
||||
// Should the response text be logged?
|
||||
config.addDefault("logResponseStatusText", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats collects some data for plugin authors like how many servers are using their plugins.\n"
|
||||
+ "To honor their work, you should not disable it.\n"
|
||||
+ "This has nearly no effect on the server performance!\n"
|
||||
+ "Check out https://bStats.org/ to learn more :)").copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
// Load the data
|
||||
enabled = config.getBoolean("enabled", true);
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
logSentData = config.getBoolean("logSentData", false);
|
||||
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||
|
||||
if (enabled) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager()
|
||||
.register(BStats.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if bStats is enabled.
|
||||
*
|
||||
* @return Whether bStats is enabled or not.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Chart cannot be null!");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer =
|
||||
new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override public void run() {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, () -> submitData());
|
||||
}
|
||||
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data.
|
||||
* This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JSONObject getPluginData() {
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
String pluginName = "FastAsyncWorldEdit";
|
||||
String pluginVersion = Fawe.get().getVersion() + "";
|
||||
|
||||
data.put("pluginName", pluginName); // Append the name of the plugin
|
||||
data.put("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JSONArray customCharts = new JSONArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JSONObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.put("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount = getPlayerCount();
|
||||
int onlineMode = Fawe.imp().isOnlineMode() ? 1 : 0;
|
||||
String serverVersion = Fawe.imp().getPlatformVersion();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
data.put("serverUUID", serverUUID);
|
||||
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", serverVersion);
|
||||
|
||||
data.put("javaVersion", javaVersion);
|
||||
data.put("osName", osName);
|
||||
data.put("osArch", osArch);
|
||||
data.put("osVersion", osVersion);
|
||||
data.put("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
return Fawe.imp() == null ? 1 : Fawe.imp().getPlayerCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JSONObject data = getServerData();
|
||||
|
||||
JSONArray pluginData = new JSONArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager()
|
||||
.getRegistrations(service)) {
|
||||
try {
|
||||
pluginData.add(provider.getService().getMethod("getPluginData")
|
||||
.invoke(provider.getProvider()));
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
data.put("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(() -> {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger()
|
||||
.log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JSONObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException(
|
||||
"This method must not be called from the main thread!");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data.toString());
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type",
|
||||
"application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
try (InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(
|
||||
new InputStreamReader(inputStream))) {
|
||||
|
||||
builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
if (logResponseStatusText) {
|
||||
plugin.getLogger()
|
||||
.info("Sent data to bStats and received response: " + builder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JSONObject getRequestJsonObject() {
|
||||
JSONObject chart = new JSONObject();
|
||||
chart.put("chartId", chartId);
|
||||
try {
|
||||
JSONObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.put("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING,
|
||||
"Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JSONObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override public JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JSONObject value = new JSONObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey())
|
||||
.entrySet()) {
|
||||
value.put(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.put(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
categoryValues.add(entry.getValue());
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(categoryValue);
|
||||
}
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,7 +8,6 @@ import com.boydti.fawe.wrappers.PlayerWrapper;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -24,13 +24,11 @@ import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.util.Jars;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.cui.CUI;
|
||||
import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.boydti.fawe.util.metrics.BStats;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.bstats.bukkit.BStats;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@ -41,7 +39,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -74,8 +71,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
return this.vault;
|
||||
}
|
||||
|
||||
private List<org.bukkit.util.Vector> locations = Arrays.asList(new Vector(0, 5, 0));
|
||||
|
||||
public FaweBukkit(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
try {
|
||||
@ -110,9 +105,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
|
||||
// Registered delayed Event Listeners
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.task(() -> {
|
||||
// This class
|
||||
Bukkit.getPluginManager().registerEvents(FaweBukkit.this, FaweBukkit.this.plugin);
|
||||
|
||||
@ -131,7 +124,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(new SyncTabCompleteListener(WorldEditPlugin.getInstance()), plugin);
|
||||
}*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -265,42 +257,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMetrics() {
|
||||
Metrics metrics = new Metrics(plugin);
|
||||
metrics.start();
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<Class<?>> services = new ArrayList(Bukkit.getServicesManager().getKnownServices());
|
||||
services.forEach(service -> {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION");
|
||||
ArrayList<RegisteredServiceProvider<?>> providers = new ArrayList(Bukkit.getServicesManager().getRegistrations(service));
|
||||
for (RegisteredServiceProvider<?> provider : providers) {
|
||||
Object instance = provider.getProvider();
|
||||
|
||||
// Link it to FAWE's metrics instead
|
||||
BStats.linkMetrics(instance);
|
||||
|
||||
// Disable the other metrics
|
||||
Bukkit.getServicesManager().unregister(service, instance);
|
||||
try {
|
||||
Class<? extends Object> clazz = instance.getClass();
|
||||
Field logFailedRequests = ReflectionUtils.findField(clazz, boolean.class);
|
||||
logFailedRequests.set(null, false);
|
||||
Field url = null;
|
||||
try { url = clazz.getDeclaredField("URL"); } catch (NoSuchFieldException ignore) {
|
||||
for (Field field : clazz.getDeclaredFields()) if (ReflectionUtils.setAccessible(field).get(null).toString().startsWith("http")) { url = field; break; }
|
||||
}
|
||||
if (url != null) ReflectionUtils.setFailsafeFieldValue(url, null, null);
|
||||
} catch (NoSuchFieldError | IllegalAccessException ignore) {}
|
||||
catch (Throwable e) {}
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
});
|
||||
}
|
||||
});
|
||||
@Override public void startMetrics() {
|
||||
BStats bStats = new BStats(plugin);
|
||||
}
|
||||
|
||||
public ItemUtil getItemUtil() {
|
||||
@ -335,11 +293,11 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
public String getDebugInfo() {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
List<String> pl = new ArrayList<>();
|
||||
msg.append("server.plugins: \n");
|
||||
msg.append("server.version: " + Bukkit.getVersion() + " / " + Bukkit.getBukkitVersion() + "\n");
|
||||
msg.append("Plugins: \n");
|
||||
for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
|
||||
msg.append(" - " + p.getName() + ": " + p.getDescription().getVersion() + "\n");
|
||||
}
|
||||
msg.append("server.version: " + Bukkit.getVersion() + " / " + Bukkit.getBukkitVersion() + "\n");
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@ -387,12 +345,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
debug("=======================================");
|
||||
ignore.printStackTrace();
|
||||
debug("=======================================");
|
||||
TaskManager.IMP.laterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendAdmin("&cNo NMS placer found, see console!");
|
||||
}
|
||||
}, 1);
|
||||
TaskManager.IMP.laterAsync(
|
||||
() -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1);
|
||||
hasNMS = false;
|
||||
}
|
||||
return new BukkitQueue_All(world);
|
||||
@ -443,12 +397,8 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
debug("=======================================");
|
||||
error.printStackTrace();
|
||||
debug("=======================================");
|
||||
TaskManager.IMP.laterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendAdmin("&cNo NMS placer found, see console!");
|
||||
}
|
||||
}, 1);
|
||||
TaskManager.IMP.laterAsync(
|
||||
() -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1);
|
||||
hasNMS = false;
|
||||
}
|
||||
}
|
||||
@ -480,15 +430,6 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
|
||||
if ((plotmePlugin != null) && plotmePlugin.isEnabled()) {
|
||||
try {
|
||||
managers.add(new PlotMeFeature(plotmePlugin, this));
|
||||
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
||||
} catch (final Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
|
||||
if ((townyPlugin != null) && townyPlugin.isEnabled()) {
|
||||
try {
|
||||
|
@ -1,584 +0,0 @@
|
||||
package com.boydti.fawe.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number.
|
||||
*/
|
||||
private static final int REVISION = 7;
|
||||
/**
|
||||
* The base url of the metrics domain.
|
||||
*/
|
||||
private static final String BASE_URL = "http://report.mcstats.org";
|
||||
/**
|
||||
* The url used to report a server's status.
|
||||
*/
|
||||
private static final String REPORT_URL = "/plugin/%s";
|
||||
/**
|
||||
* Interval of time to ping (in minutes).
|
||||
*/
|
||||
private static final int PING_INTERVAL = 15;
|
||||
/**
|
||||
* The plugin this metrics submits for.
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics.
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
/**
|
||||
* Unique server id.
|
||||
*/
|
||||
private final String guid;
|
||||
/**
|
||||
* Debug mode.
|
||||
*/
|
||||
private final boolean debug;
|
||||
/**
|
||||
* The scheduled task.
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
this.guid = UUID.randomUUID().toString();
|
||||
this.debug = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* GZip compress a string of bytes.
|
||||
*
|
||||
* @param input
|
||||
*
|
||||
* @return byte[] the file as a byte array
|
||||
*/
|
||||
public static byte[] gzip(String input) {
|
||||
FastByteArrayOutputStream baos = new FastByteArrayOutputStream();
|
||||
PGZIPOutputStream gzos = null;
|
||||
try {
|
||||
gzos = new PGZIPOutputStream(baos);
|
||||
gzos.write(input.getBytes("UTF-8"));
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
} finally {
|
||||
if (gzos != null) {
|
||||
try {
|
||||
gzos.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a json encoded key/value pair to the given string builder.
|
||||
*
|
||||
* @param json
|
||||
* @param key
|
||||
* @param value
|
||||
*
|
||||
*/
|
||||
private static void appendJSONPair(StringBuilder json, String key, String value) {
|
||||
boolean isValueNumeric = false;
|
||||
try {
|
||||
if (value.equals("0") || !value.endsWith("0")) {
|
||||
Double.parseDouble(value);
|
||||
isValueNumeric = true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
isValueNumeric = false;
|
||||
}
|
||||
if (json.charAt(json.length() - 1) != '{') {
|
||||
json.append(',');
|
||||
}
|
||||
json.append(escapeJSON(key));
|
||||
json.append(':');
|
||||
if (isValueNumeric) {
|
||||
json.append(value);
|
||||
} else {
|
||||
json.append(escapeJSON(value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string to create a valid JSON string
|
||||
*
|
||||
* @param text
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
private static String escapeJSON(String text) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('"');
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
char chr = text.charAt(index);
|
||||
switch (chr) {
|
||||
case '"':
|
||||
case '\\':
|
||||
builder.append('\\');
|
||||
builder.append(chr);
|
||||
break;
|
||||
case '\b':
|
||||
builder.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
builder.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
builder.append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (chr < ' ') {
|
||||
String t = "000" + Integer.toHexString(chr);
|
||||
builder.append("\\u" + t.substring(t.length() - 4));
|
||||
} else {
|
||||
builder.append(chr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.append('"');
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text the text to encode
|
||||
*
|
||||
* @return the encoded text, as UTF-8
|
||||
*/
|
||||
private static String urlEncode(String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
*
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
// Construct the graph object
|
||||
Graph graph = new Graph(name);
|
||||
// Now we can add our graph
|
||||
this.graphs.add(graph);
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
this.graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
// Is metrics already running?
|
||||
if (this.task != null) {
|
||||
return true;
|
||||
}
|
||||
// Begin hitting the server with glorious data
|
||||
this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
postPlugin(!this.firstPost);
|
||||
// After the first post we set firstPost to
|
||||
// false
|
||||
// Each post thereafter will be a ping
|
||||
this.firstPost = false;
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
if (Metrics.this.debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void enable() {
|
||||
// Enable Task, if it is not running
|
||||
if (this.task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
*/
|
||||
public void disable() {
|
||||
// Disable Task, if it is running
|
||||
if (this.task != null) {
|
||||
this.task.cancel();
|
||||
this.task = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store
|
||||
* data such as the GUID and opt-out status.
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set
|
||||
// via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = this.plugin.getDataFolder().getParentFile();
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website.
|
||||
*/
|
||||
private void postPlugin(boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
PluginDescriptionFile description = this.plugin.getDescription();
|
||||
String pluginName = description.getName();
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
int playersOnline = 0;
|
||||
try {
|
||||
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class) {
|
||||
playersOnline = ((Collection<?>) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null)).size();
|
||||
} else {
|
||||
playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).invoke(null)).length;
|
||||
}
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
// END server software specific section -- all code below does not use
|
||||
// any code outside of this class / Java
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
json.append('{');
|
||||
// The plugin's description file containing all of the plugin data such as name, version, author, etc
|
||||
appendJSONPair(json, "guid", this.guid);
|
||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||
// New data as of R6
|
||||
String osname = System.getProperty("os.name");
|
||||
String osarch = System.getProperty("os.arch");
|
||||
String osversion = System.getProperty("os.version");
|
||||
String java_version = System.getProperty("java.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
// normalize os arch .. amd64 -> x86_64
|
||||
if (osarch.equals("amd64")) {
|
||||
osarch = "x86_64";
|
||||
}
|
||||
appendJSONPair(json, "osname", osname);
|
||||
appendJSONPair(json, "osarch", osarch);
|
||||
appendJSONPair(json, "osversion", osversion);
|
||||
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
||||
appendJSONPair(json, "java_version", java_version);
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
appendJSONPair(json, "ping", "1");
|
||||
}
|
||||
if (!this.graphs.isEmpty()) {
|
||||
synchronized (this.graphs) {
|
||||
json.append(',');
|
||||
json.append('"');
|
||||
json.append("graphs");
|
||||
json.append('"');
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
boolean firstGraph = true;
|
||||
for (Graph graph : this.graphs) {
|
||||
StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||
}
|
||||
graphJson.append('}');
|
||||
if (!firstGraph) {
|
||||
json.append(',');
|
||||
}
|
||||
json.append(escapeJSON(graph.getName()));
|
||||
json.append(':');
|
||||
json.append(graphJson);
|
||||
firstGraph = false;
|
||||
}
|
||||
json.append('}');
|
||||
}
|
||||
}
|
||||
// close json
|
||||
json.append('}');
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
byte[] uncompressed = json.toString().getBytes();
|
||||
byte[] compressed = gzip(json.toString());
|
||||
// Headers
|
||||
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.setDoOutput(true);
|
||||
if (this.debug) {
|
||||
Fawe.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
try {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(compressed);
|
||||
os.flush();
|
||||
}
|
||||
String response;
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
response = reader.readLine();
|
||||
if (this.debug) {
|
||||
Fawe.debug("[Metrics] Response for " + pluginName + ": " + response);
|
||||
}
|
||||
}
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
} else if (response.startsWith("7")) {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
throw new IOException(response);
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if ("1".equals(response) || response.contains("This is your first update this hour")) {
|
||||
synchronized (this.graphs) {
|
||||
for (Graph graph : this.graphs) {
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (this.debug) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<>();
|
||||
|
||||
private Graph(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(Plotter plotter) {
|
||||
this.plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(Plotter plotter) {
|
||||
this.plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(this.plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
Graph graph = (Graph) object;
|
||||
return graph.name.equals(this.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
*/
|
||||
protected void onOptOut() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public abstract static class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(this.name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
|
||||
|
@ -22,22 +22,20 @@ package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.CachedBukkitAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.*;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -49,14 +47,13 @@ import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
@ -69,7 +66,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
private final Field nbtListTagListField;
|
||||
private final Method nbtCreateTagMethod;
|
||||
private Method chunkSetTypeMethod;
|
||||
|
||||
static {
|
||||
// A simple test
|
||||
@ -88,13 +84,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
// The method to create an NBTBase tag given its type ID
|
||||
nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class);
|
||||
nbtCreateTagMethod.setAccessible(true);
|
||||
|
||||
// 1.13.2 Adaptation to find the a/setType method
|
||||
try {
|
||||
chunkSetTypeMethod = Chunk.class.getMethod("setType", BlockPosition.class, IBlockData.class, boolean.class);
|
||||
}catch(NoSuchMethodException e) {
|
||||
chunkSetTypeMethod = Chunk.class.getMethod("a", BlockPosition.class, IBlockData.class, boolean.class);
|
||||
}
|
||||
}
|
||||
|
||||
private int[] idbToStateOrdinal;
|
||||
@ -186,7 +175,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
BlockTypes type = state.getBlockType();
|
||||
BlockType type = state.getBlockType();
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_13(bs.getBlock(), bs);
|
||||
}
|
||||
@ -213,7 +202,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public BlockState getBlock(Location location) {
|
||||
public BaseBlock getBlock(Location location) {
|
||||
checkNotNull(location);
|
||||
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
@ -229,11 +218,11 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
if (te != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
readTileEntityIntoTag(te, tag); // Load data
|
||||
return new BaseBlock(state, (CompoundTag) toNative(tag));
|
||||
return state.toBaseBlock((CompoundTag) toNative(tag));
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -260,10 +249,13 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
} else {
|
||||
existing = section.getType(x & 15, y & 15, z & 15);
|
||||
}
|
||||
BlockPosition pos = null;
|
||||
CompoundTag nativeTag = state.getNbtData();
|
||||
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
|
||||
nmsChunk.d(pos); // Force delete the old tile entity
|
||||
|
||||
CompoundTag nativeTag = state instanceof BaseBlock ? ((BaseBlock)state).getNbtData() : null;
|
||||
if (nativeTag != null || existing instanceof TileEntityBlock) {
|
||||
pos = new BlockPosition(x, y, z);
|
||||
nmsWorld.setTypeAndData(pos, blockData, 0);
|
||||
// remove tile
|
||||
if (nativeTag != null) {
|
||||
@ -285,18 +277,12 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
sections[y4] = section = new ChunkSection(y4 << 4, nmsWorld.worldProvider.g());
|
||||
}
|
||||
if (existing.e() != blockData.e() || existing.getMaterial().f() != blockData.getMaterial().f()) {
|
||||
try {
|
||||
chunkSetTypeMethod.invoke(nmsChunk, pos = new BlockPosition(x, y, z), blockData, false);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
logger.warning("Error when setting block!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
nmsChunk.setType(pos = new BlockPosition(x, y, z), blockData, false);
|
||||
} else {
|
||||
section.setType(x & 15, y & 15, z & 15, blockData);
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
if (pos == null) pos = new BlockPosition(x, y, z);
|
||||
nmsWorld.getMinecraftWorld().notify(pos, existing, blockData, 0);
|
||||
}
|
||||
return true;
|
||||
@ -325,7 +311,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
public org.bukkit.entity.Entity createEntity(Location location, BaseEntity state) {
|
||||
checkNotNull(location);
|
||||
checkNotNull(state);
|
||||
|
||||
if (state.getType() == com.sk89q.worldedit.world.entity.EntityTypes.PLAYER) return null;
|
||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||
WorldServer worldServer = craftWorld.getHandle();
|
||||
|
||||
@ -353,7 +339,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, ? extends Property> getProperties(BlockType blockType) {
|
||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||
Block block;
|
||||
try {
|
||||
block = IRegistry.BLOCK.getOrDefault(new MinecraftKey(blockType.getNamespace(), blockType.getResource()));
|
||||
@ -365,7 +351,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
logger.warning("Failed to find properties for " + blockType.getId());
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Property> properties = Maps.newLinkedHashMap();
|
||||
Map<String, Property<?>> properties = Maps.newLinkedHashMap();
|
||||
BlockStateList<Block, IBlockData> blockStateList = block.getStates();
|
||||
for (IBlockState state : blockStateList.d()) {
|
||||
Property property;
|
||||
@ -411,17 +397,19 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
}
|
||||
return new CompoundTag(values);
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(((NBTTagByte) foreign).asByte()); // getByte
|
||||
return new ByteTag(((NBTTagByte) foreign).asByte());
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(((NBTTagFloat) foreign).asFloat()); // getFloat
|
||||
return new FloatTag(((NBTTagFloat) foreign).asFloat());
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(((NBTTagInt) foreign).asInt()); // getInt
|
||||
return new IntTag(((NBTTagInt) foreign).asInt());
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagLongArray) {
|
||||
return new LongArrayTag(((NBTTagLongArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
try {
|
||||
return toNativeList((NBTTagList) foreign);
|
||||
@ -430,13 +418,13 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(((NBTTagLong) foreign).asLong()); // getLong
|
||||
return new LongTag(((NBTTagLong) foreign).asLong());
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(((NBTTagShort) foreign).asShort()); // getShort
|
||||
return new ShortTag(((NBTTagShort) foreign).asShort());
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(foreign.asString()); // data
|
||||
return new StringTag(foreign.asString());
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return EndTag.INSTANCE;
|
||||
return new EndTag();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
|
||||
}
|
||||
@ -454,7 +442,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
*/
|
||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<>();
|
||||
int type = foreign.getTypeId();
|
||||
int type = foreign.d();
|
||||
|
||||
List foreignList;
|
||||
foreignList = (List) nbtListTagListField.get(foreign);
|
||||
@ -497,9 +485,11 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return new NBTTagInt(((IntTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntArrayTag) {
|
||||
return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof LongArrayTag) {
|
||||
return new NBTTagLongArray(((LongArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof ListTag) {
|
||||
NBTTagList tag = new NBTTagList();
|
||||
ListTag<?> foreignList = (ListTag) foreign;
|
||||
ListTag foreignList = (ListTag) foreign;
|
||||
for (Tag t : foreignList.getValue()) {
|
||||
tag.add(fromNative(t));
|
||||
}
|
||||
@ -539,4 +529,26 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
|
||||
return material.getCraftBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundTag nbtData) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAndLightBlock(Location position, BlockState previousType) {
|
||||
this.setBlock(position.getChunk(), position.getBlockX(), position.getBlockY(), position.getBlockZ(), previousType, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight) {
|
||||
return this.setBlock(location.getChunk(), location.getBlockX(), location.getBlockY(), location.getBlockZ(), state, notifyAndLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeOP(Player player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
|
||||
HashMap<String, Object> theSingleValue = new HashMap<>();
|
||||
theSingleValue.put("stringValue", _value);
|
||||
return theSingleValue;
|
||||
}
|
||||
|
@ -177,12 +177,12 @@ public final class Reflection {
|
||||
*/
|
||||
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
if (!_loadedMethods.containsKey(clazz)) {
|
||||
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
|
||||
_loadedMethods.put(clazz, new HashMap<>());
|
||||
}
|
||||
|
||||
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
|
||||
if (!loadedMethodNames.containsKey(name)) {
|
||||
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
|
||||
loadedMethodNames.put(name, new HashMap<>());
|
||||
}
|
||||
|
||||
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.boydti.fawe.bukkit.filter;
|
||||
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
@ -34,8 +35,8 @@ public class GriefPreventionFilter extends CuboidRegionFilter {
|
||||
org.bukkit.Location bot = claim.getGreaterBoundaryCorner();
|
||||
if (world.equals(bot.getWorld())) {
|
||||
org.bukkit.Location top = claim.getGreaterBoundaryCorner();
|
||||
BlockVector2D pos1 = new BlockVector2D(bot.getBlockX(), bot.getBlockZ());
|
||||
BlockVector2D pos2 = new BlockVector2D(top.getBlockX(), top.getBlockZ());
|
||||
BlockVector2 pos1 = BlockVector2.at(bot.getBlockX(), bot.getBlockZ());
|
||||
BlockVector2 pos2 = BlockVector2.at(top.getBlockX(), top.getBlockZ());
|
||||
add(pos1, pos2);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
@ -33,14 +33,14 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
public void run(Object value) {
|
||||
WorldGuardFilter.this.manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(FaweAPI.getWorld(world.getName()));
|
||||
for (ProtectedRegion region : manager.getRegions().values()) {
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) {
|
||||
Fawe.debug("Large or complex region shapes cannot be optimized. Filtering will be slower");
|
||||
large = true;
|
||||
break;
|
||||
}
|
||||
add(min.toVector2D(), max.toVector2D());
|
||||
add(min.toBlockVector2(), max.toBlockVector2());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -49,8 +49,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
@Override
|
||||
public boolean containsChunk(int chunkX, int chunkZ) {
|
||||
if (!large) return super.containsChunk(chunkX, chunkZ);
|
||||
BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
|
||||
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
BlockVector3 pos1 = BlockVector3.at(chunkX << 4, 0, chunkZ << 4);
|
||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
|
||||
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
@ -59,8 +59,8 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
@Override
|
||||
public boolean containsRegion(int mcaX, int mcaZ) {
|
||||
if (!large) return super.containsRegion(mcaX, mcaZ);
|
||||
BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
|
||||
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
BlockVector3 pos1 = BlockVector3.at(mcaX << 9, 0, mcaZ << 9);
|
||||
BlockVector3 pos2 = BlockVector3.at(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
|
||||
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
|
@ -14,6 +14,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
@ -69,7 +72,7 @@ public class BukkitImageListener implements Listener {
|
||||
String name = player.getName().toLowerCase();
|
||||
if (!event.getMessage().toLowerCase().contains(name)) {
|
||||
ArrayDeque<String> buffered = fp.getMeta("CFIBufferedMessages");
|
||||
if (buffered == null) fp.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<String>());
|
||||
if (buffered == null) fp.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<>());
|
||||
String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
|
||||
buffered.add(full);
|
||||
iter.remove();
|
||||
@ -100,7 +103,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (event.getHand() == EquipmentSlot.OFF_HAND) return;
|
||||
} catch (NoSuchFieldError | NoSuchMethodError ignored) {}
|
||||
|
||||
List<Block> target = player.getLastTwoTargetBlocks((Set<Material>) null, 100);
|
||||
List<Block> target = player.getLastTwoTargetBlocks(null, 100);
|
||||
if (target.isEmpty()) return;
|
||||
|
||||
Block targetBlock = target.get(0);
|
||||
@ -148,7 +151,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (generator == null) return null;
|
||||
|
||||
ImageViewer viewer = generator.getImageViewer();
|
||||
if (viewer == null || !(viewer instanceof BukkitImageViewer)) return null;
|
||||
if (!(viewer instanceof BukkitImageViewer)) return null;
|
||||
|
||||
BukkitImageViewer biv = (BukkitImageViewer) viewer;
|
||||
return biv;
|
||||
@ -182,12 +185,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (frames == null || tool == null) {
|
||||
viewer.selectFrame(itemFrame);
|
||||
player.updateInventory();
|
||||
TaskManager.IMP.laterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
viewer.view(generator);
|
||||
}
|
||||
}, 1);
|
||||
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -246,14 +244,12 @@ public class BukkitImageListener implements Listener {
|
||||
|
||||
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) return;
|
||||
|
||||
Vector wPos = new Vector(worldX, 0, worldZ);
|
||||
|
||||
fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fp.runAction(() -> {
|
||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255);
|
||||
wPos.mutY(topY);
|
||||
wPos = wPos.withY(topY);
|
||||
|
||||
EditSession es = new EditSessionBuilder(fp.getWorld()).player(fp).combineStages(false).autoQueue(false).blockBag(null).limitUnlimited().build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
@ -266,7 +262,6 @@ public class BukkitImageListener implements Listener {
|
||||
}
|
||||
es.flushQueue();
|
||||
viewer.view(generator);
|
||||
}
|
||||
}, true, true);
|
||||
|
||||
|
||||
|
@ -22,15 +22,16 @@ import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
|
||||
import com.sk89q.worldedit.event.platform.Interaction;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
@ -62,12 +63,12 @@ public class CFIPacketListener implements Listener {
|
||||
this.protocolmanager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
// Direct digging to the virtual world
|
||||
registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
try {
|
||||
Player plr = event.getPlayer();
|
||||
Vector realPos = pt.add(gen.getOrigin());
|
||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||
if (!sendBlockChange(plr, gen, pt, Interaction.HIT)) {
|
||||
gen.setBlock(pt, EditSession.nullBlock);
|
||||
}
|
||||
@ -78,9 +79,9 @@ public class CFIPacketListener implements Listener {
|
||||
});
|
||||
|
||||
// Direct placing to the virtual world
|
||||
RunnableVal3<PacketEvent, VirtualWorld, Vector> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
try {
|
||||
Player plr = event.getPlayer();
|
||||
List<EnumWrappers.Hand> hands = event.getPacket().getHands().getValues();
|
||||
@ -89,12 +90,8 @@ public class CFIPacketListener implements Listener {
|
||||
PlayerInventory inv = plr.getInventory();
|
||||
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
|
||||
if (hand != null && hand.getType().isBlock()) {
|
||||
switch (hand.getType()) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
break;
|
||||
default:
|
||||
Material type = hand.getType();
|
||||
if (!type.isEmpty()) {
|
||||
BlockStateHolder block = BukkitAdapter.asBlockState(hand);
|
||||
if (block != null) {
|
||||
gen.setBlock(pt, block);
|
||||
@ -113,9 +110,9 @@ public class CFIPacketListener implements Listener {
|
||||
registerBlockEvent(PacketType.Play.Client.USE_ITEM, true, placeTask);
|
||||
|
||||
// Cancel block change packets where the real world overlaps with the virtual one
|
||||
registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, Vector>() {
|
||||
registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
|
||||
@Override
|
||||
public void run(PacketEvent event, VirtualWorld gen, Vector pt) {
|
||||
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
@ -128,7 +125,7 @@ public class CFIPacketListener implements Listener {
|
||||
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<Integer> ints = packet.getIntegers();
|
||||
int cx = ints.read(0);
|
||||
@ -137,7 +134,7 @@ public class CFIPacketListener implements Listener {
|
||||
int ocx = origin.getBlockX() >> 4;
|
||||
int ocz = origin.getBlockZ() >> 4;
|
||||
|
||||
if (gen.contains(new Vector((cx - ocx) << 4, 0, (cz - ocz) << 4))) {
|
||||
if (gen.contains(BlockVector3.at((cx - ocx) << 4, 0, (cz - ocz) << 4))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Player plr = event.getPlayer();
|
||||
@ -163,8 +160,8 @@ public class CFIPacketListener implements Listener {
|
||||
Location pos = player.getLocation();
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
Vector pt = new Vector(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
BlockVector3 pt = BlockVector3.at(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
|
||||
StructureModifier<Integer> ints = event.getPacket().getIntegers();
|
||||
int id = ints.read(0);
|
||||
@ -188,21 +185,19 @@ public class CFIPacketListener implements Listener {
|
||||
Location pos = player.getLocation();
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector origin = gen.getOrigin();
|
||||
Vector from = new Vector(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
BlockVector3 from = BlockVector3.at(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<Double> doubles = packet.getDoubles();
|
||||
Vector to = new Vector(doubles.read(0), doubles.read(1), doubles.read(2));
|
||||
BlockVector3 to = BlockVector3.at(doubles.read(0), doubles.read(1), doubles.read(2));
|
||||
if (gen.contains(to.subtract(origin)) && from.distanceSq(to) < 8) {
|
||||
int id = packet.getIntegers().read(0);
|
||||
PacketContainer reply = new PacketContainer(PacketType.Play.Client.TELEPORT_ACCEPT);
|
||||
reply.getIntegers().write(0, id);
|
||||
try {
|
||||
protocolmanager.recieveClientPacket(player, reply);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -220,10 +215,10 @@ public class CFIPacketListener implements Listener {
|
||||
if (gen != null) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
ChunkCoordIntPair chunk = packet.getChunkCoordIntPairs().read(0);
|
||||
Vector origin = gen.getOrigin();
|
||||
BlockVector3 origin = gen.getOrigin().toBlockPoint();
|
||||
int cx = chunk.getChunkX() - (origin.getBlockX() >> 4);
|
||||
int cz = chunk.getChunkZ() - (origin.getBlockX() >> 4);
|
||||
if (gen.contains(new Vector(cx << 4, 0, cz << 4))) {
|
||||
if (gen.contains(BlockVector3.at(cx << 4, 0, cz << 4))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -246,14 +241,14 @@ public class CFIPacketListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendBlockChange(Player plr, VirtualWorld gen, Vector pt, Interaction action) {
|
||||
private boolean sendBlockChange(Player plr, VirtualWorld gen, BlockVector3 pt, Interaction action) {
|
||||
PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
|
||||
com.sk89q.worldedit.entity.Player actor = FawePlayer.wrap(plr).getPlayer();
|
||||
com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt);
|
||||
com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt.toVector3());
|
||||
BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action);
|
||||
platform.handleBlockInteract(toCall);
|
||||
if (toCall.isCancelled() || action == Interaction.OPEN) {
|
||||
Vector realPos = pt.add(gen.getOrigin());
|
||||
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
|
||||
BlockStateHolder block = gen.getBlock(pt);
|
||||
sendBlockChange(plr, realPos, block);
|
||||
return true;
|
||||
@ -261,7 +256,7 @@ public class CFIPacketListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendBlockChange(Player plr, Vector pt, BlockStateHolder block) {
|
||||
private void sendBlockChange(Player plr, BlockVector3 pt, BlockStateHolder block) {
|
||||
plr.sendBlockChange(new Location(plr.getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()), BukkitAdapter.adapt(block));
|
||||
}
|
||||
|
||||
@ -280,20 +275,20 @@ public class CFIPacketListener implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Vector getRelPos(PacketEvent event, VirtualWorld generator) {
|
||||
private BlockVector3 getRelPos(PacketEvent event, VirtualWorld generator) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
|
||||
BlockPosition loc = position.readSafely(0);
|
||||
if (loc == null) return null;
|
||||
Vector origin = generator.getOrigin();
|
||||
Vector pt = new Vector(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
BlockVector3 origin = generator.getOrigin().toBlockPoint();
|
||||
BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
|
||||
return pt;
|
||||
}
|
||||
|
||||
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, Vector> task) {
|
||||
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {
|
||||
VirtualWorld gen = getGenerator(event);
|
||||
if (gen != null) {
|
||||
Vector pt = getRelPos(event, gen);
|
||||
BlockVector3 pt = getRelPos(event, gen);
|
||||
if (pt != null) {
|
||||
if (relative) pt = getRelative(event, pt);
|
||||
if (gen.contains(pt)) {
|
||||
@ -304,7 +299,7 @@ public class CFIPacketListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBlockEvent(PacketType type, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, Vector> task) {
|
||||
private void registerBlockEvent(PacketType type, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {
|
||||
protocolmanager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, type) {
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
@ -318,7 +313,7 @@ public class CFIPacketListener implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
private Vector getRelative(PacketEvent container, Vector pt) {
|
||||
private BlockVector3 getRelative(PacketEvent container, BlockVector3 pt) {
|
||||
PacketContainer packet = container.getPacket();
|
||||
StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
|
||||
EnumWrappers.Direction dir = dirs.readSafely(0);
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitMask extends FaweMask {
|
||||
@ -11,6 +12,6 @@ public class BukkitMask extends FaweMask {
|
||||
}
|
||||
|
||||
public BukkitMask(Location pos1, Location pos2, String name) {
|
||||
super(new BlockVector(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), new BlockVector(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
super(BlockVector3.at(pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()), BlockVector3.at(pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()), name);
|
||||
}
|
||||
}
|
@ -5,8 +5,8 @@ import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.queue.NullFaweQueue;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -55,8 +55,8 @@ public class FreeBuildRegion extends BukkitMaskManager {
|
||||
World bukkitWorld = player.parent.getWorld();
|
||||
AsyncWorld asyncWorld = AsyncWorld.wrap(bukkitWorld);
|
||||
|
||||
Vector vec1 = new Vector(0, 0, 0);
|
||||
Vector vec2 = vec1;
|
||||
BlockVector3 vec1 = BlockVector3.at(0, 0, 0);
|
||||
BlockVector3 vec2 = vec1;
|
||||
Location pos1 = BukkitAdapter.adapt(bukkitWorld, vec1);
|
||||
Location pos2 = BukkitAdapter.adapt(bukkitWorld, vec2);
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.regions;
|
||||
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.worldcretornica.plotme_core.Plot;
|
||||
import com.worldcretornica.plotme_core.PlotMe_Core;
|
||||
import com.worldcretornica.plotme_core.bukkit.PlotMe_CorePlugin;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitPlayer;
|
||||
import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
PlotMe_Core plotme;
|
||||
|
||||
public PlotMeFeature(final Plugin plotmePlugin, final FaweBukkit p3) {
|
||||
super(plotmePlugin.getName());
|
||||
this.plotme = ((PlotMe_CorePlugin) plotmePlugin).getAPI();
|
||||
this.plugin = p3;
|
||||
|
||||
}
|
||||
public boolean isAllowed(Player player, Plot plot, MaskType type) {
|
||||
return plot != null && type == MaskType.MEMBER ? plot.isAllowed(player.getUniqueId()) : player.getUniqueId().equals(plot.getOwnerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitMask getMask(final FawePlayer<Player> fp, MaskType type) {
|
||||
final Player player = fp.parent;
|
||||
final Location location = player.getLocation();
|
||||
final Plot plot = this.plotme.getPlotMeCoreManager().getPlotById(new BukkitPlayer(player));
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (isAllowed(player, plot, type)) {
|
||||
final Location pos1 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).bottomX(plot.getId(), new BukkitWorld(player.getWorld())), 0, this.plotme
|
||||
.getGenManager(player.getWorld().getName()).bottomZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
final Location pos2 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).topX(plot.getId(), new BukkitWorld(player.getWorld())), 256, this.plotme
|
||||
.getGenManager(player.getWorld().getName()).topZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||
return new BukkitMask(pos1, pos2) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return plot.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
return isAllowed((Player) player.parent, plot, type);
|
||||
}
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -3,7 +3,8 @@ package com.boydti.fawe.bukkit.regions;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.List;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.field.Field;
|
||||
@ -40,8 +41,8 @@ public class PreciousStonesFeature extends BukkitMaskManager implements Listener
|
||||
boolean member = fp.hasPermission("fawe.preciousstones.member");
|
||||
for (final Field myField : fields) {
|
||||
if (isAllowed(player, myField, type, member)) {
|
||||
BlockVector pos1 = new BlockVector(myField.getMinx(), myField.getMiny(), myField.getMinz());
|
||||
BlockVector pos2 = new BlockVector(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
|
||||
BlockVector3 pos1 = BlockVector3.at(myField.getMinx(), myField.getMiny(), myField.getMinz());
|
||||
BlockVector3 pos2 = BlockVector3.at(myField.getMaxx(), myField.getMaxy(), myField.getMaxz());
|
||||
return new FaweMask(pos1, pos2, "FIELD: " + myField) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
|
@ -7,8 +7,8 @@ import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
@ -61,7 +61,7 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
if (global != null && isAllowed(player, global)) {
|
||||
return global;
|
||||
}
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(new Vector(loc.getX(), loc.getY(), loc.getZ()));
|
||||
final ApplicableRegionSet regions = manager.getApplicableRegions(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ()));
|
||||
for (final ProtectedRegion region : regions) {
|
||||
if (isAllowed(player, region)) {
|
||||
return region;
|
||||
@ -145,27 +145,27 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) {
|
||||
public void expand(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) {
|
||||
public void contract(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return region.contains(position);
|
||||
}
|
||||
}
|
||||
@ -179,8 +179,8 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
if (region instanceof ProtectedPolygonalRegion) {
|
||||
ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
|
||||
BlockVector max = region.getMaximumPoint();
|
||||
BlockVector min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
|
||||
}
|
||||
return new AdaptedRegion(region);
|
||||
|
@ -5,7 +5,7 @@ import com.boydti.fawe.bukkit.filter.WorldGuardFilter;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.AbstractRegion;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
@ -65,45 +65,45 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
Vector point = null;
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
BlockVector3 point = null;
|
||||
for (Map.Entry<String, ProtectedRegion> entry : manager.getRegions().entrySet()) {
|
||||
Vector p = entry.getValue().getMinimumPoint();
|
||||
BlockVector3 p = entry.getValue().getMinimumPoint();
|
||||
if (point == null) {
|
||||
point = p;
|
||||
continue;
|
||||
}
|
||||
point = Vector.getMinimum(point, p);
|
||||
point = point.getMinimum(p);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
Vector point = null;
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
BlockVector3 point = null;
|
||||
for (Map.Entry<String, ProtectedRegion> entry : manager.getRegions().entrySet()) {
|
||||
Vector p = entry.getValue().getMaximumPoint();
|
||||
BlockVector3 p = entry.getValue().getMaximumPoint();
|
||||
if (point == null) {
|
||||
point = p;
|
||||
continue;
|
||||
}
|
||||
point = Vector.getMaximum(point, p);
|
||||
point = point.getMaximum(p);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) {
|
||||
public void expand(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) {
|
||||
public void contract(BlockVector3... changes) {
|
||||
throw new UnsupportedOperationException("Region is immutable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
// Make sure that all these flags are not denied. Denies override allows. WorldGuardExtraFlags can add Flags.WORLDEDIT
|
||||
return manager.getApplicableRegions(position).testState(localplayer, Flags.BUILD, Flags.BLOCK_PLACE, Flags.BLOCK_BREAK);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class ItemUtil {
|
||||
if (nativeTag != null) return (CompoundTag) nativeTag;
|
||||
}
|
||||
Tag nativeTag = BukkitQueue_0.toNative(nmsTag);
|
||||
map.put(nmsTag.hashCode(), new WeakReference<Tag>(nativeTag));
|
||||
map.put(nmsTag.hashCode(), new WeakReference<>(nativeTag));
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
@ -8,7 +8,8 @@ public class VaultUtil {
|
||||
public final Permission permission;
|
||||
|
||||
public VaultUtil() {
|
||||
final RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
final RegisteredServiceProvider<Permission> permissionProvider =
|
||||
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
this.permission = permissionProvider.getProvider();
|
||||
} else {
|
||||
|
@ -13,11 +13,12 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -33,10 +34,10 @@ import org.bukkit.entity.Player;
|
||||
public class StructureCUI extends CUI {
|
||||
private boolean cuboid = true;
|
||||
|
||||
private Vector pos1;
|
||||
private Vector pos2;
|
||||
private BlockVector3 pos1;
|
||||
private BlockVector3 pos2;
|
||||
|
||||
private Vector remove;
|
||||
private BlockVector3 remove;
|
||||
private NbtCompound removeTag;
|
||||
private BlockState state;
|
||||
|
||||
@ -56,7 +57,7 @@ public class StructureCUI extends CUI {
|
||||
int x = Integer.parseInt(param[1]);
|
||||
int y = Integer.parseInt(param[2]);
|
||||
int z = Integer.parseInt(param[3]);
|
||||
Vector pos = new Vector(x, y, z);
|
||||
BlockVector3 pos = BlockVector3.at(x, y, z);
|
||||
if (id == 0) {
|
||||
pos1 = pos;
|
||||
} else {
|
||||
@ -123,7 +124,7 @@ public class StructureCUI extends CUI {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendNbt(Vector pos, NbtCompound compound) {
|
||||
private void sendNbt(BlockVector3 pos, NbtCompound compound) {
|
||||
Player player = this.<Player>getPlayer().parent;
|
||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
@ -158,8 +159,8 @@ public class StructureCUI extends CUI {
|
||||
remove = null;
|
||||
}
|
||||
if (pos1 == null || pos2 == null) return;
|
||||
Vector min = Vector.getMinimum(pos1, pos2);
|
||||
Vector max = Vector.getMaximum(pos1, pos2);
|
||||
BlockVector3 min = pos1.getMinimum(pos2);
|
||||
BlockVector3 max = pos1.getMaximum(pos2);
|
||||
|
||||
// Position
|
||||
double rotX = playerLoc.getYaw();
|
||||
@ -187,7 +188,7 @@ public class StructureCUI extends CUI {
|
||||
NbtCompound compound = constructStructureNbt(x, y, z, posX, posY, posZ, sizeX, sizeY, sizeZ);
|
||||
|
||||
Block block = player.getWorld().getBlockAt(x, y, z);
|
||||
remove = new Vector(x, y, z);
|
||||
remove = BlockVector3.at(x, y, z);
|
||||
state = BukkitAdapter.adapt(block.getBlockData());
|
||||
removeTag = compound;
|
||||
|
||||
|
@ -13,7 +13,6 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.LongTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -23,6 +22,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -103,7 +104,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
int[][] sections = getCombinedIdArrays();
|
||||
final int bx = getX() << 4;
|
||||
final int bz = getZ() << 4;
|
||||
boolean update = adapter != null ? adapter.isChunkInUse(chunk) : true;
|
||||
boolean update = adapter == null || adapter.isChunkInUse(chunk);
|
||||
if (layer == -1) {
|
||||
if (adapter != null)
|
||||
{
|
||||
@ -157,7 +158,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
HashSet<UUID> entsToRemove = this.getEntityRemoves();
|
||||
if (!entsToRemove.isEmpty()) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
if (entsToRemove.contains(entity.getUniqueId())) {
|
||||
if (entsToRemove.contains(entity.getUniqueId()) && !(entity instanceof Player)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
@ -232,12 +233,10 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
if (combined == 0) continue;
|
||||
int xx = bx + x;
|
||||
|
||||
BlockTypes type = BlockTypes.getFromStateId(combined);
|
||||
BlockType type = BlockTypes.getFromStateId(combined);
|
||||
if (type == BlockTypes.__RESERVED__) continue;
|
||||
switch (type) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
String s = type.getResource().toUpperCase();
|
||||
if (type.getMaterial().isAir()) {
|
||||
if (!place) {
|
||||
mutableLoc.setX(xx);
|
||||
mutableLoc.setY(yy);
|
||||
@ -245,13 +244,14 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
}
|
||||
if (place) {
|
||||
if (type.getMaterial().hasContainer() && adapter != null) {
|
||||
CompoundTag nbt = getTile(x, yy, z);
|
||||
if (nbt != null) {
|
||||
synchronized (BukkitChunk_All.this) {
|
||||
BaseBlock state = BaseBlock.getFromInternalId(combined, nbt);
|
||||
BaseBlock state =
|
||||
BaseBlock.getFromInternalId(combined, nbt);
|
||||
adapter.setBlock(chunk, xx, yy, zz, state, update);
|
||||
}
|
||||
continue;
|
||||
@ -268,8 +268,6 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -277,12 +275,9 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
for (;index < 4096; index++) {
|
||||
int j = place ? index : 4095 - index;
|
||||
int combined = newArray[j];
|
||||
BlockTypes type = BlockTypes.getFromStateId(combined);
|
||||
BlockType type = BlockTypes.getFromStateId(combined);
|
||||
if (type == BlockTypes.__RESERVED__) continue;
|
||||
switch (type) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
if (type.getMaterial().isAir()) {
|
||||
if (!place) {
|
||||
int x = cacheX[j];
|
||||
int z = cacheZ[j];
|
||||
@ -292,8 +287,8 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
mutableLoc.setZ(bz + z);
|
||||
setBlock(adapter, chunk, mutableLoc, combined, update);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
} else {
|
||||
boolean light = type.getMaterial().getLightValue() > 0;
|
||||
if (light) {
|
||||
if (place) {
|
||||
@ -335,7 +330,6 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
if (light) {
|
||||
parent.disableLighting(disableResult);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (System.currentTimeMillis() - start > recommended) {
|
||||
index++;
|
||||
@ -356,12 +350,12 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
}
|
||||
|
||||
public void setBlock(BukkitImplAdapter adapter, Chunk chunk, Location location, int combinedId, boolean update) {
|
||||
com.sk89q.worldedit.world.block.BlockState state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId);
|
||||
com.sk89q.worldedit.world.block.BaseBlock base = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combinedId).toBaseBlock();
|
||||
if (adapter != null) {
|
||||
adapter.setBlock(chunk, (int) location.getX(), (int) location.getY(), (int) location.getZ(), state, update);
|
||||
adapter.setBlock(chunk, (int) location.getX(), (int) location.getY(), (int) location.getZ(), base, update);
|
||||
} else {
|
||||
Block block = location.getWorld().getBlockAt(location);
|
||||
block.setBlockData(BukkitAdapter.adapt(state), false);
|
||||
block.setBlockData(BukkitAdapter.adapt(base), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,14 +113,15 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
WirePacket packet = null;
|
||||
int viewDistance = Bukkit.getViewDistance();
|
||||
try {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
for (FawePlayer fawePlayer : players) {
|
||||
int cx = chunk.getX();
|
||||
int cz = chunk.getZ();
|
||||
|
||||
Player player = ((BukkitPlayer) players[i]).parent;
|
||||
Player player = ((BukkitPlayer) fawePlayer).parent;
|
||||
Location loc = player.getLocation();
|
||||
|
||||
if (Math.abs((loc.getBlockX() >> 4) - cx) <= viewDistance && Math.abs((loc.getBlockZ() >> 4) - cz) <= viewDistance) {
|
||||
if (Math.abs((loc.getBlockX() >> 4) - cx) <= viewDistance
|
||||
&& Math.abs((loc.getBlockZ() >> 4) - cz) <= viewDistance) {
|
||||
if (packet == null) {
|
||||
byte[] data;
|
||||
byte[] buffer = new byte[8192];
|
||||
@ -128,12 +129,12 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
chunk = (FaweChunk) chunk.getChunk();
|
||||
}
|
||||
// TODO FIXME
|
||||
// if (chunk instanceof MCAChunk) {
|
||||
// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer);
|
||||
// } else {
|
||||
// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer);
|
||||
// }
|
||||
// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data);
|
||||
// if (chunk instanceof MCAChunk) {
|
||||
// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer);
|
||||
// } else {
|
||||
// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer);
|
||||
// }
|
||||
// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data);
|
||||
}
|
||||
manager.sendWirePacket(player, packet);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Chunk;
|
||||
@ -153,7 +154,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
Object nmsChunk = methodGetHandleChunk.invoke(chunk);
|
||||
boolean mustSave = saveChunks && (boolean) methodNeedsSaving.invoke(nmsChunk, false);
|
||||
chunk.unload(mustSave, false);
|
||||
if (unloaded == null) unloaded = new ArrayDeque<Chunk>();
|
||||
if (unloaded == null) unloaded = new ArrayDeque<>();
|
||||
unloaded.add(chunk);
|
||||
}
|
||||
}
|
||||
@ -180,9 +181,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
|
||||
if (load && unloaded != null) {
|
||||
final ArrayDeque<Chunk> finalUnloaded = unloaded;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(() -> {
|
||||
for (Chunk chunk : finalUnloaded) {
|
||||
int cx = chunk.getX();
|
||||
int cz = chunk.getZ();
|
||||
@ -193,7 +192,6 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
// load chunks
|
||||
|
||||
@ -333,7 +331,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
return null;
|
||||
}
|
||||
Location loc = new Location(getWorld(), x, y, z);
|
||||
BlockStateHolder block = getAdapter().getBlock(loc);
|
||||
BaseBlock block = getAdapter().getBlock(loc);
|
||||
return block.getNbtData();
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,7 @@ public abstract class ChunkListener implements Listener {
|
||||
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
|
||||
plm.registerEvents(this, plugin);
|
||||
try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {}
|
||||
TaskManager.IMP.repeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.repeat(() -> {
|
||||
rateLimit--;
|
||||
physicsFreeze = false;
|
||||
itemFreeze = false;
|
||||
@ -77,7 +75,6 @@ public abstract class ChunkListener implements Listener {
|
||||
counter.put(key, badLimit);
|
||||
}
|
||||
badChunks.clear();
|
||||
}
|
||||
}, Settings.IMP.TICK_LIMITER.INTERVAL);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
//import com.sk89q.jnbt.StringTag;
|
||||
//import com.sk89q.jnbt.Tag;
|
||||
//import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
//import com.sk89q.worldedit.world.block.BlockState;
|
||||
//import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
//import com.sk89q.worldedit.entity.BaseEntity;
|
||||
//import com.sk89q.worldedit.internal.Constants;
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.World;
|
||||
|
||||
public abstract class PaperChunkCallback {
|
||||
public PaperChunkCallback(World world, int x, int z) {
|
||||
world.getChunkAtAsync(x, z, chunk -> PaperChunkCallback.this.onLoad(chunk));
|
||||
world.getChunkAtAsync(x, z, PaperChunkCallback.this::onLoad);
|
||||
}
|
||||
|
||||
public abstract void onLoad(Chunk chunk);
|
||||
|
@ -9,7 +9,10 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -20,6 +23,9 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AsyncBlock implements Block {
|
||||
|
||||
@ -198,9 +204,10 @@ public class AsyncBlock implements Block {
|
||||
@Override
|
||||
public BlockFace getFace(Block block) {
|
||||
BlockFace[] directions = BlockFace.values();
|
||||
for(int i = 0; i < directions.length; ++i) {
|
||||
BlockFace face = directions[i];
|
||||
if(this.getX() + face.getModX() == block.getX() && this.getY() + face.getModY() == block.getY() && this.getZ() + face.getModZ() == block.getZ()) {
|
||||
for (BlockFace face : directions) {
|
||||
if (this.getX() + face.getModX() == block.getX()
|
||||
&& this.getY() + face.getModY() == block.getY()
|
||||
&& this.getZ() + face.getModZ() == block.getZ()) {
|
||||
return face;
|
||||
}
|
||||
}
|
||||
@ -210,10 +217,9 @@ public class AsyncBlock implements Block {
|
||||
@Override
|
||||
public AsyncBlockState getState() {
|
||||
int combined = queue.getCombinedId4Data(x, y, z, 0);
|
||||
BlockTypes type = BlockTypes.getFromStateId(combined);
|
||||
switch (type) {
|
||||
case SIGN:
|
||||
case WALL_SIGN:
|
||||
BlockType type = BlockTypes.getFromStateId(combined);
|
||||
String s = type.getResource().toUpperCase();
|
||||
if (type == BlockTypes.SIGN || type == BlockTypes.WALL_SIGN) {
|
||||
return new AsyncSign(this, combined);
|
||||
}
|
||||
return new AsyncBlockState(this, combined);
|
||||
@ -267,20 +273,13 @@ public class AsyncBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
switch (getType()) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return getType().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiquid() {
|
||||
int combined = queue.getCombinedId4Data(x, y, z, 0);
|
||||
BlockTypes type = BlockTypes.getFromStateId(combined);
|
||||
BlockType type = BlockTypes.getFromStateId(combined);
|
||||
return type.getMaterial().isLiquid();
|
||||
}
|
||||
|
||||
@ -343,4 +342,19 @@ public class AsyncBlock implements Block {
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
this.getUnsafeBlock().removeMetadata(metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassable() {
|
||||
return this.getUnsafeBlock().isPassable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3) {
|
||||
return this.getUnsafeBlock().rayTrace(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getBoundingBox() {
|
||||
return this.getUnsafeBlock().getBoundingBox();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class AsyncChunk implements Chunk {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof Chunk)) {
|
||||
if (!(obj instanceof Chunk)) {
|
||||
return false;
|
||||
}
|
||||
Chunk other = (Chunk) obj;
|
||||
@ -88,14 +88,14 @@ public class AsyncChunk implements Chunk {
|
||||
BukkitQueue_0 bq = (BukkitQueue_0) queue;
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
long pair = MathMan.pairInt(x, z);
|
||||
Long originalKeep = bq.keepLoaded.get(pair);
|
||||
bq.keepLoaded.put(pair, Long.MAX_VALUE);
|
||||
Long originalKeep = BukkitQueue_0.keepLoaded.get(pair);
|
||||
BukkitQueue_0.keepLoaded.put(pair, Long.MAX_VALUE);
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
task.run();
|
||||
if (originalKeep != null) {
|
||||
bq.keepLoaded.put(pair, originalKeep);
|
||||
BukkitQueue_0.keepLoaded.put(pair, originalKeep);
|
||||
} else {
|
||||
bq.keepLoaded.remove(pair);
|
||||
BukkitQueue_0.keepLoaded.remove(pair);
|
||||
}
|
||||
return task.value;
|
||||
}
|
||||
@ -182,4 +182,14 @@ public class AsyncChunk implements Chunk {
|
||||
public boolean isSlimeChunk() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceLoaded() {
|
||||
return world.isChunkForceLoaded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceLoaded(boolean arg0) {
|
||||
world.getChunkAt(x, z).setForceLoaded(arg0);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,11 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -39,7 +42,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Consumer;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
@ -109,7 +114,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
this.parent = parent;
|
||||
this.queue = queue;
|
||||
if (queue instanceof BukkitQueue_0) {
|
||||
this.adapter = (BukkitImplAdapter) ((BukkitQueue_0) queue).getAdapter();
|
||||
this.adapter = BukkitQueue_0.getAdapter();
|
||||
} else {
|
||||
try {
|
||||
this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
@ -136,12 +141,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
if (queue != this.queue) {
|
||||
if (this.queue != null) {
|
||||
final FaweQueue oldQueue = this.queue;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
oldQueue.flush();
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.async(oldQueue::flush);
|
||||
}
|
||||
this.queue = queue;
|
||||
}
|
||||
@ -268,7 +268,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
for (int y = getMaxHeight() - 1; y >= 0; y--) {
|
||||
int stateId = queue.getCachedCombinedId4Data(x, y, z, BlockTypes.AIR.getInternalId());
|
||||
BlockTypes type = BlockTypes.getFromStateId(stateId);
|
||||
BlockType type = BlockTypes.getFromStateId(stateId);
|
||||
if (!type.getMaterial().isAir()) return y;
|
||||
}
|
||||
return 0;
|
||||
@ -349,7 +349,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof World)) {
|
||||
if (!(obj instanceof World)) {
|
||||
return false;
|
||||
}
|
||||
World other = (World) obj;
|
||||
@ -566,7 +566,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = (Collection<T>) parent.getEntitiesByClass(classes);
|
||||
this.value = parent.getEntitiesByClass(classes);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -576,7 +576,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = (Collection<T>) parent.getEntitiesByClass(cls);
|
||||
this.value = parent.getEntitiesByClass(cls);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -794,22 +794,12 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
@Override
|
||||
@Deprecated
|
||||
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new Supplier<FallingBlock>() {
|
||||
@Override
|
||||
public FallingBlock get() {
|
||||
return parent.spawnFallingBlock(location, material, data);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock spawnFallingBlock(Location location, BlockData blockData) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new Supplier<FallingBlock>() {
|
||||
@Override
|
||||
public FallingBlock get() {
|
||||
return parent.spawnFallingBlock(location, blockData);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1181,4 +1171,106 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Chunk> getChunkAtAsync(int arg0, int arg1, boolean arg2) {
|
||||
return parent.getChunkAtAsync(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(BoundingBox arg0) {
|
||||
return parent.getNearbyEntities(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(BoundingBox arg0, Predicate<Entity> arg1) {
|
||||
return parent.getNearbyEntities(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Entity> getNearbyEntities(Location arg0, double arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
return parent.getNearbyEntities(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkForceLoaded(int arg0, int arg1) {
|
||||
return parent.isChunkForceLoaded(arg0, arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDayTime() {
|
||||
return parent.isDayTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location locateNearestStructure(Location arg0, StructureType arg1, int arg2, boolean arg3) {
|
||||
return parent.locateNearestStructure(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTrace(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3, boolean arg4,
|
||||
double arg5, Predicate<Entity> arg6) {
|
||||
return parent.rayTrace(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(Location arg0, Vector arg1, double arg2) {
|
||||
return parent.rayTraceBlocks(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3) {
|
||||
return parent.rayTraceBlocks(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceBlocks(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3,
|
||||
boolean arg4) {
|
||||
return parent.rayTraceBlocks(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location arg0, Vector arg1, double arg2) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location arg0, Vector arg1, double arg2, double arg3) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location arg0, Vector arg1, double arg2, Predicate<Entity> arg3) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult rayTraceEntities(Location arg0, Vector arg1, double arg2, double arg3,
|
||||
Predicate<Entity> arg4) {
|
||||
return parent.rayTraceEntities(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle arg0, Location arg1, int arg2, double arg3, double arg4, double arg5,
|
||||
double arg6, T arg7, boolean arg8) {
|
||||
parent.spawnParticle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void spawnParticle(Particle arg0, double arg1, double arg2, double arg3, int arg4, double arg5,
|
||||
double arg6, double arg7, double arg8, T arg9, boolean arg10) {
|
||||
parent.spawnParticle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkForceLoaded(int x, int z, boolean forced) {
|
||||
parent.setChunkForceLoaded(x, z, forced);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Chunk> getForceLoadedChunks() {
|
||||
return parent.getForceLoadedChunks();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
||||
super(block, combined);
|
||||
}
|
||||
|
||||
private boolean isEditable = false;
|
||||
|
||||
@Override
|
||||
public String[] getLines() {
|
||||
CompoundTag nbt = getNbtData();
|
||||
@ -51,4 +53,14 @@ public class AsyncSign extends AsyncBlockState implements Sign {
|
||||
map.put("Text" + (index + 1), new StringTag(toJson(line)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return this.isEditable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean arg0) {
|
||||
this.isEditable = arg0;
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
@ -283,7 +284,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
if (plugin instanceof PermissionsProvider) {
|
||||
setPluginPermissionsResolver(plugin);
|
||||
} else if ("permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name)
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)) {
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)
|
||||
|| "vault".equalsIgnoreCase(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
@ -294,7 +296,8 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
if (event.getPlugin() instanceof PermissionsProvider
|
||||
|| "permissions".equalsIgnoreCase(name) || "permissionsex".equalsIgnoreCase(name)
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)) {
|
||||
|| "bpermissions".equalsIgnoreCase(name) || "groupmanager".equalsIgnoreCase(name)
|
||||
|| "vault".equalsIgnoreCase(name)) {
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
116
worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java
Normale Datei
116
worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java
Normale Datei
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultResolver implements PermissionsResolver {
|
||||
|
||||
private static Permission perms = null;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
if (server.getPluginManager().getPlugin("Vault") == null) {
|
||||
return null;
|
||||
}
|
||||
RegisteredServiceProvider<Permission> rsp = server.getServicesManager().getRegistration(Permission.class);
|
||||
perms = rsp.getProvider();
|
||||
if (perms == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new VaultResolver(server);
|
||||
}
|
||||
|
||||
private final Server server;
|
||||
|
||||
public VaultResolver(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetectionMessage() {
|
||||
return "Vault detected! Using Vault for permissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name, String permission) {
|
||||
return hasPermission(server.getOfflinePlayer(name), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String worldName, String name, String permission) {
|
||||
return hasPermission(worldName, server.getOfflinePlayer(name), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(String player, String group) {
|
||||
return inGroup(server.getOfflinePlayer(player), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups(String player) {
|
||||
return getGroups(server.getOfflinePlayer(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(OfflinePlayer player, String permission) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return perms.playerHas(null, player, permission);
|
||||
} else {
|
||||
return perms.playerHas(onlinePlayer.getWorld().getName(), player, permission);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission) {
|
||||
return perms.playerHas(worldName, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(OfflinePlayer player, String group) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return perms.playerInGroup(null, player, group);
|
||||
} else {
|
||||
return perms.playerInGroup(onlinePlayer, group);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups(OfflinePlayer player) {
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) {
|
||||
return perms.getPlayerGroups(null, player);
|
||||
} else {
|
||||
return perms.getPlayerGroups(onlinePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren