Removed some null checks and fixed some variable names

Dieser Commit ist enthalten in:
MattBDev 2019-05-22 14:40:56 -04:00
Ursprung e4c1ba3edf
Commit 6b0fcc8712
9 geänderte Dateien mit 27 neuen und 49 gelöschten Zeilen

Datei anzeigen

@ -110,8 +110,8 @@ public class FaweBukkit implements IFawe, Listener {
} }
try { try {
Fawe.get().setChatManager(new BukkitChatManager()); Fawe.get().setChatManager(new BukkitChatManager());
} catch (Throwable ignore) { } catch (Throwable throwable) {
ignore.printStackTrace(); throwable.printStackTrace();
} }
} catch (final Throwable e) { } catch (final Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
@ -226,11 +226,7 @@ public class FaweBukkit implements IFawe, Listener {
@Override @Override
public void debug(final String s) { public void debug(final String s) {
ConsoleCommandSender console = Bukkit.getConsoleSender(); ConsoleCommandSender console = Bukkit.getConsoleSender();
if (console != null) { console.sendMessage(BBC.color(s));
console.sendMessage(BBC.color(s));
} else {
Bukkit.getLogger().info(BBC.color(s));
}
} }
@Override @Override
@ -266,7 +262,7 @@ public class FaweBukkit implements IFawe, Listener {
Player player = (Player) obj; Player player = (Player) obj;
FawePlayer existing = Fawe.get().getCachedPlayer(player.getName()); FawePlayer existing = Fawe.get().getCachedPlayer(player.getName());
return existing != null ? existing : new BukkitPlayer(player); return existing != null ? existing : new BukkitPlayer(player);
} else if (obj != null && obj.getClass().getName().contains("EntityPlayer")) { } else if (obj.getClass().getName().contains("EntityPlayer")) {
try { try {
Method method = obj.getClass().getDeclaredMethod("getBukkitEntity"); Method method = obj.getClass().getDeclaredMethod("getBukkitEntity");
return wrap(method.invoke(obj)); return wrap(method.invoke(obj));
@ -314,7 +310,6 @@ public class FaweBukkit implements IFawe, Listener {
@Override @Override
public String getDebugInfo() { public String getDebugInfo() {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
List<String> pl = new ArrayList<>();
msg.append("server.version: " + Bukkit.getVersion() + "\n"); msg.append("server.version: " + Bukkit.getVersion() + "\n");
msg.append("Plugins: \n"); msg.append("Plugins: \n");
for (Plugin p : Bukkit.getPluginManager().getPlugins()) { for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
@ -350,7 +345,7 @@ public class FaweBukkit implements IFawe, Listener {
} }
try { try {
return getQueue(world); return getQueue(world);
} catch (Throwable ignore) { } catch (Throwable throwable) {
// Disable incompatible settings // Disable incompatible settings
Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI Settings.IMP.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
@ -365,7 +360,7 @@ public class FaweBukkit implements IFawe, Listener {
debug("Download the version of FAWE for your platform"); debug("Download the version of FAWE for your platform");
debug(" - http://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target"); debug(" - http://ci.athion.net/job/FastAsyncWorldEdit/lastSuccessfulBuild/artifact/target");
debug("======================================="); debug("=======================================");
ignore.printStackTrace(); throwable.printStackTrace();
debug("======================================="); debug("=======================================");
TaskManager.IMP.laterAsync( TaskManager.IMP.laterAsync(
() -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1); () -> MainUtil.sendAdmin("&cNo NMS placer found, see console!"), 1);
@ -398,11 +393,11 @@ public class FaweBukkit implements IFawe, Listener {
} catch (Throwable ignore) { } catch (Throwable ignore) {
} }
} }
Throwable error = null; Throwable error;
try { try {
return getQueue(world); return getQueue(world);
} catch (Throwable ignore) { } catch (Throwable throwable) {
error = ignore; error = throwable;
} }
// Disable incompatible settings // Disable incompatible settings
Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level Settings.IMP.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
@ -598,7 +593,7 @@ public class FaweBukkit implements IFawe, Listener {
BukkitQueue_0.checkVersion(v.name()); BukkitQueue_0.checkVersion(v.name());
this.version = tmp = v; this.version = tmp = v;
break; break;
} catch (IllegalStateException e) {} } catch (IllegalStateException ignored) {}
} }
} }
return tmp; return tmp;

Datei anzeigen

@ -40,10 +40,6 @@ public final class Reflection {
*/ */
public synchronized static String getVersion() { public synchronized static String getVersion() {
if (_versionString == null) { if (_versionString == null) {
if (Bukkit.getServer() == null) {
// The server hasn't started, static initializer call?
return null;
}
String name = Bukkit.getServer().getClass().getPackage().getName(); String name = Bukkit.getServer().getClass().getPackage().getName();
_versionString = name.substring(name.lastIndexOf('.') + 1) + "."; _versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
} }

Datei anzeigen

@ -153,8 +153,7 @@ public class BukkitImageListener implements Listener {
ImageViewer viewer = generator.getImageViewer(); ImageViewer viewer = generator.getImageViewer();
if (!(viewer instanceof BukkitImageViewer)) return null; if (!(viewer instanceof BukkitImageViewer)) return null;
BukkitImageViewer biv = (BukkitImageViewer) viewer; return (BukkitImageViewer) viewer;
return biv;
} }
private void handleInteract(PlayerEvent event, Entity entity, boolean primary) { private void handleInteract(PlayerEvent event, Entity entity, boolean primary) {
@ -189,7 +188,6 @@ public class BukkitImageListener implements Listener {
return; return;
} }
if (tool == null) return;
BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary(); BrushSettings context = primary ? tool.getPrimary() : tool.getSecondary();
Brush brush = context.getBrush(); Brush brush = context.getBrush();
if (brush == null) return; if (brush == null) return;

Datei anzeigen

@ -89,7 +89,7 @@ public class CFIPacketListener implements Listener {
EnumWrappers.Hand enumHand = hands.isEmpty() ? EnumWrappers.Hand.MAIN_HAND : hands.get(0); EnumWrappers.Hand enumHand = hands.isEmpty() ? EnumWrappers.Hand.MAIN_HAND : hands.get(0);
PlayerInventory inv = plr.getInventory(); PlayerInventory inv = plr.getInventory();
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
if (hand != null && hand.getType().isBlock()) { if (hand.getType().isBlock()) {
Material type = hand.getType(); Material type = hand.getType();
if (!type.isEmpty()) { if (!type.isEmpty()) {
BlockStateHolder block = BukkitAdapter.asBlockState(hand); BlockStateHolder block = BukkitAdapter.asBlockState(hand);
@ -281,8 +281,7 @@ public class CFIPacketListener implements Listener {
BlockPosition loc = position.readSafely(0); BlockPosition loc = position.readSafely(0);
if (loc == null) return null; if (loc == null) return null;
BlockVector3 origin = generator.getOrigin().toBlockPoint(); BlockVector3 origin = generator.getOrigin().toBlockPoint();
BlockVector3 pt = BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ()); return BlockVector3.at(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
return pt;
} }
private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) { private void handleBlockEvent(PacketEvent event, boolean relative, RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> task) {

Datei anzeigen

@ -14,13 +14,12 @@ import org.bukkit.plugin.Plugin;
public class FactionsFeature extends BukkitMaskManager implements Listener { public class FactionsFeature extends BukkitMaskManager implements Listener {
FaweBukkit plugin; FaweBukkit plugin;
Plugin factions; private Plugin factions;
public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) { public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
super(factionsPlugin.getName()); super(factionsPlugin.getName());
this.factions = factionsPlugin; this.factions = factionsPlugin;
this.plugin = p3; this.plugin = p3;
BoardColl.get();
} }
@Override @Override
@ -45,7 +44,7 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
} }
} }
else if (fac.getOnlinePlayers().contains(player)) { else if (fac.getOnlinePlayers().contains(player)) {
if (fac.getComparisonName().equals("wilderness") == false) { if (!fac.getComparisonName().equals("wilderness")) {
final Chunk chunk = loc.getChunk(); final Chunk chunk = loc.getChunk();
final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16); final Location pos1 = new Location(loc.getWorld(), chunk.getX() * 16, 0, chunk.getZ() * 16);
final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15); final Location pos2 = new Location(loc.getWorld(), (chunk.getX() * 16) + 15, 156, (chunk.getZ() * 16) + 15);

Datei anzeigen

@ -120,8 +120,8 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
fieldRegionMap = ReflectionUtils.findField(classRegionFileCache, Map.class); fieldRegionMap = ReflectionUtils.findField(classRegionFileCache, Map.class);
fieldRegionRAF = ReflectionUtils.findField(classRegionFile, RandomAccessFile.class); fieldRegionRAF = ReflectionUtils.findField(classRegionFile, RandomAccessFile.class);
} catch (Throwable ignore) { } catch (Throwable throwable) {
ignore.printStackTrace(); throwable.printStackTrace();
} }
} }

Datei anzeigen

@ -337,16 +337,14 @@ public abstract class ChunkListener implements Listener {
if (elem == null) return; if (elem == null) return;
String className = elem.getClassName(); String className = elem.getClassName();
int len = className.length(); int len = className.length();
if (className != null) { if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { for (Entity ent : world.getEntities()) {
for (Entity ent : world.getEntities()) { if (ent.getType() == EntityType.FIREWORK) {
if (ent.getType() == EntityType.FIREWORK) { Vector velocity = ent.getVelocity();
Vector velocity = ent.getVelocity(); double vertical = Math.abs(velocity.getY());
double vertical = Math.abs(velocity.getY()); if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) {
if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); ent.remove();
ent.remove();
}
} }
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.bukkit.wrapper; package com.boydti.fawe.bukkit.wrapper;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.wrapper.state.AsyncSign; import com.boydti.fawe.bukkit.wrapper.state.AsyncSign;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;

Datei anzeigen

@ -410,9 +410,7 @@ public enum BBC {
*/ */
BBC(final String d, final boolean prefix, final String cat) { BBC(final String d, final boolean prefix, final String cat) {
this.d = d; this.d = d;
if (this.s == null) { this.s = d;
this.s = d;
}
this.prefix = prefix; this.prefix = prefix;
this.cat = cat.toLowerCase(); this.cat = cat.toLowerCase();
} }
@ -559,11 +557,7 @@ public enum BBC {
Method method = actor.getClass().getMethod("print", String.class); Method method = actor.getClass().getMethod("print", String.class);
method.setAccessible(true); method.setAccessible(true);
method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args)); method.invoke(actor, (PREFIX.isEmpty() ? "" : PREFIX.s() + " ") + this.format(args));
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }