flewkey
/
mc.2a03.party
Archived
1
0
Fork 0

Initial commit

This commit is contained in:
flewkey 2019-05-26 23:14:20 -07:00
commit 8b9dbeabd8
Signed by: flewkey
GPG Key ID: 94F56ADFD848851E
10 changed files with 320 additions and 0 deletions

2
README.txt Normal file
View File

@ -0,0 +1,2 @@
This repository contains simple modifications for the 2a03.party Minecraft server.
You probably want to ignore this.

View File

@ -0,0 +1,22 @@
--- a/net/minecraft/command/Commands.java 2019-05-23 14:43:25 -0700
+++ b/net/minecraft/command/Commands.java 2019-05-26 17:14:30 -0700
@@ -90,6 +90,9 @@
import net.minecraft.util.text.event.HoverEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import party._2a03.command.SpawnCommand; //Patched
+import party._2a03.command.HomeCommand; //Patched
+import party._2a03.command.ConfigCommand; //Patched
public class Commands {
private static final Logger field_197061_a = LogManager.getLogger();
@@ -149,6 +152,9 @@
TriggerCommand.func_198852_a(this.field_197062_b);
WeatherCommand.func_198862_a(this.field_197062_b);
WorldBorderCommand.func_198894_a(this.field_197062_b);
+ SpawnCommand.register(this.field_197062_b); //Patched
+ HomeCommand.register(this.field_197062_b); //Patched
+ ConfigCommand.register(this.field_197062_b); //Patched
if (p_i49161_1_) {
BanIpCommand.func_198220_a(this.field_197062_b);
BanListCommand.func_198229_a(this.field_197062_b);

View File

@ -0,0 +1,13 @@
--- a/net/minecraft/command/impl/GameModeCommand.java 2019-05-23 14:43:22 -0700
+++ b/net/minecraft/command/impl/GameModeCommand.java 2019-05-26 14:13:25 -0700
@@ -48,6 +48,10 @@
private static int func_198484_a(CommandContext<CommandSource> p_198484_0_, Collection<ServerPlayerEntity> p_198484_1_, GameType p_198484_2_) {
int i = 0;
+
+ if (p_198484_2_ == GameType.CREATIVE) { //Patched
+ p_198484_0_.getSource().func_197030_a(new TranslationTextComponent("<Server> Creative mode? What are you, a cheater?"), true); //Patched
+ } //Patched
for(ServerPlayerEntity serverplayerentity : p_198484_1_) {
if (serverplayerentity.field_71134_c.func_73081_b() != p_198484_2_) {

View File

@ -0,0 +1,37 @@
--- a/net/minecraft/server/MinecraftServer.java 2019-05-23 14:43:21 -0700
+++ b/net/minecraft/server/MinecraftServer.java 2019-05-26 14:37:21 -0700
@@ -121,6 +121,7 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import party._2a03.server.Config; //Patched
public abstract class MinecraftServer extends RecursiveEventLoop<TickDelayedTask> implements ISnooperInfo, ICommandExecutor, AutoCloseable, Runnable {
private static final Logger field_147145_h = LogManager.getLogger();
@@ -810,6 +811,7 @@
}
public static void main(String[] p_main_0_) {
+ field_147145_h.info("This jar has been patched!"); //Patched
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -864,7 +866,8 @@
dedicatedserver.func_213197_c(optionset.has(optionspec5));
dedicatedserver.func_213208_c(optionset.valueOf(optionspec11));
boolean flag = !optionset.has(optionspec) && !optionset.valuesOf(optionspec12).contains("nogui");
- if (flag && !GraphicsEnvironment.isHeadless()) {
+ Config.loadConfig(); //Patched
+ if (flag && !GraphicsEnvironment.isHeadless() && false) { //Patched
dedicatedserver.func_120011_ar();
}
@@ -950,7 +953,7 @@
}
public String getServerModName() {
- return "vanilla";
+ return "mc.2a03.party"; //Patched
}
public CrashReport func_71230_b(CrashReport p_71230_1_) {

View File

@ -0,0 +1,30 @@
package party._2a03.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.TranslationTextComponent;
import party._2a03.server.Config;
public class ConfigCommand {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
LiteralArgumentBuilder<CommandSource> literalargumentbuilder = Commands.func_197057_a("config").requires((source) -> {
return source.func_197034_c(2);
});
literalargumentbuilder.then(Commands.func_197057_a("reload").executes((source) -> {
try {
Config.loadConfig();
source.getSource().func_197030_a(new TranslationTextComponent("Reloaded the configuration"), true);
} catch(Exception e) {
source.getSource().func_197030_a(new TranslationTextComponent("Failed to reload the configuration"), true);
}
return 1;
}));
literalargumentbuilder.then(Commands.func_197057_a("delete").executes((source) -> {
source.getSource().func_197030_a(new TranslationTextComponent("Did you seriously think this command did something?"), true);
return 1;
}));
dispatcher.register(literalargumentbuilder);
}
}

View File

@ -0,0 +1,52 @@
package party._2a03.command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.server.SPlayerPositionLookPacket;
import java.util.Set;
import java.util.EnumSet;
import party._2a03.server.Config;
import party._2a03.server.PlayerData;
import party._2a03.server.PlayerPosition;
public class HomeCommand {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
LiteralArgumentBuilder<CommandSource> literalargumentbuilder = Commands.func_197057_a("home").executes((source) -> {
PlayerData player = Config.getPlayer(source.getSource().func_197035_h().func_110124_au().toString());
PlayerPosition position = player.getHome();
if (position.y == -1) {
source.getSource().func_197030_a(new TranslationTextComponent("Home not found, ask a moderator to set it"), true);
return 1;
}
Set<SPlayerPositionLookPacket.Flags> set = EnumSet.noneOf(SPlayerPositionLookPacket.Flags.class);
set.add(SPlayerPositionLookPacket.Flags.X);
set.add(SPlayerPositionLookPacket.Flags.Y);
set.add(SPlayerPositionLookPacket.Flags.Z);
((ServerPlayerEntity)source.getSource().func_197035_h()).field_71135_a.func_175089_a((double)position.x, (double)position.y, (double)position.z, (float)position.yaw, (float)position.pitch, set);
source.getSource().func_197030_a(new TranslationTextComponent("Teleported to home"), true);
return 1;
});
literalargumentbuilder.then(Commands.func_197057_a("set").then(Commands.func_197056_a("UUID", StringArgumentType.word()).requires((source) -> {
return source.func_197034_c(2);
}).executes((source) -> {
PlayerData player = Config.getPlayer(StringArgumentType.getString(source, "UUID"));
ServerPlayerEntity playerEntity = source.getSource().func_197035_h();
double x = playerEntity.field_70165_t;
double y = playerEntity.field_70163_u;
double z = playerEntity.field_70161_v;
float yaw = playerEntity.field_70177_z;
float pitch = playerEntity.field_70125_A;
PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch);
player.setHome(location);
Config.setPlayer(player);
source.getSource().func_197030_a(new TranslationTextComponent("User's home has been updated"), true);
return 1;
})));
dispatcher.register(literalargumentbuilder);
}
}

View File

@ -0,0 +1,27 @@
package party._2a03.command;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.play.server.SPlayerPositionLookPacket;
import java.util.Set;
import java.util.EnumSet;
import party._2a03.server.Config;
import party._2a03.server.PlayerPosition;
public class SpawnCommand {
public static void register(CommandDispatcher<CommandSource> dispatcher) {
dispatcher.register(Commands.func_197057_a("spawn").executes((source) -> {
Set<SPlayerPositionLookPacket.Flags> set = EnumSet.noneOf(SPlayerPositionLookPacket.Flags.class);
set.add(SPlayerPositionLookPacket.Flags.X);
set.add(SPlayerPositionLookPacket.Flags.Y);
set.add(SPlayerPositionLookPacket.Flags.Z);
PlayerPosition position = Config.getPosition("spawn");
((ServerPlayerEntity)source.getSource().func_197035_h()).field_71135_a.func_175089_a((double)position.x, (double)position.y, (double)position.z, (float)position.yaw, (float)position.pitch, set);
source.getSource().func_197030_a(new TranslationTextComponent("Teleported to the spawn point"), true);
return 1;
}));
}
}

View File

@ -0,0 +1,83 @@
package party._2a03.server;
import java.io.File;
import java.io.FileWriter;
import java.io.FileInputStream;
import java.io.InputStream;
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.server.PlayerData;
import party._2a03.server.PlayerPosition;
public class Config {
private static JSONObject json;
private static final Logger logger = LogManager.getLogger();
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("Unable to find config");
}
logger.info("Configuration loaded");
}
public static PlayerData getPlayer(String uuid) {
JSONArray members = json.getJSONArray("members");
JSONObject data = 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)) {
data = item;
}
}
if (data == null) {
data = new JSONObject("{\"uuid\":\""+uuid+"\",\"home\":[-1,-1,-1,-1,-1]}");
}
return new PlayerData(data);
}
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.json);
json.put("members", members);
saveConfig();
}
public static PlayerPosition getPosition(String key) {
JSONArray data = json.getJSONArray(key);
double x = data.getDouble(0);
double y = data.getDouble(1);
double z = data.getDouble(2);
float yaw = data.getFloat(3);
float pitch = data.getFloat(4);
return new PlayerPosition((double)x, (double)y, (double)z, (float)yaw, (float)pitch);
}
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");
}
}
}

