update to v2.0.4

This commit is contained in:
Xanadu13
2023-03-25 23:50:18 +08:00
committed by GitHub
parent 448da3339d
commit aacffe8452
@@ -91,7 +91,7 @@ public class DragonManager {
} }
public static MyDragon judge(){ public static MyDragon judge(){
if(Config.special_dragon_jude_mode.equalsIgnoreCase("edge")){ if(Config.special_dragon_jude_mode.equalsIgnoreCase("weight")){
int cnt = 0, random = ThreadLocalRandom.current().nextInt(0, sum); int cnt = 0, random = ThreadLocalRandom.current().nextInt(0, sum);
for(MyDragon cur : dragons){ for(MyDragon cur : dragons){
if(cnt <= random && cnt + cur.edge > random){ if(cnt <= random && cnt + cur.edge > random){
@@ -110,6 +110,16 @@ public class DragonManager {
} }
return cur; return cur;
} }
else if(Config.special_dragon_jude_mode.equalsIgnoreCase("edge")){
int cnt = 0, random = ThreadLocalRandom.current().nextInt(0, sum);
for(MyDragon cur : dragons){
if(cnt <= random && cnt + cur.edge > random){
return cur;
}
cnt += cur.edge;
}
error("\"edge\" in \"special_dragon_jude_mode\" of config.yml is deprecated!Please use \"weight\" instead.");
}
return null; return null;
} }
public static void setSpecialKey(Entity e, String key){ public static void setSpecialKey(Entity e, String key){
@@ -242,6 +252,12 @@ public class DragonManager {
mp.clear(); mp.clear();
dragon_names.clear(); dragon_names.clear();
} }
public static void setAttribute(EnderDragon dragon, Attribute attribute, double amount){
AttributeInstance instance = dragon.getAttribute(attribute);
assert instance != null;
instance.setBaseValue(amount);
}
public static void modifyAttribute(EnderDragon dragon, Attribute attribute, double amount){ public static void modifyAttribute(EnderDragon dragon, Attribute attribute, double amount){
AttributeInstance instance = dragon.getAttribute(attribute); AttributeInstance instance = dragon.getAttribute(attribute);
assert instance != null; assert instance != null;
@@ -278,10 +294,14 @@ public class DragonManager {
} }
if(battle.getRespawnPhase() == DragonBattle.RespawnPhase.NONE){ if(battle.getRespawnPhase() == DragonBattle.RespawnPhase.NONE){
Location cen = battle.getEndPortalLocation(); Location cen = battle.getEndPortalLocation();
if(cen == null) {
battle.initiateRespawn();
cen = battle.getEndPortalLocation();
if(cen == null){ if(cen == null){
error("The world_the_end is unloaded."); error("The world_the_end is unloaded.");
return false; return false;
} }
}
placeEndCrystals(world,cen); placeEndCrystals(world,cen);
battle.initiateRespawn(); battle.initiateRespawn();
return true; return true;
@@ -311,10 +331,15 @@ public class DragonManager {
Field field = battle.getClass().getDeclaredField("o"); Field field = battle.getClass().getDeclaredField("o");
field.setAccessible(true); field.setAccessible(true);
Object BlockPosition = field.get(battle); Object BlockPosition = field.get(battle);
if(BlockPosition == null){
if (this.DragonBattle_e == null) this.DragonBattle_e = battle.getClass().getMethod("e");
this.DragonBattle_e.invoke(battle);
BlockPosition = field.get(battle);
if(BlockPosition == null){ if(BlockPosition == null){
error("The world_the_end is unloaded."); error("The world_the_end is unloaded.");
return false; return false;
} }
}
if(this.getX == null) this.getX = BlockPosition.getClass().getMethod("getX"); if(this.getX == null) this.getX = BlockPosition.getClass().getMethod("getX");
if(this.getY == null) this.getY = BlockPosition.getClass().getMethod("getY"); if(this.getY == null) this.getY = BlockPosition.getClass().getMethod("getY");
if(this.getZ == null) this.getZ = BlockPosition.getClass().getMethod("getZ"); if(this.getZ == null) this.getZ = BlockPosition.getClass().getMethod("getZ");