Skip to content

Commit

Permalink
Make Nukkit more kotlin friendly: Commands
Browse files Browse the repository at this point in the history
  • Loading branch information
xISRAPILx committed Aug 19, 2022
1 parent 9739275 commit 52ecf3a
Show file tree
Hide file tree
Showing 47 changed files with 98 additions and 46 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
<version>${jline.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.nukkit.utils.TextFormat;
import co.aikar.timings.Timing;
import co.aikar.timings.Timings;
import org.jetbrains.annotations.NotNull;

import java.util.*;

Expand Down Expand Up @@ -135,7 +136,7 @@ public Map<String, CommandOverload> getOverloads() {
return this.commandData.overloads;
}

public abstract boolean execute(CommandSender sender, String commandLabel, String[] args);
public abstract boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args);

public String getName() {
return name;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/FormattedCommandAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.MainLogger;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -27,7 +28,7 @@ public FormattedCommandAlias(String alias, List<String> formatStrings) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
boolean result = false;
ArrayList<String> commands = new ArrayList<>();
for (String formatString : formatStrings) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/PluginCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

/**
* author: MagicDroidX
Expand All @@ -21,7 +22,7 @@ public PluginCommand(String name, T owner) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.owningPlugin.isEnabled()) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/BanCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.event.player.PlayerKickEvent;
import cn.nukkit.lang.TranslationContainer;
import org.jetbrains.annotations.NotNull;

/**
* author: MagicDroidX
Expand All @@ -26,7 +27,7 @@ public BanCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/BanIpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.nbt.NBTIO;
import cn.nukkit.nbt.tag.CompoundTag;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -40,7 +41,7 @@ public BanIpCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/BanListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.permission.BanEntry;
import cn.nukkit.permission.BanList;
import org.jetbrains.annotations.NotNull;

import java.util.Iterator;

Expand All @@ -24,7 +25,7 @@ public BanListCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import cn.nukkit.utils.HastebinUtility;
import cn.nukkit.utils.MainLogger;
import cn.nukkit.utils.Utils;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
Expand All @@ -22,7 +24,7 @@ public DebugPasteCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.nukkit.command.data.CommandParamType;
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/12 by xtypr.
Expand All @@ -26,7 +27,7 @@ public DefaultGamemodeCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/DeopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/12 by xtypr.
Expand All @@ -23,7 +24,7 @@ public DeopCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.network.protocol.SetDifficultyPacket;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;

Expand All @@ -30,7 +31,7 @@ public DifficultyCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/EffectCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cn.nukkit.potion.InstantEffect;
import cn.nukkit.utils.ServerException;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
Expand Down Expand Up @@ -48,7 +49,7 @@ public EffectCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/EnchantCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created by Pub4Game on 23.01.2016.
Expand Down Expand Up @@ -38,7 +39,7 @@ public EnchantCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/13 by xtypr.
Expand Down Expand Up @@ -36,7 +37,7 @@ public GamemodeCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.level.GameRule;
import cn.nukkit.level.GameRules;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -73,7 +74,7 @@ public GameruleCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.nukkit.level.Level;
import cn.nukkit.math.NukkitMath;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/11 by xtypr.
Expand All @@ -18,7 +19,7 @@ public GarbageCollectorCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/GiveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.nukkit.item.Item;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/12/9 by xtypr.
Expand Down Expand Up @@ -40,7 +41,7 @@ public GiveCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

import java.util.Map;
import java.util.TreeMap;
Expand All @@ -27,7 +28,7 @@ public HelpCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/KickCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.nukkit.event.player.PlayerKickEvent;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/11 by xtypr.
Expand All @@ -26,7 +27,7 @@ public KickCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/KillCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.level.Level;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

import java.util.StringJoiner;

Expand All @@ -32,7 +33,7 @@ public KillCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.nukkit.Player;
import cn.nukkit.command.CommandSender;
import cn.nukkit.lang.TranslationContainer;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/11 by xtypr.
Expand All @@ -17,7 +18,7 @@ public ListCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/MeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/12 by xtypr.
Expand All @@ -23,7 +24,7 @@ public MeCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/cn/nukkit/command/defaults/OpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.nukkit.command.data.CommandParameter;
import cn.nukkit.lang.TranslationContainer;
import cn.nukkit.utils.TextFormat;
import org.jetbrains.annotations.NotNull;

/**
* Created on 2015/11/12 by xtypr.
Expand All @@ -25,7 +26,7 @@ public OpCommand(String name) {
}

@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
Expand Down
Loading

0 comments on commit 52ecf3a

Please sign in to comment.