View File

@ -0,0 +1,37 @@
package party._2a03.server;
import org.json.JSONArray;
import org.json.JSONObject;
import party._2a03.server.PlayerPosition;
public class PlayerData {
public JSONObject json;
public PlayerData(JSONObject p_json) {
this.json = p_json;
}
public PlayerPosition getHome() {
JSONArray data = json.getJSONArray("home");
double x = data.getDouble(0);
double y = data.getDouble(1);
double z = data.getDouble(2);
float yaw = data.getFloat(3);
float pitch = data.getFloat(4);
return new PlayerPosition(x, y, z, yaw, pitch);
}
public String getUUID() {
return json.getString("uuid");
}
public void setHome(PlayerPosition location) {
JSONArray locationArray = new JSONArray();
locationArray.put(location.x);
locationArray.put(location.y);
locationArray.put(location.z);
locationArray.put(location.yaw);
locationArray.put(location.pitch);
json.put("home", locationArray);
}
}

View File

@ -0,0 +1,17 @@
package party._2a03.server;
public class PlayerPosition {
public double x;
public double y;
public double z;
public float yaw;
public float pitch;
public PlayerPosition(double p_x, double p_y, double p_z, float p_yaw, float p_pitch) {
this.x = p_x;
this.y = p_y;
this.z = p_z;
this.yaw = p_yaw;
this.pitch = p_pitch;
}
}