Modules be gone!
194
build.gradle
@@ -1,57 +1,151 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '6.1.0'
|
||||
id 'org.cadixdev.licenser' version '0.5.0'
|
||||
id 'java-library'
|
||||
id 'fabric-loom' version '0.6-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '6.1.0'
|
||||
id 'org.cadixdev.licenser' version '0.5.0'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'java-library'
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
|
||||
group = project.maven_group
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
version = "${project.mod_version}+${getMCVersionString()}"
|
||||
archivesBaseName = project.archives_base_name + "-fabric"
|
||||
|
||||
// This field defines the Java version your mod target.
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too.
|
||||
def targetJavaVersion = 8
|
||||
// This field defines the Java version your mod target.
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too.
|
||||
def targetJavaVersion = 8
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = 'https://aperlambda.github.io/maven' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
||||
targetCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetJavaVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/LambdAurora/LambdaControls")
|
||||
credentials {
|
||||
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
|
||||
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
def getMCVersionString() {
|
||||
if (project.minecraft_version.matches("\\d\\dw\\d\\d[a-z]")) {
|
||||
return project.minecraft_version
|
||||
}
|
||||
int lastDot = project.minecraft_version.lastIndexOf('.')
|
||||
return project.minecraft_version.substring(0, lastDot)
|
||||
}
|
||||
|
||||
minecraft {
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = 'https://aperlambda.github.io/maven' }
|
||||
maven {
|
||||
name = 'CottonMC'
|
||||
url = 'http://server.bbkr.space:8081/artifactory/libs-snapshot'
|
||||
}
|
||||
repositories {
|
||||
maven { url = "https://jitpack.io" }
|
||||
}
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
api.extendsFrom shadow
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
modImplementation "io.github.prospector:modmenu:${project.modmenu_version}"
|
||||
modImplementation "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||
include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||
|
||||
// Compatibility mods
|
||||
modImplementation "com.github.joaoh1:okzoomer:e13183c59b"
|
||||
modImplementation "me.shedaniel:RoughlyEnoughItems:5.10.184"
|
||||
|
||||
shadow "com.electronwill.night-config:core:3.6.3"
|
||||
shadow "com.electronwill.night-config:toml:3.6.3"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
||||
targetCompatibility = JavaVersion.toVersion(targetJavaVersion)
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetJavaVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}" }
|
||||
}
|
||||
}
|
||||
|
||||
license {
|
||||
header file('HEADER')
|
||||
include '**/*.java'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependsOn jar
|
||||
configurations = [project.configurations.shadow]
|
||||
archiveClassifier.set('dev')
|
||||
|
||||
exclude 'META-INF/maven/**'
|
||||
exclude 'com/google/**'
|
||||
exclude 'javax/**'
|
||||
exclude 'org/**'
|
||||
relocate 'com.electronwill.nightconfig', 'dev.lambdaurora.lambdacontrols.shadow.nightconfig'
|
||||
}
|
||||
|
||||
task shadowRemapJar(type: RemapJarTask) {
|
||||
dependsOn shadowJar
|
||||
|
||||
input = file("${project.buildDir}/libs/$archivesBaseName-$version-dev.jar")
|
||||
archiveName = "${archivesBaseName}-${version}.jar"
|
||||
addNestedDependencies = true
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "GithubPackages"
|
||||
url = uri("https://maven.pkg.github.com/LambdAurora/LambdaControls")
|
||||
credentials {
|
||||
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
|
||||
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name + "-core"
|
||||
|
||||
dependencies {
|
||||
api "org.jetbrains:annotations:17.0.0"
|
||||
api "org.aperlambda:lambdajcommon:1.8.1"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(jar) {
|
||||
builtBy jar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy sourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.6-SNAPSHOT'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
id 'org.cadixdev.licenser'
|
||||
}
|
||||
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
|
||||
version = "${project.mod_version}+${getMCVersionString()}"
|
||||
archivesBaseName = project.archives_base_name + "-fabric"
|
||||
|
||||
def getMCVersionString() {
|
||||
if (project.minecraft_version.matches("\\d\\dw\\d\\d[a-z]")) {
|
||||
return project.minecraft_version
|
||||
}
|
||||
int lastDot = project.minecraft_version.lastIndexOf('.')
|
||||
return project.minecraft_version.substring(0, lastDot)
|
||||
}
|
||||
|
||||
minecraft {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'CottonMC'
|
||||
url = 'http://server.bbkr.space:8081/artifactory/libs-snapshot'
|
||||
}
|
||||
repositories {
|
||||
maven { url = "https://jitpack.io" }
|
||||
}
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
configurations {
|
||||
shadowInternal
|
||||
shadow
|
||||
api.extendsFrom shadow
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
modImplementation "io.github.prospector:modmenu:${project.modmenu_version}"
|
||||
modImplementation "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||
include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
|
||||
|
||||
// Compatibility mods
|
||||
modImplementation "com.github.joaoh1:okzoomer:e13183c59b"
|
||||
modImplementation "me.shedaniel:RoughlyEnoughItems:5.10.184"
|
||||
|
||||
api project(":core")
|
||||
shadow project(":core")
|
||||
shadow "com.electronwill.night-config:core:3.6.3"
|
||||
shadow "com.electronwill.night-config:toml:3.6.3"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
expand "version": project.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
from "../LICENSE"
|
||||
}
|
||||
|
||||
license {
|
||||
header file('HEADER')
|
||||
include '**/*.java'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependsOn jar
|
||||
configurations = [project.configurations.shadow]
|
||||
archiveClassifier.set('dev')
|
||||
|
||||
exclude 'META-INF/maven/**'
|
||||
exclude 'com/google/**'
|
||||
exclude 'javax/**'
|
||||
exclude 'org/**'
|
||||
relocate 'com.electronwill.nightconfig', 'dev.lambdaurora.lambdacontrols.shadow.nightconfig'
|
||||
}
|
||||
|
||||
task shadowRemapJar(type: RemapJarTask) {
|
||||
dependsOn shadowJar
|
||||
|
||||
input = file("${project.buildDir}/libs/$archivesBaseName-$version-dev.jar")
|
||||
archiveName = "${archivesBaseName}-${version}.jar"
|
||||
addNestedDependencies = true
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar.dependsOn(":core:jar")
|
||||
build.dependsOn(":core:build")
|
||||
publish.dependsOn(":core:publish")
|
||||
@@ -9,4 +9,3 @@ pluginManagement {
|
||||
}
|
||||
|
||||
rootProject.name = 'lambdacontrols'
|
||||
include 'core', 'fabric', 'spigot'
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name + "-spigot"
|
||||
|
||||
repositories {
|
||||
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
||||
maven { url = 'https://libraries.minecraft.net/' }
|
||||
}
|
||||
|
||||
configurations {
|
||||
include
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":core")
|
||||
include(project(":core")) {
|
||||
exclude group: 'com.google.code.gson'
|
||||
exclude group: 'com.google.guava'
|
||||
}
|
||||
api 'org.spigotmc:spigot-api:1.15.1-R0.1-SNAPSHOT'
|
||||
api 'io.netty:netty-all:4.1.28.Final'
|
||||
implementation "com.electronwill.night-config:core:3.5.3"
|
||||
implementation "com.electronwill.night-config:toml:3.5.3"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "plugin.yml"
|
||||
|
||||
expand 'version': project.version.toString().replace("#", "")
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from '../LICENSE'
|
||||
|
||||
dependsOn configurations.include
|
||||
from {
|
||||
(configurations.include).collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls Spigot configuration.
|
||||
*/
|
||||
public class LambdaControlsConfig
|
||||
{
|
||||
private static final boolean DEFAULT_FRONT_BLOCK_PLACING = true;
|
||||
|
||||
protected final FileConfig config = FileConfig.builder("config/lambdacontrols.toml").concurrent().defaultResource("/server_config.toml").build();
|
||||
private final LambdaControlsSpigot plugin;
|
||||
|
||||
public LambdaControlsConfig(@NotNull LambdaControlsSpigot plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
File configDir = new File("config/");
|
||||
if (!configDir.exists())
|
||||
configDir.mkdirs();
|
||||
this.config.load();
|
||||
this.plugin.log("Configuration loaded.");
|
||||
LambdaControlsFeature.HORIZONTAL_REACHAROUND.setAllowed(this.config.getOrElse("gameplay.front_block_placing", DEFAULT_FRONT_BLOCK_PLACING));
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import me.lambdaurora.lambdacontrols.event.PlayerChangeControlsModeEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.lambdaurora.lambdacontrols.LambdaControlsConstants.*;
|
||||
|
||||
/**
|
||||
* Represents the LambdaControls spigot plugin which provides extra features for servers.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class LambdaControlsSpigot extends JavaPlugin implements PluginMessageListener, Listener
|
||||
{
|
||||
private static final Map<Player, ControlsMode> PLAYERS_CONTROLS_MODE = new HashMap<>();
|
||||
public final LambdaControlsConfig config = new LambdaControlsConfig(this);
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
super.onEnable();
|
||||
|
||||
this.config.load();
|
||||
|
||||
// Note that Spigot has a bullshit channel size restriction as Minecraft SUPPORTS UP TO 32767 AS CHANNEL SIZE.
|
||||
// Please stop using that bad server software, move over Sponge or idk other things. REALLY.
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, CONTROLS_MODE_CHANNEL.toString(), this);
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, CONTROLS_MODE_CHANNEL.toString());
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, FEATURE_CHANNEL.toString());
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, HELLO_CHANNEL.toString(), this);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
this.getServer().getOnlinePlayers().forEach(player -> {
|
||||
PLAYERS_CONTROLS_MODE.put(player, ControlsMode.DEFAULT);
|
||||
|
||||
this.requestPlayerControlsMode(player);
|
||||
this.updatePlayerFeature(player, LambdaControlsFeature.HORIZONTAL_REACHAROUND);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
super.onDisable();
|
||||
|
||||
this.getServer().getMessenger().unregisterIncomingPluginChannel(this, CONTROLS_MODE_CHANNEL.toString());
|
||||
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this, CONTROLS_MODE_CHANNEL.toString());
|
||||
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this, FEATURE_CHANNEL.toString());
|
||||
this.getServer().getMessenger().unregisterIncomingPluginChannel(this, HELLO_CHANNEL.toString());
|
||||
|
||||
PLAYERS_CONTROLS_MODE.clear();
|
||||
}
|
||||
|
||||
public void requestPlayerControlsMode(@NotNull Player player)
|
||||
{
|
||||
player.sendPluginMessage(this, CONTROLS_MODE_CHANNEL.toString(), new byte[0]);
|
||||
}
|
||||
|
||||
public void updatePlayerFeature(@NotNull Player player, @NotNull LambdaControlsFeature feature)
|
||||
{
|
||||
Objects.requireNonNull(player);
|
||||
Objects.requireNonNull(feature);
|
||||
|
||||
player.sendPluginMessage(this, FEATURE_CHANNEL.toString(), this.makeFeatureMessage(feature));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a message to the terminal.
|
||||
*
|
||||
* @param info The message to print.
|
||||
*/
|
||||
public void log(String info)
|
||||
{
|
||||
this.getLogger().info(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message)
|
||||
{
|
||||
if (channel.equals(HELLO_CHANNEL.toString())) {
|
||||
NettyPacketBuffer buffer = new NettyPacketBuffer(Unpooled.copiedBuffer(message));
|
||||
String version = buffer.readString(16);
|
||||
ControlsMode.byId(buffer.readString(32)).ifPresent(controlsMode -> {
|
||||
PLAYERS_CONTROLS_MODE.put(player, controlsMode);
|
||||
PlayerChangeControlsModeEvent event = new PlayerChangeControlsModeEvent(player, controlsMode);
|
||||
this.getServer().getPluginManager().callEvent(event);
|
||||
});
|
||||
this.updatePlayerFeature(player, LambdaControlsFeature.HORIZONTAL_REACHAROUND);
|
||||
} else if (channel.equals(CONTROLS_MODE_CHANNEL.toString())) {
|
||||
NettyPacketBuffer buffer = new NettyPacketBuffer(Unpooled.copiedBuffer(message));
|
||||
ControlsMode.byId(buffer.readString(32)).ifPresent(controlsMode -> {
|
||||
PLAYERS_CONTROLS_MODE.put(player, controlsMode);
|
||||
PlayerChangeControlsModeEvent event = new PlayerChangeControlsModeEvent(player, controlsMode);
|
||||
this.getServer().getPluginManager().callEvent(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a packet byte buffer made for the lambdacontrols:feature plugin message.
|
||||
*
|
||||
* @param feature The feature data to send.
|
||||
* @return The packet byte buffer.
|
||||
*/
|
||||
public byte[] makeFeatureMessage(@NotNull LambdaControlsFeature feature)
|
||||
{
|
||||
Objects.requireNonNull(feature, "Feature cannot be null.");
|
||||
NettyPacketBuffer buffer = new NettyPacketBuffer(Unpooled.buffer());
|
||||
buffer.writeString(feature.getName());
|
||||
buffer.writeBoolean(feature.isAllowed());
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(@NotNull PlayerJoinEvent event)
|
||||
{
|
||||
PLAYERS_CONTROLS_MODE.put(event.getPlayer(), ControlsMode.DEFAULT);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(@NotNull PlayerQuitEvent event)
|
||||
{
|
||||
PLAYERS_CONTROLS_MODE.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package me.lambdaurora.lambdacontrols;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class NettyPacketBuffer extends PacketBuffer
|
||||
{
|
||||
public NettyPacketBuffer(ByteBuf byteBuf)
|
||||
{
|
||||
super(byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readVarint()
|
||||
{
|
||||
int var1 = 0;
|
||||
int var2 = 0;
|
||||
byte var3;
|
||||
|
||||
do {
|
||||
var3 = this.readByte();
|
||||
var1 |= (var3 & 127) << var2++ * 7;
|
||||
|
||||
if (var2 > 5)
|
||||
throw new RuntimeException("VarInt too big");
|
||||
} while ((var3 & 128) == 128);
|
||||
|
||||
return var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVarint(int input)
|
||||
{
|
||||
while ((input & -128) != 0) {
|
||||
this.writeByte(input & 127 | 128);
|
||||
input >>>= 7;
|
||||
}
|
||||
|
||||
this.writeByte(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readString(int maxLength)
|
||||
{
|
||||
int var2 = this.readVarint();
|
||||
|
||||
if (var2 > maxLength * 4)
|
||||
throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + var2 + " > " + maxLength * 4 + ")");
|
||||
else if (var2 < 0)
|
||||
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
|
||||
else {
|
||||
String var3 = this.readCharSequence(var2, StandardCharsets.UTF_8).toString();
|
||||
|
||||
if (var3.length() > maxLength)
|
||||
throw new DecoderException("The received string length is longer than maximum allowed (" + var2 + " > " + maxLength + ")");
|
||||
else
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeString(String string)
|
||||
{
|
||||
byte[] var2 = string.getBytes(Charset.forName("UTF-8"));
|
||||
|
||||
if (var2.length > 32767) {
|
||||
throw new EncoderException("String too big (was " + string.length() + " data encoded, max " + 32767 + ")");
|
||||
} else {
|
||||
this.writeVarint(var2.length);
|
||||
this.writeCharSequence(string, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
NettyPacketBuffer buffer = (NettyPacketBuffer) o;
|
||||
|
||||
return byteBuf.equals(buffer.byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ByteBuf buffer)
|
||||
{
|
||||
return this.byteBuf.compareTo(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.byteBuf.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2020 LambdAurora <aurora42lambda@gmail.com>
|
||||
*
|
||||
* This file is part of LambdaControls.
|
||||
*
|
||||
* Licensed under the MIT license. For more information,
|
||||
* see the LICENSE file.
|
||||
*/
|
||||
|
||||
package me.lambdaurora.lambdacontrols.event;
|
||||
|
||||
import me.lambdaurora.lambdacontrols.ControlsMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an event which is fired when a player change their controls mode.
|
||||
*
|
||||
* @author LambdAurora
|
||||
* @version 1.1.0
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class PlayerChangeControlsModeEvent extends PlayerEvent
|
||||
{
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final ControlsMode controlsMode;
|
||||
|
||||
public PlayerChangeControlsModeEvent(@NotNull Player who, @NotNull ControlsMode controlsMode)
|
||||
{
|
||||
super(who);
|
||||
this.controlsMode = controlsMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the controls mode of the player.
|
||||
*
|
||||
* @return The player's controls mode.
|
||||
*/
|
||||
public ControlsMode getControlsMode()
|
||||
{
|
||||
return this.controlsMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "PlayerChangeControlsModeEvent{" +
|
||||
"player=" + this.player +
|
||||
", controls_mode=" + this.controlsMode +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList()
|
||||
{
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
name: LambdaControls
|
||||
version: ${version}
|
||||
description: A quick Spigot plugin for LambdaControls which allow server admins to disable some features.
|
||||
|
||||
main: me.lambdaurora.lambdacontrols.LambdaControlsSpigot
|
||||
api-version: 1.13
|
||||
@@ -1,6 +0,0 @@
|
||||
# LambdaControls server configuration.
|
||||
|
||||
# Gameplay settings
|
||||
[gameplay]
|
||||
# Allows front block placing like in Bedrock Edition.
|
||||
front_block_placing = true
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 334 B After Width: | Height: | Size: 334 B |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |