22
33import io .github .bakedlibs .dough .protection .Interaction ;
44import io .github .bakedlibs .dough .protection .ProtectionModule ;
5- import net .william278 .husktowns .api .HuskTownsAPI ;
6- import net .william278 .husktowns .claim .Position ;
7- import net .william278 .husktowns .claim .World ;
8- import net .william278 .husktowns .listener .Operation ;
9- import net .william278 .husktowns .user .OnlineUser ;
5+ import net .william278 .husktowns .api .BukkitHuskTownsAPI ;
6+ import net .william278 .husktowns .libraries .cloplib .operation .Operation ;
7+ import net .william278 .husktowns .libraries .cloplib .operation .OperationType ;
108import org .bukkit .Location ;
119import org .bukkit .OfflinePlayer ;
1210import org .bukkit .plugin .Plugin ;
2018 */
2119public class HuskTownsProtectionModule implements ProtectionModule {
2220
23- private HuskTownsAPI huskTownsAPI ;
21+ private BukkitHuskTownsAPI huskTownsAPI ;
2422 private final Plugin plugin ;
2523
2624 public HuskTownsProtectionModule (@ Nonnull Plugin plugin ) {
@@ -29,7 +27,7 @@ public HuskTownsProtectionModule(@Nonnull Plugin plugin) {
2927
3028 @ Override
3129 public void load () {
32- huskTownsAPI = HuskTownsAPI .getInstance ();
30+ huskTownsAPI = BukkitHuskTownsAPI .getInstance ();
3331 }
3432
3533 @ Override
@@ -46,38 +44,32 @@ public boolean hasPermission(OfflinePlayer p, Location l, Interaction action) {
4644
4745 // Convert the dough interaction to HuskTowns' ActionType and check via the API
4846 return huskTownsAPI .isOperationAllowed (Operation .of (
49- getOnlineUser (p ), getHuskTownsAction (action ), getPosition (l )));
50- }
51-
52- private OnlineUser getOnlineUser (OfflinePlayer p ) {
53- return huskTownsAPI .getOnlineUser (p .getPlayer ());
54- }
55-
56- private Position getPosition (Location l ) {
57- org .bukkit .World w = l .getWorld ();
58- return Position .at (l .getX (), l .getY (), l .getZ (), World .of (w .getUID (), w .getName (), w .getEnvironment ().name ()));
47+ huskTownsAPI .getOnlineUser (p .getPlayer ()),
48+ getHuskTownsAction (action ),
49+ huskTownsAPI .getPosition (l )
50+ ));
5951 }
6052
6153 /**
62- * Returns the corresponding HuskTowns {@link Operation.Type } from the dough {@link Interaction}
54+ * Returns the corresponding HuskTowns {@link OperationType } from the dough {@link Interaction}
6355 *
6456 * @param doughAction The dough {@link Interaction}
65- * @return The corresponding HuskTowns {@link Operation.Type }
57+ * @return The corresponding HuskTowns {@link OperationType }
6658 */
67- public @ Nonnull Operation . Type getHuskTownsAction (@ Nonnull Interaction doughAction ) {
59+ public @ Nonnull OperationType getHuskTownsAction (@ Nonnull Interaction doughAction ) {
6860 switch (doughAction ) {
6961 case BREAK_BLOCK :
70- return Operation . Type .BLOCK_BREAK ;
62+ return OperationType .BLOCK_BREAK ;
7163 case PLACE_BLOCK :
72- return Operation . Type .BLOCK_PLACE ;
64+ return OperationType .BLOCK_PLACE ;
7365 case ATTACK_ENTITY :
74- return Operation . Type .PLAYER_DAMAGE_ENTITY ;
66+ return OperationType .PLAYER_DAMAGE_ENTITY ;
7567 case ATTACK_PLAYER :
76- return Operation . Type .PLAYER_DAMAGE_PLAYER ;
68+ return OperationType .PLAYER_DAMAGE_PLAYER ;
7769 case INTERACT_BLOCK :
78- return Operation . Type .BLOCK_INTERACT ;
70+ return OperationType .BLOCK_INTERACT ;
7971 default :
80- return Operation . Type .ENTITY_INTERACT ;
72+ return OperationType .ENTITY_INTERACT ;
8173 }
8274 }
8375}
0 commit comments