Skip to content

Commit

Permalink
Merge pull request #26 from iXanadu13/2.5.3
Browse files Browse the repository at this point in the history
update to v2.5.4
  • Loading branch information
iXanadu13 authored Jul 31, 2024
2 parents 8ac7f7b + 0adef15 commit 4fd3b73
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 37 deletions.
8 changes: 6 additions & 2 deletions src/main/java/pers/xanadu/enderdragon/EnderDragon.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static pers.xanadu.enderdragon.util.UpdateChecker.checkUpdate;

Expand Down Expand Up @@ -203,8 +204,11 @@ private void registerCommands(){
Objects.requireNonNull(getCommand("enderdragon")).setTabCompleter(new TabCompleter());
}
private void unregisterCommands(){
Objects.requireNonNull(getCommand("enderdragon")).setExecutor(null);
Objects.requireNonNull(getCommand("enderdragon")).setTabCompleter(null);
Optional.ofNullable(getCommand("enderdragon"))
.ifPresent(command -> {
command.setExecutor(null);
command.setTabCompleter(null);
});
}
private void loadConfig(){
saveDefaultConfig();
Expand Down
43 changes: 41 additions & 2 deletions src/main/java/pers/xanadu/enderdragon/config/FileUpdater.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,49 @@
package pers.xanadu.enderdragon.config;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.*;

import static pers.xanadu.enderdragon.EnderDragon.plugin;

public class FileUpdater {
public static void update() throws IOException {
Lang.warn("Nothing to update.");
boolean updated = false;
File folder = new File(plugin.getDataFolder(),"setting");
if(folder.exists()){
File[] files = folder.listFiles();
if(files != null){
for(File file : files){
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
String ver = config.getString("version");
if(!"2.4.0".equals(ver)) {
Lang.error("The version of setting/"+file.getName()+" is not supported!");
continue;
}
updated = true;
String name = file.getName();
Config.copyFile("setting/"+name,"new/setting/"+name,true);
}
File new_folder = new File(plugin.getDataFolder(),"new/setting/");
files = new_folder.listFiles();
if(files != null){
for(File file : files){
FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
fc.set("version","2.5.4");
fc.set("bossbar.create_fog",fc.getBoolean("bossbar.create_frog"));
fc.set("bossbar.create_frog",null);
fc.save(file);
}
}
}
}
if (updated){
Lang.info("New config files are generated in plugins/EnderDragon/new.");
Lang.warn("Attention: Please confirm the accuracy before using new config!");
}
else {
Lang.warn("Nothing to update!");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pers.xanadu.enderdragon.manager.DragonManager;
import pers.xanadu.enderdragon.manager.WorldManager;
import pers.xanadu.enderdragon.metadata.MyDragon;
import pers.xanadu.enderdragon.util.Version;

import static pers.xanadu.enderdragon.manager.DragonManager.getSpecialKey;

Expand All @@ -34,6 +35,7 @@ public class DragonFireballListener implements Listener {
// }
//
// }
private static final Particle ILLEGAL_SPELL_MOB = Version.NBT_UPDATE?null:Particle.valueOf("SPELL_MOB");

@EventHandler(priority = EventPriority.HIGH)
public void OnEffectCloudSpawn(final EntitySpawnEvent e){
Expand All @@ -51,8 +53,14 @@ public void OnEffectCloudSpawn(final EntitySpawnEvent e){
effectCloud.setRadiusPerTick((float) myDragon.effect_cloud_expand_speed/20f);
effectCloud.setDuration(myDragon.effect_cloud_duration * 20);
if(myDragon.effect_cloud_color_R != -1){
effectCloud.setParticle(Particle.SPELL_MOB);
effectCloud.setColor(Color.fromRGB(myDragon.effect_cloud_color_R,myDragon.effect_cloud_color_G,myDragon.effect_cloud_color_B));
Color color = Color.fromRGB(myDragon.effect_cloud_color_R,myDragon.effect_cloud_color_G,myDragon.effect_cloud_color_B);
if (Version.NBT_UPDATE){
effectCloud.setParticle(Particle.ENTITY_EFFECT, color);
}
else{
effectCloud.setParticle(ILLEGAL_SPELL_MOB);
}
effectCloud.setColor(color);
}
effectCloud.clearCustomEffects();
for(PotionEffect effect : myDragon.effect_cloud_potion){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void OnDragonSpawn(final CreatureSpawnEvent e){
if(bossBar != null){
bossBar.setColor(BarColor.valueOf(myDragon.bossbar_color));
bossBar.setStyle(BarStyle.valueOf(myDragon.bossbar_style));
if(myDragon.bossbar_create_frog) bossBar.addFlag(BarFlag.CREATE_FOG);
if(myDragon.bossbar_create_fog) bossBar.addFlag(BarFlag.CREATE_FOG);
else bossBar.removeFlag(BarFlag.CREATE_FOG);
if(myDragon.bossbar_darken_sky) bossBar.addFlag(BarFlag.DARKEN_SKY);
else bossBar.removeFlag(BarFlag.DARKEN_SKY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import pers.xanadu.enderdragon.config.Config;
import pers.xanadu.enderdragon.manager.DragonManager;
import pers.xanadu.enderdragon.manager.GlowManager;

import java.util.Collection;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void OnCrystalPlaced(final PlayerInteractEvent e){
int amount = item.getAmount();
e.getItem().setAmount(amount-1);
}
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen,EntityType.ENDER_CRYSTAL);
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen, DragonManager.getENDER_CRYSTAL());
crystal.setShowingBottom(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class DragonManager {
private static Method getY;
private static Method getZ;
private static final Pattern pattern_attacker_top = Pattern.compile("%attacker_top_(\\d+)%");
@Getter
private static final EntityType ENDER_CRYSTAL = Version.NBT_UPDATE?EntityType.END_CRYSTAL:EntityType.valueOf("ENDER_CRYSTAL");

public static void reload(){
final List<MyDragon> dragons = new ArrayList<>();
Expand Down Expand Up @@ -219,7 +221,7 @@ public static void readSettingFile(FileConfiguration f,int edge,List<MyDragon> d
myDragon.glow_color = f.getString("glow_color","random");
myDragon.bossbar_color = f.getString("bossbar.color","WHITE").toUpperCase();
myDragon.bossbar_style = f.getString("bossbar.style","SOLID").toUpperCase();
myDragon.bossbar_create_frog = f.getBoolean("bossbar.create_frog",true);
myDragon.bossbar_create_fog = f.getBoolean("bossbar.create_fog",true);
myDragon.bossbar_darken_sky = f.getBoolean("bossbar.darken_sky",true);
myDragon.bossbar_play_boss_music = f.getBoolean("bossbar.play_boss_music",true);
myDragon.effect_cloud_original_radius = f.getDouble("effect_cloud.original_radius",3);
Expand Down Expand Up @@ -583,7 +585,7 @@ private static void placeEndCrystals(final Location cen){
if(world == null) return;
cen.add(0.5,1,0.5);
for(int i = 0; i < 4; i++){
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen.clone().add(nxt[i][0],0,nxt[i][1]), EntityType.ENDER_CRYSTAL);
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen.clone().add(nxt[i][0],0,nxt[i][1]), ENDER_CRYSTAL);
if(Config.crystal_invulnerable) crystal.setInvulnerable(true);
crystal.setShowingBottom(false);
}
Expand All @@ -599,7 +601,7 @@ private static void placeEndCrystals(final Location cen,final String uniqueId){
});
}
for(int i = 0; i < 4; i++){
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen.clone().add(nxt[i][0],0,nxt[i][1]), EntityType.ENDER_CRYSTAL);
EnderCrystal crystal = (EnderCrystal) world.spawnEntity(cen.clone().add(nxt[i][0],0,nxt[i][1]), ENDER_CRYSTAL);
if(Config.crystal_invulnerable) crystal.setInvulnerable(true);
crystal.setShowingBottom(false);
crystal.addScoreboardTag("ed_spe_"+uniqueId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class MyDragon implements Comparable<MyDragon>{
public String glow_color;
public String bossbar_color;
public String bossbar_style;
public boolean bossbar_create_frog;
public boolean bossbar_create_fog;
public boolean bossbar_darken_sky;
public boolean bossbar_play_boss_music;
public double effect_cloud_original_radius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bbs.title.getText());
yml.set(path+"color",bbs.color.name());
yml.set(path+"style",bbs.style.name());
yml.set(path+"create_frog",bbs.k());
yml.set(path+"create_fog",bbs.k());
yml.set(path+"darken_sky",bbs.i());
yml.set(path+"play_boss_music",bbs.j());
}catch (ReflectiveOperationException e){
Expand Down Expand Up @@ -72,7 +72,7 @@ public void loadBossBarData(List<World> worlds){
bbs.title = CraftChatMessage.fromString(yml.getString(path+"title"), true)[0];
bbs.color = BossBattle.BarColor.valueOf(yml.getString(path+"color"));
bbs.style = BossBattle.BarStyle.valueOf(yml.getString(path+"style"));
bbs.setCreateFog(yml.getBoolean(path+"create_frog",true));
bbs.setCreateFog(yml.getBoolean(path+"create_fog",true));
bbs.setDarkenSky(yml.getBoolean(path+"darken_sky",true));
bbs.setPlayMusic(yml.getBoolean(path+"play_boss_music",true));
}catch (ReflectiveOperationException e){
Expand All @@ -86,7 +86,7 @@ public void setBossBar(World world, final MyDragon myDragon){
convertColor(myDragon.bossbar_color),
convertStyle(myDragon.bossbar_style)
);
bbs.setCreateFog(myDragon.bossbar_create_frog);
bbs.setCreateFog(myDragon.bossbar_create_fog);
bbs.setDarkenSky(myDragon.bossbar_darken_sky);
bbs.setPlayMusic(myDragon.bossbar_play_boss_music);
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bbs.title.getText());
yml.set(path+"color",bbs.color.name());
yml.set(path+"style",bbs.style.name());
yml.set(path+"create_frog",bbs.p());
yml.set(path+"create_fog",bbs.p());
yml.set(path+"darken_sky",bbs.n());
yml.set(path+"play_boss_music",bbs.o());
}catch (ReflectiveOperationException e){
Expand Down Expand Up @@ -72,7 +72,7 @@ public void loadBossBarData(List<World> worlds){
bbs.title = CraftChatMessage.fromString(yml.getString(path+"title"), true)[0];
bbs.color = BossBattle.BarColor.valueOf(yml.getString(path+"color"));
bbs.style = BossBattle.BarStyle.valueOf(yml.getString(path+"style"));
bbs.setCreateFog(yml.getBoolean(path+"create_frog",true));
bbs.setCreateFog(yml.getBoolean(path+"create_fog",true));
bbs.setDarkenSky(yml.getBoolean(path+"darken_sky",true));
bbs.setPlayMusic(yml.getBoolean(path+"play_boss_music",true));
}catch (ReflectiveOperationException e){
Expand All @@ -86,7 +86,7 @@ public void setBossBar(World world, final MyDragon myDragon){
convertColor(myDragon.bossbar_color),
convertStyle(myDragon.bossbar_style)
);
bbs.setCreateFog(myDragon.bossbar_create_frog);
bbs.setCreateFog(myDragon.bossbar_create_fog);
bbs.setDarkenSky(myDragon.bossbar_darken_sky);
bbs.setPlayMusic(myDragon.bossbar_play_boss_music);
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bbs.title.getText());
yml.set(path+"color",bbs.color.name());
yml.set(path+"style",bbs.style.name());
yml.set(path+"create_frog",bbs.isCreateFog());
yml.set(path+"create_fog",bbs.isCreateFog());
yml.set(path+"darken_sky",bbs.isDarkenSky());
yml.set(path+"play_boss_music",bbs.isPlayMusic());
}catch (ReflectiveOperationException e){
Expand Down Expand Up @@ -72,7 +72,7 @@ public void loadBossBarData(List<World> worlds){
bbs.title = CraftChatMessage.fromString(yml.getString(path+"title"), true)[0];
bbs.color = BossBattle.BarColor.valueOf(yml.getString(path+"color"));
bbs.style = BossBattle.BarStyle.valueOf(yml.getString(path+"style"));
bbs.setCreateFog(yml.getBoolean(path+"create_frog",true));
bbs.setCreateFog(yml.getBoolean(path+"create_fog",true));
bbs.setDarkenSky(yml.getBoolean(path+"darken_sky",true));
bbs.setPlayMusic(yml.getBoolean(path+"play_boss_music",true));
}catch (ReflectiveOperationException e){
Expand All @@ -86,7 +86,7 @@ public void setBossBar(World world, final MyDragon myDragon){
convertColor(myDragon.bossbar_color),
convertStyle(myDragon.bossbar_style)
);
bbs.setCreateFog(myDragon.bossbar_create_frog);
bbs.setCreateFog(myDragon.bossbar_create_fog);
bbs.setDarkenSky(myDragon.bossbar_darken_sky);
bbs.setPlayMusic(myDragon.bossbar_play_boss_music);
try{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bbs.title.getText());
yml.set(path+"color",bbs.color.name());
yml.set(path+"style",bbs.style.name());
yml.set(path+"create_frog",bbs.isCreateFog());
yml.set(path+"create_fog",bbs.isCreateFog());
yml.set(path+"darken_sky",bbs.isDarkenSky());
yml.set(path+"play_boss_music",bbs.isPlayMusic());
}catch (ReflectiveOperationException e){
Expand Down Expand Up @@ -72,7 +72,7 @@ public void loadBossBarData(List<World> worlds){
bbs.title = CraftChatMessage.fromString(yml.getString(path+"title"), true)[0];
bbs.color = BossBattle.BarColor.valueOf(yml.getString(path+"color"));
bbs.style = BossBattle.BarStyle.valueOf(yml.getString(path+"style"));
bbs.setCreateFog(yml.getBoolean(path+"create_frog",true));
bbs.setCreateFog(yml.getBoolean(path+"create_fog",true));
bbs.setDarkenSky(yml.getBoolean(path+"darken_sky",true));
bbs.setPlayMusic(yml.getBoolean(path+"play_boss_music",true));
}catch (ReflectiveOperationException e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bbs.title.getText());
yml.set(path+"color",bbs.color.name());
yml.set(path+"style",bbs.style.name());
yml.set(path+"create_frog",bbs.isCreateFog());
yml.set(path+"create_fog",bbs.isCreateFog());
yml.set(path+"darken_sky",bbs.isDarkenSky());
yml.set(path+"play_boss_music",bbs.isPlayMusic());
}catch (ReflectiveOperationException e){
Expand Down Expand Up @@ -72,7 +72,7 @@ public void loadBossBarData(List<World> worlds){
bbs.title = CraftChatMessage.fromString(yml.getString(path+"title"), true)[0];
bbs.color = BossBattle.BarColor.valueOf(yml.getString(path+"color"));
bbs.style = BossBattle.BarStyle.valueOf(yml.getString(path+"style"));
bbs.setCreateFog(yml.getBoolean(path+"create_frog",true));
bbs.setCreateFog(yml.getBoolean(path+"create_fog",true));
bbs.setDarkenSky(yml.getBoolean(path+"darken_sky",true));
bbs.setPlayMusic(yml.getBoolean(path+"play_boss_music",true));
}catch (ReflectiveOperationException e){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void saveBossBarData(List<World> worlds){
yml.set(path+"title",bossBar.getTitle());
yml.set(path+"color",bossBar.getColor().name());
yml.set(path+"style",bossBar.getStyle().name());
yml.set(path+"create_frog",bossBar.hasFlag(BarFlag.CREATE_FOG));
yml.set(path+"create_fog",bossBar.hasFlag(BarFlag.CREATE_FOG));
yml.set(path+"darken_sky",bossBar.hasFlag(BarFlag.DARKEN_SKY));
yml.set(path+"play_boss_music",bossBar.hasFlag(BarFlag.PLAY_BOSS_MUSIC));
});
Expand Down Expand Up @@ -58,7 +58,7 @@ public void loadBossBarData(List<World> worlds){
bossBar.setTitle(yml.getString(path+"title"));
bossBar.setColor(BarColor.valueOf(yml.getString(path+"color")));
bossBar.setStyle(BarStyle.valueOf(yml.getString(path+"style")));
if(yml.getBoolean(path+"create_frog",true)) bossBar.addFlag(BarFlag.CREATE_FOG);
if(yml.getBoolean(path+"create_fog",true)) bossBar.addFlag(BarFlag.CREATE_FOG);
else bossBar.removeFlag(BarFlag.CREATE_FOG);
if(yml.getBoolean(path+"darken_sky",true)) bossBar.addFlag(BarFlag.DARKEN_SKY);
else bossBar.removeFlag(BarFlag.DARKEN_SKY);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pers/xanadu/enderdragon/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.bukkit.Bukkit.getServer;

public class Version {
public static final String setting_dragon = "2.4.0";
public static final String setting_dragon = "2.5.4";
public static final String lang = "2.2.0";
public static final String config = "2.3.0";
public static final String data = "2.2.0";
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: EnderDragon
version: 2.5.3
version: 2.5.4
main: pers.xanadu.enderdragon.EnderDragon
author: Xanadu13
api-version: 1.13
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/setting/default-zhcn.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#文件版本,请勿修改
version: 2.4.0
version: 2.5.4

#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
unique_name: 'default'
Expand Down Expand Up @@ -120,7 +120,7 @@ bossbar:

# [true/false]
# 生成迷雾
create_frog: true
create_fog: true
# 使天空阴暗
darken_sky: true
# 播放打末影龙时候的BGM
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/setting/default.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.4.0
version: 2.5.4

#This is used for plugin internal identification.
#Please make sure the value is unique among all the types of dragons
Expand Down Expand Up @@ -126,7 +126,7 @@ bossbar:
style: 'SOLID'

# [true/false]
create_frog: true
create_fog: true
darken_sky: true
play_boss_music: true

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/setting/special-zhcn.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#文件版本,请勿修改
version: 2.4.0
version: 2.5.4

#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
unique_name: 'special001'
Expand Down Expand Up @@ -119,7 +119,7 @@ bossbar:

# [true/false]
# 生成迷雾
create_frog: true
create_fog: true
# 使天空阴暗
darken_sky: true
# 播放打末影龙时候的BGM
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/setting/special.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Special thanks to Phaxius for the translation

# File version, do not edit
version: 2.4.0
version: 2.5.4

# Unique ID used by plugin to identify each type of dragon
# unique_name needs to be different in each dragon settings file
Expand Down Expand Up @@ -141,7 +141,7 @@ bossbar:
style: 'SEGMENTED_12'

# [true/false]
create_frog: true
create_fog: true
darken_sky: true
play_boss_music: true

Expand Down

0 comments on commit 4fd3b73

Please sign in to comment.