-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
364 additions
and
246 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ res/ | |
bintray.properties | ||
/module/ | ||
run/ | ||
src/test/ |
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
12 changes: 6 additions & 6 deletions
12
genericmodule/src/main/java/uk/co/innoxium/candor/generic/GenericModInstaller.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
8 changes: 4 additions & 4 deletions
8
genericmodule/src/main/java/uk/co/innoxium/candor/generic/GenericModule.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
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
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,76 @@ | ||
package uk.co.innoxium.candor.mod; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.function.Consumer; | ||
|
||
public class ModList<Mod> { | ||
|
||
private ArrayList<Mod> MODS_LIST = Lists.newArrayList(); | ||
private ArrayList<ListChangeListener> listeners = Lists.newArrayList(); | ||
|
||
public boolean add(Mod mod) { | ||
|
||
boolean result = MODS_LIST.add(mod); | ||
|
||
fireChangeToListeners("add", mod, result); | ||
|
||
return result; | ||
} | ||
|
||
public boolean remove(Mod mod) { | ||
|
||
boolean result = MODS_LIST.remove(mod); | ||
|
||
fireChangeToListeners("remove", mod, result); | ||
|
||
return result; | ||
} | ||
|
||
public boolean addAll(Collection<? extends Mod> c) { | ||
|
||
boolean result = MODS_LIST.addAll(c); | ||
|
||
fireChangeToListeners("add-all", c, result); | ||
|
||
return result; | ||
} | ||
|
||
public void fireChangeToListeners(String identifier, Mod mod, boolean result) { | ||
|
||
listeners.forEach(listener -> listener.handleChange(identifier, mod, result)); | ||
} | ||
|
||
public void fireChangeToListeners(String identifier, Collection<? extends Mod> c, boolean result) { | ||
|
||
listeners.forEach(listener -> listener.handleChange(identifier, c, result)); | ||
} | ||
|
||
public Mod[] toArray() { | ||
|
||
return (Mod[]) MODS_LIST.toArray(); | ||
} | ||
|
||
public void addListener(ListChangeListener<Mod> listener) { | ||
|
||
if(!listeners.contains(listener)) listeners.add(listener); | ||
} | ||
|
||
public void forEach(Consumer action) { | ||
|
||
MODS_LIST.forEach(action); | ||
} | ||
|
||
public void clear() { | ||
|
||
MODS_LIST.clear(); | ||
} | ||
|
||
public interface ListChangeListener<T> { | ||
|
||
void handleChange(String identifier, T mod, boolean result); | ||
void handleChange(String identifier, Collection<? extends T> c, boolean result); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,76 +1,6 @@ | ||
package uk.co.innoxium.candor.mod; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.function.Consumer; | ||
|
||
public class ModsHandler { | ||
|
||
public static final ModList MODS = new ModList<Mod>(); | ||
|
||
public static class ModList<Mod> { | ||
|
||
private ArrayList<Mod> MODS_LIST = Lists.newArrayList(); | ||
private ArrayList<ListChangeListener> listeners = Lists.newArrayList(); | ||
|
||
public boolean add(Mod mod) { | ||
|
||
boolean result = MODS_LIST.add(mod); | ||
|
||
fireChangeToListeners("add", mod, result); | ||
|
||
return result; | ||
} | ||
|
||
public boolean remove(Mod mod) { | ||
|
||
boolean result = MODS_LIST.remove(mod); | ||
|
||
fireChangeToListeners("remove", mod, result); | ||
|
||
return result; | ||
} | ||
|
||
public boolean addAll(Collection<? extends Mod> c) { | ||
|
||
boolean result = MODS_LIST.addAll(c); | ||
|
||
fireChangeToListeners("add-all", c, result); | ||
|
||
return result; | ||
} | ||
|
||
public void fireChangeToListeners(String identifier, Mod mod, boolean result) { | ||
|
||
listeners.forEach(listener -> listener.handleChange(identifier, mod, result)); | ||
} | ||
|
||
public void fireChangeToListeners(String identifier, Collection<? extends Mod> c, boolean result) { | ||
|
||
listeners.forEach(listener -> listener.handleChange(identifier, c, result)); | ||
} | ||
|
||
public Mod[] toArray() { | ||
|
||
return (Mod[]) MODS_LIST.toArray(); | ||
} | ||
|
||
public void addListener(ListChangeListener<Mod> listener) { | ||
|
||
if(!listeners.contains(listener)) listeners.add(listener); | ||
} | ||
|
||
public void forEach(Consumer action) { | ||
|
||
MODS_LIST.forEach(action); | ||
} | ||
} | ||
|
||
public interface ListChangeListener<T> { | ||
|
||
void handleChange(String identifier, T mod, boolean result); | ||
void handleChange(String identifier, Collection<? extends T> c, boolean result); | ||
} | ||
// public static final ModList MODS = new ModList<Mod>(); | ||
} |
Oops, something went wrong.