Drop support for getting potion effect types by magic number IDs.

getById() is deprecated, and while this does break existing functionality, it is a good kind of breakage because it forces people over to the name-based IDs, which they will eventually be happier with.

Partial fix for #406
This commit is contained in:
Andreas Troelsen 2019-07-22 00:05:45 +02:00
parent 0009e6363a
commit fa2016acb5
2 changed files with 117 additions and 128 deletions

View File

@ -17,6 +17,7 @@ These changes will (most likely) be included in the next version.
- MobArena no longer crashes when players try to join with items that lower their max health below the default of 20. Players with lower max health will notice missing health in the lobby, but it will quickly regenerate to full.
- Food levels no longer deplete for players in the lobby and spectator area.
- Wither skeletons now correctly spawn with stone swords.
- Support for denoting potion effects by magic number IDs has been dropped. This means that if your config-file has any such magic numbers in it, MobArena will no longer successfully parse them and will throw an error on startup.
## [0.103.2] - 2019-04-23
- MobArena no longer touches the `flySpeed` player attribute when players join an arena. This should fix issues where a crash would result in players being "locked in the air" when trying to fly outside of the arena. It also introduces compatibility with plugins that use flight to augment player abilities.

View File

@ -62,7 +62,7 @@ public class PotionEffectParser
}
private static PotionEffect parseSingle(String type) {
PotionEffectType effect = getType(type);
PotionEffectType effect = PotionEffectType.getByName(type);
if (effect == null) {
return null;
@ -72,7 +72,7 @@ public class PotionEffectParser
}
private static PotionEffect withAmplifier(String type, String amplifier) {
PotionEffectType effect = getType(type);
PotionEffectType effect = PotionEffectType.getByName(type);
int amp = getAmplification(amplifier);
if (effect == null || amp == -1) {
@ -83,7 +83,7 @@ public class PotionEffectParser
}
private static PotionEffect withAmplifierAndDuration(String type, String amplifier, String duration) {
PotionEffectType effect = getType(type);
PotionEffectType effect = PotionEffectType.getByName(type);
int amp = getAmplification(amplifier);
int dur = getDuration(duration);
@ -94,18 +94,6 @@ public class PotionEffectParser
}
}
private static PotionEffectType getType(String type) {
PotionEffectType effect = null;
if (type.matches("[0-9]+")) {
effect = PotionEffectType.getById(Integer.parseInt(type));
} else {
effect = PotionEffectType.getByName(type.toUpperCase());
}
return effect;
}
private static int getDuration(String duration) {
int dur = -1;