Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Update to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pub4Game committed Jan 14, 2017
1 parent c664fad commit 6009873
Show file tree
Hide file tree
Showing 180 changed files with 3,495 additions and 1,364 deletions.
9 changes: 6 additions & 3 deletions src/main/java/cn/nukkit/Nukkit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.nukkit;

import cn.nukkit.command.CommandReader;
import cn.nukkit.network.protocol.ProtocolInfo;
import cn.nukkit.utils.MainLogger;
import cn.nukkit.utils.ServerKiller;

Expand All @@ -26,8 +27,10 @@ public class Nukkit {
public final static String VERSION = "1.0dev";
public final static String API_VERSION = "1.0.0";
public final static String CODENAME = "蘋果(Apple)派(Pie)";
public final static String MINECRAFT_VERSION = "v0.16.0 alpha";
public final static String MINECRAFT_VERSION_NETWORK = "0.16.0";
@Deprecated
public final static String MINECRAFT_VERSION = ProtocolInfo.MINECRAFT_VERSION;
@Deprecated
public final static String MINECRAFT_VERSION_NETWORK = ProtocolInfo.MINECRAFT_VERSION_NETWORK;

public final static String PATH = System.getProperty("user.dir") + "/";
public final static String DATA_PATH = System.getProperty("user.dir") + "/";
Expand Down Expand Up @@ -62,7 +65,7 @@ public static void main(String[] args) {
if (ANSI) {
System.out.print((char) 0x1b + "]0;Starting Nukkit Server For Minecraft: PE" + (char) 0x07);
}
Server server = new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
new Server(logger, PATH, DATA_PATH, PLUGIN_PATH);
} catch (Exception e) {
logger.logException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/OfflinePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void setOp(boolean value) {

@Override
public boolean isBanned() {
return this.server.getNameBans().isBanned(this.getName().toLowerCase());
return this.server.getNameBans().isBanned(this.getName());
}

@Override
Expand Down
231 changes: 136 additions & 95 deletions src/main/java/cn/nukkit/Player.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/PlayerFood.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void update(int tickDiff) {
this.foodTickTimer += tickDiff;
if (this.foodTickTimer >= 80) {
EntityDamageEvent ev = new EntityDamageEvent(this.getPlayer(), EntityDamageEvent.CAUSE_VOID, 1);
int now = this.getPlayer().getHealth();
float now = this.getPlayer().getHealth();
if (diff == 1) {
if (now > 10) this.getPlayer().attack(ev);
} else if (diff == 2) {
Expand Down
45 changes: 24 additions & 21 deletions src/main/java/cn/nukkit/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cn.nukkit.entity.mob.EntityCreeper;
import cn.nukkit.entity.passive.*;
import cn.nukkit.entity.projectile.EntityArrow;
import cn.nukkit.entity.projectile.EntityEnderPearl;
import cn.nukkit.entity.projectile.EntitySnowball;
import cn.nukkit.entity.weather.EntityLightning;
import cn.nukkit.event.HandlerList;
Expand Down Expand Up @@ -49,10 +50,7 @@
import cn.nukkit.network.Network;
import cn.nukkit.network.RakNetInterface;
import cn.nukkit.network.SourceInterface;
import cn.nukkit.network.protocol.BatchPacket;
import cn.nukkit.network.protocol.CraftingDataPacket;
import cn.nukkit.network.protocol.DataPacket;
import cn.nukkit.network.protocol.PlayerListPacket;
import cn.nukkit.network.protocol.*;
import cn.nukkit.network.query.QueryHandler;
import cn.nukkit.network.rcon.RCON;
import cn.nukkit.permission.BanEntry;
Expand Down Expand Up @@ -354,7 +352,7 @@ public Server(MainLogger logger, final String filePath, String dataPath, String
this.network = new Network(this);
this.network.setName(this.getMotd());

this.logger.info(this.getLanguage().translateString("nukkit.server.info", new String[]{this.getName(), TextFormat.YELLOW + this.getNukkitVersion() + TextFormat.WHITE, TextFormat.AQUA + this.getCodename() + TextFormat.WHITE, this.getApiVersion()}));
this.logger.info(this.getLanguage().translateString("nukkit.server.info", this.getName(), TextFormat.YELLOW + this.getNukkitVersion() + TextFormat.WHITE, TextFormat.AQUA + this.getCodename() + TextFormat.WHITE, this.getApiVersion()));
this.logger.info(this.getLanguage().translateString("nukkit.server.license", this.getName()));


Expand Down Expand Up @@ -848,7 +846,10 @@ public void updatePlayerListData(UUID uuid, long entityId, String name, Skin ski
}

public void updatePlayerListData(UUID uuid, long entityId, String name, Skin skin, Collection<Player> players) {
this.updatePlayerListData(uuid, entityId, name, skin, players.stream().toArray(Player[]::new));
this.updatePlayerListData(uuid, entityId, name, skin,
players.stream()
.filter(p -> !p.getUniqueId().equals(uuid))
.toArray(Player[]::new));
}

public void removePlayerListData(UUID uuid) {
Expand All @@ -867,18 +868,19 @@ public void removePlayerListData(UUID uuid, Collection<Player> players) {
}

public void sendFullPlayerListData(Player player) {
final UUID uuid = player.getUniqueId();
PlayerListPacket pk = new PlayerListPacket();
pk.type = PlayerListPacket.TYPE_ADD;
List<PlayerListPacket.Entry> entries = new ArrayList<>();
for (Player p : this.playerList.values()) {
if (p != player) entries.add(
new PlayerListPacket.Entry(
p.getUniqueId(),
p.getId(),
p.getDisplayName(),
p.getSkin()));
}
pk.entries = entries.stream().toArray(PlayerListPacket.Entry[]::new);
pk.entries = this.playerList.values()
.stream()
.filter(p -> !p.getUniqueId().equals(uuid))
.map(p -> new PlayerListPacket.Entry(
p.getUniqueId(),
p.getId(),
p.getDisplayName(),
p.getSkin()))
.toArray(PlayerListPacket.Entry[]::new);

player.dataPacket(pk);
}

Expand All @@ -903,7 +905,7 @@ public void sendRecipeList(Player player) {

private void checkTickUpdates(int currentTick, long tickTime) {
for (Player p : new ArrayList<>(this.players.values())) {
if (!p.loggedIn && (tickTime - p.creationTime) >= 10000 && p.kick(PlayerKickEvent.Reason.LOGIN_TIMOUT)) {
if (!p.loggedIn && (tickTime - p.creationTime) >= 10000 && p.kick(PlayerKickEvent.Reason.LOGIN_TIMEOUT, "Login timeout")) {
continue;
}
if (this.alwaysTickPlayers) {
Expand Down Expand Up @@ -1114,7 +1116,7 @@ public String getCodename() {
}

public String getVersion() {
return Nukkit.MINECRAFT_VERSION;
return ProtocolInfo.MINECRAFT_VERSION;
}

public String getApiVersion() {
Expand Down Expand Up @@ -1605,10 +1607,9 @@ public boolean generateLevel(String name, long seed, Class<? extends Generator>
}

if (provider == null) {
String providerName;
if ((provider = LevelProviderManager.getProviderByName
(providerName = (String) this.getConfig("level-settings.default-format", "mcregion"))) == null) {
provider = LevelProviderManager.getProviderByName(providerName = "mcregion");
((String) this.getConfig("level-settings.default-format", "anvil"))) == null) {
provider = LevelProviderManager.getProviderByName("anvil");
}
}

Expand Down Expand Up @@ -1874,6 +1875,7 @@ private void registerEntities() {
Entity.registerEntity("FallingSand", EntityFallingBlock.class);
Entity.registerEntity("PrimedTnt", EntityPrimedTNT.class);
Entity.registerEntity("Snowball", EntitySnowball.class);
Entity.registerEntity("EnderPearl", EntityEnderPearl.class);
Entity.registerEntity("Painting", EntityPainting.class);
//todo mobs
Entity.registerEntity("Creeper", EntityCreeper.class);
Expand Down Expand Up @@ -1910,6 +1912,7 @@ private void registerBlockEntities() {
BlockEntity.registerBlockEntity(BlockEntity.BREWING_STAND, BlockEntityBrewingStand.class);
BlockEntity.registerBlockEntity(BlockEntity.ITEM_FRAME, BlockEntityItemFrame.class);
BlockEntity.registerBlockEntity(BlockEntity.CAULDRON, BlockEntityCauldron.class);
BlockEntity.registerBlockEntity(BlockEntity.ENDER_CHEST, BlockEntityEnderChest.class);
BlockEntity.registerBlockEntity(BlockEntity.BEACON, BlockEntityBeacon.class);
}

Expand Down
Loading

0 comments on commit 6009873

Please sign in to comment.