Merge branch 'v6' into features/v6/services

This commit is contained in:
Alexander Söderberg 2020-08-21 23:02:52 +02:00 committed by GitHub
commit 45e75cc06e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
541 changed files with 3086 additions and 2717 deletions

View File

@ -98,13 +98,24 @@ task copyFiles {
}
}
def adventureVersion = '4.0.0-SNAPSHOT'
shadowJar {
dependencies {
include(dependency(":PlotSquared-Core"))
include(dependency("io.papermc:paperlib:1.0.4"))
include(dependency("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT"))
include(dependency("net.kyori:adventure-platform-bukkit:${adventureVersion}"))
include(dependency("net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT"))
include(dependency("net.kyori:adventure-text-serializer-bungeecord:${adventureVersion}"))
include(dependency("net.kyori:adventure-text-serializer-legacy:${adventureVersion}"))
include(dependency("net.kyori:adventure-text-serializer-gson:${adventureVersion}"))
include(dependency("net.kyori:adventure-api:${adventureVersion}"))
include(dependency("net.kyori:adventure-platform-api:${adventureVersion}"))
include(dependency("net.kyori:adventure-platform-common:${adventureVersion}"))
include(dependency("net.kyori:adventure-platform-viaversion:${adventureVersion}"))
include(dependency("net.kyori:adventure-nbt:${adventureVersion}"))
include(dependency("net.kyori:examination-api:1.0.0-SNAPSHOT"))
include(dependency("net.kyori:examination-string:1.0.0-SNAPSHOT"))
include(dependency("org.bstats:bstats-bukkit:1.7"))
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
@ -118,7 +129,7 @@ shadowJar {
include(dependency('com.intellectualsites:Pipeline:1.4.0-SNAPSHOT'))
}
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
relocate('net.kyori.adventure', 'com.plotsquared.core.configuration.adventure')
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
relocate("org.bstats", "com.plotsquared.metrics")
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
@ -126,6 +137,7 @@ shadowJar {
relocate('org.apache.logging.slf4j', 'com.plotsquared.logging.apache')
relocate('org.slf4j', 'com.plotsquared.logging.slf4j')
relocate('com.google.inject', 'com.plotsquared.google')
relocate('javax.inject', 'com.plotsquared.core.inject.javax')
archiveFileName = "${project.name}-${parent.version}.jar"
destinationDirectory = file "../target"

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit;
@ -29,6 +29,7 @@ import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Singleton;
import com.google.inject.Stage;
import com.google.inject.TypeLiteral;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
@ -161,7 +162,7 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID;
import static com.plotsquared.core.util.PremiumVerification.getUserID;
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused")
@SuppressWarnings("unused") @Singleton
public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitPlatform.class.getSimpleName());
@ -256,12 +257,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
if (PremiumVerification.isPremium()) {
logger.info("[P2] PlotSquared version licensed to Spigot user {}", getUserID());
logger.info("[P2] https://www.spigotmc.org/resources/{}", getResourceID());
logger.info("[P2] Download ID: {}", getDownloadID());
logger.info("[P2] Thanks for supporting us :)");
logger.info("PlotSquared version licensed to Spigot user {}", getUserID());
logger.info("https://www.spigotmc.org/resources/{}", getResourceID());
logger.info("Download ID: {}", getDownloadID());
logger.info("Thanks for supporting us :)");
} else {
logger.info("[P2] Couldn't verify purchase :(");
logger.info("Couldn't verify purchase :(");
}
// Database
@ -273,7 +274,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (!plotSquared.getConfigurationVersion().equalsIgnoreCase("v5")) {
// Perform upgrade
if (DBFunc.dbManager.convertFlags()) {
logger.info("[P2] Flags were converted successfully!");
logger.info("Flags were converted successfully!");
// Update the config version
try {
plotSquared.setConfigurationVersion("v5");
@ -297,13 +298,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// WorldEdit
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try {
logger.info("[P2] {} hooked into WorldEdit", this.getPluginName());
logger.info("{} hooked into WorldEdit", this.getPluginName());
WorldEdit.getInstance().getEventBus().register(this.getInjector().getInstance(WESubscriber.class));
if (Settings.Enabled_Components.COMMANDS) {
new WE_Anywhere();
}
} catch (Throwable e) {
logger.error("[P2] Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
logger.error("Incompatible version of WorldEdit, please upgrade: https://builds.enginehub.org/job/worldedit?branch=master");
}
}
@ -346,7 +347,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
try {
getInjector().getInstance(ComponentPresetManager.class);
} catch (final Exception e) {
logger.error("[P2] Failed to initialize the preset system", e);
logger.error("Failed to initialize the preset system", e);
}
}
@ -369,11 +370,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
continue;
}
if (!worldUtil.isWorld(world) && !world.equals("*")) {
logger.warn("[P2] `{}` was not properly loaded - {} will now try to load it properly", world, this.getPluginName());
logger.warn("`{}` was not properly loaded - {} will now try to load it properly", world, this.getPluginName());
logger.warn(
"[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
logger.warn("[P2] - Your world management plugin may be faulty (or non existent)");
logger.warn("[P2] This message may also be a false positive and could be ignored.");
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
logger.warn(" - Your world management plugin may be faulty (or non existent)");
logger.warn(" This message may also be a false positive and could be ignored.");
this.setGenerator(world);
}
}
@ -393,7 +394,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
this.impromptuPipeline.registerService(offlineModeUUIDService);
this.backgroundPipeline.registerService(offlineModeUUIDService);
logger.info("[P2] (UUID) Using the offline mode UUID service");
logger.info("(UUID) Using the offline mode UUID service");
}
if (Settings.UUID.SERVICE_BUKKIT) {
@ -414,7 +415,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final LuckPermsUUIDService luckPermsUUIDService;
if (Settings.UUID.SERVICE_LUCKPERMS && Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
luckPermsUUIDService = new LuckPermsUUIDService();
logger.info("[P2] (UUID) Using LuckPerms as a complementary UUID service");
logger.info("(UUID) Using LuckPerms as a complementary UUID service");
} else {
luckPermsUUIDService = null;
}
@ -422,7 +423,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final BungeePermsUUIDService bungeePermsUUIDService;
if (Settings.UUID.SERVICE_BUNGEE_PERMS && Bukkit.getPluginManager().getPlugin("BungeePerms") != null) {
bungeePermsUUIDService = new BungeePermsUUIDService();
logger.info("[P2] (UUID) Using BungeePerms as a complementary UUID service");
logger.info("(UUID) Using BungeePerms as a complementary UUID service");
} else {
bungeePermsUUIDService = null;
}
@ -430,7 +431,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final EssentialsUUIDService essentialsUUIDService;
if (Settings.UUID.SERVICE_ESSENTIALSX && Bukkit.getPluginManager().getPlugin("Essentials") != null) {
essentialsUUIDService = new EssentialsUUIDService();
logger.info("[P2] (UUID) Using EssentialsX as a complementary UUID service");
logger.info("(UUID) Using EssentialsX as a complementary UUID service");
} else {
essentialsUUIDService = null;
}
@ -441,7 +442,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final PaperUUIDService paperUUIDService = new PaperUUIDService();
this.impromptuPipeline.registerService(paperUUIDService);
this.backgroundPipeline.registerService(paperUUIDService);
logger.info("[P2] (UUID) Using Paper as a complementary UUID service");
logger.info("(UUID) Using Paper as a complementary UUID service");
}
this.impromptuPipeline.registerService(sqLiteUUIDService);
@ -495,17 +496,12 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
ChatFormatter.formatters.add(getInjector().getInstance(PlaceholderFormatter.class));
}
logger.info("[P2] PlotSquared hooked into PlaceholderAPI");
logger.info("PlotSquared hooked into PlaceholderAPI");
} else {
logger.info("[P2] PlaceholderAPI is not in use. Hook deactivated");
logger.info("PlaceholderAPI is not in use. Hook deactivated");
}
if (Settings.Enabled_Components.BSTATS) {
this.startMetrics();
}
else {
logger.info("[P2] bStats is disabled. Please enable it in /plugins/PlotSquared/config/settings.yml. It helps the developers to identify the features most used and organize future updates better. Cheers.");
}
this.startMetrics();
if (Settings.Enabled_Components.WORLDS) {
TaskManager.getPlatformImplementation().taskRepeat(this::unload, TaskTime.seconds(1L));
@ -574,7 +570,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final Chunk[] chunks = world.getLoadedChunks();
if (chunks.length == 0) {
if (!Bukkit.unloadWorld(world, true)) {
logger.warn("[P2] Failed to unload {}", world.getName());
logger.warn("Failed to unload {}", world.getName());
}
return;
} else {
@ -623,7 +619,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
});
logger.info("[P2] (UUID) {} UUIDs will be cached", uuidQueue.size());
logger.info("(UUID) {} UUIDs will be cached", uuidQueue.size());
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
// Begin by reading all the SQLite cache at once
@ -631,7 +627,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// Now fetch names for all known UUIDs
final int totalSize = uuidQueue.size();
int read = 0;
logger.info("[P2] (UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT);
logger.info("(UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT);
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
// Used to indicate that the second retrieval has been attempted
@ -639,7 +635,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
while (!uuidQueue.isEmpty() || !uuidList.isEmpty()) {
if (!uuidList.isEmpty() && secondRun) {
logger.warn("[P2] (UUID) Giving up on last batch. Fetching new batch instead");
logger.warn("(UUID) Giving up on last batch. Fetching new batch instead");
uuidList.clear();
}
if (uuidList.isEmpty()) {
@ -663,13 +659,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
// Print progress
final double percentage = ((double) read / (double) totalSize) * 100.0D;
if (Settings.DEBUG) {
logger.info("[P2] (UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage));
logger.info("(UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage));
}
} catch (final InterruptedException | ExecutionException e) {
logger.error("[P2] (UUID) Failed to retrieve last batch. Will try again", e);
logger.error("(UUID) Failed to retrieve last batch. Will try again", e);
}
}
logger.info("[P2] (UUID) PlotSquared has cached all UUIDs");
logger.info("(UUID) PlotSquared has cached all UUIDs");
}, 10, TimeUnit.SECONDS);
}
@ -701,7 +697,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}
@SuppressWarnings("deprecation") private void runEntityTask() {
logger.info("[P2] KillAllEntities started");
logger.info("KillAllEntities started");
TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> {
final World world = Bukkit.getWorld(plotArea.getWorldName());
try {
@ -979,7 +975,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return;
}
this.metricsStarted = true;
Metrics metrics = new Metrics(this, BSTATS_ID);// bstats
Metrics metrics = new Metrics(this, BSTATS_ID); // bstats
metrics.addCustomChart(new Metrics.DrilldownPie("area_types", () -> {
final Map<String, Map<String, Integer>> map = new HashMap<>();
for (final PlotAreaType plotAreaType : PlotAreaType.values()) {
@ -1022,7 +1018,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
}
} catch (final Exception e) {
logger.error("[P2] Failed to reload world: {} | {}", world, e.getMessage());
logger.error("Failed to reload world: {} | {}", world, e.getMessage());
Bukkit.getServer().unloadWorld(world, false);
return;
}
@ -1093,4 +1089,15 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
return (PlayerManager<BukkitPlayer, Player>) getInjector().getInstance(PlayerManager.class);
}
@Override public void copyCaptionMaps() {
/* Make this prettier at some point */
final String[] languages = new String[] { "en" };
for (final String language : languages) {
if (!new File(new File(this.getDataFolder(), "lang"), String.format("messages_%s.json", language)).exists()) {
this.saveResource(String.format("lang/messages_%s.json", language), false);
logger.info("Copied language file 'messages_{}.json'", language);
}
}
}
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;
@ -391,7 +391,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
try {
entity.getInventory().setContents(this.inventory);
} catch (IllegalArgumentException e) {
logger.error("[P2] Failed to restore inventory", e);
logger.error("Failed to restore inventory", e);
}
}
@ -738,7 +738,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
return entity;
default:
if (Settings.DEBUG) {
logger.info("[P2] Could not identify entity: {}", entity.getType());
logger.info("Could not identify entity: {}", entity.getType());
}
return entity;
// END LIVING

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.entity;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.generator;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.generator;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.generator;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.generator;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.inject;
@ -46,8 +46,8 @@ public class BackupModule extends AbstractModule {
.implement(BackupProfile.class, PlayerBackupProfile.class).build(PlayerBackupProfileFactory.class));
bind(BackupManager.class).to(SimpleBackupManager.class);
} catch (final Exception e) {
logger.error("[P2] Failed to initialize backup manager", e);
logger.error("[P2] Backup features will be disabled");
logger.error("Failed to initialize backup manager", e);
logger.error("Backup features will be disabled");
bind(BackupManager.class).to(NullBackupManager.class);
}
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.inject;
@ -84,6 +84,7 @@ public class BukkitModule extends AbstractModule {
bind(PlayerManager.class).to(BukkitPlayerManager.class);
bind(JavaPlugin.class).toInstance(bukkitPlatform);
bind(PlotPlatform.class).toInstance(bukkitPlatform);
bind(BukkitPlatform.class).toInstance(bukkitPlatform);
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class);
// Console actor
@Nonnull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.inject;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.inject;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;
@ -126,6 +126,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLocaleChangeEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
@ -148,6 +149,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
@ -1624,4 +1626,10 @@ public class PlayerEventListener extends PlotListener implements Listener {
}
}
}
@EventHandler public void onLocaleChange(final PlayerLocaleChangeEvent event) {
BukkitPlayer player = BukkitUtil.adapt(event.getPlayer());
// we're stripping the country code as we con't want to differ between countries
player.setLocale(Locale.forLanguageTag(event.getLocale().substring(0, 2)));
}
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,10 +21,11 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;
import com.google.inject.Inject;
import com.plotsquared.bukkit.BukkitPlatform;
import com.plotsquared.bukkit.placeholder.MVdWPlaceholders;
import com.plotsquared.core.PlotSquared;
@ -35,11 +36,13 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerLoadEvent;
import javax.annotation.Nonnull;
public class ServerListener implements Listener {
private final BukkitPlatform plugin;
public ServerListener(BukkitPlatform plugin) {
@Inject public ServerListener(@Nonnull final BukkitPlatform plugin) {
this.plugin = plugin;
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.listener;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.managers;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.managers;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.managers;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.permissions;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.permissions;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.placeholder;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.placeholder;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.placeholder;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.player;
@ -45,6 +45,9 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
/**
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.
*
* @param player Bukkit OfflinePlayer player to convert
* @param permissionHandler Permission Profile to be used
*/
public BukkitOfflinePlayer(@Nonnull final OfflinePlayer player, @Nonnull final
PermissionHandler permissionHandler) {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.player;
@ -78,7 +78,11 @@ public class BukkitPlayer extends PlotPlayer<Player> {
* <p>Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
*
* @param plotAreaManager PlotAreaManager instance
* @param eventDispatcher EventDispatcher instance
* @param player Bukkit player instance
* @param econHandler EconHandler instance
* @param permissionHandler PermissionHandler instance
*/
public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
@Nonnull final Player player, @Nullable final EconHandler econHandler, @Nonnull final PermissionHandler permissionHandler) {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.player;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.queue;
@ -55,7 +55,7 @@ import java.util.function.Consumer;
* and allows the caller to specify a sink for the loaded chunks. The
* coordinator will prevent the chunks from being unloaded until the sink
* has fully consumed the chunk
* <p>
* </p>
**/
public final class BukkitChunkCoordinator extends ChunkCoordinator {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.queue;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.queue;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.queue;
@ -71,6 +71,8 @@ public class GenChunk extends ScopedQueueCoordinator {
/**
* Set the internal Bukkit chunk data
*
* @param chunkData Bukkit ChunkData
*/
public void setChunkData(@Nonnull ChunkData chunkData) {
this.chunkData = chunkData;
@ -88,6 +90,8 @@ public class GenChunk extends ScopedQueueCoordinator {
/**
* Set the chunk being represented
*
* @param chunk Bukkit Chunk
*/
public void setChunk(@Nonnull Chunk chunk) {
this.chunk = chunk;
@ -96,6 +100,8 @@ public class GenChunk extends ScopedQueueCoordinator {
/**
* Set the world and XZ of the chunk being represented via {@link ChunkWrapper}
*
* @param wrap P2 ChunkWrapper
*/
public void setChunk(@Nonnull ChunkWrapper wrap) {
chunk = null;
@ -146,6 +152,12 @@ public class GenChunk extends ScopedQueueCoordinator {
/**
* Set the in the whole column of XZ
*
* @param x Relative x location within the chunk (0 - 15)
* @param z Relative z location within the chunk (0 - 15)
* @param biome Bukkit biome to set
*
* @return if successful
*/
public boolean setBiome(int x, int z, @Nonnull Biome biome) {
if (this.biomeGrid != null) {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.schematic;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.schematic;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;
@ -32,6 +32,7 @@ import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.util.InventoryUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -49,11 +50,11 @@ import java.util.stream.IntStream;
@Singleton public class BukkitInventoryUtil extends InventoryUtil {
@Override public void open(PlotInventory inv) {
BukkitPlayer bp = (BukkitPlayer) inv.player;
Inventory inventory = Bukkit.createInventory(null, inv.size * 9,
BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
Inventory inventory = Bukkit.createInventory(null, inv.getLines() * 9,
ChatColor.translateAlternateColorCodes('&', inv.getTitle()));
PlotItemStack[] items = inv.getItems();
for (int i = 0; i < inv.size * 9; i++) {
for (int i = 0; i < inv.getLines() * 9; i++) {
PlotItemStack item = items[i];
if (item != null) {
inventory.setItem(i, getItem(item));
@ -66,12 +67,12 @@ import java.util.stream.IntStream;
if (!inv.isOpen()) {
return;
}
BukkitPlayer bp = (BukkitPlayer) inv.player;
BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
bp.player.closeInventory();
}
@Override public void setItem(PlotInventory inv, int index, PlotItemStack item) {
BukkitPlayer bp = (BukkitPlayer) inv.player;
BukkitPlayer bp = (BukkitPlayer) inv.getPlayer();
InventoryView opened = bp.player.getOpenInventory();
if (!inv.isOpen()) {
return;
@ -84,18 +85,19 @@ import java.util.stream.IntStream;
if (item == null) {
return null;
}
ItemStack stack = new ItemStack(BukkitAdapter.adapt(item.getType()), item.amount);
ItemStack stack = new ItemStack(BukkitAdapter.adapt(item.getType()), item.getAmount());
ItemMeta meta = null;
if (item.name != null) {
if (item.getName() != null) {
meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', item.name));
Component nameComponent = BukkitUtil.MINI_MESSAGE.parse(item.getName());
meta.setDisplayName(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(nameComponent));
}
if (item.lore != null) {
if (item.getLore() != null) {
if (meta == null) {
meta = stack.getItemMeta();
}
List<String> lore = new ArrayList<>();
for (String entry : item.lore) {
for (String entry : item.getLore()) {
lore.add(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(BukkitUtil.MINI_MESSAGE.deserialize(entry)));
}
meta.setLore(lore);
@ -141,7 +143,7 @@ import java.util.stream.IntStream;
if (!plotInventory.isOpen()) {
return false;
}
BukkitPlayer bp = (BukkitPlayer) plotInventory.player;
BukkitPlayer bp = (BukkitPlayer) plotInventory.getPlayer();
InventoryView opened = bp.player.getOpenInventory();
if (plotInventory.isOpen()) {
if (opened.getType() == InventoryType.CRAFTING) {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;
@ -37,7 +37,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.inject.annotations.WorldFile;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.SetupObject;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.setup.PlotAreaBuilder;
import com.plotsquared.core.util.SetupUtils;
@ -118,111 +117,6 @@ import java.util.Objects;
Bukkit.unloadWorld(world, false);
}
@Deprecated @Override public String setupWorld(SetupObject object) {
this.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
String world = object.world;
PlotAreaType type = object.type;
String worldPath = "worlds." + object.world;
switch (type) {
case PARTIAL: {
if (object.id != null) {
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
worldSection.createSection(areaPath);
}
ConfigurationSection areaSection =
worldSection.getConfigurationSection(areaPath);
HashMap<String, Object> options = new HashMap<>();
for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue());
}
options.put("generator.type", object.type.toString());
options.put("generator.terrain", object.terrain.toString());
options.put("generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
options.put("generator.init", object.setupGenerator);
}
for (Entry<String, Object> entry : options.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (worldSection.contains(key)) {
Object current = worldSection.get(key);
if (!Objects.equals(value, current)) {
areaSection.set(key, value);
}
} else {
worldSection.set(key, value);
}
}
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (gen != null && gen.isFull()) {
object.setupGenerator = null;
}
break;
}
case AUGMENTED: {
if (!object.plotManager.endsWith(":single")) {
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
if (steps.length != 0) {
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
this.worldConfiguration.set("worlds." + world + ".generator.type", object.type.toString());
this.worldConfiguration.set("worlds." + world + ".generator.terrain", object.terrain.toString());
this.worldConfiguration.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
this.worldConfiguration.set("worlds." + world + ".generator.init", object.setupGenerator);
}
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (gen != null && gen.isFull()) {
object.setupGenerator = null;
}
break;
}
case NORMAL: {
if (steps.length != 0) {
if (!this.worldConfiguration.contains(worldPath)) {
this.worldConfiguration.createSection(worldPath);
}
ConfigurationSection worldSection = this.worldConfiguration.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
break;
}
}
try {
this.worldConfiguration.save(this.worldFile);
} catch (IOException e) {
e.printStackTrace();
}
Objects.requireNonNull(PlotSquared.platform()).getWorldManager()
.handleWorldCreation(object.world, object.setupGenerator);
if (Bukkit.getWorld(world) != null) {
return world;
}
return object.world;
}
@Override public String setupWorld(PlotAreaBuilder builder) {
this.updateGenerators();
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;
@ -116,7 +116,7 @@ public class BukkitUtil extends WorldUtil {
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName());
public static final BukkitAudiences BUKKIT_AUDIENCES = BukkitAudiences.create(BukkitPlatform.getPlugin(BukkitPlatform.class));
public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();
public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacySection();
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final Collection<BlockType> tileEntityTypes = new HashSet<>();
@ -334,7 +334,7 @@ public class BukkitUtil extends WorldUtil {
final Sign sign = (Sign) blockstate;
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()))));
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements)));
}
sign.update(true);
}
@ -349,7 +349,7 @@ public class BukkitUtil extends WorldUtil {
@Override public void setBiomes(@Nonnull final String worldName, @Nonnull final CuboidRegion region, @Nonnull final BiomeType biomeType) {
final World world = getWorld(worldName);
if (world == null) {
logger.warn("[P2] An error occured while setting the biome because the world was null", new RuntimeException());
logger.warn("An error occurred while setting the biome because the world was null", new RuntimeException());
return;
}
final Biome biome = BukkitAdapter.adapt(biomeType);
@ -459,7 +459,7 @@ public class BukkitUtil extends WorldUtil {
}
break;
default: {
logger.error("[P2] Unknown entity category requested: {}", category);
logger.error("Unknown entity category requested: {}", category);
}
break;
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;
@ -126,7 +126,7 @@ public class ContentMap {
try {
entity.spawn(world, xOffset, zOffset);
} catch (Exception e) {
logger.error("[P2] Failed to restore entity", e);
logger.error("Failed to restore entity", e);
}
}
this.entities.clear();

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util;
@ -72,22 +72,22 @@ public class UpdateUtility implements Listener {
.getAsJsonObject();
spigotVersion = result.get("current_version").getAsString();
} catch (IOException e) {
logger.error("[P2] Unable to check for updates. Error: {}", e.getMessage());
logger.error("Unable to check for updates. Error: {}", e.getMessage());
return;
}
if (internalVersion.isLaterVersion(spigotVersion)) {
logger.info("[P2] There appears to be a PlotSquared update available!");
logger.info("[P2] You are running version {}, the latest version is {}",
logger.info("There appears to be a PlotSquared update available!");
logger.info("You are running version {}, the latest version is {}",
internalVersion.versionString(), spigotVersion);
logger.info("[P2] https://www.spigotmc.org/resources/77506/updates");
logger.info("https://www.spigotmc.org/resources/77506/updates");
hasUpdate = true;
if (Settings.UpdateChecker.NOTIFY_ONCE) {
cancelTask();
}
} else if (notify) {
notify = false;
logger.info("[P2] Congratulations! You are running the latest PlotSquared version");
logger.info("Congratulations! You are running the latest PlotSquared version");
}
}, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20);
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.task;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.task;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.task;
@ -36,12 +36,14 @@ import javax.annotation.Nonnegative;
*/
public final class PaperTimeConverter implements TaskTime.TimeConverter {
private static final long MIN_MS_PER_TICKS = 50L;
@Override public long msToTicks(@Nonnegative final long ms) {
return Math.max(1L, (long) (ms / Bukkit.getAverageTickTime()));
return Math.max(1L, (long) (ms / Math.max(MIN_MS_PER_TICKS, Bukkit.getAverageTickTime())));
}
@Override public long ticksToMs(@Nonnegative final long ticks) {
return Math.max(1L, (long) (ticks * Bukkit.getAverageTickTime()));
return Math.max(1L, (long) (ticks * Math.max(MIN_MS_PER_TICKS, Bukkit.getAverageTickTime())));
}
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.util.task;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.bukkit.uuid;
@ -82,7 +82,7 @@ public class SquirrelIdUUIDService implements UUIDService {
//
if (uuids.size() >= 2) {
if (Settings.DEBUG) {
logger.info("[P2] (UUID) Found invalid UUID in batch. Will try each UUID individually.");
logger.info("(UUID) Found invalid UUID in batch. Will try each UUID individually.");
}
for (final UUID uuid : uuids) {
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
@ -92,7 +92,7 @@ public class SquirrelIdUUIDService implements UUIDService {
results.add(result.get(0));
}
} else if (uuids.size() == 1 && Settings.DEBUG) {
logger.info("[P2] (UUID) Found invalid UUID: {}", uuids.get(0));
logger.info("(UUID) Found invalid UUID: {}", uuids.get(0));
}
}
} catch (IOException | InterruptedException e) {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core;
@ -86,11 +86,13 @@ public interface PlotPlatform<P> extends LocaleHolder {
/**
* Gets the version of Minecraft that is running.
* @return server version as array of numbers
*/
int[] getServerVersion();
/**
* Gets the server implementation name and version
* @return server implementationa and version as string
*/
String getServerImplementation();
@ -254,6 +256,11 @@ public interface PlotPlatform<P> extends LocaleHolder {
*/
@Nonnull Audience getConsoleAudience();
/**
* Load the caption maps
*/
void copyCaptionMaps();
/**
* Get the {@link PermissionHandler} implementation for the platform
*

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core;
@ -90,7 +90,6 @@ import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.sql.SQLException;
import java.util.ArrayDeque;
@ -141,7 +140,7 @@ public class PlotSquared {
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
private YamlConfiguration config;
// Localization
private Map<String, CaptionMap> captionMaps;
private final Map<String, CaptionMap> captionMaps = new HashMap<>();
// Platform / Version / Update URL
private PlotVersion version;
// Files and configuration
@ -174,6 +173,13 @@ public class PlotSquared {
//
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
// Load caption map
try {
this.loadCaptionMap();
} catch (final Exception e) {
logger.error("Failed to load caption map", e);
}
// Setup the global flag container
GlobalFlagContainer.setup();
@ -197,8 +203,6 @@ public class PlotSquared {
return;
}
this.captionMaps = new HashMap<>();
this.worldedit = WorldEdit.getInstance();
// Create Event utility class
@ -224,16 +228,19 @@ public class PlotSquared {
}
}
public void loadCaptionMap() throws IOException {
public void loadCaptionMap() throws Exception {
this.platform.copyCaptionMaps();
// Setup localization
CaptionMap captionMap;
if (Settings.Enabled_Components.PER_USER_LOCALE) {
captionMap = CaptionLoader.loadAll(Paths.get("lang"));
captionMap = CaptionLoader.loadAll(new File(this.platform.getDirectory(), "lang").toPath());
} else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
captionMap = CaptionLoader.loadSingle(Paths.get("lang", fileName));
captionMap = CaptionLoader.loadSingle(new File(new File(this.platform.getDirectory(), "lang"), fileName).toPath());
}
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
logger.info("Loaded caption map for namespace 'plotsquared': {}",
this.captionMaps.get(TranslatableCaption.DEFAULT_NAMESPACE).getClass().getCanonicalName());
}
/**
@ -384,16 +391,16 @@ public class PlotSquared {
regionInts.forEach(l -> regions.add(BlockVector2.at(l[0], l[1])));
chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1])));
int height = (int) list.get(2);
logger.info("[P2] Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height);
logger.info("[P2] - Regions: {}", regions.size());
logger.info("[P2] - Chunks: {}", chunks.size());
logger.info("Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height);
logger.info(" - Regions: {}", regions.size());
logger.info(" - Chunks: {}", chunks.size());
HybridUtils.UPDATE = true;
PlotSquared.platform().getHybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
} catch (IOException | ClassNotFoundException e) {
logger.error("[P2] Error restarting road regeneration", e);
logger.error("Error restarting road regeneration", e);
} finally {
if (!file.delete()) {
logger.error("[P2] Error deleting persistent_regen_data_{}. Please delete this file manually", plotArea.getId());
logger.error("Error deleting persistent_regen_data_{}. Please delete this file manually", plotArea.getId());
}
}
});
@ -796,10 +803,10 @@ public class PlotSquared {
// Conventional plot generator
PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null);
PlotManager plotManager = plotArea.getPlotManager();
logger.info("[P2] Detected world load for '{}'", world);
logger.info("[P2] - generator: {}>{}", baseGenerator, plotGenerator);
logger.info("[P2] - plot world: {}", plotArea.getClass().getCanonicalName());
logger.info("[P2] - plot area manager: {}", plotManager.getClass().getCanonicalName());
logger.info("Detected world load for '{}'", world);
logger.info(" - generator: {}>{}", baseGenerator, plotGenerator);
logger.info(" - plot world: {}", plotArea.getClass().getCanonicalName());
logger.info("- plot area manager: {}", plotManager.getClass().getCanonicalName());
if (!this.worldConfiguration.contains(path)) {
this.worldConfiguration.createSection(path);
worldSection = this.worldConfiguration.getConfigurationSection(path);
@ -823,7 +830,7 @@ public class PlotSquared {
if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
return;
}
logger.info("[P2] Detected world load for '{}'", world);
logger.info("Detected world load for '{}'", world);
String gen_string = worldSection.getString("generator.plugin", platform.getPluginName());
if (type == PlotAreaType.PARTIAL) {
Set<PlotCluster> clusters =
@ -839,7 +846,7 @@ public class PlotSquared {
String fullId = name + "-" + pos1 + "-" + pos2;
worldSection.createSection("areas." + fullId);
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
logger.info("[P2] - {}-{}-{}", name, pos1, pos2);
logger.info(" - {}-{}-{}", name, pos1, pos2);
GeneratorWrapper<?> areaGen = this.platform.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
@ -853,10 +860,10 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
logger.info("[P2] | plot world: {}", pa);
logger.info("[P2] | manager: {}", pa);
logger.info("[P2] Note: Area created for cluster '{}' (invalid or old configuration?)", name);
logger.info(" | generator: {}>{}", baseGenerator, areaGen);
logger.info(" | plot world: {}", pa);
logger.info(" | manager: {}", pa);
logger.info("Note: Area created for cluster '{}' (invalid or old configuration?)", name);
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
toLoad.add(pa);
@ -878,9 +885,9 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
logger.info("[P2] - generator: {}>{}", baseGenerator, areaGen);
logger.info("[P2] - plot world: {}", pa);
logger.info("[P2] - plot area manager: {}", pa.getPlotManager());
logger.info(" - generator: {}>{}", baseGenerator, areaGen);
logger.info(" - plot world: {}", pa);
logger.info(" - plot area manager: {}", pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
addPlotArea(pa);
@ -892,7 +899,7 @@ public class PlotSquared {
+ PlotAreaType.AUGMENTED + "`");
}
for (String areaId : areasSection.getKeys(false)) {
logger.info("[P2] - {}", areaId);
logger.info(" - {}", areaId);
String[] split = areaId.split("(?<=[^;-])-");
if (split.length != 3) {
throw new IllegalArgumentException("Invalid Area identifier: " + areaId
@ -954,10 +961,10 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
logger.info("[P2] Detected area load for '{}'", world);
logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
logger.info("[P2] | plot world: {}", pa);
logger.info("[P2] | manager: {}", pa.getPlotManager());
logger.info("Detected area load for '{}'", world);
logger.info(" | generator: {}>{}", baseGenerator, areaGen);
logger.info(" | plot world: {}", pa);
logger.info(" | manager: {}", pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
addPlotArea(pa);
@ -1028,7 +1035,7 @@ public class PlotSquared {
for (String element : split) {
String[] pair = element.split("=");
if (pair.length != 2) {
logger.error("[P2] No value provided for '{}'", element);
logger.error("No value provided for '{}'", element);
return false;
}
String key = pair[0].toLowerCase();
@ -1076,11 +1083,11 @@ public class PlotSquared {
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
break;
default:
logger.error("[P2] Key not found: {}", element);
logger.error("Key not found: {}", element);
return false;
}
} catch (Exception e) {
logger.error("[P2] Invalid value '{}' for arg '{}'", value, element);
logger.error("Invalid value '{}' for arg '{}'", value, element);
e.printStackTrace();
return false;
}
@ -1148,7 +1155,7 @@ public class PlotSquared {
}
}
} catch (IOException e) {
logger.error("[P2] Could not save {}", file);
logger.error("Could not save {}", file);
e.printStackTrace();
}
}
@ -1171,7 +1178,7 @@ public class PlotSquared {
// Close the connection
DBFunc.close();
} catch (NullPointerException throwable) {
logger.error("[P2] Could not close database connection", throwable);
logger.error("Could not close database connection", throwable);
throwable.printStackTrace();
}
}
@ -1184,9 +1191,9 @@ public class PlotSquared {
HybridUtils.regions.isEmpty() && HybridUtils.chunks.isEmpty())) {
return;
}
logger.info("[P2] Road regeneration incomplete. Saving incomplete regions to disk");
logger.info("[P2] - regions: {}", HybridUtils.regions.size());
logger.info("[P2] - chunks: {}", HybridUtils.chunks.size());
logger.info("Road regeneration incomplete. Saving incomplete regions to disk");
logger.info(" - regions: {}", HybridUtils.regions.size());
logger.info(" - chunks: {}", HybridUtils.chunks.size());
ArrayList<int[]> regions = new ArrayList<>();
ArrayList<int[]> chunks = new ArrayList<>();
for (BlockVector2 r : HybridUtils.regions) {
@ -1203,14 +1210,14 @@ public class PlotSquared {
this.platform.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
.getId() + "_" + HybridUtils.area.getWorldName());
if (file.exists() && !file.delete()) {
logger.error("[P2] persistent_regene_data file already exists and could not be deleted");
logger.error("persistent_regene_data file already exists and could not be deleted");
return;
}
try (ObjectOutputStream oos = new ObjectOutputStream(
Files.newOutputStream(file.toPath(), StandardOpenOption.CREATE_NEW))) {
oos.writeObject(list);
} catch (IOException e) {
logger.error("[P2] Error creating persistent_region_data file", e);
logger.error("Error creating persistent_region_data file", e);
}
}
@ -1230,7 +1237,7 @@ public class PlotSquared {
File file = FileUtils.getFile(platform.getDirectory(), Storage.SQLite.DB + ".db");
database = new SQLite(file);
} else {
logger.error("[P2] No storage type is set. Disabling PlotSquared");
logger.error("No storage type is set. Disabling PlotSquared");
this.platform.shutdown(); //shutdown used instead of disable because no database is set
return;
}
@ -1248,11 +1255,11 @@ public class PlotSquared {
}
this.clustersTmp = DBFunc.getClusters();
} catch (ClassNotFoundException | SQLException e) {
logger.error("[P2] Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
logger.error("[P2] ==== Here is an ugly stacktrace, if you are interested in those things ===");
logger.error("Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
logger.error("==== Here is an ugly stacktrace, if you are interested in those things ===");
e.printStackTrace();
logger.error("[P2] &d==== End of stacktrace ====");
logger.error("[P2] &6Please go to the {} 'storage.yml' and configure the database correctly",
logger.error("==== End of stacktrace ====");
logger.error("Please go to the {} 'storage.yml' and configure the database correctly",
platform.getPluginName());
this.platform.shutdown(); //shutdown used instead of disable because of database error
}
@ -1278,7 +1285,7 @@ public class PlotSquared {
try {
worldConfiguration.save(worldsFile);
} catch (IOException e) {
logger.error("[P2] Failed to save worlds.yml", e);
logger.error("Failed to save worlds.yml", e);
e.printStackTrace();
}
}
@ -1306,16 +1313,18 @@ public class PlotSquared {
* Setup all configuration files<br>
* - Config: settings.yml<br>
* - Storage: storage.yml<br>
*
* @return success or not
*/
public boolean setupConfigs() {
File folder = new File(this.platform.getDirectory(), "config");
if (!folder.exists() && !folder.mkdirs()) {
logger.error("[P2] Failed to create the /plugins/config folder. Please create it manually");
logger.error("Failed to create the /plugins/PlotSquared/config folder. Please create it manually");
}
try {
this.worldsFile = new File(folder, "worlds.yml");
if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) {
logger.error("[P2] Could not create the worlds file. Please create 'worlds.yml' manually");
logger.error("Could not create the worlds file. Please create 'worlds.yml' manually");
}
this.worldConfiguration = YamlConfiguration.loadConfiguration(this.worldsFile);
@ -1325,20 +1334,20 @@ public class PlotSquared {
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worldConfiguration
.getString("configuration_version").equalsIgnoreCase("v5"))) {
// Conversion needed
logger.info("[P2] &aA legacy configuration file was detected. Conversion will be attempted.");
logger.info("A legacy configuration file was detected. Conversion will be attempted.");
try {
com.google.common.io.Files
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
logger.info("[P2] &6A copy of worlds.yml has been saved in the file worlds.yml.old");
logger.info("A copy of worlds.yml has been saved in the file worlds.yml.old");
final ConfigurationSection worlds =
this.worldConfiguration.getConfigurationSection("worlds");
final LegacyConverter converter = new LegacyConverter(worlds);
converter.convert();
this.worldConfiguration.set("worlds", worlds);
this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
logger.info("[P2] &aThe conversion has finished. PlotSquared will now be disabled and the new configuration file will be used at next startup. Please review the new worlds.yml file. Please note that schematics will not be converted, as we are now using WorldEdit to handle schematics. You need to re-generate the schematics.");
logger.info("The conversion has finished. PlotSquared will now be disabled and the new configuration file will be used at next startup. Please review the new worlds.yml file. Please note that schematics will not be converted, as we are now using WorldEdit to handle schematics. You need to re-generate the schematics.");
} catch (final Exception e) {
logger.error("[P2] &cFailed to convert the legacy configuration file. See stack trace for information.", e);
logger.error("Failed to convert the legacy configuration file. See stack trace for information.", e);
}
// Disable plugin
this.platform.shutdown();
@ -1348,27 +1357,27 @@ public class PlotSquared {
this.worldConfiguration.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
}
} catch (IOException ignored) {
logger.error("[P2] Failed to save worlds.yml");
logger.error("Failed to save worlds.yml");
}
try {
this.configFile = new File(folder, "settings.yml");
if (!this.configFile.exists() && !this.configFile.createNewFile()) {
logger.error("[P2] Could not create the settings file. Please create 'settings.yml' manually");
logger.error("Could not create the settings file. Please create 'settings.yml' manually");
}
this.config = YamlConfiguration.loadConfiguration(this.configFile);
setupConfig();
} catch (IOException ignored) {
logger.error("[P2] Failed to save settings.yml");
logger.error("Failed to save settings.yml");
}
try {
this.storageFile = new File(folder, "storage.yml");
if (!this.storageFile.exists() && !this.storageFile.createNewFile()) {
logger.error("[P2] Could not create the storage settings file. Please create 'storage.yml' manually");
logger.error("Could not create the storage settings file. Please create 'storage.yml' manually");
}
YamlConfiguration.loadConfiguration(this.storageFile);
setupStorage();
} catch (IOException ignored) {
logger.error("[P2] Failed to save storage.yml");
logger.error("Failed to save storage.yml");
}
return true;
}
@ -1399,7 +1408,7 @@ public class PlotSquared {
if (Settings.DEBUG) {
Map<String, Object> components = Settings.getFields(Settings.Enabled_Components.class);
for (Entry<String, Object> component : components.entrySet()) {
logger.info("[P2] Key: {} | Value: {}", component.getKey(), component.getValue());
logger.info("Key: {} | Value: {}", component.getKey(), component.getValue());
}
}
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.backup;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.collection;

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -48,7 +48,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "add",
description = "Allow a user to build in a plot while the plot owner is online.",
usage = "/plot add <player | *>",
category = CommandCategory.SETTINGS,
permission = "plots.add",

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -44,7 +44,6 @@ import java.util.concurrent.TimeoutException;
@CommandDeclaration(command = "alias",
permission = "plots.alias",
description = "Set the plot name",
usage = "/plot alias <set | remove> <alias>",
aliases = {"setalias", "sa", "name", "rename", "setname", "seta", "nameplot"},
category = CommandCategory.SETTINGS,

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -93,7 +93,6 @@ import java.util.UUID;
permission = "plots.area",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
description = "Create a new PlotArea",
aliases = "world",
usage = "/plot area <create | info | list | tp | regen>",
confirmation = true)

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -58,7 +58,7 @@ public abstract class Argument<T> {
}
};
public static final Argument<String> PlayerName =
new Argument<String>("PlayerName", "<player|*>") {
new Argument<String>("PlayerName", "<player | *>") {
@Override public String parse(String in) {
return in.length() <= 16 ? in : null;
}

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -64,7 +64,6 @@ import java.util.stream.Collectors;
permission = "plots.auto",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
description = "Claim the nearest plot",
aliases = "a",
usage = "/plot auto [length, width]")
public class Auto extends SubCommand {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -57,7 +57,6 @@ import java.util.stream.Stream;
@CommandDeclaration(command = "backup",
usage = "/plot backup <save | list | load>",
description = "Manage plot backups",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup")
@ -123,7 +122,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "save",
usage = "/plot backup save",
description = "Create a plot backup",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.save")
@ -174,7 +172,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "list",
usage = "/plot backup list",
description = "List available plot backups",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.list")
@ -241,7 +238,6 @@ public final class Backup extends Command {
@CommandDeclaration(command = "load",
usage = "/plot backup load <#>",
description = "Restore a plot backup",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER,
permission = "plots.backup.load")

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -40,7 +40,6 @@ import java.util.stream.Collectors;
@CommandDeclaration(command = "setbiome",
permission = "plots.set.biome",
description = "Set the plot biome",
usage = "/plot biome [biome]",
aliases = {"biome", "sb", "setb", "b"},
category = CommandCategory.APPEARANCE,
@ -67,7 +66,7 @@ public class Biome extends SetCommand {
return false;
}
plot.addRunning();
plot.setBiome(biome, () -> {
plot.getPlotModificationManager().setBiome(biome, () -> {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("biome.biome_set_to"),
@ -78,8 +77,7 @@ public class Biome extends SetCommand {
}
@Override
public Collection<Command> tab(final PlotPlayer player, final String[] args,
final boolean space) {
public Collection<Command> tab(final PlotPlayer<?> player, final String[] args, final boolean space) {
return SuggestionHelper.getNamespacedRegistrySuggestions(BiomeType.REGISTRY, args[0])
.map(value -> value.toLowerCase(Locale.ENGLISH).replace("minecraft:", ""))
.filter(value -> value.startsWith(args[0].toLowerCase(Locale.ENGLISH)))

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -46,7 +46,6 @@ import java.util.Set;
import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "buy",
description = "Buy the plot you are standing on",
usage = "/plot buy",
permission = "plots.buy",
category = CommandCategory.CLAIMING,

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -47,7 +47,6 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
@CommandDeclaration(command = "caps",
category = CommandCategory.INFO,
description = "Show plot entity caps",
usage = "/plot caps")
public class Caps extends SubCommand {

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -29,7 +29,6 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
@CommandDeclaration(command = "chat",
description = "Toggles plot chat on or off",
usage = "/plot chat",
permission = "plots.chat",
category = CommandCategory.CHAT,

View File

@ -21,7 +21,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.command;
@ -55,7 +55,6 @@ import javax.annotation.Nullable;
@CommandDeclaration(
command = "claim",
aliases = "c",
description = "Claim the current plot you're standing on",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER, permission = "plots.claim",
usage = "/plot claim")
@ -175,8 +174,7 @@ public class Claim extends SubCommand {
try {
TaskManager.getPlatformImplementation().sync(() -> {
if (!plot.claim(player, true, finalSchematic, false)) {
logger.info(TranslatableCaption.of("core.prefix") + String
.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
logger.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) {
@ -188,7 +186,7 @@ public class Claim extends SubCommand {
Template.of("value", "Auto merge on claim")
);
} else {
plot.autoMerge(mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), true);
plot.getPlotModificationManager().autoMerge(mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), true);
}
}
return null;
@ -197,9 +195,7 @@ public class Claim extends SubCommand {
e.printStackTrace();
}
}, () -> {
logger.info(TranslatableCaption.of("core.prefix") + String
.format("Failed to add plot %s to the database",
plot.getId().toCommaSeparatedString()));
logger.info("Failed to add plot to database: {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
});

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