Exposes ban and kick messages
This commit is contained in:
@@ -223,4 +223,19 @@ public class AkarinGlobalConfig {
|
||||
private static void noResponseDoGC() {
|
||||
noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", true);
|
||||
}
|
||||
|
||||
public static String messageKick;
|
||||
private static void messageKick() {
|
||||
messageKick = getString("messages.kick-player", "Kicked by an operator.");
|
||||
}
|
||||
|
||||
public static String messageBan;
|
||||
private static void messageBan() {
|
||||
messageBan = getString("messages.ban-player-name", "You are banned from this server.");
|
||||
}
|
||||
|
||||
public static String messageBanIp;
|
||||
private static void messageBanIp() {
|
||||
messageBanIp = getString("messages.ban-player-ip", "You have been IP banned.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package io.akarin.server.mixin.core;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import io.akarin.server.core.AkarinGlobalConfig;
|
||||
import net.minecraft.server.CommandAbstract;
|
||||
import net.minecraft.server.CommandBan;
|
||||
import net.minecraft.server.CommandException;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.ExceptionUsage;
|
||||
import net.minecraft.server.GameProfileBanEntry;
|
||||
import net.minecraft.server.ICommand;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@Mixin(value = CommandBan.class, remap = false)
|
||||
public class MixinCommandBan {
|
||||
@Overwrite
|
||||
public void execute(MinecraftServer server, ICommandListener sender, String[] args) throws CommandException {
|
||||
if (args.length >= 1 && args[0].length() > 1) {
|
||||
GameProfile profile = server.getUserCache().getProfile(args[0]);
|
||||
|
||||
if (profile == null) {
|
||||
throw new CommandException("commands.ban.failed", new Object[] {args[0]});
|
||||
} else {
|
||||
String message = null;
|
||||
if (args.length >= 2) {
|
||||
// Akarin start - use string
|
||||
message = "";
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
message = message + args[i];
|
||||
}
|
||||
// Akarin end
|
||||
} else {
|
||||
message = AkarinGlobalConfig.messageBan; // Akarin - modify message
|
||||
}
|
||||
|
||||
GameProfileBanEntry entry = new GameProfileBanEntry(profile, (Date) null, sender.getName(), (Date) null, message);
|
||||
|
||||
server.getPlayerList().getProfileBans().add(entry);
|
||||
EntityPlayer entityplayer = server.getPlayerList().getPlayer(args[0]);
|
||||
|
||||
if (entityplayer != null) {
|
||||
entityplayer.playerConnection.disconnect(message);
|
||||
}
|
||||
|
||||
CommandAbstract.a(sender, (ICommand) this, "commands.ban.success", args[0]); // PAIL: notifyCommandListener
|
||||
}
|
||||
} else {
|
||||
throw new ExceptionUsage("commands.ban.usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package io.akarin.server.mixin.core;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import io.akarin.server.core.AkarinGlobalConfig;
|
||||
import net.minecraft.server.CommandAbstract;
|
||||
import net.minecraft.server.CommandBanIp;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.ICommand;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.IpBanEntry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@Mixin(value = CommandBanIp.class, remap = false)
|
||||
public class MixinCommandBanIp {
|
||||
@Overwrite // PAIL: banIp
|
||||
protected void a(MinecraftServer server, ICommandListener sender, String args, @Nullable String banReason) {
|
||||
if (banReason == null) banReason = AkarinGlobalConfig.messageBanIp; // Akarin - modify message
|
||||
IpBanEntry ipbanentry = new IpBanEntry(args, (Date) null, sender.getName(), (Date) null, banReason);
|
||||
|
||||
server.getPlayerList().getIPBans().add(ipbanentry);
|
||||
List<EntityPlayer> withIpPlayers = server.getPlayerList().b(args); // PAIL: getPlayersMatchingAddress
|
||||
String[] banPlayerNames = new String[withIpPlayers.size()];
|
||||
|
||||
for (int i = 0; i < banPlayerNames.length; i++) {
|
||||
EntityPlayer each = withIpPlayers.get(i);
|
||||
banPlayerNames[i] = each.getName();
|
||||
each.playerConnection.disconnect(banReason);
|
||||
}
|
||||
|
||||
if (withIpPlayers.isEmpty()) {
|
||||
CommandAbstract.a(sender, (ICommand) this, "commands.banip.success", args); // PAIL: notifyCommandListener
|
||||
} else {
|
||||
CommandAbstract.a(sender, (ICommand) this, "commands.banip.success.players", args, CommandAbstract.a(banPlayerNames)); // PAIL: notifyCommandListener - joinNiceString
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.akarin.server.mixin.core;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import io.akarin.server.core.AkarinGlobalConfig;
|
||||
import net.minecraft.server.CommandAbstract;
|
||||
import net.minecraft.server.CommandException;
|
||||
import net.minecraft.server.CommandKick;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.ExceptionPlayerNotFound;
|
||||
import net.minecraft.server.ExceptionUsage;
|
||||
import net.minecraft.server.ICommand;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
@Mixin(value = CommandKick.class, remap = false)
|
||||
public class MixinCommandKick {
|
||||
@Overwrite
|
||||
public void execute(MinecraftServer server, ICommandListener sender, String[] args) throws CommandException {
|
||||
if (args.length > 0 && args[0].length() > 1) {
|
||||
EntityPlayer target = server.getPlayerList().getPlayer(args[0]);
|
||||
|
||||
if (target == null) {
|
||||
throw new ExceptionPlayerNotFound("commands.generic.player.notFound", args[0]);
|
||||
} else {
|
||||
if (args.length >= 2) {
|
||||
// Akarin start - use string
|
||||
String message = "";
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
message = message + args[i];
|
||||
}
|
||||
target.playerConnection.disconnect(message);
|
||||
CommandAbstract.a(sender, (ICommand) this, "commands.kick.success.reason", target.getName(), message); // PAIL: notifyCommandListener
|
||||
// Akarin end
|
||||
} else {
|
||||
target.playerConnection.disconnect(AkarinGlobalConfig.messageKick); // Akarin
|
||||
CommandAbstract.a(sender, (ICommand) this, "commands.kick.success", target.getName()); // PAIL: notifyCommandListener
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ExceptionUsage("commands.kick.usage");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import io.akarin.api.Akari;
|
||||
import io.akarin.api.mixin.IMixinChunk;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Chunk;
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import io.akarin.api.Akari;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.PlayerChunk;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user