Compare commits
No commits in common. "master" and "v1.0.0" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
logs/
|
|
||||||
mcsrc/
|
|
||||||
run/
|
run/
|
||||||
|
10
README.txt
10
README.txt
@ -1,5 +1,7 @@
|
|||||||
minecraft-tweaks-2a03
|
2a03-minecraft-tweaks
|
||||||
|
|
||||||
Simple modifications for mc.2a03.party.
|
This repository contains simple modifications for the 2a03.party Minecraft
|
||||||
|
server. I have replaced the patches with a Fabric mod.
|
||||||
Send questions, issues, and patches to flewkey@2a03.party.
|
If you want a new feature added, you can either make an issue here or e-mail
|
||||||
|
me. Preferably the latter, because I am inactive on GitHub.
|
||||||
|
You probably want to ignore this.
|
||||||
|
13
build.gradle
13
build.gradle
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.2-SNAPSHOT'
|
id 'fabric-loom' version '0.2.6-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@ -9,14 +9,9 @@ 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}"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
compile "org.json:json:20190722"
|
||||||
modImplementation "org.json:json:20211205"
|
|
||||||
modImplementation "org.xerial:sqlite-jdbc:3.36.0.3"
|
|
||||||
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
|
|
||||||
include "org.json:json:20211205"
|
|
||||||
include "org.xerial:sqlite-jdbc:3.36.0.3"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
org.gradle.parallel=true
|
minecraft_version=1.15.1
|
||||||
minecraft_version=1.20
|
yarn_mappings=1.15.1+build.1
|
||||||
yarn_mappings=1.20+build.1
|
loader_version=0.7.2+build.175
|
||||||
loader_version=0.14.21
|
mod_version = 1.0.0
|
||||||
mod_version=1.2.0
|
maven_group = party.2a03.mc
|
||||||
maven_group=party._2a03.mc
|
archives_base_name = minecraft-tweaks-2a03
|
||||||
archives_base_name=minecraft-tweaks-2a03
|
fabric_version=0.4.25+build.282-1.15
|
||||||
fabric_version=0.83.0+1.20
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#!/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,69 +1,34 @@
|
|||||||
package party._2a03.mc;
|
package party._2a03.mc;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
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.command.ConfigCommand;
|
import party._2a03.mc.command.ConfigCommand;
|
||||||
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.command.TpaCommand;
|
import party._2a03.mc.server.Config;
|
||||||
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();
|
||||||
private Path configDir;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
configDir = new File(FabricLoader.getInstance().getConfigDirectory(), "minecraft-tweaks-2a03").toPath();
|
|
||||||
if (!Files.exists(configDir)) {
|
|
||||||
LOGGER.info("Creating 2a03.party config directory");
|
|
||||||
try {
|
|
||||||
Files.createDirectory(configDir);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
ServerLifecycleEvents.SERVER_STOPPING.register(minecraftServer -> {
|
|
||||||
Database.close();
|
|
||||||
});
|
|
||||||
LOGGER.info("Registering 2a03.party commands");
|
LOGGER.info("Registering 2a03.party commands");
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
CommandRegistry.INSTANCE.register(false, dispatcher -> {
|
||||||
if (environment.dedicated) {
|
|
||||||
ConfigCommand.register(dispatcher);
|
ConfigCommand.register(dispatcher);
|
||||||
FlyCommand.register(dispatcher);
|
|
||||||
HatCommand.register(dispatcher);
|
HatCommand.register(dispatcher);
|
||||||
HeadCommand.register(dispatcher);
|
HeadCommand.register(dispatcher);
|
||||||
HomeCommand.register(dispatcher);
|
HomeCommand.register(dispatcher);
|
||||||
NameCommand.register(dispatcher);
|
|
||||||
SkinCommand.register(dispatcher);
|
|
||||||
SpawnCommand.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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
import party._2a03.mc.util.Config;
|
import party._2a03.mc.server.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(() -> Text.of("Reloaded the configuration"), true);
|
source.sendFeedback(new LiteralText("Reloaded the configuration"), true);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
source.sendFeedback(() -> Text.of("Failed to reload the configuration"), true);
|
source.sendFeedback(new LiteralText("Failed to reload the configuration"), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package party._2a03.mc.command;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import net.minecraft.entity.player.PlayerAbilities;
|
|
||||||
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.Config;
|
|
||||||
|
|
||||||
public class FlyCommand {
|
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
|
||||||
dispatcher.register(CommandManager.literal("fly").executes(ctx -> {
|
|
||||||
ServerCommandSource source = ctx.getSource();
|
|
||||||
if (Config.getBool("disableFlyCommand")) {
|
|
||||||
source.sendFeedback(() -> Text.of("The /fly command is disabled"), true);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
|
||||||
PlayerAbilities abilities = sender.getAbilities();
|
|
||||||
boolean flight = abilities.allowFlying;
|
|
||||||
abilities.allowFlying = !flight;
|
|
||||||
if (!flight)
|
|
||||||
source.sendFeedback(() -> Text.of("I wanna fly like an eagle... to the sea!"), true);
|
|
||||||
else {
|
|
||||||
source.sendFeedback(() -> Text.of("Flight disabled"), true);
|
|
||||||
abilities.flying = false;
|
|
||||||
}
|
|
||||||
sender.sendAbilitiesUpdate();
|
|
||||||
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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
|
|
||||||
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(() -> Text.of("Swapped items between main hand and head"), false);
|
source.sendFeedback(new LiteralText("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.NbtCompound;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
|
|
||||||
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());
|
||||||
NbtCompound nbt = new NbtCompound();
|
CompoundTag compoundtag = new CompoundTag();
|
||||||
nbt.putString("SkullOwner", skullowner);
|
compoundtag.putString("SkullOwner", skullowner);
|
||||||
itemstack.setNbt(nbt);
|
itemstack.setTag(compoundtag);
|
||||||
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(() -> Text.of("Player head has been given"), false);
|
source.sendFeedback(new LiteralText("Player head has been given"), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,64 +3,63 @@ 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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
import party._2a03.mc.util.Database;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import party._2a03.mc.util.PlayerData;
|
import party._2a03.mc.server.Config;
|
||||||
import party._2a03.mc.util.PlayerPosition;
|
import party._2a03.mc.server.PlayerData;
|
||||||
|
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 = Database.getPlayer(sender.getUuid().toString()).getHome();
|
PlayerPosition position = Config.getPlayer(sender.getUuid().toString()).getHome();
|
||||||
if (position.registrykey == null) {
|
if (position.dimensiontype == null) {
|
||||||
source.sendFeedback(() -> Text.of("Home not found, do /home set"), false);
|
source.sendFeedback(new LiteralText("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.dimensiontype), position.x, position.y, position.z, position.yaw, position.pitch);
|
||||||
source.sendFeedback(() -> Text.of("Teleported to home"), true);
|
source.sendFeedback(new LiteralText("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 = Database.getPlayer(sender.getUuid().toString());
|
PlayerData playerdata = Config.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.getYaw();
|
float yaw = sender.yaw;
|
||||||
float pitch = sender.getPitch();
|
float pitch = sender.pitch;
|
||||||
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
DimensionType dimensiontype = sender.getServerWorld().getDimension().getType();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, dimensiontype);
|
||||||
playerdata.setHome(location);
|
playerdata.setHome(location);
|
||||||
source.sendFeedback(() -> Text.of("Your home has been updated"), true);
|
Config.setPlayer(playerdata);
|
||||||
|
source.sendFeedback(new LiteralText("Your home has been updated"), true);
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
literalargumentbuilder.then(CommandManager.literal("assign").requires(ctx -> {
|
literalargumentbuilder.then(CommandManager.literal("sudoset").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 = Database.getPlayer(uuid);
|
PlayerData playerdata = Config.getPlayer(StringArgumentType.getString(ctx, "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.getYaw();
|
float yaw = sender.yaw;
|
||||||
float pitch = sender.getPitch();
|
float pitch = sender.pitch;
|
||||||
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
DimensionType dimensiontype = sender.getServerWorld().getDimension().getType();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, dimensiontype);
|
||||||
playerdata.setHome(location);
|
playerdata.setHome(location);
|
||||||
source.sendFeedback(() -> Text.of("User's home has been updated (" + uuid.toString() + ")"), true);
|
Config.setPlayer(playerdata);
|
||||||
|
source.sendFeedback(new LiteralText("User's home has been updated (" + StringArgumentType.getString(ctx, "UUID") + ")"), true);
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
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;
|
|
||||||
})))));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
import party._2a03.mc.util.Config;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import party._2a03.mc.util.PlayerPosition;
|
import party._2a03.mc.server.Config;
|
||||||
|
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) {
|
||||||
@ -16,16 +16,16 @@ public class SpawnCommand {
|
|||||||
ServerCommandSource source = ctx.getSource();
|
ServerCommandSource source = ctx.getSource();
|
||||||
ServerPlayerEntity sender = source.getPlayer();
|
ServerPlayerEntity sender = source.getPlayer();
|
||||||
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
||||||
if (position.registrykey == null) {
|
if (position.dimensiontype == null) {
|
||||||
if (source.hasPermissionLevel(2)) {
|
if (source.hasPermissionLevel(2)) {
|
||||||
source.sendFeedback(() -> Text.of("Spawn not found, do /spawn set"), false);
|
source.sendFeedback(new LiteralText("Spawn not found, do /spawn set"), false);
|
||||||
} else {
|
} else {
|
||||||
source.sendFeedback(() -> Text.of("Spawn not found, ask an admin to set it"), false);
|
source.sendFeedback(new LiteralText("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.dimensiontype), position.x, position.y, position.z, position.yaw, position.pitch);
|
||||||
source.sendFeedback(() -> Text.of("Teleported to the spawn point"), true);
|
source.sendFeedback(new LiteralText("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.getYaw();
|
float yaw = sender.yaw;
|
||||||
float pitch = sender.getPitch();
|
float pitch = sender.pitch;
|
||||||
RegistryKey registrykey = sender.getWorld().getRegistryKey();
|
DimensionType dimensiontype = sender.getServerWorld().getDimension().getType();
|
||||||
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey);
|
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, dimensiontype);
|
||||||
Config.setData("spawn", location.getJSON());
|
Config.setData("spawn", location.getJSON());
|
||||||
source.sendFeedback(() -> Text.of("Spawn has been set"), true);
|
source.sendFeedback(new LiteralText("Spawn has been set"), true);
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
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,23 +1,21 @@
|
|||||||
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.Text;
|
import net.minecraft.text.LiteralText;
|
||||||
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.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(GameModeCommand.class)
|
@Mixin(GameModeCommand.class)
|
||||||
public class MixinGameModeCommand {
|
public class MixinGameModeCommand {
|
||||||
@Inject(method = "execute", at = @At("HEAD"))
|
@Inject(method = "setGameMode", at = @At("HEAD"))
|
||||||
private static void OnExecute(CommandContext<ServerCommandSource> context, Collection<ServerPlayerEntity> targets, GameMode gameMode, CallbackInfoReturnable cir) {
|
private static void OnSetGameMode(ServerCommandSource source, ServerPlayerEntity player, GameMode gameMode, CallbackInfo ci) {
|
||||||
if (gameMode == GameMode.CREATIVE) {
|
if (gameMode == GameMode.CREATIVE) {
|
||||||
context.getSource().sendFeedback(() -> Text.of("<Server> Creative mode? What are you, a cheater?"), false);
|
source.sendFeedback(new LiteralText("<Server> Creative mode? What are you, a cheater?"), false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
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,34 +0,0 @@
|
|||||||
package party._2a03.mc.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.registry.RegistryKey;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.text.Text;
|
|
||||||
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.injection.callback.CallbackInfoReturnable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import party._2a03.mc.util.Config;
|
|
||||||
import party._2a03.mc.util.PlayerPosition;
|
|
||||||
|
|
||||||
@Mixin(ServerPlayerEntity.class)
|
|
||||||
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
|
||||||
@Shadow
|
|
||||||
private RegistryKey<World> spawnPointDimension;
|
|
||||||
|
|
||||||
public MixinServerPlayerEntity() {
|
|
||||||
super(null, null, 0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void OnServerPlayerSpawn(CallbackInfo ci) {
|
|
||||||
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
|
||||||
if (position.registrykey == this.spawnPointDimension) {
|
|
||||||
this.updatePositionAndAngles(position.x, position.y, position.z, position.yaw, position.pitch);
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package party._2a03.mc.mixin;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.TntBlock;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
|
||||||
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(TntBlock.class)
|
|
||||||
public abstract class MixinTntBlock extends Block {
|
|
||||||
@Shadow
|
|
||||||
public static final BooleanProperty UNSTABLE = Properties.UNSTABLE;
|
|
||||||
|
|
||||||
public MixinTntBlock(Block.Settings settings) {
|
|
||||||
super(settings);
|
|
||||||
this.setDefaultState(this.getDefaultState().with(UNSTABLE, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "primeTnt", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void OnPrimeTnt(CallbackInfo ci) {
|
|
||||||
if (Config.getBool("disableTntExplosions") == true)
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,23 +4,20 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.TntEntity;
|
import net.minecraft.entity.TntEntity;
|
||||||
import net.minecraft.world.World;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import party._2a03.mc.util.Config;
|
|
||||||
|
|
||||||
@Mixin(TntEntity.class)
|
@Mixin(TntEntity.class)
|
||||||
public abstract class MixinTntEntity extends Entity {
|
public abstract class MixinTntEntity extends Entity {
|
||||||
public MixinTntEntity(EntityType<? extends TntEntity> entityType, World world) {
|
public MixinTntEntity(EntityType<? extends TntEntity> entityType, World world) {
|
||||||
super(entityType, world);
|
super(entityType, world);
|
||||||
this.intersectionChecked = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
|
/**
|
||||||
private void OnTntExplode(CallbackInfo ci) {
|
* @reason Disable TNT entity explosions.
|
||||||
if (Config.getBool("disableTntExplosions") == true)
|
* @author flewkey
|
||||||
ci.cancel();
|
*/
|
||||||
|
@Overwrite
|
||||||
|
private void explode() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
86
src/main/java/party/_2a03/mc/server/Config.java
Normal file
86
src/main/java/party/_2a03/mc/server/Config.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package party._2a03.mc.server;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import party._2a03.mc.server.PlayerData;
|
||||||
|
import party._2a03.mc.server.PlayerPosition;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
private static JSONObject json;
|
||||||
|
|
||||||
|
public static void loadConfig() throws Exception {
|
||||||
|
LOGGER.info("Loading 2a03.party configuration");
|
||||||
|
File f = new File("2a03.json");
|
||||||
|
if (f.exists()) {
|
||||||
|
InputStream is = new FileInputStream("2a03.json");
|
||||||
|
String jsonRaw = IOUtils.toString(is, "UTF-8");
|
||||||
|
json = new JSONObject(jsonRaw);
|
||||||
|
} else {
|
||||||
|
LOGGER.info("Config not found, creating one");
|
||||||
|
json = new JSONObject("{\"spawn\":[0,0,0,0,0,-2],\"members\":[]}");
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
LOGGER.info("Configuration loaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerData getPlayer(String uuid) {
|
||||||
|
JSONArray members = json.getJSONArray("members");
|
||||||
|
PlayerPosition home = null;
|
||||||
|
for (int i = 0; i < members.length(); ++i) {
|
||||||
|
JSONObject item = members.getJSONObject(i);
|
||||||
|
String item_uuid = item.getString("uuid");
|
||||||
|
if (item_uuid.equals(uuid)) {
|
||||||
|
home = new PlayerPosition(item.getJSONArray("home"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONArray getData(String key) {
|
||||||
|
return json.getJSONArray(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setData(String key, JSONArray data) {
|
||||||
|
json.put(key, data);
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveConfig() {
|
||||||
|
try (FileWriter file = new FileWriter("2a03.json")) {
|
||||||
|
file.write(JSONObject.valueToString(json));
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Failed to save config file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
src/main/java/party/_2a03/mc/server/PlayerData.java
Normal file
34
src/main/java/party/_2a03/mc/server/PlayerData.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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,10 +1,8 @@
|
|||||||
package party._2a03.mc.util;
|
package party._2a03.mc.server;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import party._2a03.mc.server.Config;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
|
|
||||||
public class PlayerPosition {
|
public class PlayerPosition {
|
||||||
public double x;
|
public double x;
|
||||||
@ -12,48 +10,48 @@ public class PlayerPosition {
|
|||||||
public double z;
|
public double z;
|
||||||
public float yaw;
|
public float yaw;
|
||||||
public float pitch;
|
public float pitch;
|
||||||
public RegistryKey registrykey;
|
public DimensionType dimensiontype;
|
||||||
|
|
||||||
public PlayerPosition() {
|
public PlayerPosition() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerPosition(JSONArray data) {
|
public PlayerPosition(JSONArray data) {
|
||||||
String registry_string = data.getString(5);
|
int dimension_id = data.getInt(5);
|
||||||
if (!registry_string.isEmpty()) {
|
if (dimension_id != -2) {
|
||||||
this.x = data.getDouble(0);
|
this.x = data.getDouble(0);
|
||||||
this.y = data.getDouble(1);
|
this.y = data.getDouble(1);
|
||||||
this.z = data.getDouble(2);
|
this.z = data.getDouble(2);
|
||||||
this.yaw = data.getNumber(3).floatValue();
|
this.yaw = data.getFloat(3);
|
||||||
this.pitch = data.getNumber(4).floatValue();
|
this.pitch = data.getFloat(4);
|
||||||
this.registrykey = RegistryKey.of(RegistryKeys.DIMENSION, new Identifier(registry_string));
|
this.dimensiontype = DimensionType.byRawId(dimension_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerPosition(double p_x, double p_y, double p_z, float p_yaw, float p_pitch, RegistryKey p_registrykey) {
|
public PlayerPosition(double p_x, double p_y, double p_z, float p_yaw, float p_pitch, DimensionType p_dimensiontype) {
|
||||||
this.x = p_x;
|
this.x = p_x;
|
||||||
this.y = p_y;
|
this.y = p_y;
|
||||||
this.z = p_z;
|
this.z = p_z;
|
||||||
this.yaw = p_yaw;
|
this.yaw = p_yaw;
|
||||||
this.pitch = p_pitch;
|
this.pitch = p_pitch;
|
||||||
this.registrykey = p_registrykey;
|
this.dimensiontype = p_dimensiontype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray getJSON() {
|
public JSONArray getJSON() {
|
||||||
JSONArray json = new JSONArray();
|
JSONArray json = new JSONArray();
|
||||||
if (this.registrykey != null) {
|
if (this.dimensiontype != null) {
|
||||||
json.put(this.x);
|
json.put(this.x);
|
||||||
json.put(this.y);
|
json.put(this.y);
|
||||||
json.put(this.z);
|
json.put(this.z);
|
||||||
json.put(this.yaw);
|
json.put(this.yaw);
|
||||||
json.put(this.pitch);
|
json.put(this.pitch);
|
||||||
json.put(this.registrykey.getValue().toString());
|
json.put(this.dimensiontype.getRawId());
|
||||||
} else {
|
} else {
|
||||||
json.put(0);
|
json.put(0);
|
||||||
json.put(0);
|
json.put(0);
|
||||||
json.put(0);
|
json.put(0);
|
||||||
json.put(0);
|
json.put(0);
|
||||||
json.put(0);
|
json.put(0);
|
||||||
json.put("");
|
json.put(-2);
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
@ -1,77 +0,0 @@
|
|||||||
package party._2a03.mc.util;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import party._2a03.mc.MinecraftTweaks2a03;
|
|
||||||
import party._2a03.mc.util.PlayerData;
|
|
||||||
import party._2a03.mc.util.PlayerPosition;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
private static JSONObject json;
|
|
||||||
private static File config;
|
|
||||||
|
|
||||||
public static void initConfig(File configDir) {
|
|
||||||
config = new File(configDir, "2a03.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadConfig() throws Exception {
|
|
||||||
LOGGER.info("Loading 2a03.party configuration");
|
|
||||||
if (config.exists()) {
|
|
||||||
InputStream is = new FileInputStream(config);
|
|
||||||
String jsonRaw = IOUtils.toString(is, "UTF-8");
|
|
||||||
json = new JSONObject(jsonRaw);
|
|
||||||
} else {
|
|
||||||
json = new JSONObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
setDefault("overrideNames", false);
|
|
||||||
setDefault("overrideSkins", false);
|
|
||||||
setDefault("persistentFlight", false);
|
|
||||||
setDefault("disableFlyCommand", true);
|
|
||||||
setDefault("disableTntExplosions", false);
|
|
||||||
setDefault("disableCreeperExplosions", false);
|
|
||||||
setDefault("disableRespawnAnchorExplosions", false);
|
|
||||||
setDefault("iphubApiKey", "");
|
|
||||||
setDefault("spawn", (new PlayerPosition()).getJSON());
|
|
||||||
saveConfig();
|
|
||||||
|
|
||||||
LOGGER.info("Configuration loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JSONArray getData(String key) {
|
|
||||||
return json.getJSONArray(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getBool(String key) {
|
|
||||||
return json.getBoolean(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setData(String key, JSONArray data) {
|
|
||||||
json.put(key, data);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDefault(String key, Object data) {
|
|
||||||
if (!json.has(key))
|
|
||||||
json.put(key, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void saveConfig() {
|
|
||||||
try (FileWriter file = new FileWriter(config)) {
|
|
||||||
file.write(json.toString(2));
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Failed to save config file");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,163 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
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,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "minecraft-tweaks-2a03",
|
"id": "minecraft-tweaks-2a03",
|
||||||
"version": "1.2.0",
|
"version": "1.0.0",
|
||||||
"name": "minecraft-tweaks-2a03",
|
"name": "2a03.party Tweaks",
|
||||||
"description": "Simple modifications for mc.2a03.party.",
|
"description": "Simple modifications for the 2a03.party Minecraft server.",
|
||||||
"authors": [
|
"authors": [
|
||||||
"flewkey"
|
"flewkey"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://flewkey.com/",
|
"homepage": "https://flewkey.com/",
|
||||||
"sources": "https://git.sdf.org/flewkey/minecraft-tweaks-2a03"
|
"sources": "https://github.com/flewkey/minecraft-tweaks-2a03"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/minecraft-tweaks-2a03/icon.png",
|
"icon": "assets/2a03-minecraft-tweaks/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
@ -23,9 +23,8 @@
|
|||||||
"minecraft-tweaks-2a03.mixins.json"
|
"minecraft-tweaks-2a03.mixins.json"
|
||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.21",
|
"fabricloader": ">=0.7.2",
|
||||||
"fabric-api": "*",
|
"fabric": "*",
|
||||||
"minecraft": "~1.20",
|
"minecraft": "1.15.x"
|
||||||
"java": ">=17"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,9 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "party._2a03.mc.mixin",
|
"package": "party._2a03.mc.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"server": [
|
"server": [
|
||||||
"MixinCreeperEntity",
|
|
||||||
"MixinGameModeCommand",
|
"MixinGameModeCommand",
|
||||||
"MixinGameProfile",
|
|
||||||
"MixinPlayerManager",
|
|
||||||
"MixinRespawnAnchorBlock",
|
|
||||||
"MixinServerPlayerEntity",
|
|
||||||
"MixinTntBlock",
|
|
||||||
"MixinTntEntity"
|
"MixinTntEntity"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
Loading…
Reference in New Issue
Block a user