Updates spotless and adds a license header.
This commit is contained in:
8
TODO.md
8
TODO.md
@@ -26,13 +26,13 @@
|
|||||||
| MET-022 | Planning | (Optional) Add new features, quality-of-life improvements, or CI configuration after the modernization and documentation tasks are complete. |
|
| MET-022 | Planning | (Optional) Add new features, quality-of-life improvements, or CI configuration after the modernization and documentation tasks are complete. |
|
||||||
| GIT-009 | Planning | i have three reserve plots and one just got overwritten when a new player joined. |
|
| GIT-009 | Planning | i have three reserve plots and one just got overwritten when a new player joined. |
|
||||||
| GIT-008 | Ready | Implement multiple plot sizes by granting multiple plots around each other.
|
| GIT-008 | Ready | Implement multiple plot sizes by granting multiple plots around each other.
|
||||||
| GIT-007 | Ready | Allow buying and selling of homes via an ecnoomy plugin. |
|
| GIT-007 | Planning | Allow buying and selling of homes via an ecnoomy plugin. |
|
||||||
| GIT-006 | Ready | Add levels support. |
|
| GIT-006 | Ready | Add levels support. |
|
||||||
| GIT-005 | Planning | Add the possibility to create multiple plot homes in shapes. |
|
| GIT-005 | Planning | Add the possibility to create multiple plot homes in shapes. |
|
||||||
| GIT-004 | Ready | Add a command to request home allocation. |
|
| GIT-004 | Planning | Add a command to request home allocation. |
|
||||||
| GIT-003 | Ready | Add support for multiple homes. |
|
| GIT-003 | Ready | Add support for multiple homes. |
|
||||||
| GIT-002 | Ready | Add a command to teleport to a reservation you are part of. |
|
| GIT-002 | Planning | Add a command to teleport to a reservation you are part of. |
|
||||||
| GIT-001 | Ready | Add a command to move to a different home. |
|
| GIT-001 | Planning | Add a command to move to a different home. |
|
||||||
|
|
||||||
# GIT-001 - Add a command to move to a different home.
|
# GIT-001 - Add a command to move to a different home.
|
||||||
**Status:** Ready
|
**Status:** Ready
|
||||||
|
|||||||
12
build.gradle
12
build.gradle
@@ -1,4 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
|
id 'com.diffplug.spotless' version '8.10.3'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'org.danilopianini.git-sensitive-semantic-versioning' version '7.0.24'
|
id 'org.danilopianini.git-sensitive-semantic-versioning' version '7.0.24'
|
||||||
@@ -88,3 +89,14 @@ tasks.named('wrapper') {
|
|||||||
archiveBase = Wrapper.PathBase.PROJECT
|
archiveBase = Wrapper.PathBase.PROJECT
|
||||||
archivePath = '.gradle/wrapper/dists'
|
archivePath = '.gradle/wrapper/dists'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
java {
|
||||||
|
googleJavaFormat('1.36.1')
|
||||||
|
importOrder 'java', 'javax', 'com', 'net', 'org', ''
|
||||||
|
licenseHeaderFile 'config/license-header.txt'
|
||||||
|
target 'src/**/*.java'
|
||||||
|
removeUnusedImports()
|
||||||
|
toggleOffOn()
|
||||||
|
}
|
||||||
|
}
|
||||||
17
config/license-header.txt
Normal file
17
config/license-header.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -28,18 +45,22 @@ class MetropolisServerIntegrationTest {
|
|||||||
void plotReservationIsPersistedByTheLoadedWorldGuardPlugin() throws IOException {
|
void plotReservationIsPersistedByTheLoadedWorldGuardPlugin() throws IOException {
|
||||||
String regionId = "metropolis-it-" + UUID.randomUUID().toString().substring(0, 8);
|
String regionId = "metropolis-it-" + UUID.randomUUID().toString().substring(0, 8);
|
||||||
try (RconClient rcon = connectToConfiguredServer()) {
|
try (RconClient rcon = connectToConfiguredServer()) {
|
||||||
String response = rcon.execute("metropolis-plot-reserve " + regionId + " 100 60 100 105 70 105");
|
String response =
|
||||||
|
rcon.execute("metropolis-plot-reserve " + regionId + " 100 60 100 105 70 105");
|
||||||
assertTrue(response.contains("Reserved plot region " + regionId), response);
|
assertTrue(response.contains("Reserved plot region " + regionId), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path serverDirectory = Path.of(requiredEnvironment("METROPOLIS_SERVER_DIR"));
|
Path serverDirectory = Path.of(requiredEnvironment("METROPOLIS_SERVER_DIR"));
|
||||||
String worldName = System.getenv().getOrDefault("METROPOLIS_WORLD", "world");
|
String worldName = System.getenv().getOrDefault("METROPOLIS_WORLD", "world");
|
||||||
Path regionsFile = serverDirectory.resolve("plugins/WorldGuard/worlds")
|
Path regionsFile =
|
||||||
|
serverDirectory
|
||||||
|
.resolve("plugins/WorldGuard/worlds")
|
||||||
.resolve(worldName)
|
.resolve(worldName)
|
||||||
.resolve("regions.yml");
|
.resolve("regions.yml");
|
||||||
YamlConfiguration regions = YamlConfiguration.loadConfiguration(regionsFile.toFile());
|
YamlConfiguration regions = YamlConfiguration.loadConfiguration(regionsFile.toFile());
|
||||||
|
|
||||||
assertTrue(regions.contains("regions." + regionId), "WorldGuard did not persist region " + regionId);
|
assertTrue(
|
||||||
|
regions.contains("regions." + regionId), "WorldGuard did not persist region " + regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RconClient connectToConfiguredServer() throws IOException {
|
private static RconClient connectToConfiguredServer() throws IOException {
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class Cuboid implements Comparable<Cuboid> {
|
public class Cuboid implements Comparable<Cuboid> {
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@@ -17,15 +33,15 @@ public class Cuboid implements Comparable<Cuboid> {
|
|||||||
public int maxY;
|
public int maxY;
|
||||||
public int maxZ;
|
public int maxZ;
|
||||||
|
|
||||||
public int getId(){
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id){
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
public Cuboid(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
this.minZ = minZ;
|
this.minZ = minZ;
|
||||||
@@ -61,11 +77,11 @@ public class Cuboid implements Comparable<Cuboid> {
|
|||||||
this.maxZ = selection.getMaximumPoint().z();
|
this.maxZ = selection.getMaximumPoint().z();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getMin(){
|
public BlockVector3 getMin() {
|
||||||
return BlockVector3.at(minX, minY, minZ);
|
return BlockVector3.at(minX, minY, minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getMax(){
|
public BlockVector3 getMax() {
|
||||||
return BlockVector3.at(maxX, maxY, maxZ);
|
return BlockVector3.at(maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,46 +90,46 @@ public class Cuboid implements Comparable<Cuboid> {
|
|||||||
BlockVector3 min = getMin();
|
BlockVector3 min = getMin();
|
||||||
BlockVector3 otherMin = o.getMin();
|
BlockVector3 otherMin = o.getMin();
|
||||||
|
|
||||||
if(min.x() < otherMin.x()){
|
if (min.x() < otherMin.x()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(min.x() > otherMin.x()){
|
} else if (min.x() > otherMin.x()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else if(min.z() < otherMin.z()){
|
} else if (min.z() < otherMin.z()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(min.z() > otherMin.z()){
|
} else if (min.z() > otherMin.z()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else if(min.y() < otherMin.y()){
|
} else if (min.y() < otherMin.y()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(min.y() > otherMin.y()){
|
} else if (min.y() > otherMin.y()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int compareBlockVectors(BlockVector3 v1, BlockVector3 v2){
|
public static int compareBlockVectors(BlockVector3 v1, BlockVector3 v2) {
|
||||||
if(v1 == null){
|
if (v1 == null) {
|
||||||
if(v2 == null){
|
if (v2 == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}else{
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}else if(v2 == null){
|
} else if (v2 == null) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(v1.x() < v2.x()){
|
if (v1.x() < v2.x()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(v1.x() > v2.x()){
|
} else if (v1.x() > v2.x()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else if(v1.z() < v2.z()){
|
} else if (v1.z() < v2.z()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(v1.z() > v2.z()){
|
} else if (v1.z() > v2.z()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else if(v1.y() < v2.y()){
|
} else if (v1.y() < v2.y()) {
|
||||||
return -1;
|
return -1;
|
||||||
}else if(v1.y() > v2.y()){
|
} else if (v1.y() > v2.y()) {
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,89 +138,118 @@ public class Cuboid implements Comparable<Cuboid> {
|
|||||||
return compareBlockVectors(v1, v2) < 0;
|
return compareBlockVectors(v1, v2) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid inset(int amount){
|
public Cuboid inset(int amount) {
|
||||||
return inset(amount, amount, amount);
|
return inset(amount, amount, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid inset(int x, int z){
|
public Cuboid inset(int x, int z) {
|
||||||
return inset(x, 0, z);
|
return inset(x, 0, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid inset(int x, int y, int z){
|
public Cuboid inset(int x, int y, int z) {
|
||||||
return new Cuboid(this.minX + x, this.minY, this.minZ + z, this.maxX - x, this.maxY, this.maxZ - z);
|
return new Cuboid(
|
||||||
|
this.minX + x, this.minY, this.minZ + z, this.maxX - x, this.maxY, this.maxZ - z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVolume() {
|
public int getVolume() {
|
||||||
return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
|
return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
|
||||||
}
|
}
|
||||||
public int getMinX(){return minX;}
|
|
||||||
public void setMinX(int minX){this.minX = minX;}
|
public int getMinX() {
|
||||||
public int getMinY(){return minY;}
|
return minX;
|
||||||
public void setMinY(int minY){this.minY = minY;}
|
}
|
||||||
public int getMinZ(){return minZ;}
|
|
||||||
public void setMinZ(int minZ){this.minZ = minZ;}
|
public void setMinX(int minX) {
|
||||||
public int getMaxX(){return maxX;}
|
this.minX = minX;
|
||||||
public void setMaxX(int maxX){this.maxX = maxX;}
|
}
|
||||||
public int getMaxY(){return maxY;}
|
|
||||||
public void setMaxY(int maxY){this.maxY = maxY;}
|
public int getMinY() {
|
||||||
public int getMaxZ(){return maxZ;}
|
return minY;
|
||||||
public void setMaxZ(int maxZ){this.maxZ = maxZ;}
|
}
|
||||||
|
|
||||||
|
public void setMinY(int minY) {
|
||||||
|
this.minY = minY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinZ() {
|
||||||
|
return minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMinZ(int minZ) {
|
||||||
|
this.minZ = minZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxX() {
|
||||||
|
return maxX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxX(int maxX) {
|
||||||
|
this.maxX = maxX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxY() {
|
||||||
|
return maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxY(int maxY) {
|
||||||
|
this.maxY = maxY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxZ() {
|
||||||
|
return maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxZ(int maxZ) {
|
||||||
|
this.maxZ = maxZ;
|
||||||
|
}
|
||||||
|
|
||||||
public Cuboid outset(int amount) {
|
public Cuboid outset(int amount) {
|
||||||
return outset(amount, amount, amount);
|
return outset(amount, amount, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid outset(int x, int z){
|
public Cuboid outset(int x, int z) {
|
||||||
return outset(x, 0, z);
|
return outset(x, 0, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid outset(int x, int y, int z) {
|
public Cuboid outset(int x, int y, int z) {
|
||||||
return new Cuboid(this.minX - x, this.minY - y, this.minZ - z, this.maxX + x, this.maxY + y, this.maxZ + z);
|
return new Cuboid(
|
||||||
|
this.minX - x, this.minY - y, this.minZ - z, this.maxX + x, this.maxY + y, this.maxZ + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCenterX(){
|
public int getCenterX() {
|
||||||
return (this.minX + this.maxX) /2;
|
return (this.minX + this.maxX) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCenterY(){
|
public int getCenterY() {
|
||||||
return (this.minY + this.maxY)/2;
|
return (this.minY + this.maxY) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCenterZ(){
|
public int getCenterZ() {
|
||||||
return (this.minZ + this.maxZ)/2;
|
return (this.minZ + this.maxZ) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean intersects(Cuboid other) {
|
public boolean intersects(Cuboid other) {
|
||||||
if (this.maxX >= other.minX && this.minX <= other.maxX)
|
if (this.maxX >= other.minX && this.minX <= other.maxX) {
|
||||||
{
|
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ) {
|
||||||
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ)
|
if (this.maxY >= other.minY && this.minY <= other.maxY) {
|
||||||
{
|
|
||||||
if (this.maxY >= other.minY && this.minY <= other.maxY)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Location bedSpawn) {
|
public boolean contains(Location bedSpawn) {
|
||||||
if(this.minX > bedSpawn.getBlockX() || this.maxX < bedSpawn.getBlockX()){
|
if (this.minX > bedSpawn.getBlockX() || this.maxX < bedSpawn.getBlockX()) {
|
||||||
return false;
|
return false;
|
||||||
}else if(this.minZ > bedSpawn.getBlockZ() || this.maxZ < bedSpawn.getBlockZ()){
|
} else if (this.minZ > bedSpawn.getBlockZ() || this.maxZ < bedSpawn.getBlockZ()) {
|
||||||
return false;
|
return false;
|
||||||
}else if(this.minY > bedSpawn.getBlockY() || this.maxY < bedSpawn.getBlockY()){
|
} else if (this.minY > bedSpawn.getBlockY() || this.maxY < bedSpawn.getBlockY()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,8 +258,8 @@ public class Cuboid implements Comparable<Cuboid> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("{Cuboid minX=%d, minY=%d, minZ=%d, maxX=%d, maxY=%d, maxZ=%d}", minX, minY, minZ, maxX, maxY, maxZ);
|
return String.format(
|
||||||
|
"{Cuboid minX=%d, minY=%d, minZ=%d, maxX=%d, maxY=%d, maxZ=%d}",
|
||||||
|
minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,52 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
public class PlayerHome extends Plot{
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
public class PlayerHome extends Plot {
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private String playerName;
|
private String playerName;
|
||||||
public UUID getPlayerId(){return this.playerId;}
|
|
||||||
public String getPlayerName(){return this.playerName;}
|
public UUID getPlayerId() {
|
||||||
public void setPlayerName(String playerName){this.playerName = playerName;}
|
return this.playerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerName() {
|
||||||
|
return this.playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerName(String playerName) {
|
||||||
|
this.playerName = playerName;
|
||||||
|
}
|
||||||
|
|
||||||
private int number;
|
private int number;
|
||||||
|
|
||||||
public PlayerHome(UUID ownerId, String ownerName, int homeNumber, BlockVector3 min, BlockVector3 max) {
|
public PlayerHome(
|
||||||
|
UUID ownerId, String ownerName, int homeNumber, BlockVector3 min, BlockVector3 max) {
|
||||||
super(String.format("h_%d_%s", homeNumber, ownerId), min, max);
|
super(String.format("h_%d_%s", homeNumber, ownerId), min, max);
|
||||||
this.playerId = ownerId;
|
this.playerId = ownerId;
|
||||||
this.playerName = ownerName;
|
this.playerName = ownerName;
|
||||||
@@ -31,7 +58,7 @@ public class PlayerHome extends Plot{
|
|||||||
this.playerName = "";
|
this.playerName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerHome(ProtectedRegion homeRegion){
|
public PlayerHome(ProtectedRegion homeRegion) {
|
||||||
String regionName = homeRegion.getId();
|
String regionName = homeRegion.getId();
|
||||||
if (!regionName.startsWith("h_")) {
|
if (!regionName.startsWith("h_")) {
|
||||||
throw new IllegalArgumentException("Not a Metropolis home region: " + regionName);
|
throw new IllegalArgumentException("Not a Metropolis home region: " + regionName);
|
||||||
@@ -54,7 +81,8 @@ public class PlayerHome extends Plot{
|
|||||||
this.playerName = offlinePlayer.getName() == null ? regionOwner : offlinePlayer.getName();
|
this.playerName = offlinePlayer.getName() == null ? regionOwner : offlinePlayer.getName();
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
Set<UUID> ownerIds = homeRegion.getOwners().getUniqueIds();
|
Set<UUID> ownerIds = homeRegion.getOwners().getUniqueIds();
|
||||||
this.playerId = ownerIds.isEmpty()
|
this.playerId =
|
||||||
|
ownerIds.isEmpty()
|
||||||
? Bukkit.getOfflinePlayer(regionOwner).getUniqueId()
|
? Bukkit.getOfflinePlayer(regionOwner).getUniqueId()
|
||||||
: ownerIds.iterator().next();
|
: ownerIds.iterator().next();
|
||||||
this.playerName = regionOwner;
|
this.playerName = regionOwner;
|
||||||
@@ -64,17 +92,17 @@ public class PlayerHome extends Plot{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if(!(other instanceof PlayerHome)){
|
if (!(other instanceof PlayerHome)) {
|
||||||
return super.equals(other);
|
return super.equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerHome otherPlayerHome = (PlayerHome)other;
|
PlayerHome otherPlayerHome = (PlayerHome) other;
|
||||||
|
|
||||||
if(!java.util.Objects.equals(this.playerId, otherPlayerHome.playerId)){
|
if (!java.util.Objects.equals(this.playerId, otherPlayerHome.playerId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!getCuboid().equals(otherPlayerHome.getCuboid())){
|
if (!getCuboid().equals(otherPlayerHome.getCuboid())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,15 +112,24 @@ public class PlayerHome extends Plot{
|
|||||||
public String toFriendlyString() {
|
public String toFriendlyString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}", getPlayerName(), getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
sb.append(
|
||||||
|
String.format(
|
||||||
|
"Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}",
|
||||||
|
getPlayerName(),
|
||||||
|
getCuboid().getMinX(),
|
||||||
|
getCuboid().getMinY(),
|
||||||
|
getCuboid().getMinZ(),
|
||||||
|
getCuboid().getMaxX(),
|
||||||
|
getCuboid().getMaxY(),
|
||||||
|
getCuboid().getMaxZ()));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerHome get(ProtectedRegion homeRegion){
|
public static PlayerHome get(ProtectedRegion homeRegion) {
|
||||||
if(homeRegion instanceof ProtectedCuboidRegion){
|
if (homeRegion instanceof ProtectedCuboidRegion) {
|
||||||
return new PlayerHome((ProtectedCuboidRegion) homeRegion);
|
return new PlayerHome((ProtectedCuboidRegion) homeRegion);
|
||||||
}else{
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +138,7 @@ public class PlayerHome extends Plot{
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNumber(int number){
|
public void setNumber(int number) {
|
||||||
this.number = number;
|
this.number = number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -1,64 +1,100 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
public class Plot implements Comparable<Plot> {
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
|
|
||||||
public class Plot implements Comparable<Plot>{
|
|
||||||
private int _id;
|
private int _id;
|
||||||
public int getId(){return _id;}
|
|
||||||
public void setId(int id){_id = id;}
|
public int getId() {
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
private Cuboid _cuboid;
|
private Cuboid _cuboid;
|
||||||
public Cuboid getCuboid(){return _cuboid;}
|
|
||||||
public void setCuboid(Cuboid cuboid){_cuboid = cuboid;}
|
public Cuboid getCuboid() {
|
||||||
|
return _cuboid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCuboid(Cuboid cuboid) {
|
||||||
|
_cuboid = cuboid;
|
||||||
|
}
|
||||||
|
|
||||||
private String _regionName;
|
private String _regionName;
|
||||||
public String getRegionName(){return _regionName;}
|
|
||||||
public void setRegionName(String regionName){_regionName = regionName;}
|
|
||||||
|
|
||||||
public Plot(String regionName, BlockVector3 min, BlockVector3 max){
|
public String getRegionName() {
|
||||||
|
return _regionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegionName(String regionName) {
|
||||||
|
_regionName = regionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plot(String regionName, BlockVector3 min, BlockVector3 max) {
|
||||||
_cuboid = new Cuboid(min, max);
|
_cuboid = new Cuboid(min, max);
|
||||||
_regionName = regionName;
|
_regionName = regionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plot(ProtectedCuboidRegion cuboid){
|
public Plot(ProtectedCuboidRegion cuboid) {
|
||||||
_cuboid = new Cuboid(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
_cuboid = new Cuboid(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||||
_regionName = cuboid.getId();
|
_regionName = cuboid.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plot(){
|
public Plot() {
|
||||||
_cuboid = new Cuboid();
|
_cuboid = new Cuboid();
|
||||||
_regionName = "";
|
_regionName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getPlotMin(int roadWidth) {
|
public BlockVector3 getPlotMin(int roadWidth) {
|
||||||
return BlockVector3.at(_cuboid.minX - roadWidth/2, _cuboid.minY, _cuboid.minZ - roadWidth/2);
|
return BlockVector3.at(
|
||||||
|
_cuboid.minX - roadWidth / 2, _cuboid.minY, _cuboid.minZ - roadWidth / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRow(int roadWidth, int plotSizeZ){
|
public int getRow(int roadWidth, int plotSizeZ) {
|
||||||
BlockVector3 min = getPlotMin(roadWidth);
|
BlockVector3 min = getPlotMin(roadWidth);
|
||||||
return min.z() / plotSizeZ;
|
return min.z() / plotSizeZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCol(int roadWidth, int plotSizeX){
|
public int getCol(int roadWidth, int plotSizeX) {
|
||||||
return getPlotMin(roadWidth).x() / plotSizeX;
|
return getPlotMin(roadWidth).x() / plotSizeX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if(!(other instanceof Plot)){
|
if (!(other instanceof Plot)) {
|
||||||
return super.equals(other);
|
return super.equals(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plot otherPlayerHome = (Plot)other;
|
Plot otherPlayerHome = (Plot) other;
|
||||||
|
|
||||||
if(!getCuboid().equals(otherPlayerHome.getCuboid())){
|
if (!getCuboid().equals(otherPlayerHome.getCuboid())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +107,7 @@ public class Plot implements Comparable<Plot>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("{PlayerHome }"));
|
sb.append(String.format("{PlayerHome }"));
|
||||||
@@ -79,10 +115,10 @@ public class Plot implements Comparable<Plot>{
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Plot get(ProtectedRegion region){
|
public static Plot get(ProtectedRegion region) {
|
||||||
if(region instanceof ProtectedCuboidRegion){
|
if (region instanceof ProtectedCuboidRegion) {
|
||||||
return new Plot((ProtectedCuboidRegion) region);
|
return new Plot((ProtectedCuboidRegion) region);
|
||||||
}else{
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +126,15 @@ public class Plot implements Comparable<Plot>{
|
|||||||
public String toFriendlyString() {
|
public String toFriendlyString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("Metropolis Reserved Plot {min: (%d, %d, %d) max: (%d, %d, %d)}", getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
sb.append(
|
||||||
|
String.format(
|
||||||
|
"Metropolis Reserved Plot {min: (%d, %d, %d) max: (%d, %d, %d)}",
|
||||||
|
getCuboid().getMinX(),
|
||||||
|
getCuboid().getMinY(),
|
||||||
|
getCuboid().getMinZ(),
|
||||||
|
getCuboid().getMaxX(),
|
||||||
|
getCuboid().getMaxY(),
|
||||||
|
getCuboid().getMaxZ()));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@@ -101,13 +145,14 @@ public class Plot implements Comparable<Plot>{
|
|||||||
|
|
||||||
public Location getViableSpawnLocation(World world) {
|
public Location getViableSpawnLocation(World world) {
|
||||||
Cuboid cuboid = getCuboid();
|
Cuboid cuboid = getCuboid();
|
||||||
for(int y=cuboid.maxY-1; y>= cuboid.minY; y--){
|
for (int y = cuboid.maxY - 1; y >= cuboid.minY; y--) {
|
||||||
for(int x=cuboid.minX; x<= cuboid.maxX; x++){
|
for (int x = cuboid.minX; x <= cuboid.maxX; x++) {
|
||||||
for(int z=cuboid.minZ; z<= cuboid.maxZ; z++){
|
for (int z = cuboid.minZ; z <= cuboid.maxZ; z++) {
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
Block blockAbove = world.getBlockAt(x, y+1, z);
|
Block blockAbove = world.getBlockAt(x, y + 1, z);
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y - 1, z);
|
||||||
if(block.getType() == Material.AIR & blockAbove.getType() == Material.AIR && blockUnder.getType() != Material.AIR){
|
if (block.getType() == Material.AIR & blockAbove.getType() == Material.AIR
|
||||||
|
&& blockUnder.getType() != Material.AIR) {
|
||||||
return new Location(world, x, y, z);
|
return new Location(world, x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
public class UserOverride {
|
public class UserOverride {
|
||||||
@@ -5,11 +22,19 @@ public class UserOverride {
|
|||||||
private int _plotMultiplier;
|
private int _plotMultiplier;
|
||||||
private int _maxPlots;
|
private int _maxPlots;
|
||||||
|
|
||||||
public String getUsername(){return _username;}
|
public String getUsername() {
|
||||||
public int getPlotMultiplier(){return _plotMultiplier;}
|
return _username;
|
||||||
public int getMaxPlots(){return _maxPlots;}
|
}
|
||||||
|
|
||||||
public UserOverride(String username, int plotMultiplier, int maxPlots){
|
public int getPlotMultiplier() {
|
||||||
|
return _plotMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPlots() {
|
||||||
|
return _maxPlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserOverride(String username, int plotMultiplier, int maxPlots) {
|
||||||
_username = username;
|
_username = username;
|
||||||
_plotMultiplier = plotMultiplier;
|
_plotMultiplier = plotMultiplier;
|
||||||
_maxPlots = maxPlots;
|
_maxPlots = maxPlots;
|
||||||
|
|||||||
@@ -1,24 +1,40 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class MetropolisCommand implements CommandExecutor {
|
public class MetropolisCommand implements CommandExecutor {
|
||||||
private MetropolisPlugin _plugin;
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisCommand(MetropolisPlugin plugin){
|
public MetropolisCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
|
||||||
sender.sendMessage("Metropolis: version "+ _plugin.pdf.getVersion());
|
sender.sendMessage("Metropolis: version " + _plugin.pdf.getVersion());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,47 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class MetropolisDebugGenerateTestHomesCommand implements CommandExecutor {
|
public class MetropolisDebugGenerateTestHomesCommand implements CommandExecutor {
|
||||||
|
|
||||||
private MetropolisPlugin _plugin;
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisDebugGenerateTestHomesCommand(MetropolisPlugin plugin) {
|
public MetropolisDebugGenerateTestHomesCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
try{
|
try {
|
||||||
int numHomes = Integer.parseInt(args[0]);
|
int numHomes = Integer.parseInt(args[0]);
|
||||||
for(int i=1; i<= numHomes; i++){
|
for (int i = 1; i <= numHomes; i++) {
|
||||||
_plugin.generateHome(String.format("test%d", i));
|
_plugin.generateHome(String.format("test%d", i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}catch(NumberFormatException ex){
|
} catch (NumberFormatException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,35 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
import org.bukkit.command.CommandExecutor;
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
import org.bukkit.command.CommandSender;
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class MetropolisFlagResetCommand implements CommandExecutor {
|
public class MetropolisFlagResetCommand implements CommandExecutor {
|
||||||
private MetropolisPlugin _plugin;
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisFlagResetCommand(MetropolisPlugin plugin){
|
public MetropolisFlagResetCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,8 +46,8 @@ public class MetropolisFlagResetCommand implements CommandExecutor {
|
|||||||
cityRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
cityRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
||||||
cityRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
cityRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
||||||
|
|
||||||
for(ProtectedRegion homeRegion: _plugin.regionManager.getRegions().values()){
|
for (ProtectedRegion homeRegion : _plugin.regionManager.getRegions().values()) {
|
||||||
if(homeRegion.getId().startsWith("h_")){
|
if (homeRegion.getId().startsWith("h_")) {
|
||||||
homeRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||||
homeRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||||
homeRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||||
@@ -38,16 +55,11 @@ public class MetropolisFlagResetCommand implements CommandExecutor {
|
|||||||
homeRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||||
homeRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||||
homeRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
homeRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Metropolis: flags have been reset");
|
sender.sendMessage("Metropolis: flags have been reset");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,46 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class MetropolisHomeAcquire implements CommandExecutor {
|
public class MetropolisHomeAcquire implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin;
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisHomeAcquire(MetropolisPlugin plugin){
|
public MetropolisHomeAcquire(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if(!(sender instanceof Player)){
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("This command can only be used by players");
|
sender.sendMessage("This command can only be used by players");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if(_plugin.getNumPlots(player.getUniqueId()) >= _plugin.getMaxPlots(player.getUniqueId())){
|
if (_plugin.getNumPlots(player.getUniqueId()) >= _plugin.getMaxPlots(player.getUniqueId())) {
|
||||||
sender.sendMessage("You cannot have any more plots");
|
sender.sendMessage("You cannot have any more plots");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -31,5 +48,4 @@ public class MetropolisHomeAcquire implements CommandExecutor {
|
|||||||
_plugin.assignPlot(player);
|
_plugin.assignPlot(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +1,79 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
|
|
||||||
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin = null;
|
MetropolisPlugin _plugin = null;
|
||||||
|
|
||||||
public MetropolisHomeEvictCommand(MetropolisPlugin plugin){
|
public MetropolisHomeEvictCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
//get the player and region
|
// get the player and region
|
||||||
String playerName = "";
|
String playerName = "";
|
||||||
|
|
||||||
if(args.length == 0){
|
if (args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length >= 1){
|
if (args.length >= 1) {
|
||||||
playerName = args[0];
|
playerName = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflinePlayer player = _plugin.getOfflinePlayer(playerName);
|
OfflinePlayer player = _plugin.getOfflinePlayer(playerName);
|
||||||
if(player == null){
|
if (player == null) {
|
||||||
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", playerName));
|
sender.sendMessage(
|
||||||
|
String.format("The requested player {%s}does not appear to exist.", playerName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion region = _plugin.getRegion(_plugin.getCurrentHomeRegionName(player.getUniqueId()));
|
ProtectedRegion region =
|
||||||
if(region == null){
|
_plugin.getRegion(_plugin.getCurrentHomeRegionName(player.getUniqueId()));
|
||||||
|
if (region == null) {
|
||||||
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove the player as owner and/or member of the region
|
// remove the player as owner and/or member of the region
|
||||||
region.getMembers().removePlayer(player.getUniqueId());
|
region.getMembers().removePlayer(player.getUniqueId());
|
||||||
region.getOwners().removePlayer(player.getUniqueId());
|
region.getOwners().removePlayer(player.getUniqueId());
|
||||||
|
|
||||||
//if the region has no owners delete the region
|
// if the region has no owners delete the region
|
||||||
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
if (region.getMembers().size() == 0 && region.getOwners().size() == 0) {
|
||||||
_plugin.removeRegion(region.getId());
|
_plugin.removeRegion(region.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
_plugin.saveRegions();
|
_plugin.saveRegions();
|
||||||
|
|
||||||
//?optionally regen the region
|
// ?optionally regen the region
|
||||||
//_plugin.worldEdit.getCommand("regen").execute(_plugin.getServer().getConsoleSender(), "regen", new String[]{});
|
// _plugin.worldEdit.getCommand("regen").execute(_plugin.getServer().getConsoleSender(),
|
||||||
|
// "regen", new String[]{});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,40 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
||||||
|
|
||||||
private MetropolisPlugin _plugin;
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisHomeGenerateCommand(MetropolisPlugin plugin){
|
public MetropolisHomeGenerateCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if(args.length < 1){
|
if (args.length < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,5 +49,4 @@ public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,66 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
|
||||||
|
|
||||||
public class MetropolisHomeGoCommand implements CommandExecutor {
|
public class MetropolisHomeGoCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin = null;
|
MetropolisPlugin _plugin = null;
|
||||||
|
|
||||||
public MetropolisHomeGoCommand(MetropolisPlugin plugin){
|
public MetropolisHomeGoCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
Player player = null;
|
Player player = null;
|
||||||
if(sender instanceof Player){
|
if (sender instanceof Player) {
|
||||||
player = (Player)sender;
|
player = (Player) sender;
|
||||||
|
|
||||||
if(args.length >= 1){
|
if (args.length >= 1) {
|
||||||
if(player.hasPermission("")){
|
if (player.hasPermission("")) {
|
||||||
player = _plugin.getPlayer(args[0]);
|
player = _plugin.getPlayer(args[0]);
|
||||||
|
|
||||||
if(player == null){
|
if (player == null) {
|
||||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
sender.sendMessage("Permission denied");
|
sender.sendMessage("Permission denied");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(args.length >= 1){
|
if (args.length >= 1) {
|
||||||
player = _plugin.getPlayer(args[0]);
|
player = _plugin.getPlayer(args[0]);
|
||||||
|
|
||||||
if(player == null){
|
if (player == null) {
|
||||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
sender.sendMessage("You must be a player");
|
sender.sendMessage("You must be a player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -54,19 +71,20 @@ public class MetropolisHomeGoCommand implements CommandExecutor {
|
|||||||
Location loc = null;
|
Location loc = null;
|
||||||
Location bedSpawn = player.getBedSpawnLocation();
|
Location bedSpawn = player.getBedSpawnLocation();
|
||||||
|
|
||||||
if(home.contains(bedSpawn)){
|
if (home.contains(bedSpawn)) {
|
||||||
loc = bedSpawn;
|
loc = bedSpawn;
|
||||||
}else {
|
} else {
|
||||||
loc = home.getViableSpawnLocation(_plugin.getWorld());
|
loc = home.getViableSpawnLocation(_plugin.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loc != null){
|
if (loc != null) {
|
||||||
player.teleport(loc);
|
player.teleport(loc);
|
||||||
}else{
|
} else {
|
||||||
if(sender == player){
|
if (sender == player) {
|
||||||
sender.sendMessage("There is no valid spawn location in your home");
|
sender.sendMessage("There is no valid spawn location in your home");
|
||||||
}else{
|
} else {
|
||||||
sender.sendMessage(String.format("There is no valid spawn location in %s's home", player.getName()));
|
sender.sendMessage(
|
||||||
|
String.format("There is no valid spawn location in %s's home", player.getName()));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,41 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
|
||||||
|
|
||||||
public class MetropolisHomeListCommand implements CommandExecutor {
|
public class MetropolisHomeListCommand implements CommandExecutor {
|
||||||
private MetropolisPlugin _plugin;
|
private MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public MetropolisHomeListCommand(MetropolisPlugin plugin){
|
public MetropolisHomeListCommand(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
for(Plot cityBlock : _plugin.getCityBlocks()){
|
for (Plot cityBlock : _plugin.getCityBlocks()) {
|
||||||
sender.sendMessage(String.format("%s", cityBlock.toFriendlyString()));
|
sender.sendMessage(String.format("%s", cityBlock.toFriendlyString()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,29 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin;
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
@@ -19,29 +36,29 @@ public class MetropolisHomeMoveCommand implements CommandExecutor {
|
|||||||
OfflinePlayer player = null;
|
OfflinePlayer player = null;
|
||||||
int newHomeNumber = 0;
|
int newHomeNumber = 0;
|
||||||
|
|
||||||
if(sender instanceof OfflinePlayer){
|
if (sender instanceof OfflinePlayer) {
|
||||||
player = (OfflinePlayer)sender;
|
player = (OfflinePlayer) sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 1){
|
if (args.length == 1) {
|
||||||
try{
|
try {
|
||||||
newHomeNumber = Integer.parseInt(args[0]);
|
newHomeNumber = Integer.parseInt(args[0]);
|
||||||
}catch(NumberFormatException ex){
|
} catch (NumberFormatException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else if(args.length >= 2){
|
} else if (args.length >= 2) {
|
||||||
try{
|
try {
|
||||||
newHomeNumber = Integer.parseInt(args[0]);
|
newHomeNumber = Integer.parseInt(args[0]);
|
||||||
}catch(NumberFormatException ex){
|
} catch (NumberFormatException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
player = _plugin.getOfflinePlayer(args[1]);
|
player = _plugin.getOfflinePlayer(args[1]);
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player == null || !_plugin.homeExists(player.getUniqueId(), newHomeNumber)){
|
if (player == null || !_plugin.homeExists(player.getUniqueId(), newHomeNumber)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,5 +66,4 @@ public class MetropolisHomeMoveCommand implements CommandExecutor {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,30 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
|
||||||
|
|
||||||
public class MetropolisPlotGoCommand implements CommandExecutor {
|
public class MetropolisPlotGoCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin;
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
@@ -20,30 +37,29 @@ public class MetropolisPlotGoCommand implements CommandExecutor {
|
|||||||
Player player = null;
|
Player player = null;
|
||||||
Plot plot = null;
|
Plot plot = null;
|
||||||
|
|
||||||
if(sender instanceof Player){
|
if (sender instanceof Player) {
|
||||||
player = (Player) sender;
|
player = (Player) sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 1 && player != null){
|
if (args.length == 1 && player != null) {
|
||||||
plot = _plugin.getPlot(args[0]);
|
plot = _plugin.getPlot(args[0]);
|
||||||
}else if(args.length >= 2){
|
} else if (args.length >= 2) {
|
||||||
player = _plugin.getPlayer(args[1]);
|
player = _plugin.getPlayer(args[1]);
|
||||||
plot = _plugin.getPlot(args[0]);
|
plot = _plugin.getPlot(args[0]);
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(plot == null || player == null){
|
if (plot == null || player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorMessage = _plugin.teleportPlayerToPlot(player, plot);
|
String errorMessage = _plugin.teleportPlayerToPlot(player, plot);
|
||||||
if(errorMessage != null){
|
if (errorMessage != null) {
|
||||||
sender.sendMessage(errorMessage);
|
sender.sendMessage(errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
import org.bukkit.command.CommandExecutor;
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
import org.bukkit.command.CommandSender;
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
import org.bukkit.entity.Player;
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
@@ -11,6 +23,11 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class MetropolisPlotReserveCommand implements CommandExecutor {
|
public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||||
MetropolisPlugin _plugin;
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
@@ -28,40 +45,43 @@ public class MetropolisPlotReserveCommand implements CommandExecutor {
|
|||||||
int maxZ = 0;
|
int maxZ = 0;
|
||||||
Cuboid cuboid = new Cuboid();
|
Cuboid cuboid = new Cuboid();
|
||||||
|
|
||||||
if(sender instanceof Player && args.length == 1){
|
if (sender instanceof Player && args.length == 1) {
|
||||||
try {
|
try {
|
||||||
Region selection = _plugin.worldEdit.getSession((Player) sender)
|
Region selection =
|
||||||
|
_plugin
|
||||||
|
.worldEdit
|
||||||
|
.getSession((Player) sender)
|
||||||
.getSelection(BukkitAdapter.adapt(_plugin.getWorld()));
|
.getSelection(BukkitAdapter.adapt(_plugin.getWorld()));
|
||||||
cuboid = new Cuboid(selection);
|
cuboid = new Cuboid(selection);
|
||||||
} catch (IncompleteRegionException ex) {
|
} catch (IncompleteRegionException ex) {
|
||||||
sender.sendMessage("Select a WorldEdit region first.");
|
sender.sendMessage("Select a WorldEdit region first.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else if(args.length == 7){
|
} else if (args.length == 7) {
|
||||||
try{
|
try {
|
||||||
minX = Integer.parseInt(args[1]);
|
minX = Integer.parseInt(args[1]);
|
||||||
minY = Integer.parseInt(args[2]);
|
minY = Integer.parseInt(args[2]);
|
||||||
minZ = Integer.parseInt(args[3]);
|
minZ = Integer.parseInt(args[3]);
|
||||||
maxX = Integer.parseInt(args[4]);
|
maxX = Integer.parseInt(args[4]);
|
||||||
maxY = Integer.parseInt(args[5]);
|
maxY = Integer.parseInt(args[5]);
|
||||||
maxZ = Integer.parseInt(args[6]);
|
maxZ = Integer.parseInt(args[6]);
|
||||||
}catch(NumberFormatException ex){
|
} catch (NumberFormatException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}else if(args.length == 5){
|
} else if (args.length == 5) {
|
||||||
try{
|
try {
|
||||||
minX = Integer.parseInt(args[1]);
|
minX = Integer.parseInt(args[1]);
|
||||||
minY = 0;
|
minY = 0;
|
||||||
minZ = Integer.parseInt(args[2]);
|
minZ = Integer.parseInt(args[2]);
|
||||||
maxX = Integer.parseInt(args[3]);
|
maxX = Integer.parseInt(args[3]);
|
||||||
maxY = _plugin.getWorld().getMaxHeight();
|
maxY = _plugin.getWorld().getMaxHeight();
|
||||||
maxZ = Integer.parseInt(args[4]);
|
maxZ = Integer.parseInt(args[4]);
|
||||||
}catch(NumberFormatException ex){
|
} catch (NumberFormatException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,5 +92,4 @@ public class MetropolisPlotReserveCommand implements CommandExecutor {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,38 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
public class DebugListener implements Listener {
|
public class DebugListener implements Listener {
|
||||||
MetropolisPlugin _plugin;
|
MetropolisPlugin _plugin;
|
||||||
|
|
||||||
public DebugListener(MetropolisPlugin plugin){
|
public DebugListener(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onEvent(PlayerInteractEvent event){
|
public void onEvent(PlayerInteractEvent event) {
|
||||||
//event.
|
// event.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,73 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
|
||||||
|
|
||||||
public class PlayerJoinListener implements Listener {
|
public class PlayerJoinListener implements Listener {
|
||||||
private MetropolisPlugin _plugin = null;
|
private MetropolisPlugin _plugin = null;
|
||||||
|
|
||||||
public PlayerJoinListener(MetropolisPlugin plugin){
|
public PlayerJoinListener(MetropolisPlugin plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event){
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(player == null){
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerHome home = _plugin.getPlayerHome(player);
|
PlayerHome home = _plugin.getPlayerHome(player);
|
||||||
if(home==null){_plugin.getLogger().info("home is null");}
|
if (home == null) {
|
||||||
else if(home.getCuboid() == null){_plugin.getLogger().info("home.getCuboid() is null");}
|
_plugin.getLogger().info("home is null");
|
||||||
else if(home.getCuboid().getVolume() == 0){_plugin.getLogger().info("home.getCuboid().getVolume() is 0");}
|
} else if (home.getCuboid() == null) {
|
||||||
|
_plugin.getLogger().info("home.getCuboid() is null");
|
||||||
|
} else if (home.getCuboid().getVolume() == 0) {
|
||||||
|
_plugin.getLogger().info("home.getCuboid().getVolume() is 0");
|
||||||
|
}
|
||||||
|
|
||||||
if(home == null || home.getCuboid() == null || home.getCuboid().getVolume() == 0){
|
if (home == null || home.getCuboid() == null || home.getCuboid().getVolume() == 0) {
|
||||||
_plugin.getLogger().info(String.format("Metropolis: Unable to get or create home for player %s", player.getName()));
|
_plugin
|
||||||
}else{
|
.getLogger()
|
||||||
|
.info(
|
||||||
|
String.format(
|
||||||
|
"Metropolis: Unable to get or create home for player %s", player.getName()));
|
||||||
|
} else {
|
||||||
Cuboid cuboid = home.getCuboid();
|
Cuboid cuboid = home.getCuboid();
|
||||||
player.sendMessage(String.format("Metropolis: Welcome %s your home is between (%d, %d, %d) and (%d, %d, %d)", player.getName(), cuboid.getMinX(), cuboid.getMinY(), cuboid.getMinZ(), cuboid.getMaxX(), cuboid.getMaxY(), cuboid.getMaxZ()));
|
player.sendMessage(
|
||||||
|
String.format(
|
||||||
|
"Metropolis: Welcome %s your home is between (%d, %d, %d) and (%d, %d, %d)",
|
||||||
|
player.getName(),
|
||||||
|
cuboid.getMinX(),
|
||||||
|
cuboid.getMinY(),
|
||||||
|
cuboid.getMinZ(),
|
||||||
|
cuboid.getMaxX(),
|
||||||
|
cuboid.getMaxY(),
|
||||||
|
cuboid.getMaxZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.util;
|
package com.majinnaibu.bukkitplugins.metropolis.util;
|
||||||
|
|
||||||
public class Material {
|
public class Material {
|
||||||
|
|||||||
@@ -1,14 +1,31 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
class CuboidTest {
|
class CuboidTest {
|
||||||
@Test
|
@Test
|
||||||
void convertsWorldEditBoundsToCuboidCoordinates() {
|
void convertsWorldEditBoundsToCuboidCoordinates() {
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@@ -11,8 +28,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
class CurrentHomesStoreTest {
|
class CurrentHomesStoreTest {
|
||||||
@TempDir
|
@TempDir File temporaryDirectory;
|
||||||
File temporaryDirectory;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void roundTripsHomesByUuid() throws Exception {
|
void roundTripsHomesByUuid() throws Exception {
|
||||||
@@ -33,7 +49,11 @@ class CurrentHomesStoreTest {
|
|||||||
yaml.set("OldPlayerName", 2);
|
yaml.set("OldPlayerName", 2);
|
||||||
yaml.save(file);
|
yaml.save(file);
|
||||||
|
|
||||||
assertEquals(Map.of(playerId, 2), CurrentHomesStore.load(file, name -> {
|
assertEquals(
|
||||||
|
Map.of(playerId, 2),
|
||||||
|
CurrentHomesStore.load(
|
||||||
|
file,
|
||||||
|
name -> {
|
||||||
assertEquals("OldPlayerName", name);
|
assertEquals("OldPlayerName", name);
|
||||||
return playerId;
|
return playerId;
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,23 +1,37 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class PlayerHomeTest {
|
class PlayerHomeTest {
|
||||||
@Test
|
@Test
|
||||||
void buildsUuidBasedRegionIdentityAndPreservesDisplayName() {
|
void buildsUuidBasedRegionIdentityAndPreservesDisplayName() {
|
||||||
UUID playerId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
|
UUID playerId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
|
||||||
PlayerHome home = new PlayerHome(
|
PlayerHome home =
|
||||||
playerId,
|
new PlayerHome(
|
||||||
"PlayerName",
|
playerId, "PlayerName", 2, BlockVector3.at(1, 2, 3), BlockVector3.at(4, 5, 6));
|
||||||
2,
|
|
||||||
BlockVector3.at(1, 2, 3),
|
|
||||||
BlockVector3.at(4, 5, 6));
|
|
||||||
|
|
||||||
assertEquals(playerId, home.getPlayerId());
|
assertEquals(playerId, home.getPlayerId());
|
||||||
assertEquals("PlayerName", home.getPlayerName());
|
assertEquals("PlayerName", home.getPlayerName());
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis;
|
package com.majinnaibu.bukkitplugins.metropolis;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|||||||
@@ -1,7 +1,24 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -9,12 +26,12 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
class MetropolisHomeAcquireTest {
|
class MetropolisHomeAcquireTest {
|
||||||
@Test
|
@Test
|
||||||
void assignsAPlotWhenThePlayerIsBelowTheirLimit() {
|
void assignsAPlotWhenThePlayerIsBelowTheirLimit() {
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@@ -8,14 +25,14 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||||
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
|
||||||
|
|
||||||
class MetropolisPlotReserveCommandTest {
|
class MetropolisPlotReserveCommandTest {
|
||||||
@Test
|
@Test
|
||||||
void reservesCoordinatesFromAllSixArguments() {
|
void reservesCoordinatesFromAllSixArguments() {
|
||||||
@@ -24,7 +41,9 @@ class MetropolisPlotReserveCommandTest {
|
|||||||
Command command = mock(Command.class);
|
Command command = mock(Command.class);
|
||||||
MetropolisPlotReserveCommand executor = new MetropolisPlotReserveCommand(plugin);
|
MetropolisPlotReserveCommand executor = new MetropolisPlotReserveCommand(plugin);
|
||||||
|
|
||||||
assertTrue(executor.onCommand(sender, command, "reserve", new String[] {"north", "1", "2", "3", "4", "5", "6"}));
|
assertTrue(
|
||||||
|
executor.onCommand(
|
||||||
|
sender, command, "reserve", new String[] {"north", "1", "2", "3", "4", "5", "6"}));
|
||||||
|
|
||||||
ArgumentCaptor<Cuboid> cuboid = ArgumentCaptor.forClass(Cuboid.class);
|
ArgumentCaptor<Cuboid> cuboid = ArgumentCaptor.forClass(Cuboid.class);
|
||||||
verify(plugin).reserveCuboid(eq("north"), cuboid.capture());
|
verify(plugin).reserveCuboid(eq("north"), cuboid.capture());
|
||||||
@@ -43,7 +62,9 @@ class MetropolisPlotReserveCommandTest {
|
|||||||
Command command = mock(Command.class);
|
Command command = mock(Command.class);
|
||||||
MetropolisPlotReserveCommand executor = new MetropolisPlotReserveCommand(plugin);
|
MetropolisPlotReserveCommand executor = new MetropolisPlotReserveCommand(plugin);
|
||||||
|
|
||||||
assertFalse(executor.onCommand(sender, command, "reserve", new String[] {"north", "1", "two", "3", "4", "5", "6"}));
|
assertFalse(
|
||||||
|
executor.onCommand(
|
||||||
|
sender, command, "reserve", new String[] {"north", "1", "two", "3", "4", "5", "6"}));
|
||||||
verifyNoInteractions(plugin);
|
verifyNoInteractions(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
This file is part of Metropolis.
|
||||||
|
|
||||||
|
Metropolis is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Metropolis 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Metropolis. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
||||||
|
*/
|
||||||
|
|
||||||
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.contains;
|
import static org.mockito.ArgumentMatchers.contains;
|
||||||
@@ -7,14 +24,14 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class PlayerJoinListenerTest {
|
class PlayerJoinListenerTest {
|
||||||
@Test
|
@Test
|
||||||
void tellsJoiningPlayerTheirHomeBounds() {
|
void tellsJoiningPlayerTheirHomeBounds() {
|
||||||
@@ -23,7 +40,9 @@ class PlayerJoinListenerTest {
|
|||||||
PlayerJoinEvent event = mock(PlayerJoinEvent.class);
|
PlayerJoinEvent event = mock(PlayerJoinEvent.class);
|
||||||
when(event.getPlayer()).thenReturn(player);
|
when(event.getPlayer()).thenReturn(player);
|
||||||
when(player.getName()).thenReturn("PlayerName");
|
when(player.getName()).thenReturn("PlayerName");
|
||||||
when(plugin.getPlayerHome(player)).thenReturn(new PlayerHome(
|
when(plugin.getPlayerHome(player))
|
||||||
|
.thenReturn(
|
||||||
|
new PlayerHome(
|
||||||
UUID.fromString("123e4567-e89b-12d3-a456-426614174000"),
|
UUID.fromString("123e4567-e89b-12d3-a456-426614174000"),
|
||||||
"PlayerName",
|
"PlayerName",
|
||||||
1,
|
1,
|
||||||
|
|||||||
Reference in New Issue
Block a user