Skip to content

Commit

Permalink
Merge pull request #54 from Nukkit/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Creeperface01 authored Nov 28, 2017
2 parents 959af73 + b04061b commit d055d8c
Show file tree
Hide file tree
Showing 350 changed files with 14,523 additions and 6,223 deletions.
6 changes: 5 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ Nukkit will create a bug report for EVERY exception and error detected, and ther

In the report, you can see if the error is caused by Nukkit or a plugin. However, when "PLUGIN ERROR" is "false" and there are plugins running, it does not necessarily indicates that the error is caused by Nukkit.

While sending issues, please provide **as much information as you could**, or our developers might got stuck or confused when looking into your issue.
To sumbit bugs and problems, please upload the automaticly generated report. Make sure you have filled in all blanks in the template. Please provide **as much information as you could**, or our developers might got stuck or confused when looking into your issue.

To submit feature requests and suggestions, please explicitly describe the feature you want or your suggestion.

**Note that the Issues section on GitHub is not for contents that are not related to the two categories listed above. Irrelevant issues will be closed. Please visit our forums for other kinds of discussions.**

Example
---
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ It has a few key advantages over other server software:

Nukkit is **under improvement** yet, we welcome contributions.

Example servers running Nukkit
--------------------
- **play.EaseCation.net**
- **play.GameTeam.cz**
- **MultiLabs.net**

Get Nukkit & Plugins
--------------------

Expand All @@ -49,6 +55,7 @@ Get Nukkit & Plugins
*These sites are provided by our users, Nukkit staff are not responsible for the reliability of these sites. Jar files downloaded here are only for reference - to try the latest update or for commercial uses, compile by yourself.*

* __[Jenkins by MengCraft](http://ci.mengcraft.com:8080/job/Nukkit/lastSuccessfulBuild/)__ (**UNOFFICIAL**)
* __[Yivesmirror](https://yivesmirror.com/downloads/nukkit)__ (**UNOFFICIAL**)

Build JAR file
-------------
Expand All @@ -74,6 +81,10 @@ There're some tools for Nukkit developers.
* __[FDevTools](https://github.com/fengberd/FDevTools)__ (**Load source and pack them easily**)
* __[PocketServer](https://github.com/fengberd/MinecraftPEServer)__ (**Run Nukkit on android devices**)

Contributing
------------
Please read the [CONTRIBUTING](https://github.com/Nukkit/Nukkit/blob/master/.github/CONTRIBUTING.md) guide before submitting any issue. Issues with insufficient information or in the wrong format will be closed and will not be reviewed.

Discussion
-------------
* __[Forums](https://forums.nukkit.io)__
Expand Down
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,54 @@
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>

<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix>git</prefix>
<dateFormat>dd.MM.yyyy '@' HH:mm:ss z</dateFormat>
<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
<verbose>true</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<format>properties</format>
<skipPoms>true</skipPoms>
<injectAllReactorProjects>false</injectAllReactorProjects>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<skip>false</skip>
<runOnlyOnce>true</runOnlyOnce>
<excludeProperties>
<excludeProperty>git.user.*</excludeProperty>
</excludeProperties>
<includeOnlyProperties>
</includeOnlyProperties>
<useNativeGit>false</useNativeGit>
<abbrevLength>7</abbrevLength>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
<match>*</match>
<tags>false</tags>
<forceLongFormat>false</forceLongFormat>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
173 changes: 47 additions & 126 deletions src/main/java/cn/nukkit/AdventureSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import cn.nukkit.network.protocol.AdventureSettingsPacket;

import java.util.EnumMap;
import java.util.Map;

/**
* Nukkit Project
* Author: MagicDroidX
Expand All @@ -14,27 +17,12 @@ public class AdventureSettings implements Cloneable {
public static final int PERMISSION_AUTOMATION = 3;
public static final int PERMISSION_ADMIN = 4;

private boolean canDestroyBlock = true;

private boolean autoJump = true;

private boolean canFly = false;

private boolean flying = false;

private boolean noclip = false;

private boolean noPvp = false;

private boolean noPvm = false;

private boolean noMvp = false;

private boolean muted = false;
private Map<Type, Boolean> values = new EnumMap<>(Type.class);

private Player player;

private AdventureSettings() {
public AdventureSettings(Player player) {
this.player = player;
}

public AdventureSettings clone(Player newPlayer) {
Expand All @@ -47,129 +35,62 @@ public AdventureSettings clone(Player newPlayer) {
}
}

public void setCanDestroyBlock(boolean canDestroyBlock) {
this.canDestroyBlock = canDestroyBlock;
}

public void setAutoJump(boolean autoJump) {
this.autoJump = autoJump;
}

public void setCanFly(boolean canFly) {
this.canFly = canFly;
public AdventureSettings set(Type type, boolean value) {
this.values.put(type, value);
return this;
}

public void setFlying(boolean flying) {
this.flying = flying;
}

public void setNoclip(boolean noclip) {
this.noclip = noclip;
}

public void setNoPvp(boolean noPvp) {
this.noPvp = noPvp;
}

public void setNoPvm(boolean noPvm) {
this.noPvm = noPvm;
}

public void setNoMvp(boolean noMvp) {
this.noMvp = noMvp;
}

public void setMuted(boolean muted) {
this.muted = muted;
}

public boolean canDestroyBlock() {
return canDestroyBlock;
}
public boolean get(Type type) {
Boolean value = this.values.get(type);

public boolean isAutoJumpEnabled() {
return autoJump;
}

public boolean canFly() {
return canFly;
}

public boolean isFlying() {
return flying;
}

public boolean isNoclipEnabled() {
return noclip;
}

public boolean isNoPvp() {
return noPvp;
}

public boolean isNoPvm() {
return noPvm;
}

public boolean isNoMvp() {
return noMvp;
}

public boolean isMuted() {
return muted;
return value == null ? type.getDefaultValue() : value;
}

public void update() {
AdventureSettingsPacket pk = new AdventureSettingsPacket();
pk.flags = 0;
pk.worldImmutable = !canDestroyBlock;
pk.autoJump = autoJump;
pk.allowFlight = canFly;
pk.noClip = noclip;
pk.isFlying = flying;
pk.noPvp = noPvp;
pk.noPvm = noPvm;
pk.noMvp = noMvp;
pk.muted = muted;
pk.userPermission = (this.player.isOp() ? PERMISSION_OPERATOR : PERMISSION_NORMAL);
player.dataPacket(pk);

player.resetInAirTicks();
}

public static class Builder {
private final AdventureSettings settings = new AdventureSettings();

public Builder(Player player) {
if (player == null) {
throw new IllegalArgumentException("Player can not be null.");
}

settings.player = player;
for (Type t : Type.values()) {
pk.setFlag(t.getId(), get(t));
}

public Builder canFly(boolean can) {
settings.canFly = can;
return this;
}
pk.commandPermission = (player.isOp() ? AdventureSettingsPacket.PERMISSION_OPERATOR : AdventureSettingsPacket.PERMISSION_NORMAL);
pk.playerPermission = (player.isOp() ? Player.PERMISSION_OPERATOR : Player.PERMISSION_MEMBER);
pk.entityUniqueId = player.getId();

public Builder noclip(boolean noclip) {
settings.noclip = noclip;
return this;
}
Server.broadcastPacket(Server.getInstance().getOnlinePlayers().values(), pk);

player.resetInAirTicks();
}

public Builder canDestroyBlock(boolean can) {
settings.canDestroyBlock = can;
return this;
public enum Type {
WORLD_IMMUTABLE(AdventureSettingsPacket.WORLD_IMMUTABLE, false),
AUTO_JUMP(AdventureSettingsPacket.AUTO_JUMP, true),
ALLOW_FLIGHT(AdventureSettingsPacket.ALLOW_FLIGHT, false),
NO_CLIP(AdventureSettingsPacket.NO_CLIP, false),
WORLD_BUILDER(AdventureSettingsPacket.WORLD_BUILDER, true),
FLYING(AdventureSettingsPacket.FLYING, false),
MUTED(AdventureSettingsPacket.MUTED, false),
BUILD_AND_MINE(AdventureSettingsPacket.BUILD_AND_MINE, true),
DOORS_AND_SWITCHED(AdventureSettingsPacket.DOORS_AND_SWITCHES, true),
OPEN_CONTAINERS(AdventureSettingsPacket.OPEN_CONTAINERS, true),
ATTACK_PLAYERS(AdventureSettingsPacket.ATTACK_PLAYERS, true),
ATTACK_MOBS(AdventureSettingsPacket.ATTACK_MOBS, true),
OPERATOR(AdventureSettingsPacket.OPERATOR, false),
TELEPORT(AdventureSettingsPacket.TELEPORT, false);

private final int id;
private final boolean defaultValue;

Type(int id, boolean defaultValue) {
this.id = id;
this.defaultValue = defaultValue;
}

public Builder autoJump(boolean autoJump) {
settings.autoJump = autoJump;
return this;
public int getId() {
return id;
}

public AdventureSettings build() {
return this.settings;
public boolean getDefaultValue() {
return this.defaultValue;
}
}
}
33 changes: 32 additions & 1 deletion src/main/java/cn/nukkit/Nukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

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

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

/**
* `_ _ _ _ _ _
* | \ | | | | | | (_) |
Expand Down Expand Up @@ -50,16 +55,42 @@ public static void main(String[] args) {
}
}

LogLevel logLevel = LogLevel.DEFAULT_LEVEL;
int index = -1;
boolean skip = false;
//启动参数
for (String arg : args) {
index++;
if (skip) {
skip = false;
continue;
}

switch (arg) {
case "disable-ansi":
ANSI = false;
break;

case "--verbosity":
case "-v":
skip = true;
try {
String levelName = args[index + 1];
Set<String> levelNames = Arrays.stream(LogLevel.values()).map(level -> level.name().toLowerCase()).collect(Collectors.toSet());
if (!levelNames.contains(levelName.toLowerCase())) {
System.out.printf("'%s' is not a valid log level, using the default\n", levelName);
continue;
}
logLevel = Arrays.stream(LogLevel.values()).filter(level -> level.name().equalsIgnoreCase(levelName)).findAny().orElse(LogLevel.DEFAULT_LEVEL);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("You must enter the requested log level, using the default\n");
}

}
}

MainLogger logger = new MainLogger(DATA_PATH + "server.log");
MainLogger logger = new MainLogger(DATA_PATH + "server.log", logLevel);
System.out.printf("Using log level '%s'\n", logLevel);

try {
if (ANSI) {
Expand Down
Loading

0 comments on commit d055d8c

Please sign in to comment.