Skip to content

Commit

Permalink
清理一波
Browse files Browse the repository at this point in the history
  • Loading branch information
wode490390 committed Jul 29, 2023
1 parent 555121c commit c95ff0e
Show file tree
Hide file tree
Showing 114 changed files with 231 additions and 575 deletions.
38 changes: 12 additions & 26 deletions src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,6 @@ public void spawnTo(Player player) {
}
}

@Override
public Server getServer() {
return this.server;
}

public boolean getRemoveFormat() {
return removeFormat;
}
Expand Down Expand Up @@ -1080,7 +1075,7 @@ protected void doFirstSpawn() {

this.spawned = true;

if (playerJoinEvent.getJoinMessage().toString().trim().length() > 0) {
if (!playerJoinEvent.getJoinMessage().toString().trim().isEmpty()) {
this.server.broadcastMessage(playerJoinEvent.getJoinMessage());
}

Expand Down Expand Up @@ -1983,7 +1978,7 @@ public boolean onUpdate(int currentTick) {
double expectedVelocity = (-this.getGravity()) / ((double) this.getDrag()) - ((-this.getGravity()) / ((double) this.getDrag())) * Math.exp(-((double) this.getDrag()) * ((double) (this.inAirTicks - this.startAirTicks)));
double diff = (this.speed.y - expectedVelocity) * (this.speed.y - expectedVelocity);

int block = level.getBlockIdAt(0, this.getFloorX(), this.getFloorY(), this.getFloorZ());
int block = level.getBlock(this).getId();
boolean ignore = block == Block.LADDER || block == Block.VINE || block == Block.WEB || block == BlockID.BUBBLE_COLUMN || block == BlockID.SCAFFOLDING || block == BlockID.SWEET_BERRY_BUSH || block == BlockID.WEEPING_VINES || block == BlockID.TWISTING_VINES || block == BlockID.CAVE_VINES || block == BlockID.CAVE_VINES_BODY_WITH_BERRIES || block == BlockID.CAVE_VINES_HEAD_WITH_BERRIES || block == BlockID.POWDER_SNOW || block == BlockID.BIG_DRIPLEAF
|| block == BlockID.HONEY_BLOCK; //TODO: slide down

Expand Down Expand Up @@ -2102,7 +2097,7 @@ public boolean onUpdate(int currentTick) {
this.checkInteractNearby(); // 在客户端计算, 结果通过 action 为 mouseover 的 InteractPacket 发给服务端 (runtimeEntityId 为 0 表示移开)
}*/

if (this.spawned && this.dummyBossBars.size() > 0 && currentTick % 100 == 0) {
if (this.spawned && !this.dummyBossBars.isEmpty() && currentTick % 100 == 0) {
this.dummyBossBars.values().forEach(DummyBossBar::updateBossEntityPosition);
}

Expand Down Expand Up @@ -2573,7 +2568,7 @@ public void onCompletion(Server server) {
}
};

this.server.getScheduler().scheduleAsyncTask(this.preLoginEventTask);
this.server.getScheduler().scheduleAsyncTask(null, this.preLoginEventTask);

this.processLogin();
break;
Expand Down Expand Up @@ -4089,7 +4084,7 @@ public void sendTitle(String title, String subtitle) {
}

public void sendTitle(String title, String subtitle, int fadein, int duration, int fadeout) {
if (!subtitle.equals("")) {
if (!subtitle.isEmpty()) {
SetTitlePacket pk = new SetTitlePacket();
pk.type = SetTitlePacket.TYPE_SUBTITLE;
pk.text = subtitle;
Expand Down Expand Up @@ -4151,15 +4146,15 @@ public void close(TextContainer message, String reason) {

public void close(TextContainer message, String reason, boolean notify) {
if (this.connected && !this.closed) {
if (notify && reason.length() > 0) {
if (notify && !reason.isEmpty()) {
DisconnectPacket pk = new DisconnectPacket();
pk.message = reason;
this.dataPacket(pk);
}

this.connected = false;
PlayerQuitEvent ev = null;
if (this.getName() != null && this.getName().length() > 0) {
if (this.getName() != null && !this.getName().isEmpty()) {
this.server.getPluginManager().callEvent(ev = new PlayerQuitEvent(this, message, true, reason));
if (this.loggedIn && ev.getAutoSave()) {
this.save();
Expand Down Expand Up @@ -5423,18 +5418,13 @@ public void setCraftingGrid(CraftingGrid grid) {
public void resetCraftingGridType() {
if (this.craftingGrid != null) {
Item[] drops = this.inventory.addItem(this.craftingGrid.getContents().values().toArray(new Item[0]));

if (drops.length > 0) {
for (Item drop : drops) {
this.dropItem(drop);
}
for (Item drop : drops) {
this.dropItem(drop);
}

drops = this.inventory.addItem(this.getCursorInventory().getItem(0));
if (drops.length > 0) {
for (Item drop : drops) {
this.dropItem(drop);
}
for (Item drop : drops) {
this.dropItem(drop);
}

this.playerUIInventory.clearAll();
Expand All @@ -5452,10 +5442,6 @@ public void resetCraftingGridType() {
}
}

public PlayerOffhandInventory getOffhandInventory() {
return offhandInventory;
}

public void removeAllWindows() {
removeAllWindows(false);
}
Expand Down Expand Up @@ -5731,7 +5717,7 @@ public boolean pickupEntity(Entity entity, boolean near) {
EntityXPOrb xpOrb = (EntityXPOrb) entity;
if (xpOrb.getPickupDelay() <= 0) {
int exp = xpOrb.getExp();
entity.kill();
entity.close();
this.getLevel().addLevelEvent(this, LevelEventPacket.EVENT_SOUND_EXPERIENCE_ORB);
pickedXPOrb = tick;

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cn/nukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public class Server {

if (this.getPropertyBoolean("enable-rcon", false)) {
try {
this.rcon = new RCON(this, this.getPropertyString("rcon.password", ""), (!this.getIp().equals("")) ? this.getIp() : "0.0.0.0", this.getPropertyInt("rcon.port", this.getPort()));
this.rcon = new RCON(this, this.getPropertyString("rcon.password", ""), !this.getIp().isEmpty() ? this.getIp() : "0.0.0.0", this.getPropertyInt("rcon.port", this.getPort()));
} catch (IllegalArgumentException e) {
log.error(getLanguage().translate(e.getMessage(), e.getCause().getMessage()));
}
Expand Down Expand Up @@ -692,7 +692,7 @@ public void batchPackets(Player[] players, DataPacket[] packets, boolean forceSy
}

if (!forceSync && this.networkCompressionAsync) {
this.getScheduler().scheduleAsyncTask(new CompressBatchedTask(data, targets, this.networkCompressionLevel, tracks));
this.getScheduler().scheduleAsyncTask(null, new CompressBatchedTask(data, targets, this.networkCompressionLevel, tracks));
} else {
try {
this.broadcastPacketsCallback(Zlib.deflate(data, this.networkCompressionLevel), targets, tracks);
Expand Down Expand Up @@ -1618,7 +1618,7 @@ public void saveOfflinePlayerData(String name, CompoundTag tag, boolean async) {
if (this.shouldSavePlayerData()) {
try {
if (async) {
this.getScheduler().scheduleAsyncTask(new FileWriteTask(this.getDataPath() + "players/" + name.toLowerCase() + ".dat", NBTIO.writeGZIPCompressed(tag, ByteOrder.BIG_ENDIAN)));
this.getScheduler().scheduleAsyncTask(null, new FileWriteTask(this.getDataPath() + "players/" + name.toLowerCase() + ".dat", NBTIO.writeGZIPCompressed(tag, ByteOrder.BIG_ENDIAN)));
} else {
Utils.writeFile(this.getDataPath() + "players/" + name.toLowerCase() + ".dat", new ByteArrayInputStream(NBTIO.writeGZIPCompressed(tag, ByteOrder.BIG_ENDIAN)));
}
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/cn/nukkit/block/BlockBambooSapling.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public String getName() {
return "Bamboo Sapling";
}

@Override
public double getHardness() {
return 0;
}

@Override
public double getResistance() {
return 0;
}

@Override
public int getBurnChance() {
return 5;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Item toItem(boolean addUserData) {
.putInt("Type", type));
}
ListTag<CompoundTag> patterns = banner.namedTag.getList("Patterns", CompoundTag.class);
if (patterns.size() > 0) {
if (!patterns.isEmpty()) {
item.setNamedTag((item.hasCompoundTag() ? item.getNamedTag() : new CompoundTag())
.putList(patterns));
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/cn/nukkit/block/BlockBarrier.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public boolean isBreakable(Item item) {
return false;
}

@Override
public boolean isTransparent() {
return true;
}

@Override
public BlockColor getColor() {
return BlockColor.AIR_BLOCK_COLOR;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/cn/nukkit/block/BlockCarpet.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ public boolean canContainWater() {
return true;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public boolean breaksWhenMoved() {
return false;
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/cn/nukkit/block/BlockChorusFlower.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cn.nukkit.Player;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemTool;
import cn.nukkit.math.BlockFace;

public class BlockChorusFlower extends BlockFlowable {
Expand Down Expand Up @@ -35,26 +34,6 @@ public double getResistance() {
return 2;
}

@Override
public int getToolType() {
return ItemTool.TYPE_NONE;
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public boolean isVegetation() {
return true;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/cn/nukkit/block/BlockChorusPlant.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public double getResistance() {
return 2;
}

@Override
public int getToolType() {
return ItemTool.TYPE_NONE;
}

@Override
public Item[] getDrops(Item item) {
return ThreadLocalRandom.current().nextBoolean() ? new Item[]{Item.get(ItemID.CHORUS_FRUIT, 0, 1)} : new Item[0];
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/cn/nukkit/block/BlockCobweb.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ public boolean canContainWater() {
return true;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public int getFullId() {
return getId() << BLOCK_META_BITS;
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/cn/nukkit/block/BlockCocoa.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,6 @@ public BlockFace getBlockFace() {
return BlockFace.fromHorizontalIndex(this.getDamage() & 0x07);
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public boolean isVegetation() {
return true;
Expand Down
37 changes: 1 addition & 36 deletions src/main/java/cn/nukkit/block/BlockCoral.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@ public int getId() {

@Override
public String getName() {
return isDead() ? "Dead " : "" + NAMES[getCoralColor()];
}

@Override
public double getHardness() {
return 0;
}

@Override
public double getResistance() {
return 0;
return (isDead() ? "Dead " : "") + NAMES[getCoralColor()];
}

@Override
Expand Down Expand Up @@ -86,31 +76,6 @@ public BlockColor getColor() {
}
}

@Override
public boolean isSolid() {
return false;
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}

@Override
protected AxisAlignedBB recalculateBoundingBox() {
return null;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public boolean canContainWater() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/block/BlockCoralBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public int getId() {

@Override
public String getName() {
return isDead() ? "Dead " : "" + NAMES[getCoralColor()];
return (isDead() ? "Dead " : "") + NAMES[getCoralColor()];
}

@Override
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/cn/nukkit/block/BlockCoralFan.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public String getName() {
return NAMES[getCoralColor()];
}

@Override
public double getHardness() {
return 0;
}

@Override
public double getResistance() {
return 4.5;
Expand Down Expand Up @@ -87,31 +82,6 @@ public BlockColor getColor() {
}
}

@Override
public boolean isSolid() {
return false;
}

@Override
public boolean breaksWhenMoved() {
return true;
}

@Override
public boolean sticksToPiston() {
return false;
}

@Override
protected AxisAlignedBB recalculateBoundingBox() {
return null;
}

@Override
public boolean canProvideSupport(BlockFace face, SupportType type) {
return false;
}

@Override
public boolean canContainWater() {
return true;
Expand Down
Loading

0 comments on commit c95ff0e

Please sign in to comment.