Skip to content

Commit

Permalink
Add: Setting to have the public as a friend by default (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDiscordian authored Feb 24, 2024
1 parent a2dc550 commit 52a827e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
}
4 changes: 4 additions & 0 deletions spigot/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 52a827e

Please sign in to comment.