-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
Conflicts: src/main/resources/config.yml
- Loading branch information
Showing
4 changed files
with
100 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/com/archivesmc/archblock/events/protection/PlayerBucketEmpty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.archivesmc.archblock.events.protection; | ||
|
||
import com.archivesmc.archblock.Plugin; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerBucketEmptyEvent; | ||
|
||
import java.util.UUID; | ||
|
||
public class PlayerBucketEmpty implements Listener { | ||
private final Plugin plugin; | ||
|
||
public PlayerBucketEmpty(Plugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.NORMAL) | ||
public void onEvent(PlayerBucketEmptyEvent event) { | ||
UUID owner = this.plugin.getApi().getOwnerUUID(event.getBlockClicked()); | ||
UUID ourUuid = event.getPlayer().getUniqueId(); | ||
|
||
if (this.plugin.getWorldGuardIntegration().isInIgnoredRegion(event.getBlockClicked())) { | ||
this.plugin.debug("Region has bypass-protection set to true"); | ||
return; | ||
} | ||
|
||
|
||
if (owner != null && ! owner.equals(ourUuid)) { | ||
if (! event.getPlayer().hasPermission("archblock.bypass") && ! this.plugin.getApi().hasFriendship(owner, ourUuid)) { | ||
event.getPlayer().sendMessage( | ||
String.format( | ||
"%s[%sArchBlock%s]%s You may not empty buckets on blocks owned by %s%s%s.", | ||
ChatColor.LIGHT_PURPLE, ChatColor.GOLD, ChatColor.LIGHT_PURPLE, | ||
ChatColor.RED, ChatColor.AQUA, this.plugin.getApi().getUsernameForUuid(owner), | ||
ChatColor.RED | ||
) | ||
); | ||
|
||
event.setCancelled(true); | ||
return; | ||
} | ||
this.plugin.debug("Owner is different but player has a bypass or is friends with the owner"); | ||
} | ||
|
||
this.plugin.debug("Everything's okay - empty ze bucket"); | ||
this.plugin.getApi().removeOwner(event.getBlockClicked()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters