-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to the future 0.1.9 mod version.
Code clean-up. Add reset (since protocol 3) and check commands.
- Loading branch information
1 parent
218dc85
commit dfad3f0
Showing
7 changed files
with
303 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 141 additions & 88 deletions
229
src/main/java/me/superneon4ik/noxesiumutils/NoxesiumUtils.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/me/superneon4ik/noxesiumutils/modules/NoxesiumServerRuleBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package me.superneon4ik.noxesiumutils.modules; | ||
|
||
import io.netty.buffer.Unpooled; | ||
import lombok.Getter; | ||
import org.bukkit.Bukkit; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class NoxesiumServerRuleBuilder { | ||
private final FriendlyByteBuf valuesBuffer = new FriendlyByteBuf(Unpooled.buffer()); | ||
private final List<Integer> modifiedRules = new ArrayList<>(); | ||
@Getter private final int protocolVersion; | ||
|
||
public NoxesiumServerRuleBuilder(int protocolVersion) { | ||
this.protocolVersion = protocolVersion; | ||
} | ||
|
||
public NoxesiumServerRuleBuilder add(int index, boolean value) { | ||
modifiedRules.add(index); | ||
if (protocolVersion >= 3) valuesBuffer.writeVarInt(index); | ||
else if (protocolVersion >= 1) valuesBuffer.writeInt(index); | ||
valuesBuffer.writeBoolean(value); | ||
return this; | ||
} | ||
|
||
public NoxesiumServerRuleBuilder add(int index, int value) { | ||
modifiedRules.add(index); | ||
if (protocolVersion >= 3) valuesBuffer.writeVarInt(index); | ||
else if (protocolVersion >= 1) valuesBuffer.writeInt(index); | ||
valuesBuffer.writeVarInt(value); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add UTF List packet. | ||
* @param index Packet index. | ||
* @param values UTF Strings. | ||
* @return Builder. | ||
*/ | ||
public NoxesiumServerRuleBuilder add(int index, List<String> values) { | ||
return add(index, values.toArray(new String[0])); | ||
} | ||
|
||
/** | ||
* Add UTF List packet. | ||
* @param index Packet index. | ||
* @param values UTF Strings. | ||
* @return Builder. | ||
*/ | ||
public NoxesiumServerRuleBuilder add(int index, String... values) { | ||
modifiedRules.add(index); | ||
if (protocolVersion >= 3) valuesBuffer.writeVarInt(index); | ||
else if (protocolVersion >= 1) valuesBuffer.writeInt(index); | ||
valuesBuffer.writeVarInt(values.length); | ||
for (String string : values) { | ||
valuesBuffer.writeUtf(string); | ||
} | ||
return this; | ||
} | ||
|
||
/** | ||
* Builds the final byte array. | ||
* @return Packet bytes. | ||
*/ | ||
public byte[] build() { | ||
FriendlyByteBuf finalBuffer = new FriendlyByteBuf(Unpooled.buffer()); | ||
finalBuffer.writeVarIntArray(modifiedRules); | ||
if (protocolVersion >= 3) finalBuffer.writeVarInt(modifiedRules.size()); | ||
else if (protocolVersion >= 1) finalBuffer.writeInt(modifiedRules.size()); | ||
finalBuffer.writeBytes(valuesBuffer.array()); | ||
return finalBuffer.array(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/me/superneon4ik/noxesiumutils/objects/PlayerClientSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.superneon4ik.noxesiumutils.objects; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class PlayerClientSettings { | ||
@NotNull Integer guiScale; | ||
@Nullable Double internalGuiScale; | ||
@Nullable Integer scaledWidth; | ||
@Nullable Integer scaledHeight; | ||
@NotNull Boolean enforceUnicode; | ||
@Nullable Boolean touchscreenMode; | ||
@Nullable Double notificationDisplayTime; | ||
|
||
@Override | ||
public String toString() { | ||
return "PlayerClientSettings{" + | ||
"guiScale=" + guiScale + | ||
", internalGuiScale=" + internalGuiScale + | ||
", scaledWidth=" + scaledWidth + | ||
", scaledHeight=" + scaledHeight + | ||
", enforceUnicode=" + enforceUnicode + | ||
", touchscreenMode=" + touchscreenMode + | ||
", notificationDisplayTime=" + notificationDisplayTime + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# https://github.com/SuperNeon4ik/noxesium | ||
# https://github.com/Noxcrew/noxesium | ||
sendDefaultsOnJoin: false | ||
defaults: | ||
# comment out the line if you don't want to send that rule. | ||
disableAutoSpinAttack: false # since protocol 1 | ||
globalCanPlaceOn: [] # unsupported. since protocol 1 | ||
globalCanDestroy: [] # unsupported. since protocol 1 | ||
heldItemNameOffset: 0 # unsupported. since protocol 2 | ||
cameraLocked: false # since protocol 2 | ||
# disableAutoSpinAttack: false # since protocol 1 | ||
# globalCanPlaceOn: [] # unsupported. since protocol 1 | ||
# globalCanDestroy: [] # unsupported. since protocol 1 | ||
# heldItemNameOffset: 0 # unsupported. since protocol 2 | ||
# cameraLocked: false # since protocol 2 |