Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CHANGELOG

## [3.2.0] - 06-07-2025
- Added trident manager, tridents will return to player if despawned.
- MessageBuilder now has a `nomessage` key that returns early.
- UpdateUtil will no longer send a message on join if the message is "nomessage" or " ".
- SpawnCommand is now a TabExecutor (todo: make /spawn %player%).
- Added `hubbly.command.debug` permission
- /spawn can now be configured to teleport after a few seconds
- Added `spawn.timer` in config
- Added `teleporting` and `teleport_cancelled` keys in en.yml
- Added `/hubbly worlds list` command
- OPs no longer always bypass `cancel_events` (you can deny them the permission)
- Fix `/hubbly worlds` `remove` and `check` subcommands
- `/hubbly worlds` `add` and `remove` now reflect in config
- LockChat now properly sends Locale message
- Added Portuguese language (Thank you snowy727. on discord)
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
}

group = "me.calrl"
version = "3.1.1"
version = "3.2.0"
description = "Hubbly"
java.sourceCompatibility = JavaVersion.VERSION_21

Expand Down
17 changes: 15 additions & 2 deletions src/main/java/me/calrl/hubbly/Hubbly.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class Hubbly extends JavaPlugin {
private SubCommandManager subCommandManager;
private HookManager hookManager;
private ManagerFactory managerFactory;
private boolean isLoaded;

public final NamespacedKey FLY_KEY = new NamespacedKey(this, "hubbly.canfly");
private String prefix;
Expand Down Expand Up @@ -145,9 +146,10 @@ private void loadListeners() {
registerListener(new PlayerJoinListener(this));
registerListener(new CommandBlockerListener(this));
registerListener(new ForceinvListener(this), "player.forceinventory");
registerListener(new ChatListener(this), "blocked_words.enabled");
registerListener(new ChatListener(this));
registerListener(new InventoryListener(this));
registerListener(new XPListener(this), "player.experience.enabled");
registerListener(new PlayerMoveListener(this));
}

@Override
Expand Down Expand Up @@ -210,6 +212,7 @@ public void onEnable() {
}

logger.info("Hubbly has been enabled!");
this.isLoaded = true;
}

@Override
Expand Down Expand Up @@ -324,7 +327,9 @@ public void setHookManager(HookManager hookManager) {
this.hookManager = hookManager;
}
public ManagerFactory getManagerFactory() { return this.managerFactory; }

public static void setInstance(Hubbly hubbly) {
instance = hubbly;
}

public static void enableTestMode() {
testMode = true;
Expand All @@ -334,4 +339,12 @@ public static boolean isTestMode() {
return testMode;
}

public boolean isLoaded() {
return isLoaded;
}

public void setLoaded(boolean loaded) {
isLoaded = loaded;
}

}
13 changes: 8 additions & 5 deletions src/main/java/me/calrl/hubbly/commands/LockChatCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,24 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
lockChat = plugin.getLockChat();
String key;
if(lockChat.getChatLock()) {
key = "messages.chat_unlocked";
String message = plugin.getConfig().getString("messages.chat_unlocked", "Chat has been unlocked by:");
key = "chat_unlocked";
String message = plugin.getConfig().getString(key, "Chat has been unlocked by:");
if(message.contains("%player%")) {
message = message.replace("%player%", commandSender.getName());
}
} else {
key = "messages.chat_locked";
String message = plugin.getConfig().getString("messages.chat_locked", "Chat has been locked by:");
key = "chat_locked";
String message = plugin.getConfig().getString(key, "Chat has been locked by:");
if(message.contains("%player%")) {
message = message.replace("%player%", commandSender.getName());
}
}
DisabledWorlds disabledWorlds = plugin.getDisabledWorldsManager();
MessageBuilder builder = new MessageBuilder(plugin)
.setKey(key);
.setPlayer(commandSender)
.setKey(key)
.replace("%player_name%", commandSender.getName());


