├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
└── main
│ ├── resources
│ ├── grass.schematic
│ ├── sand.schematic
│ ├── snow.schematic
│ ├── wood.schematic
│ ├── skyfactory.schematic
│ ├── skyfactory4.schematic
│ └── stoneblock2.schematic
│ └── java
│ └── net
│ └── mohron
│ └── skyclaims
│ ├── command
│ ├── argument
│ │ ├── Targets.java
│ │ ├── package-info.java
│ │ ├── Arguments.java
│ │ ├── PositiveIntegerArgument.java
│ │ ├── IslandSortType.java
│ │ ├── TwoUserArgument.java
│ │ ├── SchematicArgument.java
│ │ ├── IslandArgument.java
│ │ └── TargetArgument.java
│ ├── package-info.java
│ ├── team
│ │ ├── package-info.java
│ │ ├── CommandDemote.java
│ │ ├── CommandLeave.java
│ │ └── CommandPromote.java
│ ├── user
│ │ ├── package-info.java
│ │ ├── CommandUnlock.java
│ │ ├── CommandSetSpawn.java
│ │ ├── CommandLock.java
│ │ └── CommandSetName.java
│ ├── admin
│ │ ├── package-info.java
│ │ └── CommandReload.java
│ ├── debug
│ │ ├── package-info.java
│ │ └── CommandVersion.java
│ ├── schematic
│ │ ├── package-info.java
│ │ ├── CommandSchematicDelete.java
│ │ ├── CommandSchematicSetName.java
│ │ ├── CommandSchematicSetBiome.java
│ │ ├── CommandSchematicSetPreset.java
│ │ ├── CommandSchematicSetHeight.java
│ │ ├── CommandSchematicSetDescription.java
│ │ ├── CommandSchematic.java
│ │ ├── CommandSchematicCommand.java
│ │ └── CommandSchematicCreate.java
│ └── CommandRequirement.java
│ ├── world
│ ├── gen
│ │ ├── package-info.java
│ │ ├── EndPortalFixPopulator.java
│ │ └── VoidWorldGeneratorModifier.java
│ ├── region
│ │ ├── IRegionPattern.java
│ │ ├── Region.java
│ │ └── SpiralRegionPattern.java
│ ├── Coordinate.java
│ ├── RegenerateChunkTask.java
│ ├── IslandCleanupTask.java
│ └── GenerateIslandTask.java
│ ├── exception
│ ├── CreateIslandException.java
│ ├── InvalidRegionException.java
│ └── SkyClaimsException.java
│ ├── database
│ ├── IDatabase.java
│ └── MysqlDatabase.java
│ ├── config
│ ├── type
│ │ ├── integration
│ │ │ ├── PluginIntegration.java
│ │ │ ├── GriefDefenderConfig.java
│ │ │ └── NucleusConfig.java
│ │ ├── CommandConfig.java
│ │ ├── IntegrationConfig.java
│ │ ├── EconomyConfig.java
│ │ ├── PermissionConfig.java
│ │ ├── ExpirationConfig.java
│ │ ├── MysqlConfig.java
│ │ ├── StorageConfig.java
│ │ ├── EntityConfig.java
│ │ ├── GlobalConfig.java
│ │ └── MiscConfig.java
│ └── ConfigManager.java
│ ├── PluginInfo.java
│ ├── listener
│ ├── RespawnHandler.java
│ ├── EntitySpawnHandler.java
│ └── SchematicHandler.java
│ ├── integration
│ ├── Version.java
│ ├── nucleus
│ │ ├── NucleusIntegration.java
│ │ └── CommandHome.java
│ └── griefdefender
│ │ └── GDIntegration.java
│ ├── SkyClaimsTimings.java
│ ├── team
│ └── PrivilegeType.java
│ ├── util
│ ├── WorldUtil.java
│ ├── FlatWorldUtil.java
│ └── CommandUtil.java
│ └── schematic
│ └── SchematicUI.java
├── gradle.properties
├── .gitignore
├── .travis.yml
├── .github
├── ISSUE_TEMPLATE.md
└── workflows
│ └── codeql-analysis.yml
├── .idea
└── runConfigurations
│ └── SpongeForge.xml
├── gradlew.bat
└── README.md
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'SkyClaims'
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/main/resources/grass.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/grass.schematic
--------------------------------------------------------------------------------
/src/main/resources/sand.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/sand.schematic
--------------------------------------------------------------------------------
/src/main/resources/snow.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/snow.schematic
--------------------------------------------------------------------------------
/src/main/resources/wood.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/wood.schematic
--------------------------------------------------------------------------------
/src/main/resources/skyfactory.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/skyfactory.schematic
--------------------------------------------------------------------------------
/src/main/resources/skyfactory4.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/skyfactory4.schematic
--------------------------------------------------------------------------------
/src/main/resources/stoneblock2.schematic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevOnTheRocks/SkyClaims/HEAD/src/main/resources/stoneblock2.schematic
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Version
2 | major=0
3 | minor=32
4 | patch=1
5 | api=S7.13
6 | suffix=GRIEF-DEFENDER-2-SNAPSHOT
7 | ## Dependencies
8 | spongeapi=7.3.0
9 | spongeforge=1.12.2-2768-7.1.4
10 | forge=14.23.5.2768
11 | griefdefender=2.0.0
12 | nucleus=2.3.2
13 | bstats=2.2.1
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun May 12 10:08:07 EDT 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /*
2 | !/.github/
3 | !/.idea/
4 | /.idea/*
5 | !/.idea/runConfigurations/
6 | !/gradle/
7 | !/src/
8 | !/lib/
9 | !/.gitignore
10 | !/build.gradle
11 | !/gradlew*
12 | !/CHANGELOG*.md
13 | !/LICENSE.md
14 | !/README*.md
15 | !/settings.gradle
16 | !/intellij-java-google-style.xml
17 | !/.travis.yml
18 | !/gradle.properties
19 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | sudo: required
4 |
5 | script:
6 | - ./gradlew build
7 |
8 | jdk:
9 | - openjdk8
10 |
11 | before_cache:
12 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
13 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
14 | cache:
15 | directories:
16 | - $HOME/.gradle/caches/
17 | - $HOME/.gradle/wrapper/
18 |
19 | notifications:
20 | email: false
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
6 |
7 | ### Version:
8 |
9 |
10 | - **Sponge:**
11 | - **SkyClaims:**
12 | - **GriefPrevention:**
13 | - **Permissions:**
14 |
15 | ### Expected Behavior:
16 |
17 |
18 |
19 | ### Actual Behavior:
20 |
21 |
23 |
24 | ### Steps To Reproduce:
25 |
26 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/Targets.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | public enum Targets {
22 | BLOCK, CHUNK, ISLAND;
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/gen/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.world.gen;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/team/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.team;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/user/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.user;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/admin/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.admin;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/debug/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.debug;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | @NonnullByDefault
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import org.spongepowered.api.util.annotation.NonnullByDefault;
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/exception/CreateIslandException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.exception;
20 |
21 | import org.spongepowered.api.text.Text;
22 |
23 | public class CreateIslandException extends SkyClaimsException {
24 |
25 | public CreateIslandException(Text message) {
26 | super(message);
27 | }
28 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/exception/InvalidRegionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.exception;
20 |
21 | import org.spongepowered.api.text.Text;
22 |
23 | public class InvalidRegionException extends SkyClaimsException {
24 |
25 | public InvalidRegionException(Text message) {
26 | super(message);
27 | }
28 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations/SpongeForge.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/region/IRegionPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world.region;
20 |
21 | import java.util.ArrayList;
22 | import net.mohron.skyclaims.exception.InvalidRegionException;
23 |
24 | public interface IRegionPattern {
25 |
26 | ArrayList generateRegionPattern();
27 |
28 | public Region nextRegion() throws InvalidRegionException;
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/Coordinate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world;
20 |
21 | public class Coordinate {
22 |
23 | private int x;
24 | private int z;
25 |
26 | public Coordinate(int x, int z) {
27 | this.x = x;
28 | this.z = z;
29 | }
30 |
31 | public int getX() {
32 | return x;
33 | }
34 |
35 | public int getZ() {
36 | return z;
37 | }
38 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/exception/SkyClaimsException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.exception;
20 |
21 | import org.spongepowered.api.text.Text;
22 | import org.spongepowered.api.util.TextMessageException;
23 |
24 | public class SkyClaimsException extends TextMessageException {
25 |
26 | private Text message;
27 |
28 | public SkyClaimsException(Text message) {
29 | super(message);
30 | this.message = message;
31 | }
32 |
33 | public Text getText() {
34 | return message;
35 | }
36 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/database/IDatabase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.database;
20 |
21 | import java.util.Collection;
22 | import java.util.Map;
23 | import java.util.UUID;
24 | import net.mohron.skyclaims.world.Island;
25 |
26 | public interface IDatabase {
27 |
28 | Map loadData();
29 |
30 | void saveData(Collection islands);
31 |
32 | void saveData(Map islands);
33 |
34 | void saveIsland(Island island);
35 |
36 | void removeIsland(Island island);
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/integration/PluginIntegration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type.integration;
20 |
21 | import ninja.leaping.configurate.objectmapping.Setting;
22 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
23 |
24 | @ConfigSerializable
25 | public abstract class PluginIntegration {
26 |
27 | @Setting(value = "Enabled", comment = "Set to enable/disable integration.")
28 | private boolean enabled = true;
29 |
30 | public boolean isEnabled() {
31 | return enabled;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/PluginInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims;
20 |
21 | public final class PluginInfo {
22 |
23 | public static final String ID = "skyclaims";
24 | public static final String NAME = "@NAME@";
25 | public static final String VERSION = "@VERSION@";
26 | public static final String DESCRIPTION = "@DESCRIPTION@";
27 | public static final String AUTHORS = "Mohron";
28 | public static final String SPONGE_API = "@SPONGE_API@";
29 | public static final String GD_VERSION = "[@GRIEF_DEFENDER@,)";
30 | public static final double GD_API_VERSION = 2.0D;
31 | public static final String NUCLEUS_VERSION = "@NUCLEUS@";
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/CommandConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import com.google.common.collect.Lists;
22 | import java.util.List;
23 | import ninja.leaping.configurate.objectmapping.Setting;
24 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
25 |
26 | @ConfigSerializable
27 | public class CommandConfig {
28 |
29 | @Setting(value = "Base-Command-Alias", comment = "The alias to use as the base command.")
30 | private List baseAlias = Lists.newArrayList("is", "island");
31 |
32 | public List getBaseAlias() {
33 | return baseAlias.isEmpty() ? Lists.newArrayList("is") : baseAlias;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/integration/GriefDefenderConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type.integration;
20 |
21 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
22 |
23 | @ConfigSerializable
24 | public class GriefDefenderConfig {
25 |
26 | // @Setting(value = "Wilderness-Flags", comment = "Use to set up default flags to be set on the Wilderness claim.")
27 | // private Map wildernessFlags = new HashMap() {{
28 | // put(Flags.BLOCK_BREAK, false);
29 | // put(Flags.BLOCK_PLACE, false);
30 | // }};
31 | //
32 | // public Map getWildernessFlags() {
33 | // return wildernessFlags;
34 | // }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/IntegrationConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import net.mohron.skyclaims.config.type.integration.GriefDefenderConfig;
22 | import net.mohron.skyclaims.config.type.integration.NucleusConfig;
23 | import ninja.leaping.configurate.objectmapping.Setting;
24 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
25 |
26 | @ConfigSerializable
27 | public class IntegrationConfig {
28 |
29 | @Setting(value = "Grief-Prevention")
30 | private GriefDefenderConfig griefDefenderConfig = new GriefDefenderConfig();
31 |
32 | @Setting(value = "Nucleus")
33 | private NucleusConfig nucleus = new NucleusConfig();
34 |
35 | public GriefDefenderConfig getGriefDefender() {
36 | return griefDefenderConfig;
37 | }
38 |
39 | public NucleusConfig getNucleus() {
40 | return nucleus;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/EconomyConfig.java:
--------------------------------------------------------------------------------
1 | package net.mohron.skyclaims.config.type;
2 |
3 | import java.util.Optional;
4 | import ninja.leaping.configurate.objectmapping.Setting;
5 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
6 | import org.spongepowered.api.Sponge;
7 | import org.spongepowered.api.service.economy.Currency;
8 | import org.spongepowered.api.service.economy.EconomyService;
9 |
10 | @ConfigSerializable
11 | public class EconomyConfig {
12 |
13 | @Setting(value = "use-claim-blocks", comment = "If set to true, claim blocks will be used as a currency.")
14 | private boolean useClaimBlocks = false;
15 |
16 | @Setting(value = "currency", comment = "The name of the currency to use when a Economy plugin is available.\n"
17 | + "The default currency will be used if not configured or an invalid currency is configured.")
18 | private String currency = "";
19 |
20 | @Setting(value = "cost-modifier", comment = "The cost of expanding is based on the number of blocks the expansion adds.\n"
21 | + "This will be multiplied by the number of blocks to calculate the final cost.")
22 | private double costModifier = 1.0;
23 |
24 | public boolean isUseClaimBlocks() {
25 | return useClaimBlocks;
26 | }
27 |
28 | public Optional getCurrency() {
29 | return Sponge.getServiceManager().provide(EconomyService.class)
30 | .flatMap(economyService -> economyService.getCurrencies().stream()
31 | .filter(c -> c.getName().equalsIgnoreCase(currency))
32 | .findAny());
33 | }
34 |
35 | public double getCostModifier() {
36 | return Math.max(0, costModifier);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/integration/NucleusConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type.integration;
20 |
21 | import ninja.leaping.configurate.objectmapping.Setting;
22 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
23 |
24 | @ConfigSerializable
25 | public class NucleusConfig extends PluginIntegration {
26 |
27 | @Setting(value = "First-Join-Kit", comment =
28 | "Not Implemented. Add \"kit give @p firstJoinKit\" to Reset-Commands."
29 | + "\nSet to enable/disable redeeming Nucleus' FirstJoinKit when using /is reset.")
30 | private boolean firstJoinKit = true;
31 | @Setting(value = "Island-Home", comment = "Set to enable/disable /is sethome & /is home as a configurable home separate from an island spawn.")
32 | private boolean homesEnabled = true;
33 |
34 | public boolean isFirstJoinKit() {
35 | return firstJoinKit;
36 | }
37 |
38 | public boolean isHomesEnabled() {
39 | return homesEnabled;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/Arguments.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import net.mohron.skyclaims.team.PrivilegeType;
22 | import org.spongepowered.api.text.Text;
23 |
24 | public final class Arguments {
25 |
26 | private Arguments() {
27 | }
28 |
29 | public static BiomeArgument biome(Text key) {
30 | return new BiomeArgument(key);
31 | }
32 |
33 | public static IslandArgument island(Text key, PrivilegeType type) {
34 | return new IslandArgument(key, type);
35 | }
36 |
37 | public static IslandArgument island(Text key) {
38 | return new IslandArgument(key);
39 | }
40 |
41 | public static PositiveIntegerArgument positiveInteger(Text key) {
42 | return new PositiveIntegerArgument(key);
43 | }
44 |
45 | public static SchematicArgument schematic(Text key) {
46 | return new SchematicArgument(key);
47 | }
48 |
49 | public static TargetArgument target(Text key) {
50 | return new TargetArgument(key);
51 | }
52 |
53 | public static TwoUserArgument twoUser(Text key, Text key2) {
54 | return new TwoUserArgument(key, key2);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/PermissionConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import ninja.leaping.configurate.objectmapping.Setting;
22 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
23 |
24 | @ConfigSerializable
25 | public class PermissionConfig {
26 |
27 | @Setting(value = "Separate-BiomeType-Permissions", comment = "Enable permission checking for the Biome Type Argument.")
28 | private boolean separateBiomePerms = false;
29 | @Setting(value = "Separate-Schematic-Permissions", comment = "Enable permission checking for the Schematic Argument.")
30 | private boolean separateSchematicPerms = false;
31 | @Setting(value = "Separate-Target-Permissions", comment = "Enable permission checking for the Target Argument.")
32 | private boolean separateTargetPerms = false;
33 |
34 | public boolean isSeparateBiomePerms() {
35 | return separateBiomePerms;
36 | }
37 |
38 | public boolean isSeparateSchematicPerms() {
39 | return separateSchematicPerms;
40 | }
41 |
42 | public boolean isSeparateTargetPerms() {
43 | return separateTargetPerms;
44 | }
45 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/CommandRequirement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command;
20 |
21 | import net.mohron.skyclaims.world.Island;
22 | import org.spongepowered.api.command.CommandException;
23 | import org.spongepowered.api.command.CommandResult;
24 | import org.spongepowered.api.command.CommandSource;
25 | import org.spongepowered.api.command.args.CommandContext;
26 | import org.spongepowered.api.command.spec.CommandExecutor;
27 | import org.spongepowered.api.entity.living.player.Player;
28 | import org.spongepowered.api.util.annotation.NonnullByDefault;
29 |
30 | @NonnullByDefault
31 | public interface CommandRequirement extends CommandExecutor {
32 |
33 | interface RequiresIsland {
34 |
35 | CommandResult execute(CommandSource src, Island island, CommandContext args) throws CommandException;
36 | }
37 |
38 | interface RequiresPlayer {
39 |
40 | CommandResult execute(Player player, CommandContext args) throws CommandException;
41 | }
42 |
43 | interface RequiresPlayerIsland {
44 |
45 | CommandResult execute(Player player, Island island, CommandContext args) throws CommandException;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/ExpirationConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import com.google.common.base.Preconditions;
22 | import ninja.leaping.configurate.objectmapping.Setting;
23 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
24 |
25 | @ConfigSerializable
26 | public class ExpirationConfig {
27 |
28 | @Setting(value = "Enabled", comment = "Whether SkyClaims should remove inactive islands that exceed the expiration threshold.")
29 | private boolean enabled = false;
30 | @Setting(value = "Interval", comment = "The frequency, in minutes, that islands will be considered for removal.")
31 | private int interval = 15;
32 | @Setting(value = "Threshold", comment =
33 | "The amount of time, in days, that an island must be inactive before removal.\n" +
34 | "Can be overridden with the 'skyclaims.expiration' option.")
35 | private int threshold = 30;
36 |
37 | public boolean isEnabled() {
38 | return enabled;
39 | }
40 |
41 | public int getInterval() {
42 | Preconditions.checkState(interval > 0);
43 | return interval;
44 | }
45 |
46 | public int getThreshold() {
47 | Preconditions.checkState(threshold > 0);
48 | return threshold;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/MysqlConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import ninja.leaping.configurate.objectmapping.Setting;
22 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
23 |
24 | @ConfigSerializable
25 | public class MysqlConfig {
26 |
27 | @Setting("Name")
28 | private String databaseName;
29 | @Setting("Location")
30 | private String location;
31 | @Setting("Table-Prefix (not implemented)")
32 | private String tablePrefix;
33 | @Setting("Username")
34 | private String username;
35 | @Setting("Password")
36 | private String password;
37 | @Setting("Port")
38 | private Integer port;
39 |
40 | public MysqlConfig() {
41 | databaseName = "skyclaims";
42 | location = "localhost";
43 | tablePrefix = "";
44 | username = "skyclaims";
45 | password = "skyclaims";
46 | port = 3306;
47 | }
48 |
49 | public String getDatabaseName() {
50 | return databaseName;
51 | }
52 |
53 | public String getLocation() {
54 | return location;
55 | }
56 |
57 | public String getPassword() {
58 | return password;
59 | }
60 |
61 | public String getTablePrefix() {
62 | return tablePrefix;
63 | }
64 |
65 | public String getUsername() {
66 | return username;
67 | }
68 |
69 | public int getPort() {
70 | return (port != null) ? port : 3306;
71 | }
72 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/StorageConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import java.io.File;
22 | import net.mohron.skyclaims.SkyClaims;
23 | import ninja.leaping.configurate.objectmapping.Setting;
24 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
25 |
26 | @ConfigSerializable
27 | public class StorageConfig {
28 |
29 | @Setting(value = "Location", comment = "The location to store SkyClaims data. Default: ${CONFIG}/data")
30 | private String location;
31 | @Setting(value = "Type", comment = "The type of data storage to use. Supports [SQLite, MySQL]")
32 | private String type;
33 | @Setting(value = "MySQL", comment = "MySQL Not Yet Implemented!")
34 | private MysqlConfig mysqlConfig;
35 |
36 | public StorageConfig() {
37 | location = "${CONFIG}/data";
38 | type = "SQLite";
39 | mysqlConfig = new MysqlConfig();
40 | }
41 |
42 | public String getLocation() {
43 | return location
44 | .replace("*CONFIG*", SkyClaims.getInstance().getConfigDir().toString())
45 | .replace("${CONFIG}", SkyClaims.getInstance().getConfigDir().toString())
46 | .replace("/", File.separator)
47 | .replace("\\", File.separator);
48 | }
49 |
50 | public String getType() {
51 | return type;
52 | }
53 |
54 | public MysqlConfig getMysqlConfig() {
55 | return mysqlConfig;
56 | }
57 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/EntityConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import ninja.leaping.configurate.objectmapping.Setting;
22 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
23 |
24 | @ConfigSerializable
25 | public class EntityConfig {
26 |
27 | @Setting(value = "Limit-Spawning", comment = "Whether SkyClaims should limit island entity spawns.")
28 | private boolean limitSpawning = false;
29 | @Setting(value = "Max-Hostile", comment =
30 | "The max number of hostile mob spawns allowed per island. 0 to disable.\n" +
31 | "Can be overridden with the 'skyclaims.max-spawns.hostile' option.")
32 | private int maxHostile = 50;
33 | @Setting(value = "Max-Passive", comment =
34 | "The max number of passive mob spawns allowed per island. 0 to disable.\n" +
35 | "Can be overridden with the 'skyclaims.max-spawns.passive' option.")
36 | private int maxPassive = 30;
37 | @Setting(value = "Max-Spawns", comment =
38 | "The overall max number of mob spawns allowed per island. 0 to disable.\n" +
39 | "Can be overridden with the 'skyclaims.max-spawns' option.")
40 | private int maxSpawns = 70;
41 |
42 | public boolean isLimitSpawning() {
43 | return limitSpawning;
44 | }
45 |
46 | public int getMaxHostile() {
47 | return maxHostile;
48 | }
49 |
50 | public int getMaxPassive() {
51 | return maxPassive;
52 | }
53 |
54 | public int getMaxSpawns() {
55 | return maxSpawns;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/listener/RespawnHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 | package net.mohron.skyclaims.listener;
19 |
20 | import java.util.Optional;
21 | import net.mohron.skyclaims.SkyClaims;
22 | import net.mohron.skyclaims.SkyClaimsTimings;
23 | import net.mohron.skyclaims.world.Island;
24 | import net.mohron.skyclaims.world.IslandManager;
25 | import org.spongepowered.api.Sponge;
26 | import org.spongepowered.api.entity.living.player.Player;
27 | import org.spongepowered.api.event.Listener;
28 | import org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent;
29 | import org.spongepowered.api.event.filter.cause.Root;
30 | import org.spongepowered.api.world.World;
31 |
32 | public class RespawnHandler {
33 |
34 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
35 |
36 | @Listener
37 | public void onPlayerRespawn(RespawnPlayerEvent event, @Root Player player) {
38 | SkyClaimsTimings.PLAYER_RESPAWN.startTimingIfSync();
39 | World world = PLUGIN.getConfig().getWorldConfig().getWorld();
40 |
41 | if (!event.isDeath() || !world.equals(event.getFromTransform().getExtent())) {
42 | SkyClaimsTimings.PLAYER_RESPAWN.abort();
43 | return;
44 | }
45 |
46 | final Optional island = IslandManager.getByTransform(event.getFromTransform());
47 | if (island.isPresent() && island.get().isMember(player)) {
48 | Sponge.getTeleportHelper()
49 | .getSafeLocation(island.get().getSpawn().getLocation())
50 | .ifPresent(spawn -> event.setToTransform(island.get().getSpawn().setLocation(spawn)));
51 | }
52 |
53 | SkyClaimsTimings.PLAYER_RESPAWN.stopTimingIfSync();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/integration/Version.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.integration;
20 |
21 | import javax.annotation.Nonnull;
22 | import org.apache.commons.lang3.text.StrBuilder;
23 |
24 | public class Version implements Comparable {
25 |
26 | @Nonnull
27 | private final int[] numbers;
28 |
29 | private Version(@Nonnull String version) {
30 | final String split[] = version.split("-")[0].split(".");
31 | numbers = new int[split.length];
32 | for (int i = 0; i < split.length; i++) {
33 | numbers[i] = Integer.valueOf(split[i]);
34 | }
35 | }
36 |
37 | public static Version of(@Nonnull String string) {
38 | return new Version(string);
39 | }
40 |
41 | @Override
42 | public int compareTo(@Nonnull Version other) {
43 | final int maxLength = Math.max(numbers.length, other.numbers.length);
44 | for (int i = 0; i < maxLength; i++) {
45 | final int left = i < numbers.length ? numbers[i] : 0;
46 | final int right = i < other.numbers.length ? other.numbers[i] : 0;
47 | if (left != right) {
48 | return left < right ? -1 : 1;
49 | }
50 | }
51 | return 0;
52 | }
53 |
54 | public int compareTo(@Nonnull String other) {
55 | return compareTo(new Version(other));
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | if (numbers.length == 0) {
61 | return "";
62 | }
63 | StrBuilder version = new StrBuilder();
64 | version.append(numbers[0]);
65 | for (int i = 1; i < numbers.length; i++) {
66 | version.append(".");
67 | version.append(numbers[i]);
68 | }
69 | return version.build();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/SkyClaimsTimings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims;
20 |
21 | import co.aikar.timings.Timing;
22 | import co.aikar.timings.Timings;
23 |
24 | public final class SkyClaimsTimings {
25 |
26 | private SkyClaimsTimings(){
27 | }
28 |
29 | // TASKS
30 | public static final Timing GENERATE_ISLAND = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onGenerateIsland");
31 | public static final Timing CLEAR_ISLAND = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onClearIsland");
32 | public static final Timing ISLAND_CLEANUP = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onIslandCleanupTask");
33 |
34 | // LISTENERS
35 | public static final Timing CLIENT_JOIN = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onClientJoin");
36 | public static final Timing CREATE_ISLAND_ON_JOIN = Timings.of(SkyClaims.getInstance().getPluginContainer(), "createIslandOnJoin", CLIENT_JOIN);
37 | public static final Timing DELIVER_INVITES = Timings.of(SkyClaims.getInstance().getPluginContainer(), "deliverInvites", CLIENT_JOIN);
38 | public static final Timing ENTITY_SPAWN = Timings.of(SkyClaims.getInstance().getPluginContainer(), "EntitySpawn");
39 | public static final Timing PLAYER_RESPAWN = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onPlayerRespawn");
40 | public static final Timing SCHEMATIC_HANDLER = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onSelectSchematic");
41 | public static final Timing WORLD_LOAD = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onWorldLoad");
42 | public static final Timing CLAIM_HANDLER = Timings.of(SkyClaims.getInstance().getPluginContainer(), "onClaimEvent");
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/database/MysqlDatabase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.database;
20 |
21 | import java.sql.Connection;
22 | import java.sql.DriverManager;
23 | import java.sql.SQLException;
24 | import net.mohron.skyclaims.SkyClaims;
25 | import net.mohron.skyclaims.config.type.MysqlConfig;
26 |
27 | public class MysqlDatabase extends Database {
28 |
29 | private MysqlConfig config;
30 | private String connectionString;
31 | private String databaseLocation;
32 | private String databaseTablePrefix;
33 | private String databaseName;
34 | private String username;
35 | private String password;
36 | private Integer port;
37 |
38 | public MysqlDatabase() {
39 | this.config = SkyClaims.getInstance().getConfig().getStorageConfig().getMysqlConfig();
40 | databaseLocation = config.getLocation();
41 | databaseTablePrefix = config.getTablePrefix();
42 | databaseName = config.getDatabaseName();
43 | username = config.getUsername();
44 | password = config.getPassword();
45 | port = config.getPort();
46 | connectionString = String.format("jdbc:mysql://%s:%s/%s", databaseLocation, port, databaseName);
47 |
48 | try {
49 | Class.forName("com.mysql.jdbc.Driver");
50 | getConnection();
51 | } catch (ClassNotFoundException e) {
52 | SkyClaims.getInstance().getLogger().error("Unable to load MySQL JDBC driver!", e);
53 | } catch (SQLException e) {
54 | SkyClaims.getInstance().getLogger().error("Unable to connect to the database:", e);
55 | }
56 |
57 | createTable();
58 | }
59 |
60 | Connection getConnection() throws SQLException {
61 | return DriverManager.getConnection(connectionString, username, password);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/admin/CommandReload.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.admin;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import org.spongepowered.api.command.CommandException;
25 | import org.spongepowered.api.command.CommandResult;
26 | import org.spongepowered.api.command.CommandSource;
27 | import org.spongepowered.api.command.args.CommandContext;
28 | import org.spongepowered.api.command.spec.CommandSpec;
29 | import org.spongepowered.api.text.Text;
30 | import org.spongepowered.api.text.format.TextColors;
31 |
32 | public class CommandReload extends CommandBase {
33 |
34 | public static final String HELP_TEXT = "used to reload SkyClaims's config, schematics, & database.";
35 |
36 | public static CommandSpec commandSpec = CommandSpec.builder()
37 | .permission(Permissions.COMMAND_RELOAD)
38 | .description(Text.of(HELP_TEXT))
39 | .executor(new CommandReload())
40 | .build();
41 |
42 | public static void register() {
43 | try {
44 | CommandIsland.addSubCommand(commandSpec, "reload");
45 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
46 | PLUGIN.getLogger().debug("Registered command: CommandReload");
47 | } catch (UnsupportedOperationException e) {
48 | PLUGIN.getLogger().error("Failed to register command: CommandReload", e);
49 | }
50 | }
51 |
52 | @Override
53 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
54 | PLUGIN.reload();
55 | src.sendMessage(Text.of(TextColors.GREEN, "Successfully reloaded SkyClaims!"));
56 | return CommandResult.success();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/PositiveIntegerArgument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import com.google.common.collect.Lists;
22 | import java.util.List;
23 | import javax.annotation.Nullable;
24 | import org.spongepowered.api.command.CommandSource;
25 | import org.spongepowered.api.command.args.ArgumentParseException;
26 | import org.spongepowered.api.command.args.CommandArgs;
27 | import org.spongepowered.api.command.args.CommandContext;
28 | import org.spongepowered.api.command.args.CommandElement;
29 | import org.spongepowered.api.text.Text;
30 | import org.spongepowered.api.text.format.TextColors;
31 |
32 | public class PositiveIntegerArgument extends CommandElement {
33 |
34 | private final boolean allowZero;
35 |
36 | public PositiveIntegerArgument(@Nullable Text key) {
37 | this(key, false);
38 | }
39 |
40 | public PositiveIntegerArgument(@Nullable Text key, boolean allowZero) {
41 | super(key);
42 | this.allowZero = allowZero;
43 | }
44 |
45 | @Nullable
46 | @Override
47 | protected Object parseValue(CommandSource source, CommandArgs args)
48 | throws ArgumentParseException {
49 | String i = args.next();
50 | try {
51 | int a = Integer.parseUnsignedInt(i);
52 | if (allowZero || a != 0) {
53 | return a;
54 | }
55 |
56 | throw new ArgumentParseException(Text.of(TextColors.RED, "Zero is not a valid input!"), i, 0);
57 | } catch (NumberFormatException e) {
58 | throw new ArgumentParseException(Text.of(TextColors.RED, "A positive integer is required!"),
59 | i, 0);
60 | }
61 | }
62 |
63 | @Override
64 | public List complete(CommandSource src, CommandArgs args, CommandContext context) {
65 | return Lists.newArrayList();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ grief-defender, feature/mysql, feature/world-gen, sponge/api-5, sponge/api-7 ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ grief-defender ]
20 | schedule:
21 | - cron: '23 11 * * 5'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 |
28 | strategy:
29 | fail-fast: false
30 | matrix:
31 | language: [ 'java' ]
32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
33 | # Learn more:
34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
35 |
36 | steps:
37 | - name: Checkout repository
38 | uses: actions/checkout@v2
39 |
40 | # Initializes the CodeQL tools for scanning.
41 | - name: Initialize CodeQL
42 | uses: github/codeql-action/init@v1
43 | with:
44 | languages: ${{ matrix.language }}
45 | # If you wish to specify custom queries, you can do so here or in a config file.
46 | # By default, queries listed here will override any specified in a config file.
47 | # Prefix the list here with "+" to use these queries and those in the config file.
48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
49 |
50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
51 | # If this step fails, then you should remove it and run the build manually (see below)
52 | - name: Autobuild
53 | uses: github/codeql-action/autobuild@v1
54 |
55 | # ℹ️ Command-line programs to run using the OS shell.
56 | # 📚 https://git.io/JvXDl
57 |
58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
59 | # and modify them (or add more) to build your code if your project
60 | # uses a compiled language
61 |
62 | #- run: |
63 | # make bootstrap
64 | # make release
65 |
66 | - name: Perform CodeQL Analysis
67 | uses: github/codeql-action/analyze@v1
68 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/region/Region.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world.region;
20 |
21 | import lombok.EqualsAndHashCode;
22 | import net.mohron.skyclaims.SkyClaims;
23 | import net.mohron.skyclaims.world.Coordinate;
24 | import net.mohron.skyclaims.world.Island;
25 | import net.mohron.skyclaims.world.IslandManager;
26 | import org.spongepowered.api.world.Location;
27 | import org.spongepowered.api.world.World;
28 |
29 | @EqualsAndHashCode
30 | public class Region {
31 |
32 | private int x;
33 | private int z;
34 |
35 | public Region(int x, int z) {
36 | this.x = x;
37 | this.z = z;
38 | }
39 |
40 | public static boolean isOccupied(Region region) {
41 | if (IslandManager.ISLANDS.isEmpty()) {
42 | return false;
43 | }
44 |
45 | for (Island island : IslandManager.ISLANDS.values()) {
46 | if (region.equals(island.getRegion())) {
47 | return true;
48 | }
49 | }
50 |
51 | return false;
52 | }
53 |
54 | public static Region get(Location location) {
55 | return new Region(location.getBlockX() >> 4 >> 5, location.getBlockZ() >> 4 >> 5);
56 | }
57 |
58 | public int getX() {
59 | return x;
60 | }
61 |
62 | public int getZ() {
63 | return z;
64 | }
65 |
66 | public Coordinate getLesserBoundary() {
67 | return new Coordinate(x << 5 << 4, z << 5 << 4);
68 | }
69 |
70 | public Coordinate getGreaterBoundary() {
71 | return new Coordinate((((x + 1) << 5) << 4) - 1, (((z + 1) << 5) << 4) - 1);
72 | }
73 |
74 | public Location getCenter() {
75 | return new Location<>(
76 | SkyClaims.getInstance().getConfig().getWorldConfig().getWorld(),
77 | (getGreaterBoundary().getX() + getLesserBoundary().getX()) / 2.0,
78 | SkyClaims.getInstance().getConfig().getWorldConfig().getIslandHeight(),
79 | (getGreaterBoundary().getZ() + getLesserBoundary().getZ()) / 2.0
80 | );
81 | }
82 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/integration/nucleus/NucleusIntegration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.integration.nucleus;
20 |
21 | import io.github.nucleuspowered.nucleus.api.core.NucleusAPIMetaService;
22 | import net.mohron.skyclaims.PluginInfo;
23 | import net.mohron.skyclaims.SkyClaims;
24 | import net.mohron.skyclaims.integration.Version;
25 | import org.spongepowered.api.Sponge;
26 | import org.spongepowered.api.event.Listener;
27 | import org.spongepowered.api.event.Order;
28 | import org.spongepowered.api.event.game.GameReloadEvent;
29 | import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
30 | import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
31 |
32 | public class NucleusIntegration {
33 |
34 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
35 |
36 | @Listener
37 | public void onPostInitialization(GamePostInitializationEvent event) {
38 | NucleusAPIMetaService metaService = Sponge.getServiceManager().provideUnchecked(NucleusAPIMetaService.class);
39 | if (Version.of(metaService.semanticVersion()).compareTo(PluginInfo.NUCLEUS_VERSION) >= 0) {
40 | PLUGIN.getLogger().info("Successfully integrated with Nucleus {}!", metaService.version());
41 | } else {
42 | PLUGIN.getLogger().info("Found Nucleus {}. SkyClaims requires Nucleus {}+.", metaService.semanticVersion(), PluginInfo.NUCLEUS_VERSION);
43 | Sponge.getEventManager().unregisterListeners(this);
44 | }
45 | }
46 |
47 | @Listener(order = Order.EARLY)
48 | public void onGameAboutToStart(GameAboutToStartServerEvent event) {
49 | initHomeSupport();
50 | }
51 |
52 | @Listener(order = Order.EARLY)
53 | public void onReload(GameReloadEvent event) {
54 | initHomeSupport();
55 | }
56 |
57 | private void initHomeSupport() {
58 | if (PLUGIN.getConfig().getIntegrationConfig().getNucleus().isHomesEnabled()) {
59 | CommandHome.register();
60 | CommandSetHome.register();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/team/PrivilegeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.team;
20 |
21 | import com.google.common.collect.Maps;
22 | import com.griefdefender.api.claim.TrustType;
23 | import com.griefdefender.api.claim.TrustTypes;
24 | import java.util.Map;
25 | import org.spongepowered.api.command.args.CommandElement;
26 | import org.spongepowered.api.command.args.GenericArguments;
27 | import org.spongepowered.api.text.Text;
28 | import org.spongepowered.api.text.action.TextActions;
29 | import org.spongepowered.api.text.format.TextColors;
30 |
31 | public enum PrivilegeType {
32 | OWNER(Text.of(TextColors.BLUE, "Owner"), TrustTypes.NONE),
33 | MANAGER(Text.of(TextColors.GOLD, "Manager"), TrustTypes.MANAGER),
34 | MEMBER(Text.of(TextColors.YELLOW, "Member"), TrustTypes.BUILDER),
35 | NONE(Text.of(TextColors.GRAY, "None"), TrustTypes.NONE);
36 |
37 | private Text text;
38 | private TrustType trustType;
39 |
40 | PrivilegeType(Text text, TrustType trustType) {
41 | this.text = text;
42 | this.trustType = trustType;
43 | }
44 |
45 | public Text format(Text text) {
46 | return format(text.toPlain());
47 | }
48 |
49 | public Text format(String string) {
50 | return Text.builder(string)
51 | .color(text.getColor())
52 | .onHover(TextActions.showText(text))
53 | .build();
54 | }
55 |
56 | public Text toText() {
57 | return text;
58 | }
59 |
60 | public TrustType getTrustType() {
61 | return trustType;
62 | }
63 |
64 | public static CommandElement getCommandArgument(Text key) {
65 | Map typeMap = Maps.newHashMap();
66 | for (PrivilegeType type : values()) {
67 | if (type != NONE) {
68 | typeMap.put(type.toString().toLowerCase(), type);
69 | }
70 | }
71 | return GenericArguments.choices(key, typeMap);
72 | }
73 |
74 | public boolean greaterThanOrEqualTo(PrivilegeType other) {
75 | return this.ordinal() <= other.ordinal();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/gen/EndPortalFixPopulator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world.gen;
20 |
21 | import java.util.Locale;
22 | import java.util.Random;
23 | import javax.annotation.Nonnull;
24 | import org.spongepowered.api.block.BlockState;
25 | import org.spongepowered.api.block.BlockTypes;
26 | import org.spongepowered.api.text.translation.Translation;
27 | import org.spongepowered.api.world.World;
28 | import org.spongepowered.api.world.extent.Extent;
29 | import org.spongepowered.api.world.gen.Populator;
30 | import org.spongepowered.api.world.gen.PopulatorType;
31 |
32 | public class EndPortalFixPopulator implements Populator {
33 |
34 | @Nonnull
35 | @Override
36 | public PopulatorType getType() {
37 | return new PopulatorType() {
38 | @Nonnull
39 | @Override
40 | public String getId() {
41 | return "endportalfix";
42 | }
43 |
44 | @Override
45 | public String getName() {
46 | return "End Portal Fix";
47 | }
48 |
49 | @Nonnull
50 | @Override
51 | public Translation getTranslation() {
52 | return new Translation() {
53 | @Nonnull
54 | @Override
55 | public String getId() {
56 | return getType().getId();
57 | }
58 |
59 | @Nonnull
60 | @Override
61 | public String get(@Nonnull Locale locale) {
62 | return getName();
63 | }
64 |
65 | @Nonnull
66 | @Override
67 | public String get(@Nonnull Locale locale, @Nonnull Object... args) {
68 | return getName();
69 | }
70 | };
71 | }
72 | };
73 | }
74 |
75 | @Override
76 | public void populate(@Nonnull World world, @Nonnull Extent volume, @Nonnull Random random) {
77 | if (volume.containsBlock(0, 64, 0) && volume.getBlockType(0, 64, 0).equals(BlockTypes.AIR)) {
78 | world.setBlock(0, 64, 0, BlockState.builder().blockType(BlockTypes.END_STONE).build());
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/RegenerateChunkTask.java:
--------------------------------------------------------------------------------
1 | package net.mohron.skyclaims.world;
2 |
3 | import com.flowpowered.math.vector.Vector3i;
4 | import net.mohron.skyclaims.SkyClaims;
5 | import net.mohron.skyclaims.SkyClaimsTimings;
6 | import org.spongepowered.api.block.BlockState;
7 | import org.spongepowered.api.block.tileentity.carrier.TileEntityCarrier;
8 | import org.spongepowered.api.entity.Entity;
9 | import org.spongepowered.api.entity.living.player.Player;
10 | import org.spongepowered.api.world.BlockChangeFlags;
11 | import org.spongepowered.api.world.Chunk;
12 | import org.spongepowered.api.world.Location;
13 | import org.spongepowered.api.world.World;
14 |
15 | public class RegenerateChunkTask implements Runnable {
16 |
17 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
18 |
19 | private final World world;
20 | private final Vector3i position;
21 | private final BlockState[] blocks;
22 | private final Location spawn;
23 |
24 | public RegenerateChunkTask(World world, Vector3i position, BlockState[] blocks, Location spawn) {
25 | this.world = world;
26 | this.position = position;
27 | this.blocks = blocks;
28 | this.spawn = spawn;
29 | }
30 |
31 |
32 | @Override
33 | public void run() {
34 | SkyClaimsTimings.CLEAR_ISLAND.startTimingIfSync();
35 |
36 | final Chunk chunk = world.loadChunk(position, true).orElse(null);
37 |
38 | if (chunk == null) {
39 | PLUGIN.getLogger().error("Failed to load chunk {}", position.toString());
40 | return;
41 | }
42 |
43 | PLUGIN.getLogger().debug("Began regenerating chunk {}", position.toString());
44 | // Teleport any players to world spawn
45 | chunk.getEntities(e -> e instanceof Player).forEach(e -> e.setLocationSafely(spawn));
46 | // Clear the contents of an tile entity with an inventory
47 | chunk.getTileEntities(e -> e instanceof TileEntityCarrier).forEach(e -> ((TileEntityCarrier) e).getInventory().clear());
48 | // Set the blocks
49 | for (int by = chunk.getBlockMin().getY(); by <= chunk.getBlockMax().getY(); by++) {
50 | for (int bx = chunk.getBlockMin().getX(); bx <= chunk.getBlockMax().getX(); bx++) {
51 | for (int bz = chunk.getBlockMin().getZ(); bz <= chunk.getBlockMax().getZ(); bz++) {
52 | if (!chunk.getBlock(bx, by, bz).equals(blocks[by])) {
53 | chunk.getLocation(bx, by, bz).setBlock(blocks[by], BlockChangeFlags.NONE);
54 | }
55 | }
56 | }
57 | }
58 | // Remove any remaining entities.
59 | chunk.getEntities(e -> !(e instanceof Player)).forEach(Entity::remove);
60 | chunk.unloadChunk();
61 | PLUGIN.getLogger().debug("Finished regenerating chunk {}", position.toString());
62 |
63 | SkyClaimsTimings.CLEAR_ISLAND.stopTimingIfSync();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicDelete.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.spec.CommandSpec;
30 | import org.spongepowered.api.text.Text;
31 | import org.spongepowered.api.text.format.TextColors;
32 |
33 | public class CommandSchematicDelete extends CommandBase {
34 |
35 | public static final String HELP_TEXT = "deletes a schematic";
36 | private static final Text SCHEMATIC = Text.of("schematic");
37 |
38 | public static CommandSpec commandSpec = CommandSpec.builder()
39 | .permission(Permissions.COMMAND_SCHEMATIC_DELETE)
40 | .description(Text.of(HELP_TEXT))
41 | .arguments(Arguments.schematic(SCHEMATIC))
42 | .executor(new CommandSchematicDelete())
43 | .build();
44 |
45 | public static void register() {
46 | try {
47 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
48 | PLUGIN.getLogger().debug("Registered command: CommandSchematicDelete");
49 | } catch (UnsupportedOperationException e) {
50 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicDelete", e);
51 | }
52 | }
53 |
54 | @Override
55 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
56 | IslandSchematic schematic = args.getOne(SCHEMATIC)
57 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
58 |
59 | if (PLUGIN.getSchematicManager().delete(schematic)) {
60 | src.sendMessage(Text.of(TextColors.GREEN, "Successfully deleted schematic."));
61 | return CommandResult.success();
62 | } else {
63 | throw new CommandException(Text.of(TextColors.RED, "Failed to delete schematic."));
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/util/WorldUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.util;
20 |
21 | import net.mohron.skyclaims.world.Island;
22 | import net.mohron.skyclaims.world.region.Region;
23 | import org.spongepowered.api.world.Location;
24 | import org.spongepowered.api.world.World;
25 | import org.spongepowered.api.world.biome.BiomeType;
26 |
27 | public final class WorldUtil {
28 |
29 | private WorldUtil() {
30 | }
31 |
32 | public static void setBlockBiome(Location location, BiomeType biomeType) {
33 | location.getExtent().setBiome(
34 | location.getBlockX(),
35 | 0,
36 | location.getBlockZ(),
37 | biomeType);
38 | }
39 |
40 | public static void setChunkBiome(Location location, BiomeType biomeType) {
41 | for (int x = 0; x < 16; x++) {
42 | for (int z = 0; z < 16; z++) {
43 | location.getExtent().setBiome(
44 | location.getChunkPosition().getX() * 16 + x,
45 | 0,
46 | location.getChunkPosition().getZ() * 16 + z,
47 | biomeType
48 | );
49 | }
50 | }
51 | }
52 |
53 | public static void setIslandBiome(Island island, BiomeType biomeType) {
54 | if (island.getClaim().isPresent()) {
55 | int x1 = island.getClaim().get().getLesserBoundaryCorner().getX();
56 | int x2 = island.getClaim().get().getGreaterBoundaryCorner().getX();
57 | int z1 = island.getClaim().get().getLesserBoundaryCorner().getZ();
58 | int z2 = island.getClaim().get().getGreaterBoundaryCorner().getZ();
59 | for (int x = x1; x < x2; x++) {
60 | for (int z = z1; z < z2; z++) {
61 | island.getWorld().setBiome(
62 | x,
63 | 0,
64 | z,
65 | biomeType
66 | );
67 | }
68 | }
69 | } else {
70 | setRegionBiome(island, biomeType);
71 | }
72 | }
73 |
74 | public static void setRegionBiome(Island island, BiomeType biomeType) {
75 | Region region = island.getRegion();
76 | for (int x = region.getLesserBoundary().getX(); x < region.getGreaterBoundary().getX(); x++) {
77 | for (int z = region.getLesserBoundary().getZ(); z < region.getGreaterBoundary().getZ(); z++) {
78 | island.getWorld().setBiome(x, 0, z, biomeType);
79 | }
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/GlobalConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import net.mohron.skyclaims.config.ConfigManager;
22 | import ninja.leaping.configurate.objectmapping.Setting;
23 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
24 |
25 | @ConfigSerializable
26 | public class GlobalConfig {
27 |
28 | @Setting(value = "Config-Version")
29 | private int version;
30 | @Setting(value = "Command")
31 | private CommandConfig commandConfig = new CommandConfig();
32 | @Setting(value = "Economy")
33 | private EconomyConfig economyConfig = new EconomyConfig();
34 | @Setting(value = "Entity")
35 | private EntityConfig entityConfig = new EntityConfig();
36 | @Setting(value = "Integration")
37 | private IntegrationConfig integrationConfig = new IntegrationConfig();
38 | @Setting(value = "Island-Expiration")
39 | private ExpirationConfig expirationConfig = new ExpirationConfig();
40 | @Setting(value = "Misc")
41 | private MiscConfig miscConfig = new MiscConfig();
42 | @Setting(value = "Permission")
43 | private PermissionConfig permissionConfig = new PermissionConfig();
44 | @Setting(value = "Storage")
45 | private StorageConfig storageConfig = new StorageConfig();
46 | @Setting(value = "World")
47 | private WorldConfig worldConfig = new WorldConfig();
48 |
49 | public GlobalConfig() {
50 | version = ConfigManager.CONFIG_VERSION;
51 | }
52 |
53 | public int getVersion() {
54 | return version;
55 | }
56 |
57 | public CommandConfig getCommandConfig() {
58 | return commandConfig;
59 | }
60 |
61 | public EconomyConfig getEconomyConfig() {
62 | return economyConfig;
63 | }
64 |
65 | public EntityConfig getEntityConfig() {
66 | return entityConfig;
67 | }
68 |
69 | public IntegrationConfig getIntegrationConfig() {
70 | return integrationConfig;
71 | }
72 |
73 | public ExpirationConfig getExpirationConfig() {
74 | return expirationConfig;
75 | }
76 |
77 | public MiscConfig getMiscConfig() {
78 | return miscConfig;
79 | }
80 |
81 | public PermissionConfig getPermissionConfig() {
82 | return permissionConfig;
83 | }
84 |
85 | public StorageConfig getStorageConfig() {
86 | return storageConfig;
87 | }
88 |
89 | public WorldConfig getWorldConfig() {
90 | return worldConfig;
91 | }
92 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/IslandCleanupTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world;
20 |
21 | import com.google.common.base.Stopwatch;
22 | import com.google.common.collect.ImmutableList;
23 | import java.time.Duration;
24 | import java.time.Instant;
25 | import java.util.Collection;
26 | import java.util.concurrent.CompletableFuture;
27 | import java.util.concurrent.TimeUnit;
28 | import net.mohron.skyclaims.SkyClaims;
29 | import net.mohron.skyclaims.SkyClaimsTimings;
30 | import net.mohron.skyclaims.permissions.Options;
31 | import org.spongepowered.api.Sponge;
32 | import org.spongepowered.api.scheduler.SpongeExecutorService;
33 |
34 | public class IslandCleanupTask implements Runnable {
35 |
36 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
37 | private final ImmutableList islands;
38 |
39 | public IslandCleanupTask(Collection islands) {
40 | this.islands = ImmutableList.copyOf(islands);
41 | }
42 |
43 | @Override
44 | public void run() {
45 | SkyClaimsTimings.ISLAND_CLEANUP.startTimingIfSync();
46 |
47 | PLUGIN.getLogger().info("Starting island cleanup check.");
48 | Stopwatch sw = Stopwatch.createStarted();
49 | SpongeExecutorService asyncExecutor = Sponge.getScheduler().createAsyncExecutor(PLUGIN);
50 | SpongeExecutorService syncExecutor = Sponge.getScheduler().createSyncExecutor(PLUGIN);
51 |
52 | islands.forEach(i -> {
53 | int age = (int) Duration.between(i.getDateLastActive().toInstant(), Instant.now()).toDays();
54 | int threshold = Options.getExpiration(i.getOwnerUniqueId());
55 | if (threshold <= 0 || age < threshold) {
56 | return;
57 | }
58 | PLUGIN.getLogger().info("{} ({},{}) was inactive for {} days and is being removed.",
59 | i.getName().toPlain(), i.getRegion().getX(), i.getRegion().getZ(), age
60 | );
61 | CompletableFuture
62 | .runAsync(RegenerateRegionTask.clear(i.getRegion(), i.getWorld()), asyncExecutor)
63 | .thenRunAsync(i::delete, syncExecutor)
64 | .thenRun(() -> PLUGIN.getLogger().info("{} has been successfully removed.", i.getName().toPlain()));
65 | });
66 |
67 | sw.stop();
68 | PLUGIN.getLogger().info("Finished island cleanup check in {}ms.", sw.elapsed(TimeUnit.MILLISECONDS));
69 |
70 | SkyClaimsTimings.ISLAND_CLEANUP.stopTimingIfSync();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/user/CommandUnlock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.user;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.command.argument.Arguments;
24 | import net.mohron.skyclaims.permissions.Permissions;
25 | import net.mohron.skyclaims.team.PrivilegeType;
26 | import net.mohron.skyclaims.world.Island;
27 | import org.spongepowered.api.command.CommandException;
28 | import org.spongepowered.api.command.CommandResult;
29 | import org.spongepowered.api.command.CommandSource;
30 | import org.spongepowered.api.command.args.CommandContext;
31 | import org.spongepowered.api.command.args.GenericArguments;
32 | import org.spongepowered.api.command.spec.CommandSpec;
33 | import org.spongepowered.api.text.Text;
34 | import org.spongepowered.api.text.format.TextColors;
35 |
36 | public class CommandUnlock extends CommandBase.LockCommand {
37 |
38 | public static final String HELP_TEXT = "used to allow untrusted players to visit your island.";
39 |
40 | public CommandUnlock() {
41 | super(false);
42 | }
43 |
44 | public static void register() {
45 | CommandSpec commandSpec = CommandSpec.builder()
46 | .permission(Permissions.COMMAND_LOCK)
47 | .description(Text.of(HELP_TEXT))
48 | .arguments(GenericArguments.firstParsing(
49 | GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.literal(ALL, "all"), Permissions.COMMAND_LOCK_OTHERS)),
50 | GenericArguments.optional(Arguments.island(ISLAND, PrivilegeType.MANAGER))
51 | ))
52 | .executor(new CommandUnlock())
53 | .build();
54 |
55 | try {
56 | CommandIsland.addSubCommand(commandSpec, "unlock");
57 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
58 | PLUGIN.getLogger().debug("Registered command: CommandUnlock");
59 | } catch (UnsupportedOperationException e) {
60 | PLUGIN.getLogger().error("Failed to register command: CommandUnlock", e);
61 | }
62 | }
63 |
64 | @Override
65 | public CommandResult execute(CommandSource src, Island island, CommandContext args) throws CommandException {
66 | island.setLocked(false);
67 |
68 | src.sendMessage(Text.of(island.getName(), TextColors.GREEN, " is now unlocked!"));
69 | return CommandResult.success();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/schematic/SchematicUI.java:
--------------------------------------------------------------------------------
1 | package net.mohron.skyclaims.schematic;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 | import java.util.function.Consumer;
6 | import java.util.function.Function;
7 | import net.mohron.skyclaims.SkyClaims;
8 | import org.spongepowered.api.command.CommandSource;
9 | import org.spongepowered.api.data.key.Keys;
10 | import org.spongepowered.api.entity.living.player.Player;
11 | import org.spongepowered.api.event.item.inventory.ClickInventoryEvent;
12 | import org.spongepowered.api.item.inventory.Inventory;
13 | import org.spongepowered.api.item.inventory.InventoryArchetypes;
14 | import org.spongepowered.api.item.inventory.ItemStackSnapshot;
15 | import org.spongepowered.api.item.inventory.property.InventoryDimension;
16 | import org.spongepowered.api.item.inventory.property.InventoryTitle;
17 | import org.spongepowered.api.item.inventory.property.SlotPos;
18 | import org.spongepowered.api.item.inventory.query.QueryOperationTypes;
19 | import org.spongepowered.api.text.Text;
20 | import org.spongepowered.api.text.format.TextColors;
21 |
22 | public final class SchematicUI {
23 |
24 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
25 |
26 | private SchematicUI() {
27 | }
28 |
29 | public static Inventory of(List schematics, Function> mapper) {
30 | Inventory inventory = Inventory.builder()
31 | .of(InventoryArchetypes.CHEST)
32 | .property(InventoryTitle.PROPERTY_NAME, InventoryTitle.of(Text.of(TextColors.AQUA, "Schematics")))
33 | .property(InventoryDimension.PROPERTY_NAME, InventoryDimension.of(9, schematics.size() / 9 + 1))
34 | .listener(ClickInventoryEvent.class, handleClick(mapper))
35 | .build(PLUGIN);
36 |
37 | for (int i = 0; i < schematics.size(); i++) {
38 | IslandSchematic schematic = schematics.get(i);
39 | inventory.query(QueryOperationTypes.INVENTORY_PROPERTY.of(SlotPos.of(i % 9, i / 9)))
40 | .first()
41 | .set(schematic.getItemStackRepresentation());
42 | }
43 |
44 | return inventory;
45 | }
46 |
47 | private static Consumer handleClick(Function> mapper) {
48 | return event -> {
49 | if (event.getCause().first(Player.class).isPresent()) {
50 | Player player = event.getCause().first(Player.class).get();
51 | getSchematic(event).ifPresent(s -> {
52 | mapper.apply(s).accept(player);
53 | player.closeInventory();
54 | });
55 | event.setCancelled(true);
56 | }
57 | };
58 | }
59 |
60 | private static Optional getSchematic(ClickInventoryEvent event) {
61 | if (event.getCursorTransaction().isValid()) {
62 | ItemStackSnapshot itemStack = event.getCursorTransaction().getFinal();
63 | if (itemStack.get(Keys.DISPLAY_NAME).isPresent()) {
64 | Text name = itemStack.get(Keys.DISPLAY_NAME).get();
65 | return PLUGIN.getSchematicManager().getSchematics().stream()
66 | .filter(s -> s.getText().equals(name))
67 | .findAny();
68 | }
69 | }
70 | return Optional.empty();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/listener/EntitySpawnHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.listener;
20 |
21 | import net.mohron.skyclaims.SkyClaims;
22 | import net.mohron.skyclaims.SkyClaimsTimings;
23 | import net.mohron.skyclaims.permissions.Options;
24 | import net.mohron.skyclaims.world.Island;
25 | import net.mohron.skyclaims.world.IslandManager;
26 | import org.spongepowered.api.entity.living.Ambient;
27 | import org.spongepowered.api.entity.living.Aquatic;
28 | import org.spongepowered.api.entity.living.animal.Animal;
29 | import org.spongepowered.api.entity.living.monster.Monster;
30 | import org.spongepowered.api.event.Listener;
31 | import org.spongepowered.api.event.entity.SpawnEntityEvent;
32 | import org.spongepowered.api.event.item.inventory.DropItemEvent;
33 |
34 | public class EntitySpawnHandler {
35 |
36 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
37 |
38 | @Listener
39 | public void onEntitySpawn(SpawnEntityEvent event) {
40 |
41 | SkyClaimsTimings.ENTITY_SPAWN.startTimingIfSync();
42 |
43 | if (event instanceof DropItemEvent
44 | || event.getEntities().isEmpty()
45 | || !event.getEntities().get(0).getWorld()
46 | .equals(PLUGIN.getConfig().getWorldConfig().getWorld())) {
47 | SkyClaimsTimings.ENTITY_SPAWN.abort();
48 | return;
49 | }
50 |
51 | event.filterEntities(entity -> {
52 | Island island = IslandManager.ISLANDS.values().stream()
53 | .filter(i -> i.contains(entity.getLocation())).findAny().orElse(null);
54 | if (island == null) {
55 | return true;
56 | }
57 | int limit;
58 | int hostile = island.getHostileEntities().size();
59 | int passive = island.getPassiveEntities().size();
60 | if (entity instanceof Monster) {
61 | limit = Options.getMaxHostileSpawns(island.getOwnerUniqueId());
62 | if (limit > 0 && hostile >= limit) {
63 | return false;
64 | }
65 | } else if (entity instanceof Animal || entity instanceof Aquatic || entity instanceof Ambient) {
66 | limit = Options.getMaxPassiveSpawns(island.getOwnerUniqueId());
67 | if (limit > 0 && passive >= limit) {
68 | return false;
69 | }
70 | } else {
71 | return true;
72 | }
73 | limit = Options.getMaxSpawns(island.getOwnerUniqueId());
74 | return (limit <= 0 || limit >= hostile + passive);
75 | });
76 |
77 | SkyClaimsTimings.ENTITY_SPAWN.stopTimingIfSync();
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/ConfigManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.nio.file.Files;
24 | import java.nio.file.Path;
25 | import java.nio.file.Paths;
26 | import net.mohron.skyclaims.SkyClaims;
27 | import net.mohron.skyclaims.config.type.GlobalConfig;
28 | import ninja.leaping.configurate.commented.CommentedConfigurationNode;
29 | import ninja.leaping.configurate.loader.ConfigurationLoader;
30 | import ninja.leaping.configurate.objectmapping.ObjectMapper;
31 | import ninja.leaping.configurate.objectmapping.ObjectMappingException;
32 | import org.slf4j.Logger;
33 |
34 | public class ConfigManager {
35 |
36 | public static final int CONFIG_VERSION = 1;
37 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
38 | private static final Logger LOGGER = PLUGIN.getLogger();
39 | private final ConfigurationLoader loader;
40 | private ObjectMapper.BoundInstance configMapper;
41 |
42 | public ConfigManager(ConfigurationLoader loader) {
43 | this.loader = loader;
44 | try {
45 | this.configMapper = ObjectMapper.forObject(PLUGIN.getConfig());
46 | } catch (ObjectMappingException e) {
47 | e.printStackTrace();
48 | }
49 |
50 | this.load();
51 | this.initializeData();
52 | }
53 |
54 | /**
55 | * Saves the serialized config to file
56 | */
57 | public void save() {
58 | try {
59 | CommentedConfigurationNode out = CommentedConfigurationNode.root();
60 | this.configMapper.serialize(out);
61 | this.loader.save(out);
62 | } catch (ObjectMappingException | IOException e) {
63 | LOGGER.error("Failed to save config", e);
64 | }
65 | }
66 |
67 | /**
68 | * Loads the configs into serialized objects, for the configMapper
69 | */
70 | public void load() {
71 | try {
72 | this.configMapper.populate(this.loader.load());
73 | } catch (Exception e) {
74 | LOGGER.error("Failed to load config", e);
75 | }
76 | }
77 |
78 | /**
79 | * Create the data directory if it does not exist
80 | */
81 | private void initializeData() {
82 | Path path = Paths.get(PLUGIN.getConfigDir() + File.separator + "data");
83 | if (!Files.exists(path)) {
84 | try {
85 | Files.createDirectory(path);
86 | } catch (IOException e) {
87 | LOGGER.error("Failed to create data directory", e);
88 | }
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/util/FlatWorldUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.util;
20 |
21 | import java.util.Arrays;
22 | import net.mohron.skyclaims.SkyClaims;
23 | import net.mohron.skyclaims.exception.SkyClaimsException;
24 | import org.apache.commons.lang3.StringUtils;
25 | import org.spongepowered.api.Sponge;
26 | import org.spongepowered.api.block.BlockState;
27 | import org.spongepowered.api.block.BlockType;
28 | import org.spongepowered.api.block.BlockTypes;
29 | import org.spongepowered.api.text.Text;
30 |
31 | public final class FlatWorldUtil {
32 |
33 | private static final BlockState[] voidWorld = new BlockState[256];
34 |
35 | static {
36 | Arrays.fill(voidWorld, BlockTypes.AIR.getDefaultState());
37 | }
38 |
39 | private FlatWorldUtil() {
40 | }
41 |
42 | public static BlockState[] getBlocks(String code) throws SkyClaimsException {
43 | BlockState[] list = new BlockState[256];
44 | int l = 0;
45 |
46 | // Bank code is void
47 | if (StringUtils.isBlank(code)) {
48 | return voidWorld;
49 | }
50 |
51 | // Only the first part is used
52 | if (code.contains(";")) {
53 | code = code.split(";")[0];
54 | }
55 |
56 | String[] blockIds = code.split(",");
57 |
58 | for (String layer : blockIds) {
59 | int count = 1;
60 | String blockId;
61 | // If the block id has a quantity set, split the quantity and block id
62 | if (layer.contains("*")) {
63 | String[] s = layer.split("\\*");
64 | count = Integer.valueOf(s[0]);
65 | blockId = s[1];
66 | } else {
67 | blockId = layer;
68 | }
69 |
70 | BlockType type = Sponge.getRegistry().getType(BlockType.class, blockId)
71 | .orElseThrow(() -> new SkyClaimsException(Text.of("Unable to parse flat world preset code. Unknown Block ID: ", blockId)));
72 | for (int i = 0; i < count; i++) {
73 | list[l] = BlockState.builder().blockType(type).build();
74 | l++;
75 | }
76 | }
77 |
78 | // Fill the remaining layers with air
79 | for (; l < 255; l++) {
80 | list[l] = BlockTypes.AIR.getDefaultState();
81 | }
82 |
83 | return list;
84 | }
85 |
86 | public static BlockState[] getBlocksSafely(String code) {
87 | try {
88 | return getBlocks(code);
89 | } catch (SkyClaimsException e) {
90 | SkyClaims.getInstance().getLogger().error(e.getMessage(), e);
91 | return voidWorld;
92 | }
93 | }
94 |
95 | public static BlockState[] getVoidWorld() {
96 | return voidWorld;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/user/CommandSetSpawn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.user;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.world.Island;
25 | import net.mohron.skyclaims.world.IslandManager;
26 | import org.spongepowered.api.command.CommandException;
27 | import org.spongepowered.api.command.CommandResult;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.spec.CommandSpec;
30 | import org.spongepowered.api.entity.living.player.Player;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 |
34 | public class CommandSetSpawn extends CommandBase.PlayerCommand {
35 |
36 | public static final String HELP_TEXT = "set your spawn location for your island.";
37 |
38 | public static void register() {
39 | CommandSpec commandSpec = CommandSpec.builder()
40 | .permission(Permissions.COMMAND_SET_SPAWN)
41 | .description(Text.of(HELP_TEXT))
42 | .executor(new CommandSetSpawn())
43 | .build();
44 |
45 | try {
46 | CommandIsland.addSubCommand(commandSpec, "setspawn");
47 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
48 | PLUGIN.getLogger().debug("Registered command: CommandSetSpawn");
49 | } catch (UnsupportedOperationException e) {
50 | PLUGIN.getLogger().error("Failed to register command: CommandSetSpawn", e);
51 | }
52 | }
53 |
54 | @Override
55 | public CommandResult execute(Player player, CommandContext args) throws CommandException {
56 | Island island = IslandManager.getByLocation(player.getLocation())
57 | .orElseThrow(() -> new CommandException(Text.of("You must be on an island to use this command!")));
58 |
59 | if (!island.isManager(player) && !player.hasPermission(Permissions.COMMAND_SET_SPAWN_OTHERS)) {
60 | throw new CommandException(Text.of("Only the island owner may use this command!"));
61 | }
62 |
63 | island.setSpawn(player.getTransform());
64 | player.sendMessage(Text.of("Your island spawn has been set to ", TextColors.GRAY, "(",
65 | TextColors.LIGHT_PURPLE, island.getSpawn().getPosition().getFloorX(), TextColors.GRAY, ", ",
66 | TextColors.LIGHT_PURPLE, island.getSpawn().getPosition().getFloorY(), TextColors.GRAY, ", ",
67 | TextColors.LIGHT_PURPLE, island.getSpawn().getPosition().getFloorZ(), TextColors.GRAY, ")"
68 | ));
69 |
70 | return CommandResult.success();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/IslandSortType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import java.util.Comparator;
22 | import java.util.function.Function;
23 | import net.mohron.skyclaims.world.Island;
24 | import org.spongepowered.api.data.key.Keys;
25 | import org.spongepowered.api.text.Text;
26 | import org.spongepowered.api.text.action.TextActions;
27 | import org.spongepowered.api.text.format.TextColors;
28 |
29 | public enum IslandSortType {
30 | NONE(Order.ASC),
31 | NAME(Order.ASC),
32 | CREATED(Order.ASC),
33 | ONLINE(Order.DESC),
34 | ACTIVE(Order.DESC),
35 | MEMBERS(Order.DESC),
36 | SIZE(Order.DESC),
37 | ENTITIES(Order.DESC),
38 | TILES(Order.DESC);
39 |
40 | private final Order order;
41 |
42 | IslandSortType(Order order) {
43 | this.order = order;
44 | }
45 |
46 | public enum Order {
47 | ASC, DESC;
48 |
49 | public Comparator getComparator() {
50 | switch (this) {
51 | case DESC:
52 | return Comparator.reverseOrder();
53 | case ASC:
54 | default:
55 | return Comparator.naturalOrder();
56 | }
57 | }
58 |
59 | public Text toText() {
60 | switch (this) {
61 | case DESC:
62 | return Text.builder("▼")
63 | .color(TextColors.GRAY)
64 | .onHover(TextActions.showText(Text.of("Descending")))
65 | .build();
66 | case ASC:
67 | default:
68 | return Text.builder("▲")
69 | .color(TextColors.GRAY)
70 | .onHover(TextActions.showText(Text.of("Ascending")))
71 | .build();
72 | }
73 | }
74 | }
75 |
76 | public Order getOrder() {
77 | return order;
78 | }
79 |
80 | public Function getSortFunction() {
81 | switch (this) {
82 | case CREATED:
83 | return Island::getDateCreated;
84 | case ONLINE:
85 | return i -> i.getMembers().stream()
86 | .anyMatch(user -> user.isOnline() && !user.get(Keys.VANISH).orElse(false));
87 | case ACTIVE:
88 | return Island::getDateLastActive;
89 | case MEMBERS:
90 | return Island::getTotalMembers;
91 | case SIZE:
92 | return Island::getWidth;
93 | case ENTITIES:
94 | return Island::getTotalEntities;
95 | case TILES:
96 | return Island::getTotalTileEntities;
97 | case NAME:
98 | case NONE:
99 | default:
100 | return Island::getSortableName;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SkyClaims [](https://github.com/DevOnTheRocks/SkyClaims/releases) 
2 |
3 | English
4 | | Chinese
5 |
6 |
7 | SkyClaims is a plugin for SkyBlock servers that run [Grief Defender](https://www.spigotmc.org/resources/griefdefender.68900/) for protection.
8 | Instead of reinventing the wheel and adding custom protection for islands, SkyClaims will implement claims from one of Sponge's most powerful plugins, Grief Defender!
9 | With this design, nearly every Grief Defender feature will be available to players for managing their islands.
10 |
11 | This plugin is in Beta. Live support is available for the latest builds through [Discord](https://discord.gg/EkVQycV)!
12 |
13 | ## Features
14 |
15 | - [X] Complete control of command usage with granular permissions (ie specific biomes for setbiome)
16 | - [X] Automatic creation of islands and their encompassing claim
17 | - [X] Support multiple island designs via Sponge schematics
18 | - [X] Expanding islands using claim blocks
19 | - [X] Isolation of islands to their own Minecraft region file
20 | - [X] Allow spawn/tp on your island at a configurable location
21 | - [X] Work in teams:
22 | - [X] Invite new players to an island
23 | - [X] Kick existing players from an island
24 | - [X] Leave an island
25 | - [X] Transfer island ownership to another player
26 | - [X] Limit the number of islands a player may join
27 | - [X] Change the biome of a block, chunk or entire island
28 | - [X] Limit entity spawning per island
29 | - [X] Automatic removal of inactive islands
30 | - [X] Island messaging via GP's `/townchat`/`/tc` for chatting within your island
31 | - [X] Economy support for schematics & island expansion
32 | - [ ] Configurable island layouts (linear & spiral planned)
33 |
34 | ## Dependencies
35 |
36 | - **Required:**
37 | - [Sponge](https://www.spongepowered.org/downloads) - 1.12.2-2555-7.0.0-BETA-2800+
38 | - [Grief Defender](https://www.spigotmc.org/resources/griefdefender.68900/) - 2.0.0+
39 | - Permission Plugin
40 | - [LuckPerms](https://forums.spongepowered.org/t/luckperms-an-advanced-permissions-plugin/14274) is highly recommended
41 | - **Optional:**
42 | - [Nucleus](https://nucleuspowered.org) - 1.9.0-S7.1+
43 | - Economy Plugin - [Economy Lite](https://ore.spongepowered.org/Flibio/EconomyLite), [Total Economy](https://ore.spongepowered.org/Erigitic/Total-Economy), or any other Sponge Economy plugin of your choosing.
44 |
45 | ## Additional Information
46 |
47 | **Plugin releases are available on [Ore](https://ore.spongepowered.org/Mohron/SkyClaims/).**
48 |
49 | **Detailed feature information is available on our [Wiki](https://devontherocks.github.io/SkyClaims/).**
50 |
51 | **Bug reports and feature requests can be made on [GitHub](https://github.com/DevOnTheRocks/SkyClaims/issues).**
52 |
53 | [](https://discord.gg/EkVQycV)
54 | | [](https://www.paypal.me/mohron)
55 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/user/CommandLock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.user;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.command.argument.Arguments;
24 | import net.mohron.skyclaims.permissions.Permissions;
25 | import net.mohron.skyclaims.team.PrivilegeType;
26 | import net.mohron.skyclaims.world.Island;
27 | import org.spongepowered.api.command.CommandException;
28 | import org.spongepowered.api.command.CommandResult;
29 | import org.spongepowered.api.command.CommandSource;
30 | import org.spongepowered.api.command.args.CommandContext;
31 | import org.spongepowered.api.command.args.GenericArguments;
32 | import org.spongepowered.api.command.spec.CommandSpec;
33 | import org.spongepowered.api.text.Text;
34 | import org.spongepowered.api.text.format.TextColors;
35 |
36 | public class CommandLock extends CommandBase.LockCommand {
37 |
38 | public static final String HELP_TEXT = "used to prevent untrusted players from visiting to your island.";
39 |
40 | public CommandLock() {
41 | super(true);
42 | }
43 |
44 | public static void register() {
45 | CommandSpec commandSpec = CommandSpec.builder()
46 | .permission(Permissions.COMMAND_LOCK)
47 | .description(Text.of(HELP_TEXT))
48 | .arguments(GenericArguments.firstParsing(
49 | GenericArguments.optional(GenericArguments.requiringPermission(GenericArguments.literal(ALL, "all"), Permissions.COMMAND_LOCK_OTHERS)),
50 | GenericArguments.optional(Arguments.island(ISLAND, PrivilegeType.MANAGER))
51 | ))
52 | .executor(new CommandLock())
53 | .build();
54 |
55 | try {
56 | CommandIsland.addSubCommand(commandSpec, "lock");
57 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
58 | PLUGIN.getLogger().debug("Registered command: CommandLock");
59 | } catch (UnsupportedOperationException e) {
60 | PLUGIN.getLogger().error("Failed to register command: CommandLock", e);
61 | }
62 | }
63 |
64 | @Override
65 | public CommandResult execute(CommandSource src, Island island, CommandContext args) throws CommandException {
66 | island.setLocked(true);
67 |
68 | island.getPlayers().forEach(p -> {
69 | if (!island.isMember(p) && !p.hasPermission(Permissions.EXEMPT_KICK)) {
70 | p.setLocationSafely(PLUGIN.getConfig().getWorldConfig().getSpawn());
71 | p.sendMessage(Text.of(island.getName(), TextColors.RED, " has been locked!"));
72 | }
73 | });
74 |
75 | src.sendMessage(Text.of(island.getName(), TextColors.GREEN, " is now locked!"));
76 | return CommandResult.success();
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/user/CommandSetName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.user;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.command.argument.Arguments;
24 | import net.mohron.skyclaims.permissions.Permissions;
25 | import net.mohron.skyclaims.team.PrivilegeType;
26 | import net.mohron.skyclaims.world.Island;
27 | import org.spongepowered.api.command.CommandException;
28 | import org.spongepowered.api.command.CommandResult;
29 | import org.spongepowered.api.command.args.CommandContext;
30 | import org.spongepowered.api.command.args.GenericArguments;
31 | import org.spongepowered.api.command.spec.CommandSpec;
32 | import org.spongepowered.api.entity.living.player.Player;
33 | import org.spongepowered.api.text.Text;
34 | import org.spongepowered.api.text.format.TextColors;
35 | import org.spongepowered.api.text.serializer.TextSerializers;
36 |
37 | public class CommandSetName extends CommandBase.IslandCommand {
38 |
39 | public static final String HELP_TEXT = "set your name of your island.";
40 | private static final Text NAME = Text.of("name");
41 |
42 | public static void register() {
43 | CommandSpec commandSpec = CommandSpec.builder()
44 | .permission(Permissions.COMMAND_SET_NAME)
45 | .description(Text.of(HELP_TEXT))
46 | .arguments(
47 | GenericArguments.optionalWeak(Arguments.island(ISLAND, PrivilegeType.MANAGER)),
48 | GenericArguments.text(NAME, TextSerializers.FORMATTING_CODE, true)
49 | )
50 | .executor(new CommandSetName())
51 | .build();
52 |
53 | try {
54 | CommandIsland.addSubCommand(commandSpec, "setname");
55 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
56 | PLUGIN.getLogger().debug("Registered command: CommandSetName");
57 | } catch (UnsupportedOperationException e) {
58 | PLUGIN.getLogger().error("Failed to register command: CommandSetName", e);
59 | }
60 | }
61 |
62 | @Override
63 | public CommandResult execute(Player player, Island island, CommandContext args) throws CommandException {
64 | if (!island.isManager(player) && !player.hasPermission(Permissions.COMMAND_SET_NAME_OTHERS)) {
65 | throw new CommandException(Text.of(
66 | TextColors.RED, "Only an island ", PrivilegeType.MANAGER.toText(), TextColors.RED, " may use this command!"
67 | ));
68 | }
69 |
70 | Text name = args.getOne(NAME).orElse(null);
71 | island.setName(name);
72 | player.sendMessage(Text.of(TextColors.GREEN, "Your island name has been changed to ", island.getName()));
73 |
74 | return CommandResult.success();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/TwoUserArgument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import com.google.common.collect.ImmutableList;
22 | import com.google.common.collect.Lists;
23 | import java.util.List;
24 | import java.util.Optional;
25 | import javax.annotation.Nullable;
26 | import net.mohron.skyclaims.SkyClaims;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.ArgumentParseException;
29 | import org.spongepowered.api.command.args.CommandArgs;
30 | import org.spongepowered.api.command.args.CommandContext;
31 | import org.spongepowered.api.command.args.CommandElement;
32 | import org.spongepowered.api.entity.living.player.User;
33 | import org.spongepowered.api.profile.GameProfile;
34 | import org.spongepowered.api.service.user.UserStorageService;
35 | import org.spongepowered.api.text.Text;
36 |
37 | public class TwoUserArgument extends CommandElement {
38 |
39 | private final Text key;
40 | private final Text key2;
41 |
42 | public TwoUserArgument(@Nullable Text key, Text key2) {
43 | super(key);
44 | this.key = key;
45 | this.key2 = key2;
46 | }
47 |
48 | @Nullable
49 | @Override
50 | protected Object parseValue(CommandSource source, CommandArgs args)
51 | throws ArgumentParseException {
52 | return null;
53 | }
54 |
55 | @Override
56 | public void parse(CommandSource source, CommandArgs args, CommandContext context)
57 | throws ArgumentParseException {
58 | String user1 = args.next();
59 | String user2 = args.nextIfPresent().orElse(null);
60 | if (user2 != null) {
61 | context.putArg(key, getUserFromName(user1));
62 | context.putArg(key2, getUserFromName(user2));
63 | } else {
64 | context.putArg(key2, getUserFromName(user1));
65 | }
66 | }
67 |
68 | @Override
69 | public List complete(CommandSource src, CommandArgs args, CommandContext context) {
70 | try {
71 | String name = args.peek().toLowerCase();
72 | return SkyClaims.getInstance().getGame().getServiceManager()
73 | .provideUnchecked(UserStorageService.class)
74 | .getAll().stream()
75 | .map(GameProfile::getName)
76 | .filter(s -> s.isPresent() && s.get().startsWith(name))
77 | .map(Optional::get)
78 | .collect(ImmutableList.toImmutableList());
79 | } catch (ArgumentParseException e) {
80 | return Lists.newArrayList();
81 | }
82 | }
83 |
84 | private User getUserFromName(String name) throws ArgumentParseException {
85 | return SkyClaims.getInstance().getGame().getServiceManager()
86 | .provideUnchecked(UserStorageService.class).get(name)
87 | .orElseThrow(() -> new ArgumentParseException(Text.of("Invalid User Supplied"), name, 0));
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/integration/griefdefender/GDIntegration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Required Notice: Copyright (C) 2019 Mohron (https://www.mohron.dev)
3 | *
4 | * IslandDefender is licensed under the PolyForm Noncommercial License 1.0.0 (https://polyformproject.org/licenses/noncommercial/1.0.0).
5 | */
6 |
7 | package net.mohron.skyclaims.integration.griefdefender;
8 |
9 | import com.griefdefender.api.GriefDefender;
10 | import com.griefdefender.api.event.ClaimEvent;
11 | import net.kyori.event.EventSubscription;
12 | import net.mohron.skyclaims.SkyClaims;
13 | import net.mohron.skyclaims.config.type.integration.GriefDefenderConfig;
14 | import org.spongepowered.api.event.Listener;
15 | import org.spongepowered.api.event.Order;
16 | import org.spongepowered.api.event.filter.Getter;
17 | import org.spongepowered.api.event.game.GameReloadEvent;
18 | import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
19 | import org.spongepowered.api.event.game.state.GameInitializationEvent;
20 | import org.spongepowered.api.event.world.LoadWorldEvent;
21 | import org.spongepowered.api.world.World;
22 |
23 | public class GDIntegration {
24 |
25 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
26 |
27 | private GriefDefenderConfig config;
28 | private EventSubscription eventSubscription;
29 |
30 | @Listener(order = Order.LATE)
31 | public void onInitialization(GameInitializationEvent event) {
32 | config = PLUGIN.getConfig().getIntegrationConfig().getGriefDefender();
33 | }
34 |
35 | @Listener
36 | public void onAboutToStart(GameAboutToStartServerEvent event) {
37 | registerClaimEventHandler();
38 | }
39 |
40 | @Listener
41 | public void onReload(GameReloadEvent event) {
42 | config = PLUGIN.getConfig().getIntegrationConfig().getGriefDefender();
43 | eventSubscription.unsubscribe();
44 | registerClaimEventHandler();
45 | }
46 |
47 | @Listener(order = Order.LAST)
48 | public void onWorldLoad(LoadWorldEvent event, @Getter(value = "getTargetWorld") World targetWorld) {
49 | // String world = PLUGIN.getConfig().getWorldConfig().getWorldName();
50 | //
51 | // if (targetWorld.getName().equalsIgnoreCase(world)) {
52 | // ClaimManager claimManager = GriefDefender.getCore().getClaimManager(targetWorld.getUniqueId());
53 | // Claim wilderness = claimManager.getWildernessClaim();
54 | // Set contexts = Sets.newHashSet();
55 | //
56 | // final Map wildernessFlags = config.getWildernessFlags();
57 | // if (wildernessFlags != null) {
58 | // wildernessFlags.forEach(setWildernessFlag(world, wilderness, contexts));
59 | // }
60 | // }
61 | }
62 |
63 | // private BiConsumer setWildernessFlag(String world, Claim wilderness, Set contexts) {
64 | // return (flag, value) -> {
65 | // Tristate tristate = value ? Tristate.TRUE : Tristate.FALSE;
66 | // if (wilderness.getFlagPermissionValue(flag, contexts) != tristate) {
67 | // wilderness.setFlagPermission(flag, tristate, contexts).whenComplete((result, throwable) -> {
68 | // if (result.successful()) {
69 | // PLUGIN.getLogger().info("{}: Set {} flag in wilderness to {}.", world, flag, tristate.toString());
70 | // } else {
71 | // PLUGIN.getLogger().warn(result.getResultType().toString(), throwable);
72 | // }
73 | // });
74 | // }
75 | // };
76 | // }
77 |
78 | private void registerClaimEventHandler() {
79 | eventSubscription = GriefDefender.getEventManager().getBus().subscribe(ClaimEvent.class, new ClaimEventHandler());
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicSetName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 | import org.spongepowered.api.text.serializer.TextSerializers;
34 |
35 | public class CommandSchematicSetName extends CommandBase {
36 |
37 | public static final String HELP_TEXT = "used to set the name for a schematic";
38 | private static final Text SCHEMATIC = Text.of("schematic");
39 | private static final Text NAME = Text.of("name");
40 |
41 | public static CommandSpec commandSpec = CommandSpec.builder()
42 | .permission(Permissions.COMMAND_SCHEMATIC_SET_NAME)
43 | .description(Text.of(HELP_TEXT))
44 | .arguments(
45 | Arguments.schematic(SCHEMATIC),
46 | GenericArguments.optional(GenericArguments.text(NAME, TextSerializers.FORMATTING_CODE, true))
47 | )
48 | .executor(new CommandSchematicSetName())
49 | .build();
50 |
51 | public static void register() {
52 | try {
53 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
54 | PLUGIN.getLogger().debug("Registered command: CommandSchematicSetName");
55 | } catch (UnsupportedOperationException e) {
56 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicSetName", e);
57 | }
58 | }
59 |
60 | @Override
61 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
62 | IslandSchematic schematic = args.getOne(SCHEMATIC)
63 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
64 | Text text = args.getOne(NAME).orElse(Text.of(schematic.getName()));
65 |
66 | schematic.setText(text);
67 |
68 | if (PLUGIN.getSchematicManager().save(schematic)) {
69 | src.sendMessage(Text.of(
70 | TextColors.GREEN, "Successfully updated schematic name to ", TextColors.WHITE, text, TextColors.GREEN, "."
71 | ));
72 | return CommandResult.success();
73 | } else {
74 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicSetBiome.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 | import org.spongepowered.api.world.biome.BiomeType;
34 |
35 | public class CommandSchematicSetBiome extends CommandBase {
36 |
37 | public static final String HELP_TEXT = "used to set the default biome for a schematic";
38 | private static final Text SCHEMATIC = Text.of("schematic");
39 | private static final Text BIOME = Text.of("biome-type");
40 |
41 | public static CommandSpec commandSpec = CommandSpec.builder()
42 | .permission(Permissions.COMMAND_SCHEMATIC_SET_BIOME)
43 | .description(Text.of(HELP_TEXT))
44 | .arguments(
45 | Arguments.schematic(SCHEMATIC),
46 | GenericArguments.optional(Arguments.biome(BIOME))
47 | )
48 | .executor(new CommandSchematicSetBiome())
49 | .build();
50 |
51 | public static void register() {
52 | try {
53 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
54 | PLUGIN.getLogger().debug("Registered command: CommandSchematicSetBiome");
55 | } catch (UnsupportedOperationException e) {
56 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicSetBiome", e);
57 | }
58 | }
59 |
60 | @Override
61 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
62 | IslandSchematic schematic = args.getOne(SCHEMATIC)
63 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
64 | BiomeType biome = args.getOne(BIOME).orElse(null);
65 |
66 | schematic.setBiomeType(biome);
67 |
68 | if (PLUGIN.getSchematicManager().save(schematic)) {
69 | src.sendMessage(Text.of(
70 | TextColors.GREEN, "Successfully updated schematic biome to ",
71 | TextColors.WHITE, biome != null ? biome.getName() : "none", TextColors.GREEN, "."
72 | ));
73 | return CommandResult.success();
74 | } else {
75 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/team/CommandDemote.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.team;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.team.PrivilegeType;
25 | import net.mohron.skyclaims.world.Island;
26 | import org.spongepowered.api.command.CommandException;
27 | import org.spongepowered.api.command.CommandResult;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.entity.living.player.Player;
32 | import org.spongepowered.api.entity.living.player.User;
33 | import org.spongepowered.api.text.Text;
34 | import org.spongepowered.api.text.format.TextColors;
35 |
36 | public class CommandDemote extends CommandBase.IslandCommand {
37 |
38 | public static final String HELP_TEXT = "used to demote a player on an island.";
39 | private static final Text USER = Text.of("user");
40 |
41 | public static void register() {
42 | CommandSpec commandSpec = CommandSpec.builder()
43 | .permission(Permissions.COMMAND_DEMOTE)
44 | .arguments(GenericArguments.user(USER))
45 | .description(Text.of(HELP_TEXT))
46 | .executor(new CommandDemote())
47 | .build();
48 |
49 | try {
50 | CommandIsland.addSubCommand(commandSpec, "demote");
51 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
52 | PLUGIN.getLogger().debug("Registered command: CommandDemote");
53 | } catch (UnsupportedOperationException e) {
54 | PLUGIN.getLogger().error("Failed to register command: CommandDemote", e);
55 | }
56 | }
57 |
58 | @Override
59 | public CommandResult execute(Player player, Island island, CommandContext args)
60 | throws CommandException {
61 | User user = args.getOne(USER).orElse(null);
62 |
63 | if (user == null) {
64 | throw new CommandException(Text.of(TextColors.RED, "A user argument must be provided."));
65 | } else if (player.equals(user)) {
66 | throw new CommandException(Text.of(TextColors.RED, "You cannot demote yourself!"));
67 | } else if (!island.isOwner(player)) {
68 | throw new CommandException(Text.of(TextColors.RED, "You do not have permission to demote players on this island!"));
69 | } else {
70 | PrivilegeType type = island.getPrivilegeType(user);
71 | island.demote(user);
72 | player.sendMessage(Text.of(
73 | type.format(user.getName()), TextColors.RED, " has been demoted from a ", type.toText(),
74 | TextColors.RED, " to a ", island.getPrivilegeType(user).toText(), TextColors.RED, "."
75 | ));
76 | }
77 |
78 | return CommandResult.success();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/SchematicArgument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import com.google.common.collect.Lists;
22 | import java.util.List;
23 | import java.util.Optional;
24 | import java.util.stream.Collectors;
25 | import javax.annotation.Nullable;
26 | import net.mohron.skyclaims.SkyClaims;
27 | import net.mohron.skyclaims.permissions.Permissions;
28 | import net.mohron.skyclaims.schematic.IslandSchematic;
29 | import org.spongepowered.api.command.CommandSource;
30 | import org.spongepowered.api.command.args.ArgumentParseException;
31 | import org.spongepowered.api.command.args.CommandArgs;
32 | import org.spongepowered.api.command.args.CommandContext;
33 | import org.spongepowered.api.command.args.CommandElement;
34 | import org.spongepowered.api.text.Text;
35 | import org.spongepowered.api.text.format.TextColors;
36 |
37 | public class SchematicArgument extends CommandElement {
38 |
39 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
40 |
41 | public SchematicArgument(@Nullable Text key) {
42 | super(key);
43 | }
44 |
45 | @Nullable
46 | @Override
47 | protected IslandSchematic parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
48 | String schem = args.next().toLowerCase();
49 | if (PLUGIN.getSchematicManager().getSchematics().isEmpty()) {
50 | throw args.createError(Text.of(TextColors.RED, "There are no valid schematics available!"));
51 | }
52 | Optional schematic = PLUGIN.getSchematicManager().getSchematics().stream().filter(s -> s.getName().equalsIgnoreCase(schem)).findAny();
53 | if (schematic.isPresent()) {
54 | if (PLUGIN.getConfig().getPermissionConfig().isSeparateSchematicPerms() && !hasPermission(source, schem)) {
55 | throw args.createError(Text.of(TextColors.RED, "You do not have permission to use the supplied schematic!"));
56 | }
57 | return schematic.get();
58 | }
59 | throw args.createError(Text.of(TextColors.RED, "Invalid Schematic!"));
60 | }
61 |
62 | @Override
63 | public List complete(CommandSource src, CommandArgs args, CommandContext context) {
64 | try {
65 | String name = args.peek().toLowerCase();
66 | boolean checkPerms = PLUGIN.getConfig().getPermissionConfig().isSeparateSchematicPerms();
67 | return PLUGIN.getSchematicManager().getSchematics().stream()
68 | .filter(s -> s.getName().startsWith(name))
69 | .filter(s -> !checkPerms || hasPermission(src, s.getName()))
70 | .map(IslandSchematic::getName)
71 | .collect(Collectors.toList());
72 | } catch (ArgumentParseException e) {
73 | return Lists.newArrayList();
74 | }
75 | }
76 |
77 | private boolean hasPermission(CommandSource src, String name) {
78 | return src.hasPermission(Permissions.COMMAND_ARGUMENTS_SCHEMATICS + "." + name.toLowerCase());
79 | }
80 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicSetPreset.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 |
34 | public class CommandSchematicSetPreset extends CommandBase {
35 |
36 | public static final String HELP_TEXT = "used to set the flat world preset for a schematic";
37 | private static final Text SCHEMATIC = Text.of("schematic");
38 | private static final Text PRESET = Text.of("preset");
39 |
40 | public static CommandSpec commandSpec = CommandSpec.builder()
41 | .permission(Permissions.COMMAND_SCHEMATIC_SET_PRESET)
42 | .description(Text.of(HELP_TEXT))
43 | .arguments(
44 | Arguments.schematic(SCHEMATIC),
45 | GenericArguments.optional(GenericArguments.string(PRESET))
46 | )
47 | .executor(new CommandSchematicSetPreset())
48 | .build();
49 |
50 | public static void register() {
51 | try {
52 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
53 | PLUGIN.getLogger().debug("Registered command: CommandSchematicSetPreset");
54 | } catch (UnsupportedOperationException e) {
55 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicSetPreset", e);
56 | }
57 | }
58 |
59 | @Override
60 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
61 | IslandSchematic schematic = args.getOne(SCHEMATIC)
62 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
63 | String preset = args.getOne(PRESET).orElse(null);
64 |
65 | schematic.setPreset(preset);
66 |
67 | if (PLUGIN.getSchematicManager().save(schematic)) {
68 | if (preset != null) {
69 | src.sendMessage(Text.of(
70 | TextColors.GREEN, "Successfully updated schematic preset to ",
71 | TextColors.WHITE, preset, TextColors.GREEN, "."
72 | ));
73 | } else {
74 | src.sendMessage(Text.of(TextColors.GREEN, "Successfully removed schematic preset."));
75 | }
76 | return CommandResult.success();
77 | } else {
78 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicSetHeight.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 |
34 | public class CommandSchematicSetHeight extends CommandBase {
35 |
36 | public static final String HELP_TEXT = "used to set the generation height for a schematic";
37 | private static final Text SCHEMATIC = Text.of("schematic");
38 | private static final Text HEIGHT = Text.of("height");
39 |
40 | public static CommandSpec commandSpec = CommandSpec.builder()
41 | .permission(Permissions.COMMAND_SCHEMATIC_SET_HEIGHT)
42 | .description(Text.of(HELP_TEXT))
43 | .arguments(
44 | Arguments.schematic(SCHEMATIC),
45 | GenericArguments.optional(GenericArguments.integer(HEIGHT))
46 | )
47 | .executor(new CommandSchematicSetHeight())
48 | .build();
49 |
50 | public static void register() {
51 | try {
52 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
53 | PLUGIN.getLogger().debug("Registered command: CommandSchematicSetHeight");
54 | } catch (UnsupportedOperationException e) {
55 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicSetHeight", e);
56 | }
57 | }
58 |
59 | @Override
60 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
61 | IslandSchematic schematic = args.getOne(SCHEMATIC)
62 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
63 | Integer height = args.getOne(HEIGHT).orElse(null);
64 | if (height != null && (height < 0 || height > 255)) {
65 | throw new CommandException(Text.of(TextColors.RED, "Schematic height must be between ", TextColors.LIGHT_PURPLE, "0-255", TextColors.RED, "!"));
66 | }
67 |
68 | schematic.setHeight(height);
69 |
70 | if (PLUGIN.getSchematicManager().save(schematic)) {
71 | src.sendMessage(Text.of(TextColors.GREEN, "Successfully updated schematic height to ", TextColors.LIGHT_PURPLE, height, TextColors.GREEN, "."));
72 | return CommandResult.success();
73 | } else {
74 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicSetDescription.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.argument.Arguments;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.schematic.IslandSchematic;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.args.GenericArguments;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.text.Text;
32 | import org.spongepowered.api.text.format.TextColors;
33 |
34 | public class CommandSchematicSetDescription extends CommandBase {
35 |
36 | public static final String HELP_TEXT = "used to set the name for a schematic";
37 | private static final Text SCHEMATIC = Text.of("schematic");
38 | private static final Text DESCRIPTION = Text.of("description");
39 |
40 | public static CommandSpec commandSpec = CommandSpec.builder()
41 | .permission(Permissions.COMMAND_SCHEMATIC_SET_NAME)
42 | .description(Text.of(HELP_TEXT))
43 | .arguments(
44 | Arguments.schematic(SCHEMATIC),
45 | GenericArguments.optional(GenericArguments.remainingRawJoinedStrings(DESCRIPTION))
46 | )
47 | .executor(new CommandSchematicSetDescription())
48 | .build();
49 |
50 | public static void register() {
51 | try {
52 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
53 | PLUGIN.getLogger().debug("Registered command: CommandSchematicSetDescription");
54 | } catch (UnsupportedOperationException e) {
55 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicSetDescription", e);
56 | }
57 | }
58 |
59 | @Override
60 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
61 | IslandSchematic schematic = args.getOne(SCHEMATIC)
62 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic to use this command!")));
63 | String description = args.getOne(DESCRIPTION).orElse(null);
64 |
65 | if (description != null) {
66 | schematic.setDescription(description.replace("\\n", "\n"));
67 | } else {
68 | schematic.setDescription(null);
69 | }
70 |
71 | if (PLUGIN.getSchematicManager().save(schematic)) {
72 | src.sendMessage(Text.of(
73 | TextColors.GREEN, "Successfully updated schematic description to", TextColors.WHITE, ":", Text.NEW_LINE,
74 | TextColors.RESET, schematic.getDescriptionText()
75 | ));
76 | return CommandResult.success();
77 | } else {
78 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematic.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import org.spongepowered.api.Sponge;
25 | import org.spongepowered.api.command.CommandException;
26 | import org.spongepowered.api.command.CommandResult;
27 | import org.spongepowered.api.command.CommandSource;
28 | import org.spongepowered.api.command.args.CommandContext;
29 | import org.spongepowered.api.command.spec.CommandSpec;
30 | import org.spongepowered.api.text.Text;
31 |
32 | public class CommandSchematic extends CommandBase {
33 |
34 | public static final String HELP_TEXT = "used to manage island schematics";
35 |
36 | public static CommandSpec commandSpec;
37 |
38 | public static void register() {
39 | commandSpec = CommandSpec.builder()
40 | .permission(Permissions.COMMAND_SCHEMATIC)
41 | .description(Text.of(HELP_TEXT))
42 | .child(CommandSchematicCommand.commandSpec, "command")
43 | .child(CommandSchematicCreate.commandSpec, "create")
44 | .child(CommandSchematicDelete.commandSpec, "delete")
45 | .child(CommandSchematicInfo.commandSpec, "info")
46 | .child(CommandSchematicList.commandSpec, "list")
47 | .child(CommandSchematicSetBiome.commandSpec, "setbiome")
48 | .child(CommandSchematicSetDescription.commandSpec, "setdescription")
49 | .child(CommandSchematicSetHeight.commandSpec, "setheight")
50 | .child(CommandSchematicSetIcon.commandSpec, "seticon")
51 | .child(CommandSchematicSetName.commandSpec, "setname")
52 | .child(CommandSchematicSetPreset.commandSpec, "setpreset")
53 | .childArgumentParseExceptionFallback(false)
54 | .executor(new CommandSchematicList())
55 | .build();
56 |
57 | try {
58 | registerSubCommands();
59 | CommandIsland.addSubCommand(commandSpec, "schematic");
60 | Sponge.getCommandManager().register(PLUGIN, commandSpec);
61 | PLUGIN.getLogger().debug("Registered command: CommandSchematic");
62 | } catch (UnsupportedOperationException e) {
63 | PLUGIN.getLogger().error("Failed to register command: CommandSchematic", e);
64 | }
65 | }
66 |
67 | private static void registerSubCommands() {
68 | CommandSchematicCommand.register();
69 | CommandSchematicCreate.register();
70 | CommandSchematicDelete.register();
71 | CommandSchematicInfo.register();
72 | CommandSchematicList.register();
73 | CommandSchematicSetBiome.register();
74 | CommandSchematicSetDescription.register();
75 | CommandSchematicSetHeight.register();
76 | CommandSchematicSetIcon.register();
77 | CommandSchematicSetName.register();
78 | CommandSchematicSetPreset.register();
79 | }
80 |
81 | @Override
82 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
83 | return CommandResult.success();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/integration/nucleus/CommandHome.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.integration.nucleus;
20 |
21 | import io.github.nucleuspowered.nucleus.api.module.home.NucleusHomeService;
22 | import io.github.nucleuspowered.nucleus.api.module.home.data.Home;
23 | import io.github.nucleuspowered.nucleus.api.util.data.NamedLocation;
24 | import java.util.Optional;
25 | import net.mohron.skyclaims.command.CommandBase;
26 | import net.mohron.skyclaims.command.CommandIsland;
27 | import net.mohron.skyclaims.permissions.Permissions;
28 | import org.spongepowered.api.Sponge;
29 | import org.spongepowered.api.command.CommandException;
30 | import org.spongepowered.api.command.CommandResult;
31 | import org.spongepowered.api.command.CommandSource;
32 | import org.spongepowered.api.command.args.CommandContext;
33 | import org.spongepowered.api.command.spec.CommandSpec;
34 | import org.spongepowered.api.entity.Transform;
35 | import org.spongepowered.api.entity.living.player.Player;
36 | import org.spongepowered.api.entity.living.player.User;
37 | import org.spongepowered.api.text.Text;
38 | import org.spongepowered.api.text.format.TextColors;
39 | import org.spongepowered.api.world.World;
40 |
41 | public class CommandHome extends CommandBase {
42 | public static final String HELP_TEXT = "teleport to your home island.";
43 |
44 | public static CommandSpec commandSpec = CommandSpec.builder()
45 | .permission(Permissions.COMMAND_HOME)
46 | .description(Text.of(HELP_TEXT))
47 | .executor(new CommandHome())
48 | .build();
49 |
50 | public static void register() {
51 | try {
52 | CommandIsland.addSubCommand(commandSpec, "home");
53 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
54 | PLUGIN.getLogger().debug("Registered command: CommandHome");
55 | } catch (UnsupportedOperationException e) {
56 | PLUGIN.getLogger().error("Failed to register command: CommandHome:", e);
57 | }
58 | }
59 |
60 | @Override
61 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
62 | if (!(src instanceof Player)) {
63 | throw new CommandException(Text.of("You must be a player to use this command!"));
64 | }
65 |
66 | Player player = (Player) src;
67 | Transform transform = getHome(player)
68 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must set a home before using this command!")));
69 |
70 | player.setTransformSafely(transform);
71 |
72 | return CommandResult.success();
73 | }
74 |
75 | private Optional> getHome(User user) throws CommandException {
76 | Optional homeService = Sponge.getServiceManager().provide(NucleusHomeService.class);
77 | if (homeService.isPresent()) {
78 | Optional oHome = homeService.get().getHome(user, "Island");
79 | return oHome.flatMap(NamedLocation::getTransform);
80 | }
81 | throw new CommandException(Text.of(TextColors.RED, "The Nucleus Home Service is Unavailable"));
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/GenerateIslandTask.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world;
20 |
21 | import java.util.UUID;
22 | import net.mohron.skyclaims.SkyClaims;
23 | import net.mohron.skyclaims.SkyClaimsTimings;
24 | import net.mohron.skyclaims.permissions.Options;
25 | import net.mohron.skyclaims.schematic.IslandSchematic;
26 | import net.mohron.skyclaims.util.CommandUtil;
27 | import net.mohron.skyclaims.util.WorldUtil;
28 | import org.spongepowered.api.Sponge;
29 | import org.spongepowered.api.entity.Transform;
30 | import org.spongepowered.api.world.BlockChangeFlags;
31 | import org.spongepowered.api.world.Location;
32 | import org.spongepowered.api.world.World;
33 | import org.spongepowered.api.world.extent.ArchetypeVolume;
34 |
35 | public class GenerateIslandTask implements Runnable {
36 |
37 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
38 |
39 | private UUID owner;
40 | private Island island;
41 | private IslandSchematic schematic;
42 |
43 | public GenerateIslandTask(UUID owner, Island island, IslandSchematic schematic) {
44 | this.owner = owner;
45 | this.island = island;
46 | this.schematic = schematic;
47 | }
48 |
49 | @Override
50 | public void run() {
51 | SkyClaimsTimings.GENERATE_ISLAND.startTimingIfSync();
52 | World world = PLUGIN.getConfig().getWorldConfig().getWorld();
53 |
54 | ArchetypeVolume volume = schematic.getSchematic();
55 |
56 | Location centerBlock = island.getRegion().getCenter();
57 | // Loads center chunks
58 | for (int x = -1; x <= 1; x++) {
59 | for (int z = -1; z <= 1; z++) {
60 | world.loadChunk(
61 | centerBlock.getChunkPosition().getX() + x,
62 | centerBlock.getChunkPosition().getY(),
63 | centerBlock.getChunkPosition().getZ() + z,
64 | true
65 | );
66 | }
67 | }
68 |
69 | int height = schematic.getHeight().orElse(PLUGIN.getConfig().getWorldConfig().getIslandHeight());
70 | Location spawn = new Location<>(
71 | island.getWorld(),
72 | centerBlock.getX(),
73 | height + volume.getRelativeBlockView().getBlockMax().getY() - volume.getBlockMax().getY() - 1,
74 | centerBlock.getZ()
75 | );
76 | island.setSpawn(new Transform<>(spawn.getExtent(), spawn.getPosition()));
77 |
78 | volume.apply(spawn, BlockChangeFlags.NONE);
79 |
80 | // Set the region's BiomeType using the schematic default biome or player option if set
81 | if (schematic.getBiomeType().isPresent()) {
82 | WorldUtil.setRegionBiome(island, schematic.getBiomeType().get());
83 | } else if (Options.getDefaultBiome(owner).isPresent()) {
84 | WorldUtil.setRegionBiome(island, Options.getDefaultBiome(owner).get());
85 | }
86 |
87 | if (PLUGIN.getConfig().getMiscConfig().isTeleportOnCreate()) {
88 | Sponge.getServer().getPlayer(owner).ifPresent(p -> PLUGIN.getGame().getScheduler().createTaskBuilder()
89 | .delayTicks(20)
90 | .execute(CommandUtil.createTeleportConsumer(p, spawn))
91 | .submit(PLUGIN));
92 | }
93 |
94 | SkyClaimsTimings.GENERATE_ISLAND.stopTimingIfSync();
95 | }
96 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/IslandArgument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import com.google.common.collect.Lists;
22 | import com.google.common.collect.Sets;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 | import java.util.UUID;
27 | import java.util.stream.Collectors;
28 | import javax.annotation.Nullable;
29 | import net.mohron.skyclaims.permissions.Permissions;
30 | import net.mohron.skyclaims.team.PrivilegeType;
31 | import net.mohron.skyclaims.world.Island;
32 | import net.mohron.skyclaims.world.IslandManager;
33 | import org.spongepowered.api.command.CommandSource;
34 | import org.spongepowered.api.command.args.ArgumentParseException;
35 | import org.spongepowered.api.command.args.CommandArgs;
36 | import org.spongepowered.api.command.args.CommandContext;
37 | import org.spongepowered.api.command.args.CommandElement;
38 | import org.spongepowered.api.entity.living.player.Player;
39 | import org.spongepowered.api.text.Text;
40 | import org.spongepowered.api.text.format.TextColors;
41 |
42 | public class IslandArgument extends CommandElement {
43 |
44 | private PrivilegeType requirement;
45 |
46 | public IslandArgument(@Nullable Text key) {
47 | this(key, PrivilegeType.MEMBER);
48 | }
49 |
50 | public IslandArgument(@Nullable Text key, PrivilegeType requiredPrivilege) {
51 | super(key);
52 | this.requirement = requiredPrivilege;
53 | }
54 |
55 | @Nullable
56 | protected Object parseValue(CommandSource source, CommandArgs args)
57 | throws ArgumentParseException {
58 | String arg = args.next().toLowerCase();
59 | if (IslandManager.ISLANDS.isEmpty()) {
60 | throw args.createError(Text.of(TextColors.RED, "There are no valid islands!"));
61 | }
62 | try {
63 | UUID uuid = UUID.fromString(arg);
64 | if (IslandManager.ISLANDS.containsKey(uuid)) {
65 | return Sets.newHashSet(uuid);
66 | }
67 | } catch (IllegalArgumentException ignored) {
68 | }
69 | Set islands = IslandManager.ISLANDS.entrySet().stream()
70 | .filter(i -> i.getValue().getOwnerName().equalsIgnoreCase(arg))
71 | .map(Map.Entry::getKey)
72 | .collect(Collectors.toSet());
73 | if (islands.isEmpty()) {
74 | throw args.createError(Text.of(TextColors.RED, "There are no valid islands found for ", arg, "!"));
75 | } else {
76 | return islands;
77 | }
78 | }
79 |
80 | public List complete(CommandSource src, CommandArgs args, CommandContext context) {
81 | try {
82 | String arg = args.peek().toLowerCase();
83 | boolean admin = src.hasPermission(Permissions.COMMAND_LIST_ALL);
84 | return IslandManager.ISLANDS.values().stream()
85 | .filter(i -> admin
86 | || !i.isLocked()
87 | || src instanceof Player && i.getPrivilegeType((Player) src) == requirement)
88 | .filter(i -> i.getOwnerName().toLowerCase().startsWith(arg))
89 | .filter(i -> i.getSortableName().toLowerCase().startsWith(arg))
90 | .map(Island::getOwnerName)
91 | .collect(Collectors.toList());
92 | } catch (ArgumentParseException e) {
93 | return Lists.newArrayList();
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/argument/TargetArgument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.argument;
20 |
21 | import com.google.common.collect.Lists;
22 | import com.google.common.collect.Maps;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.stream.Collectors;
26 | import javax.annotation.Nullable;
27 | import net.mohron.skyclaims.SkyClaims;
28 | import net.mohron.skyclaims.permissions.Permissions;
29 | import org.spongepowered.api.command.CommandSource;
30 | import org.spongepowered.api.command.args.ArgumentParseException;
31 | import org.spongepowered.api.command.args.CommandArgs;
32 | import org.spongepowered.api.command.args.CommandContext;
33 | import org.spongepowered.api.command.args.CommandElement;
34 | import org.spongepowered.api.text.Text;
35 | import org.spongepowered.api.text.format.TextColors;
36 |
37 | public class TargetArgument extends CommandElement {
38 |
39 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
40 |
41 | private static final Map TARGETS = Maps.newHashMap();
42 |
43 | static {
44 | TARGETS.put("island", Targets.ISLAND);
45 | TARGETS.put("i", Targets.ISLAND);
46 | TARGETS.put("chunk", Targets.CHUNK);
47 | TARGETS.put("c", Targets.CHUNK);
48 | TARGETS.put("block", Targets.BLOCK);
49 | TARGETS.put("b", Targets.BLOCK);
50 | }
51 |
52 | public TargetArgument(@Nullable Text key) {
53 | super(key);
54 | }
55 |
56 | @Nullable
57 | @Override
58 | protected Object parseValue(CommandSource source, CommandArgs args)
59 | throws ArgumentParseException {
60 | String target = args.next().toLowerCase();
61 | if (TARGETS.containsKey(target)) {
62 | if (!hasPermission(source, TARGETS.get(target))) {
63 | throw new ArgumentParseException(
64 | Text.of(TextColors.RED, "You do not have permission to use the supplied target!"),
65 | target, 0);
66 | }
67 | return TARGETS.get(target);
68 | }
69 | throw new ArgumentParseException(Text.of(TextColors.RED, "Invalid target!"), target, 0);
70 | }
71 |
72 | @Override
73 | public List complete(CommandSource src, CommandArgs args, CommandContext context) {
74 | try {
75 | String name = args.peek().toLowerCase();
76 | return TARGETS.entrySet().stream()
77 | .filter(s -> s.getKey().length() > 1)
78 | .filter(s -> s.getKey().startsWith(name))
79 | .filter(s -> hasPermission(src, s.getValue()))
80 | .map(Map.Entry::getKey)
81 | .collect(Collectors.toList());
82 | } catch (ArgumentParseException e) {
83 | return Lists.newArrayList();
84 | }
85 | }
86 |
87 | private boolean hasPermission(CommandSource src, Targets target) {
88 | if (!PLUGIN.getConfig().getPermissionConfig().isSeparateTargetPerms()) {
89 | return true;
90 | }
91 | switch (target) {
92 | case BLOCK:
93 | return src.hasPermission(Permissions.COMMAND_ARGUMENTS_BLOCK);
94 | case CHUNK:
95 | return src.hasPermission(Permissions.COMMAND_ARGUMENTS_CHUNK);
96 | case ISLAND:
97 | return true;
98 | default:
99 | return false;
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/util/CommandUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.util;
20 |
21 | import java.util.function.Consumer;
22 | import org.spongepowered.api.Sponge;
23 | import org.spongepowered.api.command.CommandException;
24 | import org.spongepowered.api.command.CommandSource;
25 | import org.spongepowered.api.entity.living.player.Player;
26 | import org.spongepowered.api.scheduler.Task;
27 | import org.spongepowered.api.text.Text;
28 | import org.spongepowered.api.text.action.TextActions;
29 | import org.spongepowered.api.text.format.TextColors;
30 | import org.spongepowered.api.world.Location;
31 | import org.spongepowered.api.world.World;
32 |
33 | public class CommandUtil {
34 |
35 | public static Consumer createTeleportConsumer(CommandSource src, Location location) {
36 | return teleport -> {
37 | if (src instanceof Player) {
38 | Player player = (Player) src;
39 | Location safeLocation = Sponge.getGame().getTeleportHelper().getSafeLocation(location).orElse(null);
40 | if (safeLocation == null) {
41 | player.sendMessage(Text.of(
42 | TextColors.RED, "Location is not safe. ",
43 | TextColors.WHITE, "Are you sure you want to teleport here?", Text.NEW_LINE,
44 | Text.builder("[YES]")
45 | .onHover(TextActions.showText(Text.of("Click to teleport")))
46 | .onClick(TextActions.executeCallback(createForceTeleportConsumer(player, location)))
47 | .color(TextColors.GREEN)
48 | ));
49 | } else {
50 | player.setLocation(safeLocation);
51 | }
52 | }
53 | };
54 | }
55 |
56 | public static Consumer createTeleportConsumer(Player player, Location location) {
57 | return teleport -> {
58 | Location safeLocation = Sponge.getGame().getTeleportHelper().getSafeLocation(location).orElse(null);
59 | if (safeLocation == null) {
60 | player.sendMessage(Text.of(
61 | TextColors.RED, "Location is not safe. ",
62 | TextColors.WHITE, "Are you sure you want to teleport here?", Text.NEW_LINE,
63 | TextColors.WHITE, "[",
64 | Text.builder("YES")
65 | .color(TextColors.GREEN)
66 | .onHover(TextActions.showText(Text.of("Click to teleport")))
67 | .onClick(TextActions.executeCallback(createForceTeleportConsumer(player, location))),
68 | TextColors.WHITE, "]"
69 | ));
70 | } else {
71 | player.setLocation(safeLocation);
72 | }
73 | };
74 | }
75 |
76 | private static Consumer createForceTeleportConsumer(Player player, Location location) {
77 | return teleport -> player.setLocation(location);
78 | }
79 |
80 | public static Consumer createCommandConsumer(CommandSource src, String command, String arguments,
81 | Consumer postConsumerTask) {
82 | return consumer -> {
83 | try {
84 | Sponge.getCommandManager().get(command).get().getCallable().process(src, arguments);
85 | } catch (CommandException e) {
86 | src.sendMessage(e.getText());
87 | }
88 | if (postConsumerTask != null) {
89 | postConsumerTask.accept(src);
90 | }
91 | };
92 | }
93 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/region/SpiralRegionPattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world.region;
20 |
21 | import java.util.ArrayList;
22 | import net.mohron.skyclaims.SkyClaims;
23 | import net.mohron.skyclaims.exception.InvalidRegionException;
24 | import net.mohron.skyclaims.integration.griefdefender.ClaimUtil;
25 | import net.mohron.skyclaims.world.IslandManager;
26 | import org.apache.commons.lang3.text.StrBuilder;
27 | import org.spongepowered.api.text.Text;
28 |
29 | public class SpiralRegionPattern implements IRegionPattern {
30 |
31 | private static final SkyClaims PLUGIN = SkyClaims.getInstance();
32 | private static int spawnRegions;
33 |
34 | /**
35 | * A method to generate a region-scaled spiral region and return the x/y pairs of each region
36 | *
37 | * @return An ArrayList of Points containing the x,y of regions, representing a spiral shape
38 | */
39 | public ArrayList generateRegionPattern() {
40 | spawnRegions = PLUGIN.getConfig().getWorldConfig().getSpawnRegions();
41 | int islandCount = IslandManager.ISLANDS.size();
42 | int generationSize = (int) Math.sqrt((double) islandCount + spawnRegions) + 1;
43 | StrBuilder log = new StrBuilder("Region Pattern: [");
44 |
45 | ArrayList coordinates = new ArrayList<>(generationSize);
46 | int[] delta = {0, -1};
47 | int x = 0;
48 | int y = 0;
49 |
50 | for (int i = (int) Math.pow(Math.max(generationSize, generationSize), 2); i > 0; i--) {
51 | if (x == y || (x < 0 && x == -y) || (x > 0 && x == 1 - y)) {
52 | // change direction
53 | int a = delta[0];
54 | delta[0] = -delta[1];
55 | delta[1] = a;
56 | }
57 | coordinates.add(new Region(x, y));
58 | if (i % 10 == 0) {
59 | log.appendNewLine();
60 | }
61 | log.append(String.format("(%s,%s),", x, y));
62 | x += delta[0];
63 | y += delta[1];
64 | }
65 |
66 | PLUGIN.getLogger().debug(log.append("]").build());
67 | PLUGIN.getLogger().debug("Coordinates length: {}", coordinates.size());
68 | return coordinates;
69 | }
70 |
71 | public Region nextRegion() throws InvalidRegionException {
72 | spawnRegions = PLUGIN.getConfig().getWorldConfig().getSpawnRegions();
73 | ArrayList spawn = new ArrayList<>(spawnRegions);
74 | ArrayList regions = generateRegionPattern();
75 | int iterator = 0;
76 |
77 | PLUGIN.getLogger()
78 | .debug("Checking for next region out of {} points with {} spawn regions.", regions.size(),
79 | spawnRegions);
80 |
81 | for (Region region : regions) {
82 | if (iterator < spawnRegions) {
83 | spawn.add(region);
84 | PLUGIN.getLogger().debug("Skipping ({}, {}) for spawn", region.getX(), region.getZ());
85 | iterator++;
86 | continue;
87 | } else if (IslandManager.ISLANDS.isEmpty()) {
88 | ClaimUtil.createSpawnClaim(spawn);
89 | }
90 |
91 | PLUGIN.getLogger().debug("Checking region ({}, {}) for island", region.getX(), region.getZ());
92 |
93 | if (!Region.isOccupied(region)) {
94 | return region;
95 | }
96 | }
97 |
98 | throw new InvalidRegionException(Text.of("Failed to find a valid region!"));
99 | }
100 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/world/gen/VoidWorldGeneratorModifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.world.gen;
20 |
21 | import net.mohron.skyclaims.SkyClaims;
22 | import org.spongepowered.api.Sponge;
23 | import org.spongepowered.api.data.DataContainer;
24 | import org.spongepowered.api.world.DimensionTypes;
25 | import org.spongepowered.api.world.World;
26 | import org.spongepowered.api.world.biome.BiomeGenerationSettings;
27 | import org.spongepowered.api.world.biome.BiomeType;
28 | import org.spongepowered.api.world.biome.BiomeTypes;
29 | import org.spongepowered.api.world.gen.PopulatorTypes;
30 | import org.spongepowered.api.world.gen.WorldGenerator;
31 | import org.spongepowered.api.world.gen.WorldGeneratorModifier;
32 | import org.spongepowered.api.world.storage.WorldProperties;
33 |
34 | /**
35 | * A modifier that causes a {@link World} to generate with empty chunks.
36 | */
37 | public class VoidWorldGeneratorModifier implements WorldGeneratorModifier {
38 |
39 | @Override
40 | public void modifyWorldGenerator(WorldProperties world, DataContainer settings, WorldGenerator worldGenerator) {
41 | if (world.getDimensionType().equals(DimensionTypes.NETHER)) {
42 | modifyNether(worldGenerator);
43 | } else if (world.getDimensionType().equals(DimensionTypes.THE_END)) {
44 | modifyEnd(worldGenerator);
45 | } else {
46 | modifySurface(worldGenerator);
47 | }
48 | worldGenerator.setBaseGenerationPopulator((world1, buffer, biomes) -> {
49 | });
50 | }
51 |
52 | private void modifySurface(WorldGenerator worldGenerator) {
53 | worldGenerator.getPopulators().clear();
54 | worldGenerator.getGenerationPopulators().clear();
55 | for (BiomeType biome : Sponge.getRegistry().getAllOf(BiomeType.class)) {
56 | BiomeGenerationSettings biomeSettings = worldGenerator.getBiomeSettings(biome);
57 | biomeSettings.getPopulators().clear();
58 | biomeSettings.getGenerationPopulators().clear();
59 | biomeSettings.getGroundCoverLayers().clear();
60 | }
61 | }
62 |
63 | private void modifyNether(WorldGenerator worldGenerator) {
64 | BiomeGenerationSettings biomeSettings = worldGenerator.getBiomeSettings(BiomeTypes.HELL);
65 | try {
66 | worldGenerator.getGenerationPopulators().remove(Class.forName("net.minecraft.world.gen.MapGenCavesHell"));
67 | } catch (ClassNotFoundException e) {
68 | SkyClaims.getInstance().getLogger().error("Error modifying nether generation:", e);
69 | }
70 | biomeSettings.getPopulators().remove(PopulatorTypes.NETHER_FIRE);
71 | biomeSettings.getPopulators().remove(PopulatorTypes.GLOWSTONE);
72 | biomeSettings.getPopulators().remove(PopulatorTypes.ORE);
73 | biomeSettings.getPopulators().remove(PopulatorTypes.MUSHROOM);
74 | }
75 |
76 | private void modifyEnd(WorldGenerator worldGenerator) {
77 | worldGenerator.getPopulators().add(new EndPortalFixPopulator());
78 | BiomeGenerationSettings biomeSettings = worldGenerator.getBiomeSettings(BiomeTypes.SKY);
79 | biomeSettings.getPopulators().remove(PopulatorTypes.END_ISLAND);
80 | biomeSettings.getPopulators().remove(PopulatorTypes.CHORUS_FLOWER);
81 | biomeSettings.getGenerationPopulators().clear();
82 | }
83 |
84 | @Override
85 | public String getId() {
86 | return "skyclaims:void";
87 | }
88 |
89 | @Override
90 | public String getName() {
91 | return "Enhanced Void Modifier";
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/team/CommandLeave.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.team;
20 |
21 | import java.util.function.Consumer;
22 | import net.mohron.skyclaims.command.CommandBase;
23 | import net.mohron.skyclaims.command.CommandIsland;
24 | import net.mohron.skyclaims.permissions.Permissions;
25 | import net.mohron.skyclaims.world.Island;
26 | import org.spongepowered.api.command.CommandException;
27 | import org.spongepowered.api.command.CommandResult;
28 | import org.spongepowered.api.command.CommandSource;
29 | import org.spongepowered.api.command.args.CommandContext;
30 | import org.spongepowered.api.command.spec.CommandSpec;
31 | import org.spongepowered.api.entity.living.player.Player;
32 | import org.spongepowered.api.text.Text;
33 | import org.spongepowered.api.text.action.TextActions;
34 | import org.spongepowered.api.text.format.TextColors;
35 |
36 | public class CommandLeave extends CommandBase.IslandCommand {
37 |
38 | public static final String HELP_TEXT = "used to leave an island.";
39 |
40 | public static void register() {
41 | CommandSpec commandSpec = CommandSpec.builder()
42 | .permission(Permissions.COMMAND_LEAVE)
43 | .description(Text.of(HELP_TEXT))
44 | .executor(new CommandLeave())
45 | .build();
46 |
47 | try {
48 | CommandIsland.addSubCommand(commandSpec, "leave");
49 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
50 | PLUGIN.getLogger().debug("Registered command: CommandLeave");
51 | } catch (UnsupportedOperationException e) {
52 | PLUGIN.getLogger().error("Failed to register command: CommandLeave", e);
53 | }
54 | }
55 |
56 | @Override
57 | public CommandResult execute(Player player, Island island, CommandContext args)
58 | throws CommandException {
59 |
60 | if (island.isOwner(player)) {
61 | throw new CommandException(Text.of(TextColors.RED, "You must transfer island ownership before leaving."));
62 | } else if (!island.isMember(player)) {
63 | throw new CommandException(Text.of(TextColors.RED, "You are not a member of ", island.getName(), TextColors.RED, "!"));
64 | }
65 |
66 | player.sendMessage(Text.of(
67 | "Are you sure you want to leave ",
68 | island.getName(),
69 | TextColors.RESET, "?", Text.NEW_LINE,
70 | TextColors.WHITE, "[",
71 | Text.builder("YES")
72 | .color(TextColors.GREEN)
73 | .onClick(TextActions.executeCallback(leaveIsland(player, island))),
74 | TextColors.WHITE, "] [",
75 | Text.builder("NO")
76 | .color(TextColors.RED)
77 | .onClick(
78 | TextActions.executeCallback(s -> s.sendMessage(Text.of("Leave island canceled!")))),
79 | TextColors.WHITE, "]"
80 | ));
81 |
82 | return CommandResult.success();
83 | }
84 |
85 | private Consumer leaveIsland(Player player, Island island) {
86 | return src -> {
87 | if (island.getPlayers().contains(player)) {
88 | player.setLocationSafely(PLUGIN.getConfig().getWorldConfig().getSpawn());
89 | }
90 |
91 | clearMemberInventory(player, Permissions.KEEP_INV_PLAYER_LEAVE, Permissions.KEEP_INV_ENDERCHEST_LEAVE);
92 |
93 | island.removeMember(player);
94 | player.sendMessage(Text.of(TextColors.RED, "You have been removed from ", island.getName(), TextColors.RED, "!"));
95 | };
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/team/CommandPromote.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.team;
20 |
21 | import net.mohron.skyclaims.command.CommandBase;
22 | import net.mohron.skyclaims.command.CommandIsland;
23 | import net.mohron.skyclaims.permissions.Permissions;
24 | import net.mohron.skyclaims.team.Invite;
25 | import net.mohron.skyclaims.team.PrivilegeType;
26 | import net.mohron.skyclaims.world.Island;
27 | import org.spongepowered.api.command.CommandException;
28 | import org.spongepowered.api.command.CommandResult;
29 | import org.spongepowered.api.command.args.CommandContext;
30 | import org.spongepowered.api.command.args.GenericArguments;
31 | import org.spongepowered.api.command.spec.CommandSpec;
32 | import org.spongepowered.api.entity.living.player.Player;
33 | import org.spongepowered.api.entity.living.player.User;
34 | import org.spongepowered.api.text.Text;
35 | import org.spongepowered.api.text.format.TextColors;
36 |
37 |
38 | public class CommandPromote extends CommandBase.IslandCommand {
39 |
40 | public static final String HELP_TEXT = "used to promote a player on an island.";
41 | private static final Text USER = Text.of("user");
42 |
43 | public static void register() {
44 | CommandSpec commandSpec = CommandSpec.builder()
45 | .permission(Permissions.COMMAND_PROMOTE)
46 | .arguments(GenericArguments.user(USER))
47 | .description(Text.of(HELP_TEXT))
48 | .executor(new CommandPromote())
49 | .build();
50 |
51 | try {
52 | CommandIsland.addSubCommand(commandSpec, "promote");
53 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
54 | PLUGIN.getLogger().debug("Registered command: CommandPromote");
55 | } catch (UnsupportedOperationException e) {
56 | PLUGIN.getLogger().error("Failed to register command: CommandPromote", e);
57 | }
58 | }
59 |
60 | @Override
61 | public CommandResult execute(Player player, Island island, CommandContext args)
62 | throws CommandException {
63 | User user = args.getOne(USER).orElse(null);
64 |
65 | if (user == null) {
66 | throw new CommandException(Text.of(TextColors.RED, "A user argument must be provided."));
67 | } else if (player.equals(user)) {
68 | throw new CommandException(Text.of(TextColors.RED, "You cannot promote yourself!"));
69 | } else if (!island.isOwner(player)) {
70 | throw new CommandException(Text.of(TextColors.RED, "You do not have permission to promote players on this island!"));
71 | } else {
72 | PrivilegeType type = island.getPrivilegeType(user);
73 | if (type == PrivilegeType.MANAGER) {
74 | Invite.builder()
75 | .island(island)
76 | .sender(player)
77 | .receiver(user)
78 | .privilegeType(type)
79 | .build()
80 | .send();
81 | player.sendMessage(Text.of(
82 | TextColors.GREEN, "Island ownership transfer request sent to ", type.format(user.getName()), TextColors.GREEN, "."
83 | ));
84 | } else {
85 | island.promote(user);
86 | player.sendMessage(Text.of(
87 | type.format(user.getName()), TextColors.GREEN, " has been promoted from a ", type.toText(),
88 | TextColors.GREEN, " to a ", island.getPrivilegeType(user).toText(), TextColors.GREEN, "."
89 | ));
90 | }
91 | }
92 |
93 | return CommandResult.success();
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import java.util.List;
22 | import net.mohron.skyclaims.command.CommandBase;
23 | import net.mohron.skyclaims.command.argument.Arguments;
24 | import net.mohron.skyclaims.permissions.Permissions;
25 | import net.mohron.skyclaims.schematic.IslandSchematic;
26 | import org.spongepowered.api.command.CommandException;
27 | import org.spongepowered.api.command.CommandResult;
28 | import org.spongepowered.api.command.CommandSource;
29 | import org.spongepowered.api.command.args.CommandContext;
30 | import org.spongepowered.api.command.args.GenericArguments;
31 | import org.spongepowered.api.command.spec.CommandSpec;
32 | import org.spongepowered.api.text.Text;
33 | import org.spongepowered.api.text.format.TextColors;
34 |
35 | public class CommandSchematicCommand extends CommandBase {
36 |
37 | public static final String HELP_TEXT = "used to configure schematic commands";
38 | private static final Text SCHEMATIC = Text.of("schematic");
39 | private static final Text ACTION = Text.of("add|remove");
40 | private static final Text COMMAND = Text.of("command");
41 |
42 | private enum Action {
43 | add, remove
44 | }
45 |
46 | public static CommandSpec commandSpec = CommandSpec.builder()
47 | .permission(Permissions.COMMAND_SCHEMATIC_COMMAND)
48 | .description(Text.of(HELP_TEXT))
49 | .arguments(
50 | Arguments.schematic(SCHEMATIC),
51 | GenericArguments.enumValue(ACTION, Action.class),
52 | GenericArguments.remainingJoinedStrings(COMMAND)
53 | )
54 | .executor(new CommandSchematicCommand())
55 | .build();
56 |
57 | public static void register() {
58 | try {
59 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
60 | PLUGIN.getLogger().debug("Registered command: CommandSchematicAddCommand");
61 | } catch (UnsupportedOperationException e) {
62 | PLUGIN.getLogger().error("Failed to register command: CommandSchematicAddCommand", e);
63 | }
64 | }
65 |
66 | @Override
67 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
68 | IslandSchematic schematic = args.getOne(SCHEMATIC)
69 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a schematic argument to use this command!")));
70 | Action action = args.getOne(ACTION)
71 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide an action argument to use this command!")));
72 | String command = args.getOne(COMMAND)
73 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must provide a command argument to use this command!")));
74 |
75 | List commands;
76 | if (action == Action.add) {
77 | commands = schematic.getCommands();
78 | commands.add(command);
79 | schematic.setCommands(commands);
80 | } else {
81 | commands = schematic.getCommands();
82 | commands.remove(command);
83 | schematic.setCommands(commands);
84 | }
85 |
86 | if (PLUGIN.getSchematicManager().save(schematic)) {
87 | src.sendMessage(Text.of(TextColors.GREEN, "Successfully updated schematic."));
88 | return CommandResult.success();
89 | } else {
90 | throw new CommandException(Text.of(TextColors.RED, "Failed to update schematic."));
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/config/type/MiscConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.config.type;
20 |
21 | import java.text.SimpleDateFormat;
22 | import java.util.ArrayList;
23 | import java.util.List;
24 | import net.mohron.skyclaims.SkyClaims;
25 | import net.mohron.skyclaims.command.argument.IslandSortType;
26 | import ninja.leaping.configurate.objectmapping.Setting;
27 | import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
28 | import org.spongepowered.api.item.ItemType;
29 |
30 | @ConfigSerializable
31 | public class MiscConfig {
32 |
33 | public enum ClearItemsType {BLACKLIST, WHITELIST}
34 |
35 | @Setting(value = "Log-Biomes", comment = "Whether a list of biomes and their permissions should be logged.")
36 | private boolean logBiomes = false;
37 | @Setting(value = "Island-on-Join", comment = "Automatically create an island for a player on join.\n" +
38 | "Requires a valid default schematic to be set (skyclaims.default-schematic)")
39 | private boolean islandOnJoin = false;
40 | @Setting(value = "Teleport-on-Creation", comment = "Automatically teleport the owner to their island on creation.")
41 | private boolean teleportOnCreate = true;
42 | @Setting(value = "Text-Schematic-List", comment = "Enable to use a text based schematic list instead of a chest UI.")
43 | private boolean textSchematicList = false;
44 | @Setting(value = "Island-Commands", comment = "Commands to run on island creation, join or reset. Use @p in place of the player's name.")
45 | private List islandCommands = new ArrayList<>();
46 | @Setting(value = "Clear-Items", comment = "Items to be removed from players inventories when going on or off an island / claim")
47 | private List clearItems = new ArrayList<>();
48 | @Setting(value = "Clear-Items-Type", comment = "Sets whether the Clear-Items list should be treated as a blacklist or whitelist.")
49 | private ClearItemsType clearItemsType = ClearItemsType.BLACKLIST;
50 | @Setting(value = "Date-Format", comment = "The date format used throughout the plugin.\n" +
51 | "http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html")
52 | private String dateFormat = "MMMM d, yyyy h:mm a";
53 | @Setting(value = "Primary-List-Sort", comment = "If set, SkyClaims will sort islands in the list command by this before applying the sort argument.")
54 | private IslandSortType primaryListSort = IslandSortType.NONE;
55 |
56 | public boolean isLogBiomes() {
57 | return logBiomes;
58 | }
59 |
60 | public boolean isCreateIslandOnJoin() {
61 | return islandOnJoin;
62 | }
63 |
64 | public boolean isTeleportOnCreate() {
65 | return teleportOnCreate;
66 | }
67 |
68 | public boolean isTextSchematicList() {
69 | return textSchematicList;
70 | }
71 |
72 | public List getIslandCommands() {
73 | return islandCommands;
74 | }
75 |
76 | public List getClearItems() {
77 | return clearItems;
78 | }
79 |
80 | public ClearItemsType getClearItemsType() {
81 | return clearItemsType;
82 | }
83 |
84 | public SimpleDateFormat getDateFormat() {
85 | try {
86 | return new SimpleDateFormat(dateFormat);
87 | } catch (IllegalArgumentException e) {
88 | SkyClaims.getInstance().getLogger().error("Invalid Date Format: {}", dateFormat);
89 | return new SimpleDateFormat("MMMM d, yyyy h:mm a");
90 | }
91 | }
92 |
93 | public IslandSortType getPrimaryListSort() {
94 | return primaryListSort;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/listener/SchematicHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.listener;
20 |
21 | import com.flowpowered.math.vector.Vector3i;
22 | import com.google.common.collect.Maps;
23 | import java.util.Map;
24 | import java.util.Optional;
25 | import java.util.UUID;
26 | import net.mohron.skyclaims.SkyClaimsTimings;
27 | import net.mohron.skyclaims.permissions.Permissions;
28 | import org.spongepowered.api.block.BlockSnapshot;
29 | import org.spongepowered.api.data.type.HandTypes;
30 | import org.spongepowered.api.entity.living.player.Player;
31 | import org.spongepowered.api.event.Listener;
32 | import org.spongepowered.api.event.block.InteractBlockEvent;
33 | import org.spongepowered.api.event.filter.cause.Root;
34 | import org.spongepowered.api.item.ItemTypes;
35 | import org.spongepowered.api.item.inventory.ItemStack;
36 | import org.spongepowered.api.text.Text;
37 | import org.spongepowered.api.text.format.TextColors;
38 |
39 | public class SchematicHandler {
40 |
41 | private static final Map PLAYER_DATA = Maps.newHashMap();
42 |
43 | @Listener
44 | public void onInteract(InteractBlockEvent.Secondary.MainHand event, @Root Player player) {
45 | SkyClaimsTimings.SCHEMATIC_HANDLER.startTimingIfSync();
46 |
47 | if (!player.hasPermission(Permissions.COMMAND_SCHEMATIC_CREATE)) {
48 | SkyClaimsTimings.SCHEMATIC_HANDLER.abort();
49 | return;
50 | }
51 |
52 | Optional item = player.getItemInHand(HandTypes.MAIN_HAND);
53 | if (item.isPresent() && item.get().getItem().equals(ItemTypes.GOLDEN_AXE)
54 | && event.getTargetBlock() != BlockSnapshot.NONE) {
55 | get(player).setPos2(event.getTargetBlock().getPosition());
56 | player.sendMessage(Text.of(TextColors.LIGHT_PURPLE,
57 | "Position 2 set to " + event.getTargetBlock().getPosition()));
58 | event.setCancelled(true);
59 | }
60 |
61 | SkyClaimsTimings.SCHEMATIC_HANDLER.stopTimingIfSync();
62 | }
63 |
64 | @Listener
65 | public void onInteract(InteractBlockEvent.Primary.MainHand event, @Root Player player) {
66 | SkyClaimsTimings.SCHEMATIC_HANDLER.startTimingIfSync();
67 |
68 | if (!player.hasPermission(Permissions.COMMAND_SCHEMATIC_CREATE)) {
69 | SkyClaimsTimings.SCHEMATIC_HANDLER.abort();
70 | return;
71 | }
72 |
73 | Optional item = player.getItemInHand(HandTypes.MAIN_HAND);
74 | if (item.isPresent() && item.get().getItem().equals(ItemTypes.GOLDEN_AXE)) {
75 | get(player).setPos1(event.getTargetBlock().getPosition());
76 | player.sendMessage(Text.of(TextColors.LIGHT_PURPLE,
77 | "Position 1 set to " + event.getTargetBlock().getPosition()));
78 | event.setCancelled(true);
79 | }
80 |
81 | SkyClaimsTimings.SCHEMATIC_HANDLER.stopTimingIfSync();
82 | }
83 |
84 | public static PlayerData get(Player pl) {
85 | return PLAYER_DATA.computeIfAbsent(pl.getUniqueId(), k -> new PlayerData(pl.getUniqueId()));
86 | }
87 |
88 | public static class PlayerData {
89 |
90 | private final UUID uid;
91 | private Vector3i pos1;
92 | private Vector3i pos2;
93 |
94 | public PlayerData(UUID uid) {
95 | this.uid = uid;
96 | }
97 |
98 | public UUID getUid() {
99 | return this.uid;
100 | }
101 |
102 | public Vector3i getPos1() {
103 | return this.pos1;
104 | }
105 |
106 | public void setPos1(Vector3i pos) {
107 | this.pos1 = pos;
108 | }
109 |
110 | public Vector3i getPos2() {
111 | return this.pos2;
112 | }
113 |
114 | public void setPos2(Vector3i pos) {
115 | this.pos2 = pos;
116 | }
117 | }
118 | }
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/schematic/CommandSchematicCreate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.schematic;
20 |
21 | import static org.spongepowered.api.command.args.GenericArguments.string;
22 |
23 | import com.flowpowered.math.vector.Vector3i;
24 | import java.time.Instant;
25 | import net.mohron.skyclaims.command.CommandBase;
26 | import net.mohron.skyclaims.listener.SchematicHandler;
27 | import net.mohron.skyclaims.permissions.Permissions;
28 | import org.spongepowered.api.command.CommandException;
29 | import org.spongepowered.api.command.CommandResult;
30 | import org.spongepowered.api.command.args.CommandContext;
31 | import org.spongepowered.api.command.spec.CommandSpec;
32 | import org.spongepowered.api.entity.living.player.Player;
33 | import org.spongepowered.api.text.Text;
34 | import org.spongepowered.api.text.format.TextColors;
35 | import org.spongepowered.api.world.extent.ArchetypeVolume;
36 | import org.spongepowered.api.world.schematic.BlockPaletteTypes;
37 | import org.spongepowered.api.world.schematic.Schematic;
38 |
39 | public class CommandSchematicCreate extends CommandBase.PlayerCommand {
40 |
41 | public static final String HELP_TEXT = "used to save the selected area as an island schematic";
42 | private static final Text NAME = Text.of("name");
43 |
44 | public static CommandSpec commandSpec = CommandSpec.builder()
45 | .permission(Permissions.COMMAND_SCHEMATIC_CREATE)
46 | .description(Text.of(HELP_TEXT))
47 | .arguments(string(NAME))
48 | .executor(new CommandSchematicCreate())
49 | .build();
50 |
51 | public static void register() {
52 | try {
53 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec);
54 | PLUGIN.getLogger().debug("Registered command: CommandCreateSchematic");
55 | } catch (UnsupportedOperationException e) {
56 | PLUGIN.getLogger().error("Failed to register command: CommandCreateSchematic", e);
57 | }
58 | }
59 |
60 | @Override
61 | public CommandResult execute(Player player, CommandContext args) throws CommandException {
62 | SchematicHandler.PlayerData data = SchematicHandler.get(player);
63 | if (data.getPos1() == null || data.getPos2() == null) {
64 | throw new CommandException(Text.of(TextColors.RED, "You must set both positions before copying."));
65 | }
66 | Vector3i min = data.getPos1().min(data.getPos2());
67 | Vector3i max = data.getPos1().max(data.getPos2());
68 | ArchetypeVolume volume = player.getWorld().createArchetypeVolume(min, max, player.getLocation().getPosition().toInt());
69 |
70 | String name = args.getOne(NAME)
71 | .orElseThrow(() -> new CommandException(Text.of(TextColors.RED, "You must supply a name to use this command!")));
72 |
73 | Schematic schematic = Schematic.builder()
74 | .volume(volume)
75 | .metaValue(Schematic.METADATA_AUTHOR, player.getName())
76 | .metaValue(Schematic.METADATA_NAME, name)
77 | .metaValue(Schematic.METADATA_DATE, Instant.now().toString())
78 | .paletteType(BlockPaletteTypes.LOCAL)
79 | .build();
80 |
81 | if (PLUGIN.getSchematicManager().create(schematic, name)) {
82 | player.sendMessage(Text.of(TextColors.GREEN, "Successfully created ", TextColors.WHITE, name, TextColors.GREEN, "."));
83 | if (PLUGIN.getConfig().getPermissionConfig().isSeparateSchematicPerms()){
84 | player.sendMessage(Text.of(
85 | TextColors.GREEN, "Use ", TextColors.GRAY, Permissions.COMMAND_ARGUMENTS_SCHEMATICS, ".", name,
86 | TextColors.GREEN, " to give permission to use."
87 | ));
88 | }
89 | return CommandResult.success();
90 | } else {
91 | throw new CommandException(Text.of(TextColors.RED, "Error saving schematic!"));
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/net/mohron/skyclaims/command/debug/CommandVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SkyClaims - A Skyblock plugin made for Sponge
3 | * Copyright (C) 2017 Mohron
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * SkyClaims is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with SkyClaims. If not, see .
17 | */
18 |
19 | package net.mohron.skyclaims.command.debug;
20 |
21 | import com.google.common.collect.Lists;
22 | import com.griefdefender.api.GriefDefender;
23 | import java.util.List;
24 | import java.util.Optional;
25 | import net.mohron.skyclaims.PluginInfo;
26 | import net.mohron.skyclaims.command.CommandBase;
27 | import net.mohron.skyclaims.permissions.Permissions;
28 | import org.spongepowered.api.Platform;
29 | import org.spongepowered.api.Sponge;
30 | import org.spongepowered.api.command.CommandException;
31 | import org.spongepowered.api.command.CommandResult;
32 | import org.spongepowered.api.command.CommandSource;
33 | import org.spongepowered.api.command.args.CommandContext;
34 | import org.spongepowered.api.command.spec.CommandSpec;
35 | import org.spongepowered.api.plugin.PluginContainer;
36 | import org.spongepowered.api.service.permission.PermissionService;
37 | import org.spongepowered.api.text.Text;
38 | import org.spongepowered.api.text.format.TextColors;
39 |
40 | public class CommandVersion extends CommandBase {
41 |
42 | public static final String HELP_TEXT = "used to view loaded config settings.";
43 |
44 | public static void register() {
45 | CommandSpec commandSpec = CommandSpec.builder()
46 | .permission(Permissions.COMMAND_VERSION)
47 | .description(Text.of(HELP_TEXT))
48 | .executor(new CommandVersion())
49 | .build();
50 |
51 | try {
52 | PLUGIN.getGame().getCommandManager().register(PLUGIN, commandSpec, "scversion");
53 | PLUGIN.getLogger().debug("Registered command: CommandVersion");
54 | } catch (UnsupportedOperationException e) {
55 | PLUGIN.getLogger().error("Failed to register command: CommandVersion", e);
56 | }
57 | }
58 |
59 | @Override
60 | public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
61 | List texts = Lists.newArrayList();
62 |
63 | // Minecraft
64 | texts.add(Text.of(
65 | TextColors.DARK_AQUA, "Minecraft", TextColors.WHITE, " : ",
66 | TextColors.YELLOW, Sponge.getPlatform().getMinecraftVersion().getName()
67 | ));
68 | // Sponge
69 | PluginContainer sponge = Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION);
70 | texts.add(Text.of(
71 | TextColors.DARK_AQUA, "Sponge", TextColors.WHITE, " : ",
72 | TextColors.YELLOW, sponge.getName(), " ", sponge.getVersion().orElse("Unknown")
73 | ));
74 | // SkyClaims
75 | texts.add(Text.of(TextColors.DARK_AQUA, "SkyClaims", TextColors.WHITE, " : ", TextColors.YELLOW, PluginInfo.VERSION));
76 | // GriefDefender
77 | String gd = "Error/Missing";
78 | try {
79 | gd = GriefDefender.getVersion().getImplementationVersion();
80 | } catch (Exception e) {
81 | PLUGIN.getLogger().error("Error getting Grief Defender version.", e);
82 | }
83 | texts.add(Text.of(TextColors.DARK_AQUA, "Grief Defender", TextColors.WHITE, " : ", TextColors.YELLOW, gd));
84 | // Permissions
85 | PluginContainer perms = Sponge.getServiceManager().getRegistration(PermissionService.class).get().getPlugin();
86 | texts.add(Text.of(
87 | TextColors.DARK_AQUA, "Permissions", TextColors.WHITE, " : ",
88 | TextColors.YELLOW, perms.getName(), " ", perms.getVersion().orElse("Unknown")
89 | ));
90 | // Nucleus
91 | Optional nucleus = Sponge.getPluginManager().getPlugin("nucleus");
92 | texts.add(Text.of(
93 | TextColors.DARK_AQUA, "Nucleus", TextColors.WHITE, " : ",
94 | TextColors.YELLOW,
95 | nucleus.isPresent() ? nucleus.get().getVersion().orElse("Unknown") : "Not Installed"
96 | ));
97 |
98 | texts.forEach(src::sendMessage);
99 |
100 | return CommandResult.success();
101 | }
102 | }
103 |
--------------------------------------------------------------------------------