Skip to content

Commit 1f1a2ef

Browse files
committed
Remove some unnecessary/outdated code from core plugin components
1 parent c672a13 commit 1f1a2ef

File tree

5 files changed

+7
-64
lines changed

5 files changed

+7
-64
lines changed

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
* text=auto
1+
* text=auto eol=lf
22

33
# Force Batch files to CRLF
4-
*.bat text=crlf
4+
*.bat eol=crlf -text
55

66
# Java sources
77
*.java text diff=java

craftbook-bukkit/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ dependencies {
4343
"api"(libs.worldguard.bukkit) { isTransitive = false }
4444

4545
"localImplementation"(libs.paperApi) {
46-
exclude("org.slf4j", "slf4j-api")
4746
exclude("junit", "junit")
4847
}
4948
"implementation"(libs.vaultApi) { isTransitive = false }

craftbook-bukkit/doctools/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ repositories {
3636

3737
dependencies {
3838
"implementation"(project(":craftbook-bukkit"))
39-
"implementation"(libs.paperApi) {
40-
exclude(group = "org.slf4j", module = "slf4j-api")
41-
}
39+
"implementation"(libs.paperApi);
4240
"implementation"("com.sk89q.worldedit:worldedit-cli:${libs.versions.worldedit.get()}")
4341
}

craftbook-bukkit/src/main/java/org/enginehub/craftbook/bukkit/CraftBookPlugin.java

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
package org.enginehub.craftbook.bukkit;
1717

1818
import com.google.common.base.Joiner;
19-
import com.sk89q.minecraft.util.commands.CommandException;
2019
import com.sk89q.wepif.PermissionsResolverManager;
2120
import com.sk89q.worldedit.extension.platform.Actor;
2221
import com.sk89q.worldedit.internal.command.CommandUtil;
22+
import net.kyori.adventure.text.Component;
23+
import net.kyori.adventure.text.format.NamedTextColor;
2324
import org.bukkit.Bukkit;
24-
import org.bukkit.ChatColor;
2525
import org.bukkit.command.Command;
2626
import org.bukkit.command.CommandSender;
27-
import org.bukkit.command.ConsoleCommandSender;
2827
import org.bukkit.entity.Player;
2928
import org.bukkit.event.EventHandler;
3029
import org.bukkit.event.EventPriority;
@@ -163,7 +162,7 @@ public void playerJoin(PlayerJoinEvent event) {
163162
}
164163

165164
if (!foundAMech) {
166-
event.getPlayer().sendMessage(ChatColor.RED + "[CraftBook] Warning! You have no mechanics enabled, the plugin will appear to do nothing until a feature is enabled!");
165+
event.getPlayer().sendMessage(Component.text("[CraftBook] Warning! You have no mechanics enabled, the plugin will appear to do nothing until a feature is enabled!", NamedTextColor.RED));
167166
}
168167
}
169168
}, this);
@@ -179,7 +178,7 @@ public void playerJoin(PlayerJoinEvent event) {
179178

180179
if (!foundAMech) {
181180
Bukkit.getScheduler().runTaskTimer(this,
182-
() -> getLogger().warning(ChatColor.RED + "Warning! You have no mechanics enabled, the plugin will appear to do nothing until a feature is enabled!"), 20L, 20 * 60 * 5);
181+
() -> getComponentLogger().warn(Component.text("Warning! You have no mechanics enabled, the plugin will appear to do nothing until a feature is enabled!", NamedTextColor.RED)), 20L, 20 * 60 * 5);
183182
}
184183
}
185184

@@ -306,37 +305,6 @@ public String[] getGroups(Player player) {
306305
}
307306
}
308307

309-
/**
310-
* Gets the name of a command sender. This is a unique name and this
311-
* method should never return a "display name".
312-
*
313-
* @param sender The sender to get the name of
314-
* @return The unique name of the sender.
315-
*/
316-
public String toUniqueName(CommandSender sender) {
317-
if (sender instanceof ConsoleCommandSender) {
318-
return "*Console*";
319-
} else {
320-
return sender.getName();
321-
}
322-
}
323-
324-
/**
325-
* Gets the name of a command sender. This play be a display name.
326-
*
327-
* @param sender The CommandSender to get the name of.
328-
* @return The name of the given sender
329-
*/
330-
public String toName(CommandSender sender) {
331-
if (sender instanceof ConsoleCommandSender) {
332-
return "*Console*";
333-
} else if (sender instanceof Player) {
334-
return ((Player) sender).getDisplayName();
335-
} else {
336-
return sender.getName();
337-
}
338-
}
339-
340308
/**
341309
* Checks permissions.
342310
*
@@ -363,22 +331,6 @@ public boolean hasPermission(CommandSender sender, String perm) {
363331
return false;
364332
}
365333

366-
/**
367-
* Checks to see if the sender is a player, otherwise throw an exception.
368-
*
369-
* @param sender The {@link CommandSender} to check
370-
* @return {@code sender} casted to a player
371-
* @throws CommandException if {@code sender} isn't a {@link Player}
372-
*/
373-
public static Player checkPlayer(CommandSender sender)
374-
throws CommandException {
375-
if (sender instanceof Player) {
376-
return (Player) sender;
377-
} else {
378-
throw new CommandException("A player is expected.");
379-
}
380-
}
381-
382334
public Actor wrapCommandSender(CommandSender sender) {
383335
if (sender instanceof Player) {
384336
return wrapPlayer((Player) sender);

craftbook-core/src/main/java/org/enginehub/craftbook/PlatformCommandManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ public void handleCommand(Actor actor, String arguments) {
186186
.build());
187187
}
188188
} catch (CommandExecutionException e) {
189-
// FIXME: Put this in an exception converter.
190-
if (e.getCause() instanceof com.sk89q.minecraft.util.commands.CommandException) {
191-
actor.printError(TextComponent.of(e.getCause().getMessage()));
192-
return;
193-
}
194-
195189
handleUnknownException(actor, e.getCause());
196190
} catch (CommandException e) {
197191
actor.printError(TextComponent.builder("")

0 commit comments

Comments
 (0)