Merge pull request #34 from Minestom/small-optimizations

Small optimizations.
This commit is contained in:
TheMode 2020-08-09 00:01:17 +02:00 committed by GitHub
commit ac809c4ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 15 deletions

View File

@ -294,8 +294,7 @@ public class Advancement {
final Advancement parent = getParent(); final Advancement parent = getParent();
if (parent != null) { if (parent != null) {
final String parentIdentifier = parent.getIdentifier(); adv.parentIdentifier = parent.getIdentifier();
adv.parentIdentifier = parentIdentifier;
} }
adv.displayData = toDisplayData(); adv.displayData = toDisplayData();

View File

@ -58,7 +58,7 @@ public class ChatParser {
String colorString = textObject.get("color").getAsString(); String colorString = textObject.get("color").getAsString();
if (colorString.startsWith("#")) { if (colorString.startsWith("#")) {
// RGB format // RGB format
builder.append("{" + colorString + "}"); builder.append("{").append(colorString).append("}");
} else { } else {
// Color simple name // Color simple name
ChatColor color = ChatColor.fromName(colorString); ChatColor color = ChatColor.fromName(colorString);

View File

@ -203,9 +203,7 @@ public class CommandManager {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
names.add(command.getName()); names.add(command.getName());
for (String alias : command.getAliases()) { names.addAll(Arrays.asList(command.getAliases()));
names.add(alias);
}
for (String name : names) { for (String name : names) {
createCommand(nodes, cmdChildren, name, syntaxes, rootChildren); createCommand(nodes, cmdChildren, name, syntaxes, rootChildren);
} }

View File

@ -27,7 +27,7 @@ public class AnvilInventory extends Inventory {
* @param cost the new anvil repair cost * @param cost the new anvil repair cost
*/ */
public void setRepairCost(short cost) { public void setRepairCost(short cost) {
this.repairCost = repairCost; this.repairCost = cost;
sendProperty(InventoryProperty.ANVIL_REPAIR_COST, cost); sendProperty(InventoryProperty.ANVIL_REPAIR_COST, cost);
} }
} }

View File

@ -54,13 +54,11 @@ public class Task implements Runnable {
try { try {
this.runnable.run(); this.runnable.run();
} catch (Exception e) { } catch (Exception e) {
System.err.println( System.err.printf(
String.format( "An exception in %s task %s is occurred! (%s)%n",
"An exception in %s task %s is occurred! (%s)", this.shutdown ? "shutdown" : "",
this.shutdown ? "shutdown" : "", this.id,
this.id, e.getMessage()
e.getMessage()
)
); );
e.printStackTrace(); e.printStackTrace();
} finally { } finally {

View File

@ -124,7 +124,8 @@ public final class ChunkUtils {
public static int[] indexToPosition(int index, int chunkX, int chunkZ) { public static int[] indexToPosition(int index, int chunkX, int chunkZ) {
int z = (byte) (index >> 12 & 0xF); int z = (byte) (index >> 12 & 0xF);
final int y = (index >>> 4 & 0xFF); final int y = (index >>> 4 & 0xFF);
int x = (byte) (index >> 0 & 0xF); // index >> 0 = index
int x = (byte) (index & 0xF);
x += 16 * chunkX; x += 16 * chunkX;
z += 16 * chunkZ; z += 16 * chunkZ;