Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.

Commit

Permalink
Remove Java 7 classes
Browse files Browse the repository at this point in the history
Apparently some people still use Java 6.
  • Loading branch information
SquidDev committed Sep 5, 2015
1 parent 1d26766 commit 1cc271f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ private IIcon getModemIcon(int id) {
for (int i = 0; i < 4; i++) {
icons[i] = modemIcons[i * 2];
}
} catch (ReflectiveOperationException e) {
} catch (IllegalAccessException e) {
DebugLogger.error("Cannot find TileCable texture", e);
} catch (NoSuchFieldException e) {
DebugLogger.error("Cannot find TileCable texture", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.squiddev.cctweaks.api.peripheral.IPeripheralHost;
import org.squiddev.cctweaks.blocks.TileLazyNBT;
import org.squiddev.cctweaks.core.network.modem.MultiPeripheralModem;
import org.squiddev.cctweaks.core.utils.Helpers;

import java.util.Arrays;
import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -60,7 +60,7 @@ public boolean onActivated(EntityPlayer player, int side) {

Set<String> newNames = modem.getPeripheralNames();

if (!Objects.equals(names, newNames)) {
if (!Helpers.equals(names, newNames)) {
if (names != null) {
player.addChatMessage(new ChatComponentTranslation("gui.computercraft:wired_modem.peripheral_disconnected", StringUtils.join(names, ", ")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import org.squiddev.cctweaks.core.network.cable.SingleModemCable;
import org.squiddev.cctweaks.core.network.modem.DirectionalPeripheralModem;
import org.squiddev.cctweaks.core.utils.DebugLogger;
import org.squiddev.cctweaks.core.utils.Helpers;
import org.squiddev.patcher.visitors.MergeVisitor;

import java.util.Objects;

@MergeVisitor.Rename(from = "dan200/computercraft/shared/peripheral/modem/TileCable$Packet", to = "org/squiddev/cctweaks/api/network/Packet")
public class TileCable_Patch extends TileCable implements IWorldNetworkNodeHost, IWorldPosition {
public static final double MIN = 0.375;
Expand Down Expand Up @@ -180,7 +179,7 @@ public boolean onActivate(EntityPlayer player, int side, float hitX, float hitY,
getModem().toggleEnabled();
String periphName = getModem().getPeripheralName();

if (!Objects.equals(periphName, oldPeriphName)) {
if (!Helpers.equals(periphName, oldPeriphName)) {
if (oldPeriphName != null) {
player.addChatMessage(new ChatComponentTranslation("gui.computercraft:wired_modem.peripheral_disconnected", oldPeriphName));
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/squiddev/cctweaks/core/utils/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,8 @@ public static int nextId(World world, String type) {
public static int nextId(World world, IPeripheral peripheral) {
return nextId(world, peripheral.getType());
}

public static boolean equals(Object a, Object b) {
return a == b || (a != null && a.equals(b));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ public IIcon[] getIcons() {
Field field = TileCable.class.getDeclaredField("s_cableIcons");
field.setAccessible(true);
icons = (IIcon[]) field.get(null);
} catch (ReflectiveOperationException e) {
} catch (IllegalAccessException e) {
DebugLogger.error("Cannot find TileCable texture", e);
icons = new IIcon[2];
} catch (NoSuchFieldException e) {
DebugLogger.error("Cannot find TileCable texture", e);
icons = new IIcon[2];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ public IIcon[] getIcons() {
Field field = TileCable.class.getDeclaredField("s_modemIcons");
field.setAccessible(true);
icons = (IIcon[]) field.get(null);
} catch (ReflectiveOperationException e) {
} catch (IllegalAccessException e) {
DebugLogger.error("Cannot find TileCable texture", e);
icons = new IIcon[8];
} catch (NoSuchFieldException e) {
DebugLogger.error("Cannot find TileCable texture", e);
icons = new IIcon[8];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.squiddev.cctweaks.core.utils.ComputerAccessor;
import org.squiddev.cctweaks.core.utils.DebugLogger;

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -45,7 +46,10 @@ private ServerComputer getComputer() {
try {
Object computer = ComputerAccessor.pocketServerComputer.invoke(ComputerCraft.Items.pocketComputer, entity.worldObj, inventory, stack);
return computer == null ? null : (ServerComputer) computer;
} catch (ReflectiveOperationException e) {
} catch (InvocationTargetException e) {
DebugLogger.error("Cannot find computer", e);
return null;
} catch (IllegalAccessException e) {
DebugLogger.error("Cannot find computer", e);
return null;
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/squiddev/cctweaks/items/ItemDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ protected boolean useComputer(ItemStack stack, EntityPlayer player, TileComputer

LuaValue globals = (LuaValue) ComputerAccessor.luaMachineGlobals.get(luaMachine);
globals.load(new DebugLib());

} catch (ReflectiveOperationException e) {
} catch (NullPointerException e) {
DebugLogger.warn("Could not add DebugLib", e);
return false;
} catch (NullPointerException e) {
} catch (IllegalAccessException e) {
DebugLogger.warn("Could not add DebugLib", e);
return false;
} catch (Exception e) {
Expand Down

0 comments on commit 1cc271f

Please sign in to comment.