diff --git a/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java b/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java index 4005aa79..994ce293 100644 --- a/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java +++ b/spigot/src/main/java/de/sean/blockprot/bukkit/config/DefaultConfig.java @@ -265,6 +265,17 @@ public boolean lockOnPlaceByDefault() { return this.config.getBoolean("lock_on_place_by_default"); } + /** + * Whether the public should be a friend by default. + * + * @return Boolean for the default value of public is friend. + * @since 1.1.15 + */ + public boolean publicIsFriendByDefault() { + if (!this.config.contains("public_on_place_by_default")) return false; + return this.config.getBoolean("public_on_place_by_default"); + } + /** * * @since 1.0.0 diff --git a/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/JoinEventListener.java b/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/JoinEventListener.java index 7529bd19..e8c9e6d6 100644 --- a/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/JoinEventListener.java +++ b/spigot/src/main/java/de/sean/blockprot/bukkit/listeners/JoinEventListener.java @@ -19,8 +19,10 @@ package de.sean.blockprot.bukkit.listeners; import de.sean.blockprot.bukkit.BlockProt; +import de.sean.blockprot.bukkit.nbt.PlayerSettingsHandler; import de.sean.blockprot.bukkit.tasks.UpdateChecker; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; @@ -30,14 +32,18 @@ public class JoinEventListener implements Listener { @EventHandler public void onJoin(PlayerJoinEvent event) { - if (BlockProt.getDefaultConfig().shouldNotifyOpOfUpdates() && event.getPlayer().isOp()) { + Player player = event.getPlayer(); + if (BlockProt.getDefaultConfig().shouldNotifyOpOfUpdates() && player.isOp()) { Bukkit.getScheduler().runTaskAsynchronously( BlockProt.getInstance(), new UpdateChecker( BlockProt.getInstance().getDescription(), - Collections.singletonList(event.getPlayer()) + Collections.singletonList(player) ) ); } + if (BlockProt.getDefaultConfig().publicIsFriendByDefault() && !player.hasPlayedBefore()) { + new PlayerSettingsHandler(player).addEveryoneAsFriend(); + } } } diff --git a/spigot/src/main/resources/config.yml b/spigot/src/main/resources/config.yml index f2dbd281..a4f56988 100644 --- a/spigot/src/main/resources/config.yml +++ b/spigot/src/main/resources/config.yml @@ -43,6 +43,10 @@ excluded_worlds: [ ] # played on the server. lock_on_place_by_default: true +# Setting this to 'true' will make "the public" a friend by +# default. +public_is_friend_by_default: false + # The maximum amount of blocks a player can lock. If removed # or set to any negative value, this is interpreted as setting # no limit.