for(Player p : Bukkit.getOnlinePlayers()) {
if(disabledWorlds.inDisabledWorld(p.getWorld())) {
Expand Down
32 changes: 24 additions & 8 deletions src/main/java/me/calrl/hubbly/commands/SpawnCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@
package me.calrl.hubbly.commands;

import me.calrl.hubbly.Hubbly;
import me.calrl.hubbly.enums.LocaleKey;
import me.calrl.hubbly.events.HubblySpawnEvent;
import me.calrl.hubbly.interfaces.CustomItem;
import me.calrl.hubbly.managers.SpawnTaskManager;
import me.calrl.hubbly.tasks.spawn.SpawnTeleportTask;
import me.calrl.hubbly.utils.MessageBuilder;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SpawnCommand implements CommandExecutor {
public class SpawnCommand implements TabExecutor {

private final Hubbly plugin;
private FileConfiguration config;
Expand All @@ -46,12 +50,15 @@ public SpawnCommand(Hubbly plugin) {
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
config = plugin.getConfig();


if(!(sender instanceof Player player)) {
sender.sendMessage(ChatColor.RED + config.getString("messages.no_console"));
return true;
}

Location spawn = plugin.getUtils().getSpawn();
HubblySpawnEvent event = new HubblySpawnEvent(player, spawn);
Bukkit.getPluginManager().callEvent(event);
Expand All @@ -64,13 +71,22 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
return true;
}

if(!event.isCancelled()) {
Bukkit.getScheduler().runTaskLater(plugin, ()-> {
player.teleport(spawn);
}, 1L);

if(!event.isCancelled()) {
long timer = plugin.getConfig().getLong("spawn.timer");
SpawnTaskManager manager = plugin.getManagerFactory().getSpawnTaskManager();
new SpawnTeleportTask(plugin, player, timer).start();
}

return true;
}

@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (!(sender instanceof Player player)) return null;

final List<String> completions = new ArrayList<>();

return completions;
}
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
package me.calrl.hubbly.commands.subcommands.worlds;
package me.calrl.hubbly.commands.debug;

import me.calrl.hubbly.Hubbly;
import me.calrl.hubbly.enums.Permissions;
import me.calrl.hubbly.interfaces.SubCommand;
import me.calrl.hubbly.enums.Result;
import me.calrl.hubbly.utils.CommandNode;
import me.calrl.hubbly.utils.MessageBuilder;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.*;

public class WorldsCommand extends CommandNode {
import java.util.List;

public class DebugCommand extends CommandNode {
private Hubbly plugin;
public WorldsCommand(Hubbly plugin) {
super("worlds");
public DebugCommand(Hubbly plugin) {
super("debug");
this.plugin = plugin;

this.loadNodes();
}

private void loadNodes() {
addChild("add", new AddCommand(plugin));
addChild("remove", new RemoveCommand(plugin));
addChild("check", new CheckCommand(plugin));
}

@Override
public void execute(CommandSender sender, String[] args, int depth) {
if(!sender.hasPermission(Permissions.COMMAND_WORLDS.getPermission())) {
public Result execute(CommandSender sender, String[] args, int depth) {
if(!sender.hasPermission(Permissions.COMMAND_DEBUG.getPermission())) {
new MessageBuilder(plugin).setKey("no_permission_command").setPlayer(sender).send();
return;
return Result.NO_PERMISSION;
}

if (args.length > depth) {
CommandNode child = children.get(args[depth].toLowerCase());
if (child != null) {
child.execute(sender, args, depth + 1);
return;
return Result.SUCCESS;
}
}

new MessageBuilder(plugin)
.setKey("subcommands.worlds.usage")
.setKey("subcommands.debug.usage")
.setPlayer(sender)
.send();
return Result.USAGE_PRINTED;
}

private void loadNodes() {

}

@Override
public List<String> tabComplete(CommandSender sender, String[] args, int depth) {
return super.tabComplete(sender, args, depth);
}

}
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
package me.calrl.hubbly.commands.subcommands.worlds;
package me.calrl.hubbly.commands.worlds;

import me.calrl.hubbly.Hubbly;
import me.calrl.hubbly.enums.Permissions;
import me.calrl.hubbly.interfaces.SubCommand;
import me.calrl.hubbly.enums.Result;
import me.calrl.hubbly.utils.CommandNode;
import me.calrl.hubbly.utils.MessageBuilder;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.List;

public class AddCommand extends CommandNode {
public class AddWorldCommand extends CommandNode {
private Hubbly plugin;
public AddCommand(Hubbly plugin) {
public AddWorldCommand(Hubbly plugin) {
super("add");
this.plugin = plugin;
}

@Override
public void execute(CommandSender sender, String[] args, int depth) {
public Result execute(CommandSender sender, String[] args, int depth) {
if(!sender.hasPermission(Permissions.COMMAND_WORLDS_ADD.getPermission())) {
new MessageBuilder(plugin).setKey("no_permission_command").setPlayer(sender).send();
return;
return Result.NO_PERMISSION;
}

if(args.length <= depth) {
new MessageBuilder(plugin).setKey("subcommands.worlds.add.usage").setPlayer(sender).send();
return;
return Result.USAGE_PRINTED;
}

String worldName = args[depth];
Expand All @@ -41,7 +39,7 @@ public void execute(CommandSender sender, String[] args, int depth) {
.setPlayer(sender)
.replace("%world%", worldName)
.send();
return;
return Result.FAILURE;
}

plugin.getDisabledWorldsManager().addWorld(world);
Expand All @@ -51,6 +49,7 @@ public void execute(CommandSender sender, String[] args, int depth) {
.setPlayer(sender)
.replace("%world%", world.getName())
.send();
return Result.SUCCESS;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
package me.calrl.hubbly.commands.subcommands.worlds;
package me.calrl.hubbly.commands.worlds;

import me.calrl.hubbly.Hubbly;
import me.calrl.hubbly.enums.Permissions;
import me.calrl.hubbly.interfaces.SubCommand;
import me.calrl.hubbly.enums.Result;
import me.calrl.hubbly.utils.CommandNode;
import me.calrl.hubbly.utils.MessageBuilder;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.List;

public class CheckCommand extends CommandNode {
public class CheckWorldCommand extends CommandNode {
private final Hubbly plugin;
public CheckCommand(Hubbly plugin) {
super("add");
public CheckWorldCommand(Hubbly plugin) {
super("check");
this.plugin = plugin;
}

@Override
public void execute(CommandSender sender, String[] args, int depth) {
public Result execute(CommandSender sender, String[] args, int depth) {
if(!sender.hasPermission(Permissions.COMMAND_WORLDS_CHECK.getPermission())) {
new MessageBuilder(plugin).setKey("no_permission_command").setPlayer(sender).send();
return;
return Result.NO_PERMISSION;
}

if(args.length <= depth) {
new MessageBuilder(plugin).setKey("subcommands.worlds.check.usage").setPlayer(sender).send();
return;
return Result.USAGE_PRINTED;
}

String worldName = args[depth];
Expand All @@ -41,7 +39,7 @@ public void execute(CommandSender sender, String[] args, int depth) {
.setPlayer(sender)
.replace("%world%", worldName)
.send();
return;
return Result.FAILURE;
}

MessageBuilder builder = new MessageBuilder(plugin);
Expand All @@ -51,13 +49,14 @@ public void execute(CommandSender sender, String[] args, int depth) {
builder.setKey("subcommands.worlds.check.disabled")
.setPlayer(sender)
.replace("%world%", world.getName()).send();
return;
return Result.SUCCESS;
}

builder.setKey("subcommands.worlds.check.enabled")
.setPlayer(sender)
.replace("%world%", world.getName()).send();

return Result.SUCCESS;
}

@Override
Expand Down
Loading