Skip to content

Commit

Permalink
small settings changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ActualPlayer committed Aug 17, 2019
1 parent c01391e commit 8f65c36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
32 changes: 14 additions & 18 deletions src/main/java/com/actualplayer/modpermissions/ModPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,33 +157,29 @@ public void onEntityInteract(InteractEntityEvent event) {

@Listener
public void onPreItemPickup(ChangeInventoryEvent.Pickup.Pre event) {
if (configuration.isBlacklistItemPickup()) {
try {
Player player = ((Player) event.getCause().all().get(0));
String itemId = event.getFinal().get(0).getType().getId();

if (!hasPermission(player, itemId, "pickup")) {
event.setCancelled(true);
}
} catch (Exception ignored) {
try {
Player player = ((Player) event.getCause().all().get(0));
String itemId = event.getFinal().get(0).getType().getId();

if (!hasPermission(player, itemId, "pickup")) {
event.setCancelled(true);
}
} catch (Exception ignored) {

}
}

@Listener
public void onBlockPlace(ChangeBlockEvent.Place event) {
if (configuration.isBlacklistItemPickup()) {
try {
Player player = ((Player) event.getCause().all().get(0));
String itemId = event.getTransactions().get(0).getDefault().getState().getId();

if (!hasPermission(player, itemId, "pickup")) {
event.setCancelled(true);
}
} catch (Exception ignored) {
try {
Player player = ((Player) event.getCause().all().get(0));
String itemId = event.getTransactions().get(0).getDefault().getState().getId();

if (!hasPermission(player, itemId, "pickup")) {
event.setCancelled(true);
}
} catch (Exception ignored) {

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,18 @@ public class Configuration {

public static TypeToken<Configuration> TYPE = TypeToken.of(Configuration.class);

@Setting(value = "blacklistItemPickup", comment = "When a player does not have permission to a mod, also disable picking up of items on the floor.")
private boolean blacklistItemPickup = false;

@Setting(value = "informationMessage", comment = "What message to send to the user when he attempts to use a mod that he does not have permission to use. Leave this empty to disable messaging. %m is the mod id.")
private String informationMessage = "You do not have access to %m.";

@Setting(value = "allowBreakingOfBlocks", comment = "Allows breaking of blocks even with the permission to prevent griefing.")
@Setting(value = "allowBreakingOfBlocks", comment = "Allows breaking of blocks disregarding any permission to prevent griefing.")
private boolean allowBreakingOfBlocks = true;

@Setting(value = "allowItemsToDrop", comment = "If allowBreakingOfBlocks is true, this will also drop the item to the ground. The user will not be able to pick up the item if he has the modpermissions.blacklist.{mod id}.pickup permission")
private boolean allowItemsToDrop = false;
private boolean allowItemsToDrop = true;

@Setting(value = "allowItemMove", comment = "Allows the moving of mod items between inventories. This value is ignored if the user attempts to move items from his inventory.")
private boolean allowItemMove = true;

public boolean isBlacklistItemPickup() {
return blacklistItemPickup;
}

public void setBlacklistItemPickup(boolean blacklistItemPickup) {
this.blacklistItemPickup = blacklistItemPickup;
}

public String getInformationMessage() {
return informationMessage;
}
Expand Down

0 comments on commit 8f65c36

Please sign in to comment.