20w16a fixes, updating.
This commit is contained in:
parent
52f2f3c3f8
commit
898ed03e26
|
@ -10,6 +10,6 @@ loader_version=0.8.2+build.194
|
||||||
fabric_version=0.5.10+build.320-1.16
|
fabric_version=0.5.10+build.320-1.16
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.3.3
|
mod_version = 1.4.0
|
||||||
maven_group = org.samo_lego
|
maven_group = org.samo_lego
|
||||||
archives_base_name = simpleauth
|
archives_base_name = simpleauth
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.samo_lego.simpleauth.commands;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -82,7 +83,7 @@ public class AuthCommand {
|
||||||
SimpleAuth.config = AuthConfig.load(new File("./mods/SimpleAuth/config.json"));
|
SimpleAuth.config = AuthConfig.load(new File("./mods/SimpleAuth/config.json"));
|
||||||
|
|
||||||
if(sender != null)
|
if(sender != null)
|
||||||
sender.sendMessage(configurationReloaded);
|
((PlayerEntity) sender).sendMessage(configurationReloaded, false);
|
||||||
else
|
else
|
||||||
LOGGER.info(SimpleAuth.config.lang.configurationReloaded);
|
LOGGER.info(SimpleAuth.config.lang.configurationReloaded);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -98,7 +99,7 @@ public class AuthCommand {
|
||||||
SimpleAuth.config.save(new File("./mods/SimpleAuth/config.json"));
|
SimpleAuth.config.save(new File("./mods/SimpleAuth/config.json"));
|
||||||
|
|
||||||
if(sender != null)
|
if(sender != null)
|
||||||
sender.sendMessage(globalPasswordSet);
|
sender.sendSystemMessage(globalPasswordSet);
|
||||||
else
|
else
|
||||||
LOGGER.info(SimpleAuth.config.lang.globalPasswordSet);
|
LOGGER.info(SimpleAuth.config.lang.globalPasswordSet);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -111,7 +112,7 @@ public class AuthCommand {
|
||||||
SimpleAuth.deauthenticatedUsers.put(uuid, new PlayerCache(uuid, ""));
|
SimpleAuth.deauthenticatedUsers.put(uuid, new PlayerCache(uuid, ""));
|
||||||
|
|
||||||
if(sender != null)
|
if(sender != null)
|
||||||
sender.sendMessage(userdataDeleted);
|
((PlayerEntity) sender).sendMessage(userdataDeleted, false);
|
||||||
else
|
else
|
||||||
LOGGER.info(SimpleAuth.config.lang.userdataDeleted);
|
LOGGER.info(SimpleAuth.config.lang.userdataDeleted);
|
||||||
return 1; // Success
|
return 1; // Success
|
||||||
|
@ -129,7 +130,7 @@ public class AuthCommand {
|
||||||
|
|
||||||
if(SimpleAuth.db.registerUser(uuid, playerdata.toString())) {
|
if(SimpleAuth.db.registerUser(uuid, playerdata.toString())) {
|
||||||
if(sender != null)
|
if(sender != null)
|
||||||
sender.sendMessage(userdataUpdated);
|
((PlayerEntity) sender).sendMessage(userdataUpdated, false);
|
||||||
else
|
else
|
||||||
LOGGER.info(SimpleAuth.config.lang.userdataUpdated);
|
LOGGER.info(SimpleAuth.config.lang.userdataUpdated);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -149,9 +150,10 @@ public class AuthCommand {
|
||||||
|
|
||||||
SimpleAuth.db.updateUserData(uuid, playerdata.toString());
|
SimpleAuth.db.updateUserData(uuid, playerdata.toString());
|
||||||
if(sender != null)
|
if(sender != null)
|
||||||
sender.sendMessage(userdataUpdated);
|
((PlayerEntity) sender).sendMessage(userdataUpdated, false);
|
||||||
else
|
else
|
||||||
LOGGER.info(SimpleAuth.config.lang.userdataUpdated);
|
LOGGER.info(SimpleAuth.config.lang.userdataUpdated);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// todo PlayerEntity.getOfflinePlayerUuid("")
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ public class ChangepwCommand {
|
||||||
// Registering the "/changepw" command
|
// Registering the "/changepw" command
|
||||||
dispatcher.register(literal("changepw")
|
dispatcher.register(literal("changepw")
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(enterPassword);
|
ctx.getSource().getPlayer().sendMessage(enterPassword, false);
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(argument("oldPassword", word())
|
.then(argument("oldPassword", word())
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(enterNewPassword);
|
ctx.getSource().getPlayer().sendMessage(enterNewPassword, false);
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(argument("newPassword", word())
|
.then(argument("newPassword", word())
|
||||||
|
@ -52,20 +52,20 @@ public class ChangepwCommand {
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
|
|
||||||
if (SimpleAuth.config.main.enableGlobalPassword) {
|
if (SimpleAuth.config.main.enableGlobalPassword) {
|
||||||
player.sendMessage(cannotChangePassword);
|
player.sendMessage(cannotChangePassword, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (AuthHelper.checkPass(player.getUuidAsString(), oldPass.toCharArray()) == 1) {
|
else if (AuthHelper.checkPass(player.getUuidAsString(), oldPass.toCharArray()) == 1) {
|
||||||
if(newPass.length() < SimpleAuth.config.main.minPasswordChars) {
|
if(newPass.length() < SimpleAuth.config.main.minPasswordChars) {
|
||||||
player.sendMessage(new LiteralText(
|
player.sendMessage(new LiteralText(
|
||||||
String.format(SimpleAuth.config.lang.minPasswordChars, SimpleAuth.config.main.minPasswordChars)
|
String.format(SimpleAuth.config.lang.minPasswordChars, SimpleAuth.config.main.minPasswordChars)
|
||||||
));
|
), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(newPass.length() > SimpleAuth.config.main.maxPasswordChars && SimpleAuth.config.main.maxPasswordChars != -1) {
|
else if(newPass.length() > SimpleAuth.config.main.maxPasswordChars && SimpleAuth.config.main.maxPasswordChars != -1) {
|
||||||
player.sendMessage(new LiteralText(
|
player.sendMessage(new LiteralText(
|
||||||
String.format(SimpleAuth.config.lang.maxPasswordChars, SimpleAuth.config.main.maxPasswordChars)
|
String.format(SimpleAuth.config.lang.maxPasswordChars, SimpleAuth.config.main.maxPasswordChars)
|
||||||
));
|
), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// JSON object holding password (may hold some other info in the future)
|
// JSON object holding password (may hold some other info in the future)
|
||||||
|
@ -74,10 +74,10 @@ public class ChangepwCommand {
|
||||||
playerdata.addProperty("password", hash);
|
playerdata.addProperty("password", hash);
|
||||||
|
|
||||||
SimpleAuth.db.updateUserData(player.getUuidAsString(), playerdata.toString());
|
SimpleAuth.db.updateUserData(player.getUuidAsString(), playerdata.toString());
|
||||||
player.sendMessage(passwordUpdated);
|
player.sendMessage(passwordUpdated, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
player.sendMessage(wrongPassword);
|
player.sendMessage(wrongPassword, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class LoginCommand {
|
||||||
.executes(ctx -> login(ctx.getSource(), getString(ctx, "password")) // Tries to authenticate user
|
.executes(ctx -> login(ctx.getSource(), getString(ctx, "password")) // Tries to authenticate user
|
||||||
))
|
))
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(enterPassword);
|
ctx.getSource().getPlayer().sendMessage(enterPassword, false);
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class LoginCommand {
|
||||||
int passwordResult = AuthHelper.checkPass(uuid, pass.toCharArray());
|
int passwordResult = AuthHelper.checkPass(uuid, pass.toCharArray());
|
||||||
|
|
||||||
if(SimpleAuth.isAuthenticated(player)) {
|
if(SimpleAuth.isAuthenticated(player)) {
|
||||||
player.sendMessage(alreadyAuthenticated);
|
player.sendMessage(alreadyAuthenticated, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(SimpleAuth.deauthenticatedUsers.get(uuid).loginTries >= maxLoginTries && maxLoginTries != -1) {
|
else if(SimpleAuth.deauthenticatedUsers.get(uuid).loginTries >= maxLoginTries && maxLoginTries != -1) {
|
||||||
|
@ -55,7 +55,7 @@ public class LoginCommand {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if(passwordResult == -1) {
|
else if(passwordResult == -1) {
|
||||||
player.sendMessage(notRegistered);
|
player.sendMessage(notRegistered, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Kicking the player out
|
// Kicking the player out
|
||||||
|
@ -64,7 +64,7 @@ public class LoginCommand {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Sending wrong pass message
|
// Sending wrong pass message
|
||||||
player.sendMessage(wrongPassword);
|
player.sendMessage(wrongPassword, false);
|
||||||
// ++ the login tries
|
// ++ the login tries
|
||||||
SimpleAuth.deauthenticatedUsers.get(uuid).loginTries += 1;
|
SimpleAuth.deauthenticatedUsers.get(uuid).loginTries += 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LogoutCommand {
|
||||||
private static int logout(ServerCommandSource serverCommandSource) throws CommandSyntaxException {
|
private static int logout(ServerCommandSource serverCommandSource) throws CommandSyntaxException {
|
||||||
ServerPlayerEntity player = serverCommandSource.getPlayer();
|
ServerPlayerEntity player = serverCommandSource.getPlayer();
|
||||||
SimpleAuth.deauthenticatePlayer(player);
|
SimpleAuth.deauthenticatePlayer(player);
|
||||||
player.sendMessage(successfulLogout);
|
player.sendMessage(successfulLogout, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class RegisterCommand {
|
||||||
.executes( ctx -> register(ctx.getSource(), getString(ctx, "password"), getString(ctx, "passwordAgain")))
|
.executes( ctx -> register(ctx.getSource(), getString(ctx, "password"), getString(ctx, "passwordAgain")))
|
||||||
))
|
))
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(enterPassword);
|
ctx.getSource().getPlayer().sendMessage(enterPassword, false);
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -42,24 +42,24 @@ public class RegisterCommand {
|
||||||
private static int register(ServerCommandSource source, String pass1, String pass2) throws CommandSyntaxException {
|
private static int register(ServerCommandSource source, String pass1, String pass2) throws CommandSyntaxException {
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
if(SimpleAuth.config.main.enableGlobalPassword) {
|
if(SimpleAuth.config.main.enableGlobalPassword) {
|
||||||
player.sendMessage(loginRequired);
|
player.sendMessage(loginRequired, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(SimpleAuth.isAuthenticated(player)) {
|
else if(SimpleAuth.isAuthenticated(player)) {
|
||||||
player.sendMessage(alreadyAuthenticated);
|
player.sendMessage(alreadyAuthenticated, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(pass1.equals(pass2)) {
|
else if(pass1.equals(pass2)) {
|
||||||
if(pass1.length() < SimpleAuth.config.main.minPasswordChars) {
|
if(pass1.length() < SimpleAuth.config.main.minPasswordChars) {
|
||||||
player.sendMessage(new LiteralText(
|
player.sendMessage(new LiteralText(
|
||||||
String.format(SimpleAuth.config.lang.minPasswordChars, SimpleAuth.config.main.minPasswordChars)
|
String.format(SimpleAuth.config.lang.minPasswordChars, SimpleAuth.config.main.minPasswordChars)
|
||||||
));
|
), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(pass1.length() > SimpleAuth.config.main.maxPasswordChars && SimpleAuth.config.main.maxPasswordChars != -1) {
|
else if(pass1.length() > SimpleAuth.config.main.maxPasswordChars && SimpleAuth.config.main.maxPasswordChars != -1) {
|
||||||
player.sendMessage(new LiteralText(
|
player.sendMessage(new LiteralText(
|
||||||
String.format(SimpleAuth.config.lang.maxPasswordChars, SimpleAuth.config.main.maxPasswordChars)
|
String.format(SimpleAuth.config.lang.maxPasswordChars, SimpleAuth.config.main.maxPasswordChars)
|
||||||
));
|
), false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
String hash = AuthHelper.hashPass(pass1.toCharArray());
|
String hash = AuthHelper.hashPass(pass1.toCharArray());
|
||||||
|
@ -71,10 +71,10 @@ public class RegisterCommand {
|
||||||
SimpleAuth.authenticatePlayer(player, registerSuccess);
|
SimpleAuth.authenticatePlayer(player, registerSuccess);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
player.sendMessage(alreadyRegistered);
|
player.sendMessage(alreadyRegistered, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
player.sendMessage(matchPass);
|
player.sendMessage(matchPass, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class UnregisterCommand {
|
||||||
// Registering the "/unregister" command
|
// Registering the "/unregister" command
|
||||||
dispatcher.register(literal("unregister")
|
dispatcher.register(literal("unregister")
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
ctx.getSource().getPlayer().sendMessage(enterPassword);
|
ctx.getSource().getPlayer().sendMessage(enterPassword, false);
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(argument("password", word())
|
.then(argument("password", word())
|
||||||
|
@ -42,16 +42,16 @@ public class UnregisterCommand {
|
||||||
// Getting the player who send the command
|
// Getting the player who send the command
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
if (SimpleAuth.config.main.enableGlobalPassword) {
|
if (SimpleAuth.config.main.enableGlobalPassword) {
|
||||||
player.sendMessage(cannotUnregister);
|
player.sendMessage(cannotUnregister, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (AuthHelper.checkPass(player.getUuidAsString(), pass.toCharArray()) == 1) {
|
else if (AuthHelper.checkPass(player.getUuidAsString(), pass.toCharArray()) == 1) {
|
||||||
SimpleAuth.deauthenticatePlayer(player);
|
SimpleAuth.deauthenticatePlayer(player);
|
||||||
SimpleAuth.db.deleteUserData(player.getUuidAsString());
|
SimpleAuth.db.deleteUserData(player.getUuidAsString());
|
||||||
player.sendMessage(accountDeleted);
|
player.sendMessage(accountDeleted, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
player.sendMessage(wrongPassword);
|
player.sendMessage(wrongPassword, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class AuthEventHandler {
|
||||||
player.networkHandler.disconnect(new LiteralText(String.format(config.lang.disallowedUsername, regex)));
|
player.networkHandler.disconnect(new LiteralText(String.format(config.lang.disallowedUsername, regex)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking if session is still valid
|
// Checking if session is still valid
|
||||||
String uuid = player.getUuidAsString();
|
String uuid = player.getUuidAsString();
|
||||||
PlayerCache playerCache = deauthenticatedUsers.getOrDefault(uuid, null);
|
PlayerCache playerCache = deauthenticatedUsers.getOrDefault(uuid, null);
|
||||||
|
@ -126,7 +127,7 @@ public class AuthEventHandler {
|
||||||
}
|
}
|
||||||
if(wasSuccessful) {
|
if(wasSuccessful) {
|
||||||
player.teleport(x, y, z);
|
player.teleport(x, y, z);
|
||||||
player.sendMessage(successfulPortalRescue);
|
player.sendMessage(successfulPortalRescue, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,9 +155,9 @@ public class AuthEventHandler {
|
||||||
!isAuthenticated((ServerPlayerEntity) player) &&
|
!isAuthenticated((ServerPlayerEntity) player) &&
|
||||||
!msg.startsWith("/login") &&
|
!msg.startsWith("/login") &&
|
||||||
!msg.startsWith("/register") &&
|
!msg.startsWith("/register") &&
|
||||||
(!config.main.allowChat || msg.startsWith("/"))
|
(!config.experimental.allowChat || msg.startsWith("/"))
|
||||||
) {
|
) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
|
@ -164,7 +165,7 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
// Player movement
|
// Player movement
|
||||||
public static ActionResult onPlayerMove(PlayerEntity player) {
|
public static ActionResult onPlayerMove(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowMovement) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowMovement) {
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
|
@ -172,8 +173,8 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
// Using a block (right-click function)
|
// Using a block (right-click function)
|
||||||
public static ActionResult onUseBlock(PlayerEntity player) {
|
public static ActionResult onUseBlock(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowBlockUse) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowBlockUse) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
|
@ -181,8 +182,8 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
// Punching a block
|
// Punching a block
|
||||||
public static ActionResult onAttackBlock(PlayerEntity player) {
|
public static ActionResult onAttackBlock(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowBlockPunch) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowBlockPunch) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
|
@ -190,8 +191,8 @@ public class AuthEventHandler {
|
||||||
|
|
||||||
// Using an item
|
// Using an item
|
||||||
public static TypedActionResult<ItemStack> onUseItem(PlayerEntity player) {
|
public static TypedActionResult<ItemStack> onUseItem(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowItemUse) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowItemUse) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return TypedActionResult.fail(ItemStack.EMPTY);
|
return TypedActionResult.fail(ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,16 +200,16 @@ public class AuthEventHandler {
|
||||||
}
|
}
|
||||||
// Dropping an item
|
// Dropping an item
|
||||||
public static ActionResult onDropItem(PlayerEntity player) {
|
public static ActionResult onDropItem(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowItemDrop) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowItemDrop) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
// Changing inventory (item moving etc.)
|
// Changing inventory (item moving etc.)
|
||||||
public static ActionResult onTakeItem(PlayerEntity player) {
|
public static ActionResult onTakeItem(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowItemMoving) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowItemMoving) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +217,8 @@ public class AuthEventHandler {
|
||||||
}
|
}
|
||||||
// Attacking an entity
|
// Attacking an entity
|
||||||
public static ActionResult onAttackEntity(PlayerEntity player) {
|
public static ActionResult onAttackEntity(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowEntityPunch) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.experimental.allowEntityPunch) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ public class AuthEventHandler {
|
||||||
// Interacting with entity
|
// Interacting with entity
|
||||||
public static ActionResult onUseEntity(PlayerEntity player) {
|
public static ActionResult onUseEntity(PlayerEntity player) {
|
||||||
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowEntityInteract) {
|
if(!isAuthenticated((ServerPlayerEntity) player) && !config.main.allowEntityInteract) {
|
||||||
player.sendMessage(notAuthenticated());
|
player.sendMessage(notAuthenticated(), false);
|
||||||
return ActionResult.FAIL;
|
return ActionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.samo_lego.simpleauth.mixin;
|
package org.samo_lego.simpleauth.mixin;
|
||||||
|
|
||||||
import net.minecraft.network.packet.c2s.play.*;
|
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||||
|
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
|
||||||
|
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
@ -31,7 +33,7 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void onChatMessage(ChatMessageC2SPacket chatMessageC2SPacket, CallbackInfo ci) {
|
private void onChatMessage(ChatMessageC2SPacket chatMessageC2SPacket, CallbackInfo ci) {
|
||||||
ActionResult result = ChatCallback.EVENT.invoker().onPlayerChat(player, chatMessageC2SPacket);
|
ActionResult result = ChatCallback.EVENT.invoker().onPlayerChat(this.player, chatMessageC2SPacket);
|
||||||
if (result == ActionResult.FAIL) {
|
if (result == ActionResult.FAIL) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +50,7 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
)
|
)
|
||||||
private void onPlayerAction(PlayerActionC2SPacket packet, CallbackInfo ci) {
|
private void onPlayerAction(PlayerActionC2SPacket packet, CallbackInfo ci) {
|
||||||
if(packet.getAction() == SWAP_HELD_ITEMS) {
|
if(packet.getAction() == SWAP_HELD_ITEMS) {
|
||||||
ActionResult result = TakeItemCallback.EVENT.invoker().onTakeItem(player);
|
ActionResult result = TakeItemCallback.EVENT.invoker().onTakeItem(this.player);
|
||||||
if (result == ActionResult.FAIL) {
|
if (result == ActionResult.FAIL) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
@ -65,10 +67,10 @@ public abstract class MixinServerPlayNetworkHandler {
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) {
|
private void onPlayerMove(PlayerMoveC2SPacket playerMoveC2SPacket, CallbackInfo ci) {
|
||||||
ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(player);
|
ActionResult result = PlayerMoveCallback.EVENT.invoker().onPlayerMove(this.player);
|
||||||
if (result == ActionResult.FAIL) {
|
if (result == ActionResult.FAIL) {
|
||||||
// A bit ugly, I know. (we need to update player position)
|
// A bit ugly, I know. (we need to update player position)
|
||||||
player.requestTeleport(player.getX(), player.getY(), player.getZ());
|
this.player.requestTeleport(this.player.getX(), this.player.getY(), this.player.getZ());
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue