Skip to content

Commit

Permalink
Removed some dangerous methods from Workspace class (MCreator#4313)
Browse files Browse the repository at this point in the history
* Removed some dangerous methods from Workspace class

* Hide another way
  • Loading branch information
Defeatomizer authored Oct 15, 2023
1 parent 4d354aa commit c69fa25
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions src/main/java/net/mcreator/workspace/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public boolean isRegenerateRequired() {

// Below are methods that may still be used by some plugins

public void loadStoredDataFrom(Workspace other) {
@SuppressWarnings("unused") void loadStoredDataFrom(Workspace other) {
this.mod_elements = other.mod_elements;
this.variable_elements = other.variable_elements;
this.sound_elements = other.sound_elements;
Expand All @@ -480,56 +480,4 @@ public void loadStoredDataFrom(Workspace other) {
this.workspaceSettings.setWorkspace(this);
}

@SuppressWarnings("unused") public void setFoldersRoot(FolderElement foldersRoot) {
this.foldersRoot = foldersRoot;
markDirty();
}

@SuppressWarnings("unused") public void updateModElement(ModElement element) {
for (ModElement el : mod_elements) {
if (el == element || el.getName().equals(element.getName())) {
el.loadDataFrom(element);
el.reloadElementIcon(); // update ME icon
el.getMCItems().forEach(mcItem -> mcItem.icon.getImage().flush()); // update MCItem icons

break; // there can be only one element with given name so no need to iterate further
}
}
markDirty();
}

@SuppressWarnings("unused")
public void updateSoundElement(SoundElement originalElement, SoundElement updatedElement) {
Set<SoundElement> tmp = new HashSet<>(sound_elements);
for (SoundElement el : tmp) {
if (el.getName().equals(originalElement.getName())) {
sound_elements.remove(el);
sound_elements.add(updatedElement);
}
}
markDirty();
}

@SuppressWarnings("unused")
public void updateVariableElement(VariableElement originalElement, VariableElement updatedElement) {
Set<VariableElement> tmp = new HashSet<>(variable_elements);
for (VariableElement el : tmp) {
if (el.getName().equals(originalElement.getName())) {
variable_elements.remove(el);
variable_elements.add(updatedElement);
}
}
markDirty();
}

@SuppressWarnings("unused") public void reloadFromFS() {
String workspace_string = FileIO.readFileToString(fileManager.getWorkspaceFile());
Workspace workspace_on_fs = WorkspaceFileManager.gson.fromJson(workspace_string, Workspace.class);
fileManager.getModElementManager().invalidateCache();
loadStoredDataFrom(workspace_on_fs);
reloadModElements();
reloadFolderStructure();
LOG.info("Reloaded current workspace from the workspace file");
}

}

0 comments on commit c69fa25

Please sign in to comment.