mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
6b208b98bc
commit
a309488cdf
214 files changed
+9283
-9265
No files matched your search
@@ -1,15 +1,16 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||
* Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.mc1710.actions;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.mc1710.util.MineTweakerHacks;
|
||||
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
/**
|
||||
@@ -17,53 +18,54 @@ import net.minecraft.util.StringTranslate;
|
||||
* @author Stan
|
||||
*/
|
||||
public class SetTranslationAction implements IUndoableAction {
|
||||
private static final StringTranslate INSTANCE = MineTweakerHacks.getStringTranslateInstance();
|
||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
||||
|
||||
private final String key;
|
||||
private final String newValue;
|
||||
private final String oldValue;
|
||||
private static final StringTranslate INSTANCE = MineTweakerHacks.getStringTranslateInstance();
|
||||
private static final Charset UTF8 = Charset.forName("utf-8");
|
||||
|
||||
public SetTranslationAction(String key, String value) {
|
||||
this.key = key;
|
||||
newValue = value;
|
||||
oldValue = INSTANCE.translateKey(key);
|
||||
}
|
||||
private final String key;
|
||||
private final String newValue;
|
||||
private final String oldValue;
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
set(key, newValue);
|
||||
}
|
||||
public SetTranslationAction(String key, String value) {
|
||||
this.key = key;
|
||||
newValue = value;
|
||||
oldValue = INSTANCE.translateKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void apply() {
|
||||
set(key, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
set(key, oldValue);
|
||||
}
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Translating " + key + " to " + newValue;
|
||||
}
|
||||
@Override
|
||||
public void undo() {
|
||||
set(key, oldValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Reverting " + key + " to " + oldValue;
|
||||
}
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Translating " + key + " to " + newValue;
|
||||
}
|
||||
|
||||
private static void set(String key, String value) {
|
||||
if (value.contains("\\\"")) {
|
||||
value = value.replace("\\\"", "\"");
|
||||
}
|
||||
StringTranslate.inject(new ByteArrayInputStream((key + "=" + value).getBytes(UTF8)));
|
||||
}
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Reverting " + key + " to " + oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
private static void set(String key, String value) {
|
||||
if (value.contains("\\\"")) {
|
||||
value = value.replace("\\\"", "\"");
|
||||
}
|
||||
StringTranslate.inject(new ByteArrayInputStream((key + "=" + value).getBytes(UTF8)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user