Skip to content

Commit

Permalink
Merge pull request #12 from Alujjdnd/potential-op-command-fix
Browse files Browse the repository at this point in the history
Potential op command fix
  • Loading branch information
Flooflez authored Apr 16, 2022
2 parents 955e196 + 0309869 commit e0c9793
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.13.3

# Mod Properties
mod_version = 1.4.0
mod_version = 1.4.1
maven_group = alujjdnd.ngrok.lan
archives_base_name = ngrok-lan-expose-mod

Expand Down
13 changes: 5 additions & 8 deletions src/main/java/alujjdnd/ngrok/lan/command/LanDeopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.server.OperatorEntry;
import net.minecraft.server.OperatorList;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -32,20 +33,16 @@ private static int execute(CommandContext<ServerCommandSource> ctx) throws Comma
NgrokLan.LOGGER.info("/deop called"); //for debugging
Collection<ServerPlayerEntity> targets = EntityArgumentType.getPlayers(ctx, "players");

OperatorList ops = ctx.getSource().getServer().getPlayerManager().getOpList();
PlayerManager playerManager = ctx.getSource().getServer().getPlayerManager();


for (ServerPlayerEntity playerToOp : targets) {
GameProfile gameProfile = playerToOp.getGameProfile();

if (ops.get(gameProfile) != null) {
ops.remove(gameProfile);
//bypassPlayerLimit -> allow player to join when server is full (not sure if it kicks people)
if (playerManager.isOperator(gameProfile)) {
playerManager.removeFromOperators(gameProfile);

TranslatableText message = new TranslatableText("commands.deop.success", gameProfile.getName());

ctx.getSource().sendFeedback(message, true);
mc.inGameHud.getChatHud().addMessage(message);
ctx.getSource().sendFeedback(new TranslatableText("commands.deop.success", gameProfile.getName()), true);
} else {
mc.inGameHud.getChatHud().addMessage(new TranslatableText("commands.deop.failed"));
}
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/alujjdnd/ngrok/lan/command/LanOpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.server.OperatorEntry;
import net.minecraft.server.OperatorList;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -33,22 +34,17 @@ private static int execute(CommandContext<ServerCommandSource> ctx) throws Comma
NgrokLan.LOGGER.info("/op called"); //for debugging
Collection<ServerPlayerEntity> targets = EntityArgumentType.getPlayers(ctx, "players");

OperatorList ops = ctx.getSource().getServer().getPlayerManager().getOpList();
PlayerManager playerManager = ctx.getSource().getServer().getPlayerManager();



for(ServerPlayerEntity playerToOp: targets){
GameProfile gameProfile = playerToOp.getGameProfile();
if(!playerManager.isOperator(gameProfile)){
playerManager.addToOperators(gameProfile);

if(ops.get(gameProfile) == null){
ops.add(new OperatorEntry(gameProfile, 3, false) );
//bypassPlayerLimit -> allow player to join when server is full (not sure if it kicks people)
ctx.getSource().sendFeedback(new TranslatableText("commands.op.success", gameProfile.getName()), true);

TranslatableText message = new TranslatableText("commands.op.success", gameProfile.getName());

ctx.getSource().sendFeedback(message, true);

mc.inGameHud.getChatHud().addMessage(message);
}
else{
mc.inGameHud.getChatHud().addMessage(new TranslatableText("commands.op.fail"));
Expand Down

0 comments on commit e0c9793

Please sign in to comment.