Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
fa28c8bed1 | |||
9358086717 | |||
b617dd4d54 | |||
e5a9c1b04d | |||
ca09970fda | |||
de8df562de | |||
94b26089a8 | |||
ff5774f3cb | |||
d7c1f5297a | |||
8c51919e4e | |||
326e9cc4fc | |||
5e3a9793e6 | |||
95412f6cf8 | |||
cbea81f9ce | |||
037342e553 | |||
6ff2142538 | |||
320199d2a6 | |||
af915a696c | |||
67f9bb49c0 | |||
a0c50e0fb0 | |||
03264c281f | |||
02cfe9623a | |||
0778e579d0 | |||
5e0cbb265b | |||
89798e76f1 | |||
e452490317 | |||
48bc060e5c | |||
93f546a5ce | |||
edd3cc8689 | |||
212f2db61a | |||
654cdbd09a | |||
e84fab4abf |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
|
logs/
|
||||||
mcsrc/
|
mcsrc/
|
||||||
run/
|
run/
|
||||||
|
12
README.txt
12
README.txt
@ -1,7 +1,5 @@
|
|||||||
minecraft-tweaks-2a03
|
minecraft-tweaks-2a03
|
||||||
|
|
||||||
This repository contains simple modifications for the 2a03.party Minecraft
|
Simple modifications for mc.2a03.party.
|
||||||
server. I have replaced the patches with a Fabric mod.
|
|
||||||
Send enhancements and bug fixes to my e-mail address, and I'll fix them myself
|
Send questions, issues, and patches to flewkey@2a03.party.
|
||||||
if I think they're important. Do not send random pull requests on GitHub.
|
|
||||||
You probably want to ignore this.
|
|
||||||
|
13
build.gradle
13
build.gradle
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.4-SNAPSHOT'
|
id 'fabric-loom' version '1.2-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -9,11 +9,14 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
modCompile "org.json:json:20200518"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
modImplementation "org.json:json:20211205"
|
||||||
|
modImplementation "org.xerial:sqlite-jdbc:3.36.0.3"
|
||||||
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
|
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
include "org.json:json:20200518"
|
include "org.json:json:20211205"
|
||||||
|
include "org.xerial:sqlite-jdbc:3.36.0.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
minecraft_version=1.16
|
org.gradle.parallel=true
|
||||||
yarn_mappings=1.16+build.1
|
minecraft_version=1.20
|
||||||
loader_version=0.8.8+build.202
|
yarn_mappings=1.20+build.1
|
||||||
mod_version = 1.1.0
|
loader_version=0.14.21
|
||||||
maven_group = party.2a03.mc
|
mod_version=1.2.0
|
||||||
archives_base_name = minecraft-tweaks-2a03
|
maven_group=party._2a03.mc
|
||||||
fabric_version=0.13.1+build.370-1.16
|
archives_base_name=minecraft-tweaks-2a03
|
||||||
|
fabric_version=0.83.0+1.20
|
||||||
|
14
scripts/migrate_players.py
Executable file
14
scripts/migrate_players.py
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import json
|
||||||
|
import sqlite3
|
||||||
|
with open("2a03.json", "r") as f:
|
||||||
|
config = json.loads(f.read())
|
||||||
|
sql = "INSERT INTO players (uuid, home) VALUES "
|
||||||
|
def sql_values(player):
|
||||||
|
return "('"+player["uuid"]+"', '"+json.dumps(player["home"])+"')"
|
||||||
|
sql += ", ".join(list(map(sql_values, config["members"])))
|
||||||
|
sql += ";"
|
||||||
|
conn = sqlite3.connect("2a03.db")
|
||||||
|
conn.execute(sql)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
@ -1,7 +1,8 @@
|
|||||||
package party._2a03.mc;
|
package party._2a03.mc;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -13,8 +14,12 @@ import party._2a03.mc.command.FlyCommand;
|
|||||||
import party._2a03.mc.command.HatCommand;
|
import party._2a03.mc.command.HatCommand;
|
||||||
import party._2a03.mc.command.HeadCommand;
|
import party._2a03.mc.command.HeadCommand;
|
||||||
import party._2a03.mc.command.HomeCommand;
|
import party._2a03.mc.command.HomeCommand;
|
||||||
|
import party._2a03.mc.command.NameCommand;
|
||||||
|
import party._2a03.mc.command.SkinCommand;
|
||||||
import party._2a03.mc.command.SpawnCommand;
|
import party._2a03.mc.command.SpawnCommand;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.command.TpaCommand;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
|
||||||
public class MinecraftTweaks2a03 implements ModInitializer {
|
public class MinecraftTweaks2a03 implements ModInitializer {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
@ -34,21 +39,31 @@ public class MinecraftTweaks2a03 implements ModInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Config.initConfig(configDir.toFile());
|
Config.initConfig(configDir.toFile());
|
||||||
|
Database.init(configDir.toFile());
|
||||||
try {
|
try {
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
|
Database.open();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ServerLifecycleEvents.SERVER_STOPPING.register(minecraftServer -> {
|
||||||
|
Database.close();
|
||||||
|
});
|
||||||
LOGGER.info("Registering 2a03.party commands");
|
LOGGER.info("Registering 2a03.party commands");
|
||||||
CommandRegistry.INSTANCE.register(false, dispatcher -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||||
ConfigCommand.register(dispatcher);
|
if (environment.dedicated) {
|
||||||
FlyCommand.register(dispatcher);
|
ConfigCommand.register(dispatcher);
|
||||||
HatCommand.register(dispatcher);
|
FlyCommand.register(dispatcher);
|
||||||
HeadCommand.register(dispatcher);
|
HatCommand.register(dispatcher);
|
||||||
HomeCommand.register(dispatcher);
|
HeadCommand.register(dispatcher);
|
||||||
SpawnCommand.register(dispatcher);
|
HomeCommand.register(dispatcher);
|
||||||
|
NameCommand.register(dispatcher);
|
||||||
|
SkinCommand.register(dispatcher);
|
||||||
|
SpawnCommand.register(dispatcher);
|
||||||
|
TpaCommand.register(dispatcher);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
public class ConfigCommand {
|
public class ConfigCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
@ -17,9 +17,9 @@ public class ConfigCommand {
|
|||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
try {
|
try {
|
||||||
Config.loadConfig();
|
Config.loadConfig();
|
||||||
source.sendFeedback(new LiteralText("Reloaded the configuration"), true);
|
source.sendFeedback(() -> Text.of("Reloaded the configuration"), true);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
source.sendFeedback(new LiteralText("Failed to reload the configuration"), true);
|
source.sendFeedback(() -> Text.of("Failed to reload the configuration"), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
package party._2a03.mc.command;
|
package party._2a03.mc.command;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import net.minecraft.entity.player.PlayerAbilities;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
public class FlyCommand {
|
public class FlyCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
dispatcher.register(CommandManager.literal("fly").executes(ctx -> {
|
dispatcher.register(CommandManager.literal("fly").executes(ctx -> {
|
||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
|
if (Config.getBool("disableFlyCommand")) {
|
||||||
|
source.sendFeedback(() -> Text.of("The /fly command is disabled"), true);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
boolean flight = sender.abilities.allowFlying;
|
PlayerAbilities abilities = sender.getAbilities();
|
||||||
sender.abilities.allowFlying = !flight;
|
boolean flight = abilities.allowFlying;
|
||||||
|
abilities.allowFlying = !flight;
|
||||||
if (!flight)
|
if (!flight)
|
||||||
source.sendFeedback(new LiteralText("I wanna fly like an eagle... to the sea!"), true);
|
source.sendFeedback(() -> Text.of("I wanna fly like an eagle... to the sea!"), true);
|
||||||
else {
|
else {
|
||||||
source.sendFeedback(new LiteralText("Flight disabled"), true);
|
source.sendFeedback(() -> Text.of("Flight disabled"), true);
|
||||||
sender.abilities.flying = false;
|
abilities.flying = false;
|
||||||
}
|
}
|
||||||
sender.sendAbilitiesUpdate();
|
sender.sendAbilitiesUpdate();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class HatCommand {
|
public class HatCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
@ -17,7 +17,7 @@ public class HatCommand {
|
|||||||
ItemStack head = sender.getEquippedStack(EquipmentSlot.HEAD);
|
ItemStack head = sender.getEquippedStack(EquipmentSlot.HEAD);
|
||||||
sender.equipStack(EquipmentSlot.MAINHAND, head);
|
sender.equipStack(EquipmentSlot.MAINHAND, head);
|
||||||
sender.equipStack(EquipmentSlot.HEAD, mainhand);
|
sender.equipStack(EquipmentSlot.HEAD, mainhand);
|
||||||
source.sendFeedback(new LiteralText("Swapped items between main hand and head"), false);
|
source.sendFeedback(() -> Text.of("Swapped items between main hand and head"), false);
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ import net.minecraft.block.Blocks;
|
|||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
public class HeadCommand {
|
public class HeadCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
@ -23,13 +23,13 @@ public class HeadCommand {
|
|||||||
|
|
||||||
private static int giveHead(ServerCommandSource source, ServerPlayerEntity sender, String skullowner) {
|
private static int giveHead(ServerCommandSource source, ServerPlayerEntity sender, String skullowner) {
|
||||||
ItemStack itemstack = new ItemStack(Blocks.PLAYER_HEAD.asItem());
|
ItemStack itemstack = new ItemStack(Blocks.PLAYER_HEAD.asItem());
|
||||||
CompoundTag compoundtag = new CompoundTag();
|
NbtCompound nbt = new NbtCompound();
|
||||||
compoundtag.putString("SkullOwner", skullowner);
|
nbt.putString("SkullOwner", skullowner);
|
||||||
itemstack.setTag(compoundtag);
|
itemstack.setNbt(nbt);
|
||||||
ItemEntity itementity = sender.dropItem(itemstack, false);
|
ItemEntity itementity = sender.dropItem(itemstack, false);
|
||||||
itementity.resetPickupDelay();
|
itementity.resetPickupDelay();
|
||||||
itementity.setOwner(sender.getUuid());
|
itementity.setOwner(sender.getUuid());
|
||||||
source.sendFeedback(new LiteralText("Player head has been given"), false);
|
source.sendFeedback(() -> Text.of("Player head has been given"), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,63 +3,64 @@ package party._2a03.mc.command;
|
|||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import party._2a03.mc.util.Database;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.PlayerData;
|
||||||
import party._2a03.mc.server.PlayerData;
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
import party._2a03.mc.server.PlayerPosition;
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class HomeCommand {
|
public class HomeCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("home").executes(ctx -> {
|
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("home").executes(ctx -> {
|
||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
PlayerPosition position = Config.getPlayer(sender.getUuid().toString()).getHome();
|
PlayerPosition position = Database.getPlayer(sender.getUuid().toString()).getHome();
|
||||||
if (position.registrykey == null) {
|
if (position.registrykey == null) {
|
||||||
source.sendFeedback(new LiteralText("Home not found, do /home set"), false);
|
source.sendFeedback(() -> Text.of("Home not found, do /home set"), false);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch);
|
sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch);
|
||||||
source.sendFeedback(new LiteralText("Teleported to home"), true);
|
source.sendFeedback(() -> Text.of("Teleported to home"), true);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
literalargumentbuilder.then(CommandManager.literal("set").executes(ctx -> {
|
literalargumentbuilder.then(CommandManager.literal("set").executes(ctx -> {
|
||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
PlayerData playerdata = Config.getPlayer(sender.getUuid().toString());
|
PlayerData playerdata = Database.getPlayer(sender.getUuid().toString());
|
||||||
double x = sender.getX();
|
double x = sender.getX();
|
||||||
double y = sender.getY();
|
double y = sender.getY();
|
||||||
double z = sender.getZ();
|
double z = sender.getZ();
|
||||||
float yaw = sender.yaw;
|
float yaw = sender.getYaw();
|
||||||
float pitch = sender.pitch;
|
float pitch = sender.getPitch();
|
||||||
RegistryKey registrykey = sender.getServerWorld().getRegistryKey();
|
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
||||||
playerdata.setHome(location);
|
playerdata.setHome(location);
|
||||||
Config.setPlayer(playerdata);
|
source.sendFeedback(() -> Text.of("Your home has been updated"), true);
|
||||||
source.sendFeedback(new LiteralText("Your home has been updated"), true);
|
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
literalargumentbuilder.then(CommandManager.literal("sudoset").requires(ctx -> {
|
literalargumentbuilder.then(CommandManager.literal("assign").requires(ctx -> {
|
||||||
return ctx.hasPermissionLevel(2);
|
return ctx.hasPermissionLevel(2);
|
||||||
}).then(CommandManager.argument("UUID", StringArgumentType.word()).executes(ctx -> {
|
}).then(CommandManager.argument("UUID", StringArgumentType.word()).executes(ctx -> {
|
||||||
|
UUID uuid = UUID.fromString(StringArgumentType.getString(ctx, "UUID"));
|
||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
PlayerData playerdata = Config.getPlayer(StringArgumentType.getString(ctx, "UUID"));
|
PlayerData playerdata = Database.getPlayer(uuid);
|
||||||
double x = sender.getX();
|
double x = sender.getX();
|
||||||
double y = sender.getY();
|
double y = sender.getY();
|
||||||
double z = sender.getZ();
|
double z = sender.getZ();
|
||||||
float yaw = sender.yaw;
|
float yaw = sender.getYaw();
|
||||||
float pitch = sender.pitch;
|
float pitch = sender.getPitch();
|
||||||
RegistryKey registrykey = sender.getServerWorld().getRegistryKey();
|
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
||||||
playerdata.setHome(location);
|
playerdata.setHome(location);
|
||||||
Config.setPlayer(playerdata);
|
source.sendFeedback(() -> Text.of("User's home has been updated (" + uuid.toString() + ")"), true);
|
||||||
source.sendFeedback(new LiteralText("User's home has been updated (" + StringArgumentType.getString(ctx, "UUID") + ")"), true);
|
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
32
src/main/java/party/_2a03/mc/command/NameCommand.java
Normal file
32
src/main/java/party/_2a03/mc/command/NameCommand.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package party._2a03.mc.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
import party._2a03.mc.util.PlayerData;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class NameCommand {
|
||||||
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(CommandManager.literal("name")
|
||||||
|
.then(CommandManager.literal("assign")
|
||||||
|
.requires(ctx -> { return ctx.hasPermissionLevel(2); })
|
||||||
|
.then(CommandManager.argument("UUID", StringArgumentType.word())
|
||||||
|
.then(CommandManager.argument("name", StringArgumentType.word())
|
||||||
|
.executes(ctx -> {
|
||||||
|
UUID uuid = UUID.fromString(StringArgumentType.getString(ctx, "UUID"));
|
||||||
|
ServerCommandSource source = ctx.getSource();
|
||||||
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
|
PlayerData playerdata = Database.getPlayer(uuid);
|
||||||
|
playerdata.setName(StringArgumentType.getString(ctx, "name"));
|
||||||
|
source.sendFeedback(() -> Text.of("User's name has been updated (" + uuid.toString() + ")"), true);
|
||||||
|
return 1;
|
||||||
|
})))));
|
||||||
|
}
|
||||||
|
}
|
52
src/main/java/party/_2a03/mc/command/SkinCommand.java
Normal file
52
src/main/java/party/_2a03/mc/command/SkinCommand.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package party._2a03.mc.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class SkinCommand {
|
||||||
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
LiteralArgumentBuilder literalargumentbuilder = CommandManager.literal("skin");
|
||||||
|
|
||||||
|
literalargumentbuilder.then(CommandManager.literal("assign")
|
||||||
|
.requires(ctx -> { return ctx.hasPermissionLevel(2); })
|
||||||
|
.then(CommandManager.argument("UUID", StringArgumentType.word())
|
||||||
|
.then(CommandManager.argument("url", StringArgumentType.greedyString())
|
||||||
|
.executes(ctx -> {
|
||||||
|
ServerCommandSource source = ctx.getSource();
|
||||||
|
String magic, skinval, skinsig;
|
||||||
|
try {
|
||||||
|
URL url = new URL(StringArgumentType.getString(ctx, "url"));
|
||||||
|
BufferedReader read = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||||
|
magic = read.readLine();
|
||||||
|
skinval = read.readLine();
|
||||||
|
skinsig = read.readLine();
|
||||||
|
read.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
source.sendFeedback(() -> Text.of("Failed to access skin"), false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!magic.equals("SKIN:1") || skinval == null || skinsig == null) {
|
||||||
|
source.sendFeedback(() -> Text.of("Invalid skin"), false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
UUID uuid = UUID.fromString(StringArgumentType.getString(ctx, "UUID"));
|
||||||
|
Database.getPlayer(uuid).setTextures(skinval, skinsig);
|
||||||
|
source.sendFeedback(() -> Text.of("User's skin has been updated (" + uuid.toString() + ")"), true);
|
||||||
|
return 1;
|
||||||
|
}))));
|
||||||
|
|
||||||
|
dispatcher.register(literalargumentbuilder);
|
||||||
|
}
|
||||||
|
}
|
@ -2,13 +2,13 @@ package party._2a03.mc.command;
|
|||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import party._2a03.mc.util.Config;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
import party._2a03.mc.server.PlayerPosition;
|
|
||||||
|
|
||||||
public class SpawnCommand {
|
public class SpawnCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
@ -18,14 +18,14 @@ public class SpawnCommand {
|
|||||||
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
||||||
if (position.registrykey == null) {
|
if (position.registrykey == null) {
|
||||||
if (source.hasPermissionLevel(2)) {
|
if (source.hasPermissionLevel(2)) {
|
||||||
source.sendFeedback(new LiteralText("Spawn not found, do /spawn set"), false);
|
source.sendFeedback(() -> Text.of("Spawn not found, do /spawn set"), false);
|
||||||
} else {
|
} else {
|
||||||
source.sendFeedback(new LiteralText("Spawn not found, ask an admin to set it"), false);
|
source.sendFeedback(() -> Text.of("Spawn not found, ask an admin to set it"), false);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch);
|
sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch);
|
||||||
source.sendFeedback(new LiteralText("Teleported to the spawn point"), true);
|
source.sendFeedback(() -> Text.of("Teleported to the spawn point"), true);
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,12 +37,12 @@ public class SpawnCommand {
|
|||||||
double x = sender.getX();
|
double x = sender.getX();
|
||||||
double y = sender.getY();
|
double y = sender.getY();
|
||||||
double z = sender.getZ();
|
double z = sender.getZ();
|
||||||
float yaw = sender.yaw;
|
float yaw = sender.getYaw();
|
||||||
float pitch = sender.pitch;
|
float pitch = sender.getPitch();
|
||||||
RegistryKey registrykey = sender.getServerWorld().getRegistryKey();
|
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
||||||
Config.setData("spawn", location.getJSON());
|
Config.setData("spawn", location.getJSON());
|
||||||
source.sendFeedback(new LiteralText("Spawn has been set"), true);
|
source.sendFeedback(() -> Text.of("Spawn has been set"), true);
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
102
src/main/java/party/_2a03/mc/command/TpaCommand.java
Normal file
102
src/main/java/party/_2a03/mc/command/TpaCommand.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package party._2a03.mc.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import net.minecraft.command.argument.EntityArgumentType;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class TpaCommand {
|
||||||
|
private static class TpaRequest {
|
||||||
|
private UUID requester;
|
||||||
|
private UUID accepter;
|
||||||
|
|
||||||
|
public TpaRequest(UUID requester, UUID accepter) {
|
||||||
|
this.requester = requester;
|
||||||
|
this.accepter = accepter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return requester.toString()+"->"+accepter.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return (requester.hashCode() << 1) ^ (accepter.hashCode() >> 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Hashtable<Integer, Long> requests = new Hashtable<>();
|
||||||
|
|
||||||
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(CommandManager.literal("tpa")
|
||||||
|
.then(CommandManager.argument("target", EntityArgumentType.player())
|
||||||
|
.executes(TpaCommand::executeRequest)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
dispatcher.register(CommandManager.literal("tpaccept")
|
||||||
|
.then(CommandManager.argument("target", EntityArgumentType.player())
|
||||||
|
.executes(TpaCommand::executeAccept)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int executeRequest(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
||||||
|
ServerCommandSource source = ctx.getSource();
|
||||||
|
ServerPlayerEntity source_player = source.getPlayer();
|
||||||
|
ServerPlayerEntity target_player = EntityArgumentType.getPlayer(ctx, "target");
|
||||||
|
final String source_name = source_player.getEntityName();
|
||||||
|
final String target_name = target_player.getEntityName();
|
||||||
|
|
||||||
|
if (source_player.getUuid() == target_player.getUuid()) {
|
||||||
|
source.sendFeedback(() -> Text.of("Teleported "+source_name+" to "+target_name), false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TpaRequest req = new TpaRequest(source_player.getUuid(), target_player.getUuid());
|
||||||
|
requests.put(req.hashCode(), System.currentTimeMillis());
|
||||||
|
|
||||||
|
source.sendFeedback(() -> Text.of("Requested to teleport to "+target_name), false);
|
||||||
|
target_player.sendMessage(Text.of(source_name+" requested to teleport to you"));
|
||||||
|
target_player.sendMessage(Text.of("Type /tpaccept "+source_name+" within 30 seconds to accept it"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int executeAccept(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
||||||
|
ServerCommandSource source = ctx.getSource();
|
||||||
|
ServerPlayerEntity source_player = source.getPlayer();
|
||||||
|
ServerPlayerEntity target_player = EntityArgumentType.getPlayer(ctx, "target");
|
||||||
|
final String source_name = source_player.getEntityName();
|
||||||
|
final String target_name = target_player.getEntityName();
|
||||||
|
|
||||||
|
TpaRequest req = new TpaRequest(target_player.getUuid(), source_player.getUuid());
|
||||||
|
Long req_time = requests.get(req.hashCode());
|
||||||
|
|
||||||
|
if (req_time == null) {
|
||||||
|
source.sendFeedback(() -> Text.of(target_name+" has not requested to teleport to you"), false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - req_time.longValue() > 30e3) {
|
||||||
|
requests.remove(req.hashCode());
|
||||||
|
source.sendFeedback(() -> Text.of(target_name+"'s teleport request has expired"), false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (source_player.getAbilities().flying && !target_player.getAbilities().flying) {
|
||||||
|
source.sendFeedback(() -> Text.of("Stop flying, dumbass! You'll kill them!"), false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
requests.remove(req.hashCode());
|
||||||
|
target_player.teleport(source_player.getServerWorld(), source_player.getX(), source_player.getY(), source_player.getZ(), source_player.getYaw(), source_player.getPitch());
|
||||||
|
source.sendFeedback(() -> Text.of("Teleported "+target_name+" to "+source_name), false);
|
||||||
|
target_player.sendMessage(Text.of(target_name+" has accepted your teleport request"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
29
src/main/java/party/_2a03/mc/mixin/MixinCreeperEntity.java
Normal file
29
src/main/java/party/_2a03/mc/mixin/MixinCreeperEntity.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.mob.CreeperEntity;
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.explosion.Explosion;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
|
@Mixin(CreeperEntity.class)
|
||||||
|
public abstract class MixinCreeperEntity extends HostileEntity {
|
||||||
|
public MixinCreeperEntity(EntityType<? extends CreeperEntity> entityType, World world) {
|
||||||
|
super((EntityType<? extends HostileEntity>)entityType, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "explode()V", at = @At(value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/world/World;createExplosion(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/world/World$ExplosionSourceType;)Lnet/minecraft/world/explosion/Explosion;"))
|
||||||
|
private Explosion OnCreeperExplode(World self, Entity entity,
|
||||||
|
double x, double y, double z, float r,
|
||||||
|
World.ExplosionSourceType explosionSourceType) {
|
||||||
|
if (Config.getBool("disableCreeperExplosions"))
|
||||||
|
explosionSourceType = World.ExplosionSourceType.NONE;
|
||||||
|
return self.createExplosion(entity, x, y, z, r, explosionSourceType);
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,23 @@
|
|||||||
package party._2a03.mc.mixin;
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.command.GameModeCommand;
|
import net.minecraft.server.command.GameModeCommand;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.world.GameMode;
|
import net.minecraft.world.GameMode;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(GameModeCommand.class)
|
@Mixin(GameModeCommand.class)
|
||||||
public class MixinGameModeCommand {
|
public class MixinGameModeCommand {
|
||||||
@Inject(method = "setGameMode", at = @At("HEAD"))
|
@Inject(method = "execute", at = @At("HEAD"))
|
||||||
private static void OnSetGameMode(ServerCommandSource source, ServerPlayerEntity player, GameMode gameMode, CallbackInfo ci) {
|
private static void OnExecute(CommandContext<ServerCommandSource> context, Collection<ServerPlayerEntity> targets, GameMode gameMode, CallbackInfoReturnable cir) {
|
||||||
if (gameMode == GameMode.CREATIVE) {
|
if (gameMode == GameMode.CREATIVE) {
|
||||||
source.sendFeedback(new LiteralText("<Server> Creative mode? What are you, a cheater?"), false);
|
context.getSource().sendFeedback(() -> Text.of("<Server> Creative mode? What are you, a cheater?"), false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
36
src/main/java/party/_2a03/mc/mixin/MixinGameProfile.java
Normal file
36
src/main/java/party/_2a03/mc/mixin/MixinGameProfile.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
import party._2a03.mc.util.PlayerData;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Mixin(value = GameProfile.class, remap = false)
|
||||||
|
public class MixinGameProfile {
|
||||||
|
int ready = 0;
|
||||||
|
String server_name = "";
|
||||||
|
|
||||||
|
@Inject(method = "getName", at = @At("RETURN"), cancellable = true)
|
||||||
|
public void replaceName(CallbackInfoReturnable<String> ci) {
|
||||||
|
if (ready++ < 2) // wait until authenticated
|
||||||
|
return;
|
||||||
|
UUID uuid = ((GameProfile)(Object)this).getId();
|
||||||
|
if (uuid == null) // wait until UUID is set
|
||||||
|
return;
|
||||||
|
if (!Config.getBool("overrideNames"))
|
||||||
|
return;
|
||||||
|
if (this.server_name == "") {
|
||||||
|
PlayerData playerdata = Database.getPlayer(uuid.toString());
|
||||||
|
this.server_name = playerdata.getName();
|
||||||
|
}
|
||||||
|
ci.setReturnValue(this.server_name);
|
||||||
|
}
|
||||||
|
}
|
45
src/main/java/party/_2a03/mc/mixin/MixinPlayerManager.java
Normal file
45
src/main/java/party/_2a03/mc/mixin/MixinPlayerManager.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
|
import net.minecraft.entity.player.PlayerAbilities;
|
||||||
|
import net.minecraft.server.PlayerManager;
|
||||||
|
import net.minecraft.network.ClientConnection;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.world.GameMode;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
import party._2a03.mc.util.PlayerData;
|
||||||
|
|
||||||
|
@Mixin(PlayerManager.class)
|
||||||
|
public abstract class MixinPlayerManager {
|
||||||
|
@Inject(method = "onPlayerConnect", at = @At(value = "HEAD"))
|
||||||
|
void onConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
||||||
|
if (!Config.getBool("overrideSkins"))
|
||||||
|
return;
|
||||||
|
PlayerData playerdata = Database.getPlayer(player.getGameProfile().getId());
|
||||||
|
PropertyMap map = player.getGameProfile().getProperties();
|
||||||
|
map.removeAll("textures");
|
||||||
|
map.put("textures", playerdata.getTextures());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "onPlayerConnect", at = @At(value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/server/network/ServerPlayerEntity;getAbilities()Lnet/minecraft/entity/player/PlayerAbilities;"))
|
||||||
|
public void persistFlight(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
||||||
|
if (!Config.getBool("persistentFlight"))
|
||||||
|
return;
|
||||||
|
if (player.isOnGround())
|
||||||
|
return;
|
||||||
|
GameMode gameMode = player.interactionManager.getGameMode();
|
||||||
|
if (gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR)
|
||||||
|
return;
|
||||||
|
PlayerAbilities abilities = player.getAbilities();
|
||||||
|
abilities.allowFlying = true;
|
||||||
|
abilities.flying = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.RespawnAnchorBlock;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.state.property.IntProperty;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
|
@Mixin(RespawnAnchorBlock.class)
|
||||||
|
public abstract class MixinRespawnAnchorBlock extends Block {
|
||||||
|
@Shadow
|
||||||
|
public static final IntProperty CHARGES = Properties.CHARGES;
|
||||||
|
|
||||||
|
public MixinRespawnAnchorBlock(Block.Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
this.setDefaultState((BlockState)this.stateManager.getDefaultState().with(CHARGES, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void onExplode(CallbackInfo ci) {
|
||||||
|
if (Config.getBool("disableRespawnAnchorExplosions") == true)
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,18 @@
|
|||||||
package party._2a03.mc.mixin;
|
package party._2a03.mc.mixin;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.Config;
|
||||||
import party._2a03.mc.server.PlayerPosition;
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
|
|
||||||
@Mixin(ServerPlayerEntity.class)
|
@Mixin(ServerPlayerEntity.class)
|
||||||
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
||||||
@ -18,7 +20,7 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
|||||||
private RegistryKey<World> spawnPointDimension;
|
private RegistryKey<World> spawnPointDimension;
|
||||||
|
|
||||||
public MixinServerPlayerEntity() {
|
public MixinServerPlayerEntity() {
|
||||||
super(null, null, null);
|
super(null, null, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true)
|
||||||
|
@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
@Mixin(TntBlock.class)
|
@Mixin(TntBlock.class)
|
||||||
public abstract class MixinTntBlock extends Block {
|
public abstract class MixinTntBlock extends Block {
|
||||||
|
@ -9,17 +9,13 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import party._2a03.mc.server.Config;
|
import party._2a03.mc.util.Config;
|
||||||
|
|
||||||
@Mixin(TntEntity.class)
|
@Mixin(TntEntity.class)
|
||||||
public abstract class MixinTntEntity extends Entity {
|
public abstract class MixinTntEntity extends Entity {
|
||||||
@Shadow
|
|
||||||
private int fuseTimer;
|
|
||||||
|
|
||||||
public MixinTntEntity(EntityType<? extends TntEntity> entityType, World world) {
|
public MixinTntEntity(EntityType<? extends TntEntity> entityType, World world) {
|
||||||
super(entityType, world);
|
super(entityType, world);
|
||||||
this.fuseTimer = 80;
|
this.intersectionChecked = true;
|
||||||
this.inanimate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
package party._2a03.mc.server;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import party._2a03.mc.server.PlayerPosition;
|
|
||||||
|
|
||||||
public class PlayerData {
|
|
||||||
private String uuid;
|
|
||||||
private PlayerPosition home;
|
|
||||||
|
|
||||||
public PlayerData(String p_uuid, PlayerPosition p_home) {
|
|
||||||
this.uuid = p_uuid;
|
|
||||||
this.home = p_home;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerPosition getHome() {
|
|
||||||
return this.home;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUUID() {
|
|
||||||
return this.uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHome(PlayerPosition location) {
|
|
||||||
this.home = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject getJSON() {
|
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
json.put("uuid", uuid);
|
|
||||||
json.put("home", home.getJSON());
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package party._2a03.mc.server;
|
package party._2a03.mc.util;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -13,8 +13,8 @@ import org.apache.commons.io.IOUtils;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import party._2a03.mc.MinecraftTweaks2a03;
|
import party._2a03.mc.MinecraftTweaks2a03;
|
||||||
import party._2a03.mc.server.PlayerData;
|
import party._2a03.mc.util.PlayerData;
|
||||||
import party._2a03.mc.server.PlayerPosition;
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
@ -32,45 +32,21 @@ public class Config {
|
|||||||
String jsonRaw = IOUtils.toString(is, "UTF-8");
|
String jsonRaw = IOUtils.toString(is, "UTF-8");
|
||||||
json = new JSONObject(jsonRaw);
|
json = new JSONObject(jsonRaw);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("Config not found, creating one");
|
json = new JSONObject();
|
||||||
json = new JSONObject("{\"disableTntExplosions\":false,\"spawn\":[0,0,0,0,0,\"\"],\"members\":[]}");
|
|
||||||
saveConfig();
|
|
||||||
}
|
}
|
||||||
LOGGER.info("Configuration loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerData getPlayer(String uuid) {
|
setDefault("overrideNames", false);
|
||||||
JSONArray members = json.getJSONArray("members");
|
setDefault("overrideSkins", false);
|
||||||
PlayerPosition home = null;
|
setDefault("persistentFlight", false);
|
||||||
for (int i = 0; i < members.length(); ++i) {
|
setDefault("disableFlyCommand", true);
|
||||||
JSONObject item = members.getJSONObject(i);
|
setDefault("disableTntExplosions", false);
|
||||||
String item_uuid = item.getString("uuid");
|
setDefault("disableCreeperExplosions", false);
|
||||||
if (item_uuid.equals(uuid)) {
|
setDefault("disableRespawnAnchorExplosions", false);
|
||||||
home = new PlayerPosition(item.getJSONArray("home"));
|
setDefault("iphubApiKey", "");
|
||||||
}
|
setDefault("spawn", (new PlayerPosition()).getJSON());
|
||||||
}
|
|
||||||
if (home == null) {
|
|
||||||
home = new PlayerPosition();
|
|
||||||
}
|
|
||||||
return new PlayerData(uuid, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPlayer(PlayerData player) {
|
|
||||||
JSONArray members = json.getJSONArray("members");
|
|
||||||
int playerIndex = -1;
|
|
||||||
for (int i = 0; i < members.length(); ++i) {
|
|
||||||
JSONObject item = members.getJSONObject(i);
|
|
||||||
String item_uuid = item.getString("uuid");
|
|
||||||
if (item_uuid.equals(player.getUUID())) {
|
|
||||||
playerIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (playerIndex >= 0) {
|
|
||||||
members.remove(playerIndex);
|
|
||||||
}
|
|
||||||
members.put(player.getJSON());
|
|
||||||
json.put("members", members);
|
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
|
LOGGER.info("Configuration loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JSONArray getData(String key) {
|
public static JSONArray getData(String key) {
|
||||||
@ -86,9 +62,14 @@ public class Config {
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDefault(String key, Object data) {
|
||||||
|
if (!json.has(key))
|
||||||
|
json.put(key, data);
|
||||||
|
}
|
||||||
|
|
||||||
private static void saveConfig() {
|
private static void saveConfig() {
|
||||||
try (FileWriter file = new FileWriter(config)) {
|
try (FileWriter file = new FileWriter(config)) {
|
||||||
file.write(JSONObject.valueToString(json));
|
file.write(json.toString(2));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Failed to save config file");
|
LOGGER.error("Failed to save config file");
|
||||||
}
|
}
|
163
src/main/java/party/_2a03/mc/util/Database.java
Normal file
163
src/main/java/party/_2a03/mc/util/Database.java
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
package party._2a03.mc.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import party._2a03.mc.util.PlayerData;
|
||||||
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Database {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static Connection conn = null;
|
||||||
|
private static File file;
|
||||||
|
|
||||||
|
public static void init(File configDir) {
|
||||||
|
file = new File(configDir, "2a03.db");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void open() throws Exception {
|
||||||
|
LOGGER.info("Loading 2a03.party database");
|
||||||
|
String url = "jdbc:sqlite:";
|
||||||
|
url = url.concat(file.getPath());
|
||||||
|
conn = DriverManager.getConnection(url);
|
||||||
|
try {
|
||||||
|
Statement stmt;
|
||||||
|
stmt = conn.createStatement();
|
||||||
|
stmt.executeUpdate(
|
||||||
|
"CREATE TABLE IF NOT EXISTS players (" +
|
||||||
|
"uuid TEXT NOT NULL UNIQUE," +
|
||||||
|
"name TEXT," +
|
||||||
|
"skinval TEXT," +
|
||||||
|
"skinsig TEXT," +
|
||||||
|
"home TEXT," +
|
||||||
|
"asn INTEGER," +
|
||||||
|
"PRIMARY KEY(uuid)" +
|
||||||
|
");");
|
||||||
|
stmt.executeUpdate(
|
||||||
|
"CREATE TABLE IF NOT EXISTS claims (" +
|
||||||
|
"id TEXT NOT NULL UNIQUE," +
|
||||||
|
"owner TEXT NOT NULL," +
|
||||||
|
"members TEXT NOT NULL," +
|
||||||
|
"rules TEXT NOT NULL," +
|
||||||
|
"PRIMARY KEY(id)" +
|
||||||
|
");");
|
||||||
|
stmt.executeUpdate(
|
||||||
|
"CREATE TABLE IF NOT EXISTS areas (" +
|
||||||
|
"chunk_x INTEGER NOT NULL," +
|
||||||
|
"chunk_z INTEGER NOT NULL," +
|
||||||
|
"min_x INTEGER NOT NULL," +
|
||||||
|
"min_z INTEGER NOT NULL," +
|
||||||
|
"max_x INTEGER NOT NULL," +
|
||||||
|
"max_z INTEGER NOT NULL," +
|
||||||
|
"claim TEXT NOT NULL" +
|
||||||
|
");");
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
LOGGER.info("Database loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void close() {
|
||||||
|
LOGGER.info("Unloading 2a03.party database");
|
||||||
|
try {
|
||||||
|
if (conn != null)
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerData getPlayer(UUID uuid) {
|
||||||
|
return getPlayer(uuid.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerData getPlayer(String uuid) {
|
||||||
|
try {
|
||||||
|
PreparedStatement pstmt;
|
||||||
|
pstmt = conn.prepareStatement(
|
||||||
|
"SELECT home, name, skinval, skinsig FROM players WHERE uuid = ?;");
|
||||||
|
pstmt.setString(1, uuid);
|
||||||
|
ResultSet res = pstmt.executeQuery();
|
||||||
|
if (res.next()) {
|
||||||
|
String homeData = res.getString("home");
|
||||||
|
PlayerPosition home = new PlayerPosition();
|
||||||
|
if (homeData != "" && homeData != null)
|
||||||
|
home = new PlayerPosition(new JSONArray(homeData));
|
||||||
|
String name = res.getString("name");
|
||||||
|
String skinval = res.getString("skinval");
|
||||||
|
String skinsig = res.getString("skinsig");
|
||||||
|
return new PlayerData(uuid, home, name, skinval, skinsig);
|
||||||
|
}
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return new PlayerData(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPlayerTextures(String uuid, String skinval, String skinsig) {
|
||||||
|
try {
|
||||||
|
PreparedStatement pstmt;
|
||||||
|
pstmt = conn.prepareStatement(
|
||||||
|
"INSERT INTO players (uuid, skinval, skinsig) " +
|
||||||
|
"VALUES(?, ?, ?) " +
|
||||||
|
"ON CONFLICT(uuid) " +
|
||||||
|
"DO UPDATE SET skinval=?, skinsig=?;");
|
||||||
|
pstmt.setString(1, uuid);
|
||||||
|
pstmt.setString(2, skinval);
|
||||||
|
pstmt.setString(3, skinsig);
|
||||||
|
pstmt.setString(4, skinval);
|
||||||
|
pstmt.setString(5, skinsig);
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPlayerName(String uuid, String name) {
|
||||||
|
try {
|
||||||
|
PreparedStatement pstmt;
|
||||||
|
pstmt = conn.prepareStatement(
|
||||||
|
"INSERT INTO players (uuid, name) " +
|
||||||
|
"VALUES(?, ?) " +
|
||||||
|
"ON CONFLICT(uuid) " +
|
||||||
|
"DO UPDATE SET name=?;");
|
||||||
|
pstmt.setString(1, uuid);
|
||||||
|
pstmt.setString(2, name);
|
||||||
|
pstmt.setString(3, name);
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPlayerHome(String uuid, PlayerPosition home) {
|
||||||
|
try {
|
||||||
|
PreparedStatement pstmt;
|
||||||
|
pstmt = conn.prepareStatement(
|
||||||
|
"INSERT INTO players (uuid, home) " +
|
||||||
|
"VALUES(?, ?) " +
|
||||||
|
"ON CONFLICT(uuid) " +
|
||||||
|
"DO UPDATE SET home=?;");
|
||||||
|
pstmt.setString(1, uuid);
|
||||||
|
pstmt.setString(2, home.getJSON().toString());
|
||||||
|
pstmt.setString(3, home.getJSON().toString());
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
pstmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
LOGGER.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
72
src/main/java/party/_2a03/mc/util/PlayerData.java
Normal file
72
src/main/java/party/_2a03/mc/util/PlayerData.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package party._2a03.mc.util;
|
||||||
|
|
||||||
|
import com.mojang.authlib.properties.Property;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import party._2a03.mc.util.Database;
|
||||||
|
import party._2a03.mc.util.PlayerPosition;
|
||||||
|
|
||||||
|
public class PlayerData {
|
||||||
|
private String uuid;
|
||||||
|
private PlayerPosition home;
|
||||||
|
private String name;
|
||||||
|
private String skinval;
|
||||||
|
private String skinsig;
|
||||||
|
|
||||||
|
public PlayerData(String p_uuid) {
|
||||||
|
this.uuid = p_uuid;
|
||||||
|
this.home = new PlayerPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerData(String p_uuid, PlayerPosition p_home, String p_name, String p_skinval, String p_skinsig) {
|
||||||
|
this.uuid = p_uuid;
|
||||||
|
this.home = p_home;
|
||||||
|
this.name = p_name;
|
||||||
|
this.skinval = p_skinval;
|
||||||
|
this.skinsig = p_skinsig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Property getTextures() {
|
||||||
|
// Return a Steve texture if unset
|
||||||
|
if (this.skinval == null || this.skinsig == null || this.skinval.length() == 0 || this.skinsig.length() == 0)
|
||||||
|
return new Property("textures", "ewogICJ0aW1lc3RhbXAiIDogMTY2NjMwMjkxNzkzOCwKICAicHJvZmlsZUlkIiA6ICJjOWRlZTM4MDUzYjg0YzI5YjZlZjA5YjJlMDM5OTc0ZiIsCiAgInByb2ZpbGVOYW1lIiA6ICJTQVJfRGVjZW1iZXI1IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzMxZjQ3N2ViMWE3YmVlZTYzMWMyY2E2NGQwNmY4ZjY4ZmE5M2EzMzg2ZDA0NDUyYWIyN2Y0M2FjZGYxYjYwY2IiCiAgICB9CiAgfQp9", "tTCtASRIyuzlNUgSoXgUr6arxABhCR4EQ9+eHaUoO8bADljmUFoQfb6oba8zqe2gIa2mnu5KQaOPQCxcTDjgNv9aIL2smINKxy/60VE4Mgnrh5ntH+mGuDi00V3Bk2CsObFZXz1vgk2UxdQUQ41eVQYm2xBrXFEbXMSoTafWGv0FMTPFpGxGRdduTe3QTEie3GcfAMHCn/9xMMmUxZZ6UVZ+mDe8ARt9/cmK+GmqT8m3kmrz/vq+i29KV4tWvJqsKIVAXm97jVPH9XxVR3tYlheimQSFNrCU8SzNPum/ZhxNAf5Uw90+/K0eaJE59y8tS7KDV5DHrRrHHXb/ywGGklSri1YjFm9AEBk6BeH8Y3Ot/e+zfQbF3rOny2DkBAm/v28FooYd25gXB4MjUFNPj3KdveQh7DpRAvnkmBZMqJCO+Z9fdY4Dw+jmqjII88r6mukWAODvXed/x8bvv55zzNOAxtqtwBTWHIdqWFr/7pMZF26RY1Tluw+pAWGWaKMHtqlGzyOLGMxMKwXqtLNEpIYw52ETwGKaWh8h34cOoI8dhpjfjym4UOihMmazK9LC0EUEHuBlgy5b/Ae71+6UsLNIX8bJwIvN16sP6wpSTNbV6htWoS7/ehvoxdKhI6XEUqWgEoAwmquClPfWiveCV057reoKeVHB9RdTl0sW+HM=");
|
||||||
|
// Otherwise...
|
||||||
|
return new Property("textures", this.skinval, this.skinsig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return (this.name == null || this.name.length() == 0) ? "Unknown" : this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerPosition getHome() {
|
||||||
|
return this.home;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUUID() {
|
||||||
|
return this.uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextures(String skinval, String skinsig) {
|
||||||
|
this.skinval = skinval;
|
||||||
|
this.skinsig = skinsig;
|
||||||
|
Database.setPlayerTextures(this.uuid, this.skinval, this.skinsig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
Database.setPlayerName(this.uuid, this.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHome(PlayerPosition location) {
|
||||||
|
this.home = location;
|
||||||
|
Database.setPlayerHome(this.uuid, this.home);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getJSON() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("uuid", uuid);
|
||||||
|
json.put("home", home.getJSON());
|
||||||
|
json.put("name", name);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
package party._2a03.mc.server;
|
package party._2a03.mc.util;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.util.registry.RegistryKey;
|
|
||||||
import party._2a03.mc.server.Config;
|
|
||||||
|
|
||||||
public class PlayerPosition {
|
public class PlayerPosition {
|
||||||
public double x;
|
public double x;
|
||||||
@ -25,7 +25,7 @@ public class PlayerPosition {
|
|||||||
this.z = data.getDouble(2);
|
this.z = data.getDouble(2);
|
||||||
this.yaw = data.getNumber(3).floatValue();
|
this.yaw = data.getNumber(3).floatValue();
|
||||||
this.pitch = data.getNumber(4).floatValue();
|
this.pitch = data.getNumber(4).floatValue();
|
||||||
this.registrykey = RegistryKey.of(Registry.DIMENSION, new Identifier(registry_string));
|
this.registrykey = RegistryKey.of(RegistryKeys.DIMENSION, new Identifier(registry_string));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "minecraft-tweaks-2a03",
|
"id": "minecraft-tweaks-2a03",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"name": "2a03.party Tweaks",
|
"name": "minecraft-tweaks-2a03",
|
||||||
"description": "Simple modifications for the 2a03.party Minecraft server.",
|
"description": "Simple modifications for mc.2a03.party.",
|
||||||
"authors": [
|
"authors": [
|
||||||
"flewkey"
|
"flewkey"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://flewkey.com/",
|
"homepage": "https://flewkey.com/",
|
||||||
"sources": "https://github.com/flewkey/minecraft-tweaks-2a03"
|
"sources": "https://git.sdf.org/flewkey/minecraft-tweaks-2a03"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/2a03-minecraft-tweaks/icon.png",
|
"icon": "assets/minecraft-tweaks-2a03/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
@ -23,8 +23,9 @@
|
|||||||
"minecraft-tweaks-2a03.mixins.json"
|
"minecraft-tweaks-2a03.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.8.2",
|
"fabricloader": ">=0.14.21",
|
||||||
"fabric": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": "1.16.x"
|
"minecraft": "~1.20",
|
||||||
|
"java": ">=17"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "party._2a03.mc.mixin",
|
"package": "party._2a03.mc.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"server": [
|
"server": [
|
||||||
|
"MixinCreeperEntity",
|
||||||
"MixinGameModeCommand",
|
"MixinGameModeCommand",
|
||||||
|
"MixinGameProfile",
|
||||||
|
"MixinPlayerManager",
|
||||||
|
"MixinRespawnAnchorBlock",
|
||||||
"MixinServerPlayerEntity",
|
"MixinServerPlayerEntity",
|
||||||
"MixinTntBlock",
|
"MixinTntBlock",
|
||||||
"MixinTntEntity"
|
"MixinTntEntity"
|
||||||
|
Loading…
Reference in New Issue
Block a user