-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
6 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
Binary file not shown.
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
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
53 changes: 53 additions & 0 deletions
53
project/src/main/java/net/momirealms/antigrieflib/comp/PlotSquaredV6V7Comp.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,53 @@ | ||
package net.momirealms.antigrieflib.comp; | ||
|
||
import com.plotsquared.bukkit.util.BukkitUtil; | ||
import net.momirealms.antigrieflib.AbstractComp; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.Optional; | ||
|
||
public class PlotSquaredV6V7Comp extends AbstractComp { | ||
|
||
public PlotSquaredV6V7Comp(JavaPlugin plugin) { | ||
super(plugin, "PlotSquared"); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
} | ||
|
||
@Override | ||
public boolean canPlace(Player player, Location location) { | ||
return isPlotMember(player, location); | ||
} | ||
|
||
@Override | ||
public boolean canBreak(Player player, Location location) { | ||
return isPlotMember(player, location); | ||
} | ||
|
||
@Override | ||
public boolean canInteract(Player player, Location location) { | ||
return isPlotMember(player, location); | ||
} | ||
|
||
@Override | ||
public boolean canInteractEntity(Player player, Entity entity) { | ||
return isPlotMember(player, entity.getLocation()); | ||
} | ||
|
||
@Override | ||
public boolean canDamage(Player player, Entity entity) { | ||
return isPlotMember(player, entity.getLocation()); | ||
} | ||
|
||
private boolean isPlotMember(Player player, Location location) { | ||
var psLocation = BukkitUtil.adapt(location); | ||
if (psLocation.isPlotRoad()) return false; | ||
if (!psLocation.isPlotArea()) return true; | ||
return Optional.ofNullable(psLocation.getPlotArea().getPlot(psLocation)).map(plot -> plot.isAdded(player.getUniqueId()) || plot.isOwner(player.getUniqueId())).orElse(false); | ||
} | ||
} |