Skip to content

Commit

Permalink
some fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
boiscljo committed Sep 23, 2023
1 parent 15989be commit 83ca8c7
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugin/src/main/java/io/github/pronze/sba/SBA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
92 changes: 92 additions & 0 deletions plugin/src/main/java/io/github/pronze/sba/fix/SLib203Fix.java
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit 83ca8c7

Please sign in to comment.