Force skip command + 1.6.2
This commit is contained in:
parent
c5d76a70a2
commit
4d158872d3
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>xyz.nkomarn</groupId>
|
||||
<artifactId>Harbor</artifactId>
|
||||
<version>1.6.2-SNAPSHOT</version>
|
||||
<version>1.6.2</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.plugin.PluginManager;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.nkomarn.harbor.command.ForceSkipCommand;
|
||||
import xyz.nkomarn.harbor.command.HarborCommand;
|
||||
import xyz.nkomarn.harbor.listener.BedListener;
|
||||
import xyz.nkomarn.harbor.listener.PlayerListener;
|
||||
|
@ -44,6 +45,7 @@ public class Harbor extends JavaPlugin {
|
|||
).forEach(listener -> pluginManager.registerEvents(listener, this));
|
||||
|
||||
getCommand("harbor").setExecutor(new HarborCommand(this));
|
||||
getCommand("forceskip").setExecutor(new ForceSkipCommand(this));
|
||||
|
||||
if (essentials == null) {
|
||||
getLogger().info("Essentials not present- registering fallback AFK detection system.");
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package xyz.nkomarn.harbor.command;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nkomarn.harbor.Harbor;
|
||||
import xyz.nkomarn.harbor.task.Checker;
|
||||
import xyz.nkomarn.harbor.util.Config;
|
||||
|
||||
public class ForceSkipCommand implements CommandExecutor {
|
||||
|
||||
private final Harbor harbor;
|
||||
private final Config config;
|
||||
|
||||
public ForceSkipCommand(@NotNull Harbor harbor) {
|
||||
this.harbor = harbor;
|
||||
this.config = harbor.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(config.getPrefix() + "This command can only be used by a player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
World world = player.getWorld();
|
||||
Checker checker = harbor.getChecker();
|
||||
|
||||
if (checker.isSkipping(world)) {
|
||||
sender.sendMessage(config.getPrefix() + "This world's time is already being accelerated.");
|
||||
} else {
|
||||
sender.sendMessage(config.getPrefix() + "Forcing night skip in your world.");
|
||||
checker.forceSkip(world);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,64 +1,39 @@
|
|||
package xyz.nkomarn.harbor.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nkomarn.harbor.Harbor;
|
||||
import xyz.nkomarn.harbor.task.Checker;
|
||||
import xyz.nkomarn.harbor.util.Config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HarborCommand implements TabExecutor {
|
||||
|
||||
private final Harbor harbor;
|
||||
private final Config config;
|
||||
|
||||
public HarborCommand(@NotNull Harbor harbor) {
|
||||
this.harbor = harbor;
|
||||
this.config = harbor.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
Config config = harbor.getConfiguration();
|
||||
String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("messages.miscellaneous.chat-prefix"));
|
||||
|
||||
if (args.length < 1 || !sender.hasPermission("harbor.admin")) {
|
||||
sender.sendMessage(prefix + "Harbor " + harbor.getVersion() + " by TechToolbox (@nkomarn).");
|
||||
sender.sendMessage(config.getPrefix() + "Harbor " + harbor.getVersion() + " by TechToolbox (@nkomarn).");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
config.reload();
|
||||
sender.sendMessage(prefix + "Reloaded configuration.");
|
||||
sender.sendMessage(config.getPrefix() + "Reloaded configuration.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("forceskip")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(prefix + "This command can only be used by a player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
World world = player.getWorld();
|
||||
Checker checker = harbor.getChecker();
|
||||
|
||||
if (checker.isSkipping(world)) {
|
||||
sender.sendMessage(prefix + "This world's time is already being accelerated.");
|
||||
} else {
|
||||
sender.sendMessage(prefix + "Forcing night skip in your world.");
|
||||
checker.forceSkip(world);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(prefix + config.getString("messages.miscellaneous.unrecognized-command"));
|
||||
sender.sendMessage(config.getPrefix() + config.getString("messages.miscellaneous.unrecognized-command"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,6 +47,6 @@ public class HarborCommand implements TabExecutor {
|
|||
return null;
|
||||
}
|
||||
|
||||
return Arrays.asList("forceskip", "reload");
|
||||
return Collections.singletonList("reload");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package xyz.nkomarn.harbor.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import xyz.nkomarn.harbor.Harbor;
|
||||
|
@ -32,6 +33,15 @@ public class Config {
|
|||
harbor.reloadConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prefix for Harbor messages.
|
||||
* @return Harbor message prefix.
|
||||
*/
|
||||
@NotNull
|
||||
public String getPrefix() {
|
||||
return ChatColor.translateAlternateColorCodes('&', getString("messages.miscellaneous.chat-prefix"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a boolean from the configuration
|
||||
* if location is not found, false is returned
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
name: Harbor
|
||||
description: Harbor is a Spigot plugin that redefines how sleep works in your server, making it easier for all the online players to get in bed quickly and skip through the night!
|
||||
main: xyz.nkomarn.harbor.Harbor
|
||||
version: 1.6.2-SNAPSHOT
|
||||
author: TechToolbox (@nkomarn)
|
||||
website: https://nkomarn.xyz
|
||||
softdepend: [Essentials]
|
||||
api-version: 1.14
|
||||
name: "Harbor"
|
||||
description: "Harbor redefines how sleep works in your server, making it easier for all the online players to get in bed quickly and skip through the night!"
|
||||
main: "xyz.nkomarn.harbor.Harbor"
|
||||
author: "TechToolbox (@nkomarn)"
|
||||
website: "https://nkomarn.xyz"
|
||||
version: "1.6.2"
|
||||
api-version: "1.14"
|
||||
|
||||
softdepend:
|
||||
- "Essentials"
|
||||
|
||||
commands:
|
||||
harbor:
|
||||
description: "Base command for Harbor!"
|
||||
usage: "/harbor [subcommand]"
|
||||
description: "Base command for Harbor."
|
||||
usage: "/harbor <subcommand>"
|
||||
forceskip:
|
||||
description: "Allows players to accelerate the night of their current world."
|
||||
permission: "harbor.forceskip"
|
||||
|
||||
permissions:
|
||||
harbor.ignored:
|
||||
default: false
|
||||
harbor.admin:
|
||||
default: op
|
||||
default: op
|
||||
harbor.forceskip:
|
||||
description: "Permits usage of the /forceskip command."
|
||||
default: op
|
||||
harbor.ignored:
|
||||
default: false
|
Loading…
Reference in New Issue