mirror of
https://github.com/Freezy-Studios/BlazeSMP.git
synced 2025-04-21 19:44:05 +02:00
add EndCommand
This commit is contained in:
parent
6ade7cd2ad
commit
3a9f229d81
3 changed files with 100 additions and 11 deletions
|
@ -28,26 +28,25 @@ public final class BlazeSMP extends JavaPlugin {
|
||||||
@Getter private BukkitTask tabListUpdateTask;
|
@Getter private BukkitTask tabListUpdateTask;
|
||||||
private boolean isEndOpen;
|
private boolean isEndOpen;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
this.log=getSLF4JLogger();
|
this.log = getSLF4JLogger();
|
||||||
|
|
||||||
this.log.info("Loading BlazeSMP...");
|
this.log.info("Loading BlazeSMP...");
|
||||||
|
|
||||||
this.log.info("Loading ProtectedBlocks...");
|
this.log.info("Loading ProtectedBlocks...");
|
||||||
this.protectedBlocks=new ProtectedBlocks();
|
this.protectedBlocks = new ProtectedBlocks();
|
||||||
this.protectedBlocks.load();
|
this.protectedBlocks.load();
|
||||||
this.log.info("Loaded ProtectedBlocks!");
|
this.log.info("Loaded ProtectedBlocks!");
|
||||||
|
|
||||||
this.log.info("Loading Clans...");
|
this.log.info("Loading Clans...");
|
||||||
this.clans=new Clans();
|
this.clans = new Clans();
|
||||||
this.clans.loadAllClans();
|
this.clans.loadAllClans();
|
||||||
this.log.info("Loaded Clans!");
|
this.log.info("Loaded Clans!");
|
||||||
|
|
||||||
this.log.info("Loading config...");
|
this.log.info("Loading config...");
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
this.configuration= getConfig();
|
this.configuration = getConfig();
|
||||||
saveConfig();
|
saveConfig();
|
||||||
this.log.info("Loaded config!");
|
this.log.info("Loaded config!");
|
||||||
|
|
||||||
|
@ -60,12 +59,13 @@ public final class BlazeSMP extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
BlazeSMP.instance=this;
|
BlazeSMP.instance = this;
|
||||||
|
isEndOpen = getConfig().getBoolean("isEndOpen", false);
|
||||||
|
|
||||||
this.log.info("Enabling BlazeSMP...");
|
this.log.info("Enabling BlazeSMP...");
|
||||||
|
|
||||||
this.log.info("Loading Homes...");
|
this.log.info("Loading Homes...");
|
||||||
this.homes=new Homes();
|
this.homes = new Homes();
|
||||||
this.homes.load();
|
this.homes.load();
|
||||||
this.log.info("Loaded Homes!");
|
this.log.info("Loaded Homes!");
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ public final class BlazeSMP extends JavaPlugin {
|
||||||
new DiscordCommand().register();
|
new DiscordCommand().register();
|
||||||
new ReloadCommand().register();
|
new ReloadCommand().register();
|
||||||
new VanishCommand().register();
|
new VanishCommand().register();
|
||||||
|
new EventCommand(this).register();
|
||||||
this.log.info("Registered Commands!");
|
this.log.info("Registered Commands!");
|
||||||
|
|
||||||
this.log.info("Registering EventListeners...");
|
this.log.info("Registering EventListeners...");
|
||||||
|
@ -125,11 +126,14 @@ public final class BlazeSMP extends JavaPlugin {
|
||||||
|
|
||||||
this.log.info("Disabling BlazeSMP!");
|
this.log.info("Disabling BlazeSMP!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEndOpen() {
|
public boolean isEndOpen() {
|
||||||
return isEndOpen;
|
return isEndOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndOpen(boolean endOpen) {
|
public void setEndOpen(boolean endOpen) {
|
||||||
isEndOpen = endOpen;
|
isEndOpen = endOpen;
|
||||||
|
getConfig().set("isEndOpen", endOpen);
|
||||||
|
saveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package me.freezy.plugins.papermc.blazesmp.command;
|
||||||
|
|
||||||
|
import me.freezy.plugins.papermc.blazesmp.BlazeSMP;
|
||||||
|
import me.freezy.plugins.papermc.blazesmp.command.util.SimpleCommand;
|
||||||
|
import me.freezy.plugins.papermc.blazesmp.module.manager.L4M4;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EventCommand extends SimpleCommand {
|
||||||
|
|
||||||
|
private final BlazeSMP plugin;
|
||||||
|
|
||||||
|
public EventCommand(BlazeSMP plugin) {
|
||||||
|
super("event");
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length == 1 && args[0].equalsIgnoreCase("open")) {
|
||||||
|
if (!(sender.getName().equals("BlazeGHC") || sender.getName().equals("EmrageGHC"))) {
|
||||||
|
sender.sendMessage(MiniMessage.miniMessage().deserialize(L4M4.get("error.no_permission")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.isEndOpen()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "The End is already open!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender instanceof Player || sender instanceof ConsoleCommandSender) {
|
||||||
|
for (int i = 10; i > 0; i--) {
|
||||||
|
int finalI = i;
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
String titleMessage = "<red><bold>" + finalI + "</bold></red>";
|
||||||
|
String subtitleMessage = "<gradient:#ff0000:#ff00ff><bold>The End is opening soon!</bold></gradient>";
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.showTitle(Title.title(
|
||||||
|
MiniMessage.miniMessage().deserialize(titleMessage),
|
||||||
|
MiniMessage.miniMessage().deserialize(subtitleMessage)
|
||||||
|
));
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
|
||||||
|
});
|
||||||
|
}, (10 - i) * 20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
|
plugin.setEndOpen(true);
|
||||||
|
plugin.getConfig().set("isEndOpen", true);
|
||||||
|
plugin.saveConfig();
|
||||||
|
Bukkit.broadcastMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "The End is now open! Good luck!");
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1.0f, 1.0f);
|
||||||
|
player.showTitle(Title.title(
|
||||||
|
MiniMessage.miniMessage().deserialize("<gradient:#ff0000:#ff00ff><bold>Open!</bold></gradient>"),
|
||||||
|
MiniMessage.miniMessage().deserialize("<gradient:#00ff00:#00ffff><bold>Good luck!</bold></gradient>"),
|
||||||
|
Title.Times.times(Duration.ofSeconds(1), Duration.ofSeconds(3), Duration.ofSeconds(1))
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}, 10 * 20L);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package me.freezy.plugins.papermc.blazesmp.listener;
|
package me.freezy.plugins.papermc.blazesmp.listener;
|
||||||
|
|
||||||
import me.freezy.plugins.papermc.blazeghcsmpclan.Main;
|
import me.freezy.plugins.papermc.blazesmp.BlazeSMP;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
|
@ -11,9 +11,9 @@ import org.bukkit.event.player.PlayerPortalEvent;
|
||||||
|
|
||||||
public class EndPortalListener implements Listener {
|
public class EndPortalListener implements Listener {
|
||||||
|
|
||||||
private final Main plugin;
|
private final BlazeSMP plugin;
|
||||||
|
|
||||||
public EndPortalListener(Main plugin) {
|
public EndPortalListener(BlazeSMP plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue