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();
if (parent != null) {
final String parentIdentifier = parent.getIdentifier();
adv.parentIdentifier = parentIdentifier;
adv.parentIdentifier = parent.getIdentifier();
}
adv.displayData = toDisplayData();

View File

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

View File

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

View File

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

View File

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

View File

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