Remove mod-menu for 1.17
This commit is contained in:
parent
d01f75f758
commit
e8f29b2d30
@ -28,7 +28,7 @@ dependencies {
|
||||
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
// modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modImplementation include("io.github.cottonmc:LibGui:${project.libgui_version}")
|
||||
}
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
package me.bionicbeanie.mods.savecoords.gui.impl;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
|
||||
import me.bionicbeanie.mods.savecoords.IFileStore;
|
||||
import me.bionicbeanie.mods.savecoords.IKeyBinds;
|
||||
import me.bionicbeanie.mods.savecoords.IModGui;
|
||||
import me.bionicbeanie.mods.savecoords.IPlayerLocator;
|
||||
import me.bionicbeanie.mods.savecoords.impl.Factory;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
//All of this works because single-threaded initialization!! Sed lyf :(
|
||||
public class DIContainer {
|
||||
@ -19,7 +16,7 @@ public class DIContainer {
|
||||
private static IPlayerLocator playerLocator;
|
||||
private static IModGui modGui;
|
||||
private static IKeyBinds keyBinds;
|
||||
private static ConfigScreenFactory<Screen> modMenuScreenFactory;
|
||||
//private static ConfigScreenFactory<Screen> modMenuScreenFactory;
|
||||
private static PingPositionOperation pingPositionOperation;
|
||||
|
||||
public static IModGui getModGui() {
|
||||
@ -32,25 +29,25 @@ public class DIContainer {
|
||||
return keyBinds;
|
||||
}
|
||||
|
||||
public static ConfigScreenFactory<Screen> getModMenuScreenFactory() {
|
||||
initialize();
|
||||
|
||||
if (modMenuScreenFactory == null) {
|
||||
modMenuScreenFactory = (parent) -> {
|
||||
ConfigViewHandler handler = new ConfigViewHandler();
|
||||
|
||||
handler.onSave(() -> {
|
||||
new SaveConfigsOperation(keyBinds, fileStore, handler::getState).run();
|
||||
guiController.closeScreen();
|
||||
});
|
||||
|
||||
handler.onBack(() -> guiController.closeScreen());
|
||||
|
||||
return handler.createView(keyBinds.getAllBinds());
|
||||
};
|
||||
}
|
||||
return modMenuScreenFactory;
|
||||
}
|
||||
// public static ConfigScreenFactory<Screen> getModMenuScreenFactory() {
|
||||
// initialize();
|
||||
//
|
||||
// if (modMenuScreenFactory == null) {
|
||||
// modMenuScreenFactory = (parent) -> {
|
||||
// ConfigViewHandler handler = new ConfigViewHandler();
|
||||
//
|
||||
// handler.onSave(() -> {
|
||||
// new SaveConfigsOperation(keyBinds, fileStore, handler::getState).run();
|
||||
// guiController.closeScreen();
|
||||
// });
|
||||
//
|
||||
// handler.onBack(() -> guiController.closeScreen());
|
||||
//
|
||||
// return handler.createView(keyBinds.getAllBinds());
|
||||
// };
|
||||
// }
|
||||
// return modMenuScreenFactory;
|
||||
// }
|
||||
|
||||
public static Runnable getPingPositionOperation() {
|
||||
initialize();
|
||||
@ -59,7 +56,6 @@ public class DIContainer {
|
||||
|
||||
private static void initialize() {
|
||||
if (!initialized) {
|
||||
|
||||
initialized = true;
|
||||
|
||||
MinecraftClient minecraftClient = MinecraftClient.getInstance();
|
||||
|
||||
@ -81,8 +81,9 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
try {
|
||||
List<PlayerPosition> positions = fileStore.listPositions();
|
||||
Collections.sort(positions, (p1, p2) -> {
|
||||
if(p1.getPositionMetadata() != null && p2.getPositionMetadata() != null) {
|
||||
return p2.getPositionMetadata().getLastModified().compareTo(p1.getPositionMetadata().getLastModified());
|
||||
if (p1.getPositionMetadata() != null && p2.getPositionMetadata() != null) {
|
||||
return p2.getPositionMetadata().getLastModifiedMillis() > p1.getPositionMetadata().getLastModifiedMillis() ? 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -155,7 +156,7 @@ class ListViewHandler extends ViewHandlerBase<Void> {
|
||||
this.icon.setImage(ResourceUtils.CreateWorldIconIdentifier(position.getWorldDimension()));
|
||||
this.location.setText(new LiteralText(position.getLocationName()));
|
||||
this.location.setColor(0x3939ac);
|
||||
if(position.getPositionMetadata() != null) {
|
||||
if (position.getPositionMetadata() != null) {
|
||||
this.world.setText(new LiteralText("[" + position.getPositionMetadata().getWorldName() + "]"));
|
||||
this.world.setColor(0xb80000);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import io.github.cottonmc.cotton.gui.GuiDescription;
|
||||
import io.github.cottonmc.cotton.gui.widget.WGridPanel;
|
||||
import io.github.cottonmc.cotton.gui.widget.WWidget;
|
||||
import io.github.cottonmc.cotton.gui.widget.data.Insets;
|
||||
import me.bionicbeanie.mods.savecoords.gui.IRootPanel;
|
||||
|
||||
class RootGridPanel extends WGridPanel implements IRootPanel{
|
||||
@ -15,6 +16,7 @@ class RootGridPanel extends WGridPanel implements IRootPanel{
|
||||
|
||||
public RootGridPanel(GuiDescription guiDescription) {
|
||||
this(18);
|
||||
setInsets(Insets.ROOT_PANEL);
|
||||
|
||||
this.guiDescription = guiDescription;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class SaveConfigsOperation extends ViewOperationBase<List<IKeyBinding>>{
|
||||
for (IKeyBinding binding : state) {
|
||||
Config config = new Config();
|
||||
config.setName(binding.getName());
|
||||
config.setType(parseTypeInt(binding.getType()));
|
||||
config.setType(parseTypeString(binding.getType()));
|
||||
config.setCode(binding.getCode());
|
||||
|
||||
keyBinds.updateKeyBind(binding.getName(), binding.getType(), binding.getCode());
|
||||
@ -43,11 +43,11 @@ public class SaveConfigsOperation extends ViewOperationBase<List<IKeyBinding>>{
|
||||
fileStore.writeConfigs(configData);
|
||||
}
|
||||
|
||||
private int parseTypeInt(Type type) {
|
||||
private String parseTypeString(Type type) {
|
||||
if(type == Type.KEYSYM) {
|
||||
return 0;
|
||||
return "KEYSYM";
|
||||
}
|
||||
|
||||
return 1;
|
||||
return "MOUSE";
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ class FileStore implements IFileStore {
|
||||
private Gson gson;
|
||||
|
||||
public FileStore(String baseDir) {
|
||||
this.gson = new GsonBuilder().setPrettyPrinting().setLenient().create();
|
||||
this.gson = new GsonBuilder().setPrettyPrinting().setLenient(). create();
|
||||
this.saveFilePath = Paths.get(baseDir, DEFAULT_DIR, DEFAULT_FILE);
|
||||
|
||||
try {
|
||||
@ -141,15 +141,7 @@ class FileStore implements IFileStore {
|
||||
return data;
|
||||
|
||||
} catch (Exception e) {
|
||||
// Fallback for old versions
|
||||
ModData data = new ModData();
|
||||
data.setDefaultWorldName("");
|
||||
data.setPositions(gson.fromJson(String.join("", lines), PlayerPosition[].class));
|
||||
data.setConfigData(new ConfigData());
|
||||
|
||||
dump(data);
|
||||
|
||||
return data;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -154,8 +154,8 @@ class KeyBinds implements IKeyBinds {
|
||||
|
||||
}
|
||||
|
||||
private Type parseType(int type) {
|
||||
if(type == 0) {
|
||||
private Type parseType(String type) {
|
||||
if("KEYSYM".equalsIgnoreCase(type)) {
|
||||
return Type.KEYSYM;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ public class ConfigData {
|
||||
|
||||
public static class Config{
|
||||
private String name;
|
||||
private int type;
|
||||
private String type;
|
||||
private int code;
|
||||
|
||||
public int getCode() {
|
||||
@ -42,10 +42,10 @@ public class ConfigData {
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
public int getType() {
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(int type) {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public String getName() {
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
package me.bionicbeanie.mods.savecoords.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class PositionMetadata {
|
||||
|
||||
private String worldName, notes;
|
||||
private LocalDateTime created, lastModified;
|
||||
private long createdMillis, lastModifiedMillis;
|
||||
|
||||
public PositionMetadata(String worldName, String notes) {
|
||||
this.worldName = worldName;
|
||||
this.notes = notes;
|
||||
this.created = LocalDateTime.now();
|
||||
this.lastModified = this.created;
|
||||
this.createdMillis = System.currentTimeMillis();
|
||||
this.lastModifiedMillis = this.createdMillis;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
@ -30,15 +28,15 @@ public class PositionMetadata {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreated() {
|
||||
return created;
|
||||
public long getCreatedMillis() {
|
||||
return createdMillis;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastModified() {
|
||||
return lastModified;
|
||||
public long getLastModifiedMillis() {
|
||||
return lastModifiedMillis;
|
||||
}
|
||||
|
||||
public void updateLastModified() {
|
||||
this.lastModified = LocalDateTime.now();
|
||||
this.lastModifiedMillis = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
package me.bionicbeanie.mods.savecoords.modmenu;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
import me.bionicbeanie.mods.savecoords.gui.impl.DIContainer;
|
||||
|
||||
public class SaveCoordinatesModMenu implements ModMenuApi {
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return DIContainer.getModMenuScreenFactory();
|
||||
}
|
||||
}
|
||||
//package me.bionicbeanie.mods.savecoords.modmenu;
|
||||
//
|
||||
//import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
//import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
//
|
||||
//import me.bionicbeanie.mods.savecoords.gui.impl.DIContainer;
|
||||
//
|
||||
//public class SaveCoordinatesModMenu implements ModMenuApi {
|
||||
//
|
||||
// @Override
|
||||
// public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
// return DIContainer.getModMenuScreenFactory();
|
||||
// }
|
||||
//}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user