mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Generics for everyone \o/
This commit is contained in:
1 parent
ac9344cbda
commit
23ed2dcaea
55 files changed
+164
-163
No files matched your search
@@ -49,13 +49,12 @@ public class ControlList<T> extends Control implements IControlValue<T> {
|
||||
public void setOptions(final Collection<T> options) {
|
||||
this.deleteAllChildren();
|
||||
this.allOptions.clear();
|
||||
int i = 0;
|
||||
for (final T option : options) {
|
||||
final IWidget optionWidget = ((ControlListBox) this.getParent()).createOption(option, 0);
|
||||
@SuppressWarnings("unchecked")
|
||||
final IWidget optionWidget = ((ControlListBox<T>) this.getParent()).createOption(option, 0);
|
||||
if (optionWidget != null) {
|
||||
this.allOptions.put(option, optionWidget);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
this.filterOptions();
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ public class Tooltip {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void add(final List list) {
|
||||
for (final Object obj : list) {
|
||||
this.tooltip.add((String) obj);
|
||||
public void add(final List<String> list) {
|
||||
for (final String obj : list) {
|
||||
this.tooltip.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Widget implements IWidget {
|
||||
IWidget cropWidget;
|
||||
boolean cropped;
|
||||
int colour;
|
||||
private Collection<EventHandler> globalEventHandlers;
|
||||
private Collection<EventHandler<? extends Event>> globalEventHandlers;
|
||||
private boolean enabled;
|
||||
private boolean visible;
|
||||
|
||||
@@ -219,12 +219,12 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventHandler(final EventHandler handler) {
|
||||
public <E extends Event> void addEventHandler(final EventHandler<E> handler) {
|
||||
this.globalEventHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelfEventHandler(final EventHandler handler) {
|
||||
public <E extends Event> void addSelfEventHandler(final EventHandler<E> handler) {
|
||||
this.addEventHandler(handler.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@@ -234,10 +234,11 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void recieveEvent(final Event event) {
|
||||
for (final EventHandler handler : this.globalEventHandlers) {
|
||||
for (final EventHandler<? extends Event> handler : this.globalEventHandlers) {
|
||||
if (handler.handles(event)) {
|
||||
handler.onEvent(event);
|
||||
((EventHandler<Event>)handler).onEvent(event);
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -438,6 +439,7 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getWidget(final Class<T> x) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
if (x.isInstance(child)) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public abstract class EventHandler<E extends Event> {
|
||||
this.eventClass = eventClass;
|
||||
}
|
||||
|
||||
public EventHandler setOrigin(final Origin origin, final IWidget relative) {
|
||||
public EventHandler<E> setOrigin(final Origin origin, final IWidget relative) {
|
||||
this.origin = origin;
|
||||
this.relative = relative;
|
||||
return this;
|
||||
|
||||
@@ -61,8 +61,8 @@ public class ContainerCraftGUI extends Container {
|
||||
this.window = window;
|
||||
final IMachine machine = Machine.getMachine(window.getInventory());
|
||||
if (this.getSide() == Side.SERVER) {
|
||||
this.inventoryItemStacks = new ListMap();
|
||||
this.inventorySlots = new ListMap();
|
||||
this.inventoryItemStacks = new ListMap<>();
|
||||
this.inventorySlots = new ListMap<>();
|
||||
if (machine != null) {
|
||||
final GameProfile user = machine.getOwner();
|
||||
if (user != null) {
|
||||
|
||||
@@ -6,8 +6,6 @@ import binnie.craftgui.minecraft.Window;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -31,7 +29,7 @@ public class ControlSpeciesBox extends ControlListBox<IAlleleSpecies> {
|
||||
final List<IAlleleSpecies> speciesList2 = new ArrayList<>();
|
||||
this.movePercentage(-100.0f);
|
||||
this.setOptions(speciesList2);
|
||||
final EntityPlayer player = Window.get(this).getPlayer();
|
||||
//final EntityPlayer player = Window.get(this).getPlayer();
|
||||
final GameProfile playerName = Window.get(this).getUsername();
|
||||
final WindowAbstractDatabase db = Window.get(this);
|
||||
final Collection<IAlleleSpecies> speciesList3 = db.isNEI ? db.getBreedingSystem().getAllSpecies() : db.getBreedingSystem().getDiscoveredSpecies(db.getWorld(), playerName);
|
||||
|
||||
Reference in new issue
Block a user