diff --git a/plugin/src/main/java/io/github/pronze/sba/SBA.java b/plugin/src/main/java/io/github/pronze/sba/SBA.java index ee2f7c91..3e5d9935 100644 --- a/plugin/src/main/java/io/github/pronze/sba/SBA.java +++ b/plugin/src/main/java/io/github/pronze/sba/SBA.java @@ -12,6 +12,7 @@ import io.github.pronze.sba.fix.PerWorldPluginFix; import io.github.pronze.sba.fix.ViaVersionFix; import io.github.pronze.sba.fix.WoolFix; +import io.github.pronze.sba.fix.SLib203Fix; import io.github.pronze.sba.game.ArenaManager; import io.github.pronze.sba.game.IGameStorage; import io.github.pronze.sba.game.tasks.GameTaskManager; @@ -163,6 +164,7 @@ public void enable() { fixs.add(new MagmaFix()); fixs.add(new PerWorldPluginFix()); fixs.add(new WoolFix()); + fixs.add(new SLib203Fix()); fixs.add(citizensFix=new CitizensFix()); for (BaseFix fix : fixs) { diff --git a/plugin/src/main/java/io/github/pronze/sba/fix/SLib203Fix.java b/plugin/src/main/java/io/github/pronze/sba/fix/SLib203Fix.java new file mode 100644 index 00000000..1d499050 --- /dev/null +++ b/plugin/src/main/java/io/github/pronze/sba/fix/SLib203Fix.java @@ -0,0 +1,92 @@ +package io.github.pronze.sba.fix; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileFilter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.FilenameFilter; + +import org.bukkit.enchantments.Enchantment; + +import io.github.pronze.sba.SBA; +import io.github.pronze.sba.config.SBAConfig; + +public class SLib203Fix extends BaseFix { + + @Override + public void detect() { + + } + + public void shopReplace(String search, String replace) { + var path2 = SBA.getBedwarsPlugin().getDataFolder().listFiles(); + + for (File f : path2) { + if (f.getName().toLowerCase().endsWith("yml")) { + try { + FileReader fr = new FileReader(f); + String s; + String totalStr = ""; + try (BufferedReader br = new BufferedReader(fr)) { + + while ((s = br.readLine()) != null) { + totalStr += s + System.lineSeparator(); + } + totalStr = totalStr.replace(search, replace); + FileWriter fw = new FileWriter(f); + fw.write(totalStr); + fw.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + @Override + public void fix(SBAConfig cfg) { + shopReplace("FIREWORK;", "FIREWORK_ROCKET;"); + shopReplace("KNOCKBACK:", "knockback:"); + shopReplace("ARROW_DAMAGE:", "power:"); + shopReplace("ARROW_KNOCKBACK:", "punch:"); + shopReplace(": JUMP", ": jump_boost"); + shopReplace(": REGENERATION", ": regeneration"); + shopReplace(": SLOW", ": slowness"); + shopReplace(": FAST_DIGGING", ": haste"); + shopReplace(": SLOW_DIGGING", ": mining_fatigue"); + shopReplace(": INCREASE_DAMAGE", ": strength"); + shopReplace(": HEAL", ": instant_health"); + shopReplace(": HARM", ": instant_damage"); + shopReplace(": CONFUSION", ": nausea"); + shopReplace(": DAMAGE_RESISTANCE", ": resistance"); + + try{ + for (Enchantment values : Enchantment.values()) { + shopReplace(values.getName()+":", values.getKey().getKey()+":"); + } + } + catch(Throwable t) + { + //Enchantment enum for removed? + } + + } + + @Override + public void warn() { + + } + + @Override + public boolean IsProblematic() { + return false; + } + + @Override + public boolean IsCritical() { + return false; + } + +}