Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix revert explosion entities being wiped #5777

Merged
merged 1 commit into from
Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions resources/config-migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,17 @@
"worldAction": "UPDATE_WORLD_BLOCK_IGNORE"
}
]
},
{
"version": "0.98.0.3",
"changes": [
{
"type": "REPLACE",
"path": "new_world_settings.plot_management.wild_revert_on_mob_explosion.entities",
"key": "Creeper,EnderCrystal,EnderDragon,Fireball,SmallFireball,LargeFireball,TNTPrimed,ExplosiveMinecart,Wither,WitherSkull",
"value": "CREEPER,ENDER_CRYSTAL,ENDER_DRAGON,FIREBALL,SMALL_FIREBALL,LARGE_FIREBALL,PRIMED_TNT,MINECART_TNT,WITHER,WITHER_SKULL",
"worldAction": "UPDATE_WORLD_EXPLOSION_REVERT_ENTITIES"
}
]
}
]
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/config/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ public enum ConfigNodes {
"# wilderness by monsters exploding."),
NWS_PLOT_MANAGEMENT_WILD_ENTITY_REVERT_LIST(
"new_world_settings.plot_management.wild_revert_on_mob_explosion.entities",
"Creeper,EnderCrystal,EnderDragon,Fireball,SmallFireball,LargeFireball,TNTPrimed,ExplosiveMinecart,Wither,WitherSkull",
"CREEPER,ENDER_CRYSTAL,ENDER_DRAGON,FIREBALL,SMALL_FIREBALL,LARGE_FIREBALL,PRIMED_TNT,MINECART_TNT,WITHER,WITHER_SKULL",
"# The list of entities whose explosions should be reverted."),
NWS_PLOT_MANAGEMENT_WILD_MOB_REVERT_TIME(
"new_world_settings.plot_management.wild_revert_on_mob_explosion.delay",
Expand Down
9 changes: 5 additions & 4 deletions src/com/palmergames/bukkit/towny/TownySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,19 @@ private static void loadSwitchAndItemUseMaterialsLists() {

public static EnumSet<EntityType> toEntityTypeEnumSet(List<String> entityList) {
EnumSet<EntityType> entities = EnumSet.noneOf(EntityType.class);
for (String entityName : entityList)
for (String entityName : entityList) {
try {
EntityType type = EntityType.valueOf(entityName);
entities.add(type);
entities.add(EntityType.valueOf(entityName.toUpperCase(Locale.ROOT)));
} catch (IllegalArgumentException ignored) {}
}

return entities;
}

public static EnumSet<Material> toMaterialEnumSet(List<String> materialList) {
EnumSet<Material> materials = EnumSet.noneOf(Material.class);
for (String materialName : materialList) {
Material material = Material.matchMaterial(materialName);
Material material = Material.matchMaterial(materialName.toUpperCase(Locale.ROOT));
if (material != null)
materials.add(material);
}
Expand Down
7 changes: 2 additions & 5 deletions src/com/palmergames/bukkit/towny/object/TownyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,8 @@ public void setPlotManagementWildRevertDelay(long plotManagementWildRevertDelay)
}

public void setPlotManagementWildRevertEntities(List<String> entities) {

entityExplosionProtection = EnumSet.noneOf(EntityType.class);

for (EntityType mob : TownySettings.toEntityTypeEnumSet(entities))
entityExplosionProtection.add(mob);
entityExplosionProtection.clear();
entityExplosionProtection.addAll(TownySettings.toEntityTypeEnumSet(entities));

}

Expand Down