-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change config to ini. default invis armor stands to off (#11)
- Loading branch information
Showing
8 changed files
with
221 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package tf.ssf.sfort.invisframes; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class Config { | ||
public static Logger LOGGER = LogManager.getLogger(); | ||
public enum ItemCheck { | ||
CLIENT(true, false), | ||
SERVER(false, true), | ||
BOTH(true, true), | ||
NONE(false, false); | ||
public final boolean client; | ||
public final boolean server; | ||
ItemCheck(boolean client, boolean server) { | ||
this.client = client; | ||
this.server = server; | ||
} | ||
} | ||
public enum NameCheck { | ||
NEVER, ALWAYS, INVIS_ONLY | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package tf.ssf.sfort.invisframes; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.apache.logging.log4j.Level; | ||
import tf.ssf.sfort.ini.SFIni; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ConfigLegacy { | ||
public static void loadLegacy(SFIni inIni) { | ||
Map<String, String> oldConf = new HashMap<>(); | ||
File confFile = new File( | ||
FabricLoader.getInstance().getConfigDir().toString(), | ||
"InvisFrames.conf" | ||
); | ||
if (!confFile.exists()) return; | ||
try { | ||
List<String> la = Files.readAllLines(confFile.toPath()); | ||
String[] ls = la.toArray(new String[Math.max(la.size(), 18)|1]); | ||
|
||
try{ | ||
oldConf.put("frame.clientForceInvis", Boolean.toString(ls[0].contains("true"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("frame.allowProjectile", Boolean.toString(ls[2].contains("true"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("frame.itemCheck", ls[4].contains("both")? "both" : ls[4].contains("server")? "server" : ls[4].contains("none")? "none" : "client"); | ||
}catch (Exception ignore){} | ||
try { | ||
oldConf.put("frame.clientHideCustomName", ls[6].contains("always") ? "always" : ls[6].contains("invis_only") ? "invis_only" : "never"); | ||
} catch (Exception ignore) {} | ||
try{ | ||
oldConf.put("frame.equipSound", Boolean.toString(!ls[8].contains("false"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("frame.toggleable", Boolean.toString(!ls[10].contains("false"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("stand.toggleable", Boolean.toString(!ls[12].contains("false"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("stand.allowProjectile", Boolean.toString(ls[14].contains("true"))); | ||
}catch (Exception ignore){} | ||
try{ | ||
oldConf.put("stand.itemCheck", ls[16].contains("both")? "both" : ls[16].contains("server")? "server" : ls[16].contains("none")? "none" : "client"); | ||
}catch (Exception ignore){} | ||
for (Map.Entry<String, String> entry : oldConf.entrySet()) { | ||
SFIni.Data data = inIni.getLastData(entry.getKey()); | ||
if (data != null) { | ||
data.val = entry.getValue(); | ||
} | ||
} | ||
|
||
Files.delete(confFile.toPath()); | ||
Config.LOGGER.log(Level.INFO,"tf.ssf.sfort.invisframes successfully loaded legacy config file"); | ||
} catch(Exception e) { | ||
Config.LOGGER.log(Level.ERROR,"tf.ssf.sfort.invisframes failed to load legacy config file\n"+e); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/tf/ssf/sfort/invisframes/InvisFramesShared.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tf.ssf.sfort.invisframes; | ||
|
||
import net.minecraft.entity.decoration.ArmorStandEntity; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class InvisFramesShared { | ||
public static boolean IsEmpty(ArmorStandEntity entity) { | ||
for (ItemStack item : entity.getArmorItems()) | ||
if (!item.isEmpty()) | ||
return false; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters