Skip to content

Commit

Permalink
Fixed bug with ConfigManager not saving properly
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Jun 4, 2020
1 parent 711848c commit e1289c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/redempt/redlib/configmanager/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public ConfigManager save() {
if (!registered) {
throw new IllegalStateException("Config manager is not registered");
}
fields.forEach(f -> f.load(data, config));
fields.forEach(f -> f.save(data, config));
try {
config.save(file);
} catch (IOException e) {
Expand Down
19 changes: 14 additions & 5 deletions src/redempt/redlib/region/ProtectionPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,21 @@ public void onInteract(PlayerInteractEvent e) {

@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
Block block = e.getBlockClicked().getRelative(e.getBlockFace());
if (protections.contains(ProtectionType.USE_BUCKETS)
&& protectionCheck.test(e.getBlockClicked())
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, e.getBlockClicked())) {
&& protectionCheck.test(block)
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, block)) {
e.setCancelled(true);
sendMessage(e.getPlayer(), ProtectionType.USE_BUCKETS);
}
}

@EventHandler
public void onBucketFill(PlayerBucketFillEvent e) {
Block block = e.getBlockClicked().getRelative(e.getBlockFace());
if (protections.contains(ProtectionType.USE_BUCKETS)
&& protectionCheck.test(e.getBlockClicked())
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, e.getBlockClicked())) {
&& protectionCheck.test(block)
&& !canBypass(e.getPlayer(), ProtectionType.USE_BUCKETS, block)) {
e.setCancelled(true);
sendMessage(e.getPlayer(), ProtectionType.USE_BUCKETS);
}
Expand Down Expand Up @@ -287,6 +289,9 @@ public void onEntityChangeBlock(EntityChangeBlockEvent e) {
return;
}
e.setCancelled(true);
} else if (e.getEntityType() == EntityType.SILVERFISH && protectionCheck.test(e.getBlock()) && protections.contains(ProtectionType.SILVERFISH)
&& !canBypass(null, ProtectionType.SILVERFISH, e.getBlock())) {
e.setCancelled(true);
}
}

Expand Down Expand Up @@ -414,7 +419,11 @@ public static enum ProtectionType {
/**
* Mobs spawning
*/
MOB_SPAWN;
MOB_SPAWN,
/**
* Silverfish infesting or breaking blocks
*/
SILVERFISH;

/**
* Every protection type
Expand Down

0 comments on commit e1289c6

Please sign in to comment.