Compare commits
6 Commits
53c259622f
...
392b6cc4db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
392b6cc4db | ||
|
|
9c6e2f02fb | ||
|
|
e33fdd71f7 | ||
|
|
960729e0c7 | ||
|
|
f5ae50ec34 | ||
|
|
9fe2630f42 |
|
|
@ -1,12 +1,14 @@
|
|||
import java.io.ByteArrayOutputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.net.URL
|
||||
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
import net.minecrell.pluginyml.paper.PaperPluginDescription
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("xyz.jpenilla.run-paper") version "2.3.0"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.8.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
@ -19,7 +21,7 @@ dependencies {
|
|||
}
|
||||
|
||||
group = "com.alttd.altitudetag"
|
||||
version = System.getenv("BUILD_NUMBER") ?: gitCommit()
|
||||
version = System.getenv("BUILD_NUMBER") ?: "DEV-BUILD"
|
||||
description = "AltitudeTag"
|
||||
|
||||
publishing {
|
||||
|
|
@ -82,21 +84,37 @@ fun download(link: String, path: File) {
|
|||
}
|
||||
}
|
||||
|
||||
fun gitCommit(): String {
|
||||
// val os = ByteArrayOutputStream()
|
||||
// project.exec {
|
||||
// commandLine = "git rev-parse --short HEAD".split(" ")
|
||||
// standardOutput = os
|
||||
// }
|
||||
// return String(os.toByteArray()).trim()
|
||||
return "FIXME"
|
||||
}
|
||||
|
||||
bukkit {
|
||||
paper {
|
||||
name = rootProject.name
|
||||
main = "$group.${rootProject.name}"
|
||||
bootstrapper = "$group.${rootProject.name}Bootstrap"
|
||||
version = "${rootProject.version}"
|
||||
apiVersion = "1.21"
|
||||
authors = listOf("Michael Ziluck", "destro174")
|
||||
depend = listOf("DecentHolograms")
|
||||
serverDependencies {
|
||||
register("DecentHolograms") {
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
}
|
||||
permissions {
|
||||
register("tag.play") {
|
||||
description = "Base permission for the ${rootProject.name} plugin."
|
||||
default = BukkitPluginDescription.Permission.Default.FALSE
|
||||
}
|
||||
register("tag.commands.admin") {
|
||||
description = "Admin permission for the ${rootProject.name} plugin."
|
||||
default = BukkitPluginDescription.Permission.Default.FALSE
|
||||
children = listOf(
|
||||
"tag.play"
|
||||
)
|
||||
}
|
||||
register("tag.commands.admin.location") {
|
||||
description = "Admin permission for setting the scoreboard location."
|
||||
default = BukkitPluginDescription.Permission.Default.FALSE
|
||||
children = listOf(
|
||||
"tag.play",
|
||||
"tag.commands.admin"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,23 @@
|
|||
package com.alttd.altitudetag;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.alttd.altitudeapi.commands.CommandHandler;
|
||||
import com.alttd.altitudeapi.commands.CommandLang;
|
||||
import com.alttd.altitudetag.commands.TagCommand;
|
||||
import com.alttd.altitudetag.configuration.Config;
|
||||
import com.alttd.altitudetag.configuration.Lang;
|
||||
import com.alttd.altitudetag.listeners.ConnectionListener;
|
||||
import com.alttd.altitudetag.listeners.InteractListener;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -48,13 +51,6 @@ public class AltitudeTag extends JavaPlugin
|
|||
|
||||
reloadConfiguration();
|
||||
|
||||
// update the CommandLang values
|
||||
CommandLang.NO_PERMISSION.setValue(Lang.NO_PERMS.getRawMessage()[0]);
|
||||
CommandLang.HEADER_FOOTER.setValue(Lang.HEADER_FOOTER.getRawMessage()[0]);
|
||||
CommandLang.NO_SUBS.setValue(Lang.NO_SUBS.getRawMessage()[0]);
|
||||
CommandLang.ONLY_PLAYERS.setValue(Lang.ONLY_PLAYERS.getRawMessage()[0]);
|
||||
CommandLang.USAGE_FORMAT.setValue(Lang.USAGE.getRawMessage()[0]);
|
||||
|
||||
try
|
||||
{
|
||||
TagConnection.initialize();
|
||||
|
|
@ -71,11 +67,18 @@ public class AltitudeTag extends JavaPlugin
|
|||
|
||||
NotificationHandler.loadBossBar();
|
||||
|
||||
CommandHandler.initialize();
|
||||
CommandHandler.getInstance().registerCommand(new TagCommand(), this);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new ConnectionListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new InteractListener(), this);
|
||||
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
LifecycleEventManager<Plugin> manager = this.getLifecycleManager();
|
||||
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
||||
final Commands commands = event.registrar();
|
||||
commands.register(new TagCommand().command(), "Tag, you're it!", List.of("tags", "tagging", "tagger"));
|
||||
});
|
||||
}
|
||||
|
||||
private static void reloadConfiguration()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.alttd.altitudetag;
|
||||
|
||||
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class AltitudeTagBootstrap implements PluginBootstrap {
|
||||
|
||||
@Override
|
||||
public void bootstrap(BootstrapContext context) {}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.alttd.altitudetag;
|
||||
|
||||
public enum Permission
|
||||
{
|
||||
COMMAND_ADMIN("tag.commands.admin"),
|
||||
COMMAND_ADMIN_LOCATION("tag.commands.admin.location");
|
||||
|
||||
private String permission;
|
||||
|
||||
private Permission(String permission)
|
||||
{
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public String getPermission()
|
||||
{
|
||||
return permission;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.alttd.altitudetag.commands;
|
||||
|
||||
import com.alttd.altitudeapi.commands.ValidBaseCommand;
|
||||
import com.alttd.altitudetag.Permission;
|
||||
import com.alttd.altitudetag.commands.admin.TagAdminLocationCommand;
|
||||
|
||||
public class TagAdminCommand extends ValidBaseCommand
|
||||
{
|
||||
protected TagAdminCommand()
|
||||
{
|
||||
super("admin", "Management commands", Permission.COMMAND_ADMIN.getPermission(), new String[]{ "a" });
|
||||
|
||||
addSubCommand(new TagAdminLocationCommand());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +1,55 @@
|
|||
package com.alttd.altitudetag.commands;
|
||||
|
||||
import com.alttd.altitudeapi.commands.ValidBaseCommand;
|
||||
import com.alttd.altitudetag.AltitudeTag;
|
||||
import com.alttd.altitudetag.Leaderboard;
|
||||
import com.alttd.altitudetag.configuration.Config;
|
||||
import com.alttd.altitudetag.configuration.Lang;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TagCommand extends ValidBaseCommand
|
||||
public class TagCommand
|
||||
{
|
||||
public TagCommand()
|
||||
{
|
||||
super("tag", "Tag, you're it!", "tag.play", new String[]{ "tags", "tagging", "tagger" });
|
||||
public @NotNull LiteralCommandNode<CommandSourceStack> command() {
|
||||
final LiteralArgumentBuilder<CommandSourceStack> builder =
|
||||
Commands.literal("tag")
|
||||
.requires(commandSourceStack ->
|
||||
commandSourceStack.getSender() instanceof Player player &&
|
||||
player.hasPermission("tag.play")
|
||||
)
|
||||
.then(Commands.literal("admin")
|
||||
.requires(commandSourceStack ->
|
||||
commandSourceStack.getSender() instanceof Player player &&
|
||||
player.hasPermission("tag.commands.admin")
|
||||
)
|
||||
.then(Commands.literal("location")
|
||||
.requires(commandSourceStack ->
|
||||
commandSourceStack.getSender() instanceof Player player &&
|
||||
player.hasPermission("tag.commands.admin.location")
|
||||
)
|
||||
.executes((source) -> {
|
||||
if (!(source.getSource().getSender() instanceof Player player))
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
||||
addSubCommand(new TagAdminCommand());
|
||||
}
|
||||
Leaderboard.setLocation(player.getLocation());
|
||||
Lang.SET_LEADERBOARD_LOCATION.send(player);
|
||||
|
||||
@Override
|
||||
public void help(CommandSender sender, String[] label)
|
||||
{
|
||||
if (sender.hasPermission(getSubCommand("admin").getPermission()))
|
||||
{
|
||||
sender.sendMessage(Lang.renderString(Config.NOTIFICATION_GLOBAL_BOSS_BAR_MESSAGE.getValue(),
|
||||
"{player}", Bukkit.getOfflinePlayer(AltitudeTag.getTagger()).getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
super.help(sender, label);
|
||||
}
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
)
|
||||
)
|
||||
.executes((source) -> {
|
||||
source.getSource().getSender()
|
||||
.sendMessage(Lang.renderString(Config.NOTIFICATION_GLOBAL_BOSS_BAR_MESSAGE.getValue(),
|
||||
"{player}", Bukkit.getOfflinePlayer(AltitudeTag.getTagger()).getName()));
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
;
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package com.alttd.altitudetag.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alttd.altitudeapi.commands.CommandArgument;
|
||||
import com.alttd.altitudeapi.commands.ValidCommand;
|
||||
import com.alttd.altitudetag.Leaderboard;
|
||||
import com.alttd.altitudetag.Permission;
|
||||
import com.alttd.altitudetag.configuration.Lang;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TagAdminLocationCommand extends ValidCommand
|
||||
{
|
||||
public TagAdminLocationCommand()
|
||||
{
|
||||
super("location",
|
||||
"Sets the leaderboard location",
|
||||
Permission.COMMAND_ADMIN_LOCATION.getPermission(),
|
||||
true,
|
||||
new String[]{ "loc", "setloc", "setlocation", "leaderboard", "board" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRun(CommandSender commandSender, String[] strings, List<CommandArgument<?>> list)
|
||||
{
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
Leaderboard.setLocation(player.getLocation());
|
||||
|
||||
Lang.SET_LEADERBOARD_LOCATION.send(player);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.alttd.altitudetag.commands.parsers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alttd.altitudeapi.commands.CommandHandler;
|
||||
import com.alttd.altitudeapi.commands.Parser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class StringParser implements Parser<String>
|
||||
{
|
||||
@Override
|
||||
public String parseArgument(CommandSender sender, String[] label, String rawArgument)
|
||||
{
|
||||
return rawArgument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRecommendations(CommandSender sender, String lastWord)
|
||||
{
|
||||
return CommandHandler.defaultTabComplete(sender, lastWord);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,19 +17,16 @@ public class InteractListener implements Listener
|
|||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player))
|
||||
if (!(event.getDamager() instanceof Player tagger) || !(event.getEntity() instanceof Player tagged))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player tagger = (Player) event.getDamager();
|
||||
if (!AltitudeTag.getTagger().equals(tagger.getUniqueId()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player tagged = (Player) event.getEntity();
|
||||
|
||||
|
||||
// check for time since last tag
|
||||
if (lastTagTime != -1 && Config.TAG_DELAY_ENABLED.getValue() && (System.currentTimeMillis() - lastTagTime) / 50 < Config.TAG_DELAY_DURATION.getValue())
|
||||
|
|
|
|||
|
|
@ -16,19 +16,13 @@ public class BarUtils
|
|||
*/
|
||||
public static BarStyle parseBarStyle(int style)
|
||||
{
|
||||
switch (style)
|
||||
{
|
||||
case 6:
|
||||
return BarStyle.SEGMENTED_6;
|
||||
case 10:
|
||||
return BarStyle.SEGMENTED_10;
|
||||
case 12:
|
||||
return BarStyle.SEGMENTED_12;
|
||||
case 20:
|
||||
return BarStyle.SEGMENTED_20;
|
||||
default:
|
||||
return BarStyle.SOLID;
|
||||
}
|
||||
return switch (style) {
|
||||
case 6 -> BarStyle.SEGMENTED_6;
|
||||
case 10 -> BarStyle.SEGMENTED_10;
|
||||
case 12 -> BarStyle.SEGMENTED_12;
|
||||
case 20 -> BarStyle.SEGMENTED_20;
|
||||
default -> BarStyle.SOLID;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user