[REPO REFACTOR]: changed to a better git repository structure with branches
This commit is contained in:
209
pom.xml
Normal file
209
pom.xml
Normal file
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.miarma</groupId>
|
||||
<artifactId>MKernel</artifactId>
|
||||
<version>1.4.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MKernel</name>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mc.version>1.21.10</mc.version>
|
||||
<bukkit.fork>paper</bukkit.fork>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.4.2</version>
|
||||
<configuration>
|
||||
<finalName>MKernel-${bukkit.fork}-${project.version}-${mc.version}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<shadedClassifierName>shaded</shadedClassifierName>
|
||||
<finalName>MKernel-${bukkit.fork}-${project.version}-${mc.version}</finalName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>dev.jorel:commandapi-paper-shade</include>
|
||||
<include>dev.dejvokep:boosted-yaml</include>
|
||||
<include>com.github.stefvanschie.inventoryframework:IF</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>net.miarma.mkernel.MKernel</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<outputDirectory>
|
||||
/home/jomaa/Escritorio
|
||||
</outputDirectory>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>dev.jorel.commandapi</pattern>
|
||||
<shadedPattern>net.miarma.mkernel.commandapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>dev.dejvokep.boostedyaml</pattern>
|
||||
<shadedPattern>net.miarma.mkernel.boostedyaml</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.stefvanschie.inventoryframework</pattern>
|
||||
<shadedPattern>net.miarma.mkernel.inventoryframework</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<delete
|
||||
file="/home/jomaa/Escritorio/MKernel-${bukkit.fork}-${project.version}-${mc.version}" />
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mccommandapi</id>
|
||||
<url>
|
||||
https://raw.githubusercontent.com/JorelAli/1.13-Command-API/mvn-repo/1.13CommandAPI/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minecraft-repo</id>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>pcgf-repo</id>
|
||||
<url>https://repo.pcgamingfreaks.at/repository/maven-everything</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.jorel</groupId>
|
||||
<artifactId>commandapi-paper-shade</artifactId>
|
||||
<version>11.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dev.dejvokep</groupId>
|
||||
<artifactId>boosted-yaml</artifactId>
|
||||
<version>1.3.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>Minepacks-API</artifactId>
|
||||
<version>2.4.31.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>item-nbt-api-plugin</artifactId>
|
||||
<version>2.15.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.stefvanschie.inventoryframework</groupId>
|
||||
<artifactId>IF</artifactId>
|
||||
<version>0.11.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.GriefPrevention</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
82
src/main/java/net/miarma/mkernel/MKernel.java
Normal file
82
src/main/java/net/miarma/mkernel/MKernel.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package net.miarma.mkernel;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPI;
|
||||
import dev.jorel.commandapi.CommandAPIPaperConfig;
|
||||
import net.miarma.mkernel.commands.CommandHandler;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.GlobalChest;
|
||||
import net.miarma.mkernel.config.ConfigWrapper;
|
||||
import net.miarma.mkernel.config.CustomConfigManager;
|
||||
import net.miarma.mkernel.events.EventListener;
|
||||
import net.miarma.mkernel.recipes.RecipeManager;
|
||||
import net.miarma.mkernel.tasks.LocationTrackerTask;
|
||||
import net.miarma.mkernel.util.FileUtil;
|
||||
|
||||
public class MKernel extends JavaPlugin {
|
||||
|
||||
public static MKernel PLUGIN;
|
||||
public static final ConfigWrapper CONFIG = new ConfigWrapper();
|
||||
public static CustomConfigManager HOME_CONFIG;
|
||||
public static CustomConfigManager WORLD_BLOCKER_CONFIG;
|
||||
public static Logger LOGGER;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
CommandAPI.onLoad(
|
||||
new CommandAPIPaperConfig(this)
|
||||
.verboseOutput(true)
|
||||
.setNamespace("mkernel")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// main plugin stuff
|
||||
super.onEnable();
|
||||
PLUGIN = this;
|
||||
LOGGER = PLUGIN.getLogger();
|
||||
CONFIG.onEnable();
|
||||
|
||||
// files handling
|
||||
HOME_CONFIG = new CustomConfigManager(PLUGIN, "homes.yml");
|
||||
WORLD_BLOCKER_CONFIG = new CustomConfigManager(PLUGIN, "blockedWorlds.yml");
|
||||
|
||||
if(!Files.exists(PLUGIN.getDataFolder().toPath().resolve("inventories/"))) {
|
||||
File file = new File(PLUGIN.getDataFolder(), "inventories/");
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
if(!Files.exists(PLUGIN.getDataFolder().toPath().resolve("warps/"))) {
|
||||
File file = new File(PLUGIN.getDataFolder(), "warps/");
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
FileUtil.createLangs("lang.yml");
|
||||
|
||||
// onEnable methods
|
||||
CommandAPI.onEnable();
|
||||
CommandHandler.onEnable();
|
||||
RecipeManager.onEnable();
|
||||
EventListener.onEnable();
|
||||
|
||||
// final stage: location tracker and Global Chest
|
||||
LocationTrackerTask.start();
|
||||
|
||||
GlobalChest.loadConfig();
|
||||
GlobalChest.loadChest();
|
||||
|
||||
PLUGIN.getLogger().info("I've been enabled! :)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
GlobalChest.saveChest();
|
||||
CommandAPI.onDisable();
|
||||
PLUGIN.getLogger().info("I've been disabled! :(");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.miarma.mkernel.commands;
|
||||
|
||||
import net.miarma.mkernel.commands.admin.*;
|
||||
import net.miarma.mkernel.commands.base.BaseCommand;
|
||||
import net.miarma.mkernel.commands.misc.*;
|
||||
import net.miarma.mkernel.commands.roleplay.DoCommand;
|
||||
import net.miarma.mkernel.commands.roleplay.MeCommand;
|
||||
import net.miarma.mkernel.commands.tp.TpDenyCommand;
|
||||
import net.miarma.mkernel.commands.tp.TpaAcceptCommand;
|
||||
import net.miarma.mkernel.commands.tp.TpaCommand;
|
||||
import net.miarma.mkernel.commands.tp.TpaHereCommand;
|
||||
import net.miarma.mkernel.commands.troll.LaunchCommand;
|
||||
import dev.jorel.commandapi.CommandAPI;
|
||||
|
||||
public class CommandHandler {
|
||||
private static void registerCommands() {
|
||||
BaseCommand.register();
|
||||
TpaCommand.register();
|
||||
TpaAcceptCommand.register();
|
||||
TpDenyCommand.register();
|
||||
TpaHereCommand.register();
|
||||
CommandAPI.unregister("me");
|
||||
MeCommand.register();
|
||||
DoCommand.register();
|
||||
GlobalChestCommand.register();
|
||||
DisposalCommand.register();
|
||||
OpMeCommand.register();
|
||||
DeOpMeCommand.register();
|
||||
SpawnCommand.register();
|
||||
LobbyCommand.register();
|
||||
BlockWorldCommand.register();
|
||||
SpecialItemCommand.register();
|
||||
SendCoordsCommand.register();
|
||||
PayXpCommand.register();
|
||||
HomeCommand.register();
|
||||
SetHomeCommand.register();
|
||||
InventoryRecoveryCommand.register();
|
||||
GmcCommand.register();
|
||||
GmsCommand.register();
|
||||
GmspCommand.register();
|
||||
GmaCommand.register();
|
||||
VanishCommand.register();
|
||||
WarpCommand.register();
|
||||
SpyCommand.register();
|
||||
FreezeCommand.register();
|
||||
HealCommand.register();
|
||||
LaunchCommand.register();
|
||||
DayCommand.register();
|
||||
NightCommand.register();
|
||||
ThunderCommand.register();
|
||||
SunCommand.register();
|
||||
RainCommand.register();
|
||||
InvseeCommand.register();
|
||||
DegreeCommand.register();
|
||||
}
|
||||
|
||||
public static void onEnable() {
|
||||
registerCommands();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.tasks.LocationTrackerTask;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.miarma.mkernel.MKernel.WORLD_BLOCKER_CONFIG;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockWorldCommand {
|
||||
public static void register() {
|
||||
CommandWrapper blockWorldCmd = CommandProvider.getBlockWorldCommand();
|
||||
List<String> blockedWorlds = WORLD_BLOCKER_CONFIG.getConfig().getStringList("blockedWorlds");
|
||||
new CommandAPICommand(blockWorldCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.worlds())
|
||||
.withAliases(blockWorldCmd.getAliases())
|
||||
.withFullDescription(blockWorldCmd.getDescription())
|
||||
.withPermission(blockWorldCmd.getPermission().base())
|
||||
.withShortDescription(blockWorldCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() != 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.invalidArgument(), true);
|
||||
}
|
||||
|
||||
String world = args.getRaw(0);
|
||||
|
||||
if (blockedWorlds.contains(world)) {
|
||||
blockedWorlds.remove(world);
|
||||
MessageUtil.sendMessage(sender, blockWorldCmd.getMessages()[1], true,
|
||||
List.of("%world%"), List.of(world));
|
||||
} else {
|
||||
blockedWorlds.add(world);
|
||||
List<Player> playersInWorld = Bukkit.getWorld(world).getPlayers();
|
||||
if(!playersInWorld.isEmpty()) {
|
||||
playersInWorld.forEach(p -> p.teleport(LocationTrackerTask.getPlayerRealTimeLocation(p)));
|
||||
}
|
||||
MessageUtil.sendMessage(sender, blockWorldCmd.getMessages()[0], true,
|
||||
List.of("%world%"), List.of(world));
|
||||
}
|
||||
|
||||
WORLD_BLOCKER_CONFIG.getConfig().set("blockedWorlds", blockedWorlds);
|
||||
WORLD_BLOCKER_CONFIG.saveConfig();
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class DayCommand {
|
||||
public static void register() {
|
||||
CommandWrapper dayCmd = CommandProvider.getDayCommand();
|
||||
new CommandAPICommand(dayCmd.getName())
|
||||
.withShortDescription(dayCmd.getDescription())
|
||||
.withFullDescription(dayCmd.getDescription())
|
||||
.withPermission(dayCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
sender.getWorld().setTime(0);
|
||||
MessageUtil.sendMessage(sender, dayCmd.getMessages()[0], true);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class DeOpMeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper deopMeCmd = CommandProvider.getDeopMeCommand();
|
||||
new CommandAPICommand(deopMeCmd.getName())
|
||||
.withFullDescription(deopMeCmd.getDescription())
|
||||
.withShortDescription(deopMeCmd.getDescription())
|
||||
.withPermission(deopMeCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(sender.isOp()) {
|
||||
sender.setOp(false);
|
||||
MessageUtil.sendMessage(sender, deopMeCmd.getMessages()[0], true);
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, deopMeCmd.getMessages()[1], true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.FROZEN_KEY;
|
||||
|
||||
public class FreezeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper freezeCmd = CommandProvider.getFreezeCommand();
|
||||
new CommandAPICommand(freezeCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withFullDescription(freezeCmd.getDescription())
|
||||
.withShortDescription(freezeCmd.getDescription())
|
||||
.withUsage(freezeCmd.getUsage())
|
||||
.withPermission(freezeCmd.getPermission().base())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if (target == null) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
}
|
||||
|
||||
if(args.count() > 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
}
|
||||
|
||||
PersistentDataContainer data = target.getPersistentDataContainer();
|
||||
boolean isFrozen = Boolean.TRUE.equals(data.get(FROZEN_KEY, PersistentDataType.BOOLEAN));
|
||||
data.set(FROZEN_KEY, PersistentDataType.BOOLEAN, !isFrozen);
|
||||
|
||||
if(isFrozen) {
|
||||
unsetFrozen(target);
|
||||
MessageUtil.sendMessage(sender, freezeCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, freezeCmd.getMessages()[3], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
} else {
|
||||
setFrozen(target);
|
||||
MessageUtil.sendMessage(sender, freezeCmd.getMessages()[0], true,
|
||||
List.of("%player%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, freezeCmd.getMessages()[2], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
}
|
||||
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
private static void setFrozen(Player player) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
data.set(FROZEN_KEY, PersistentDataType.BOOLEAN, true);
|
||||
}
|
||||
|
||||
private static void unsetFrozen(Player player) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
data.set(FROZEN_KEY, PersistentDataType.BOOLEAN, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class GmaCommand {
|
||||
public static void register() {
|
||||
CommandWrapper gmaCmd = CommandProvider.getGmaCommand();
|
||||
new CommandAPICommand(gmaCmd.getName())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
gmaCmd.getPermission().others()
|
||||
)
|
||||
)
|
||||
.withShortDescription(gmaCmd.getDescription())
|
||||
.withFullDescription(gmaCmd.getDescription())
|
||||
.withUsage(gmaCmd.getUsage())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(args.rawArgs().length == 0) {
|
||||
sender.setGameMode(GameMode.ADVENTURE);
|
||||
MessageUtil.sendMessage(sender, gmaCmd.getMessages()[0], true);
|
||||
} else {
|
||||
Bukkit.getPlayer(args.getRaw(0)).setGameMode(GameMode.ADVENTURE);
|
||||
MessageUtil.sendMessage(sender, gmaCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(args.getRaw(0)));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class GmcCommand {
|
||||
public static void register() {
|
||||
CommandWrapper gmcCmd = CommandProvider.getGmcCommand();
|
||||
new CommandAPICommand(gmcCmd.getName())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
gmcCmd.getPermission().others()
|
||||
)
|
||||
)
|
||||
.withShortDescription(gmcCmd.getDescription())
|
||||
.withFullDescription(gmcCmd.getDescription())
|
||||
.withUsage(gmcCmd.getUsage())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(args.rawArgs().length == 0) {
|
||||
sender.setGameMode(GameMode.CREATIVE);
|
||||
MessageUtil.sendMessage(sender, gmcCmd.getMessages()[0], true);
|
||||
} else {
|
||||
Bukkit.getPlayer(args.getRaw(0)).setGameMode(GameMode.CREATIVE);
|
||||
MessageUtil.sendMessage(sender, gmcCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(args.getRaw(0)));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class GmsCommand {
|
||||
public static void register() {
|
||||
CommandWrapper gmsCmd = CommandProvider.getGmsCommand();
|
||||
new CommandAPICommand(gmsCmd.getName())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
gmsCmd.getPermission().others()
|
||||
)
|
||||
)
|
||||
.withShortDescription(gmsCmd.getDescription())
|
||||
.withFullDescription(gmsCmd.getDescription())
|
||||
.withUsage(gmsCmd.getUsage())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(args.rawArgs().length == 0) {
|
||||
sender.setGameMode(GameMode.SURVIVAL);
|
||||
MessageUtil.sendMessage(sender, gmsCmd.getMessages()[0], true);
|
||||
} else {
|
||||
Bukkit.getPlayer(args.getRaw(0)).setGameMode(GameMode.SURVIVAL);
|
||||
MessageUtil.sendMessage(sender, gmsCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(args.getRaw(0)));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class GmspCommand {
|
||||
public static void register() {
|
||||
CommandWrapper gmspCmd = CommandProvider.getGmspCommand();
|
||||
new CommandAPICommand(gmspCmd.getName())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
gmspCmd.getPermission().others()
|
||||
)
|
||||
)
|
||||
.withShortDescription(gmspCmd.getDescription())
|
||||
.withFullDescription(gmspCmd.getDescription())
|
||||
.withUsage(gmspCmd.getUsage())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(args.rawArgs().length == 0) {
|
||||
sender.setGameMode(GameMode.SPECTATOR);
|
||||
MessageUtil.sendMessage(sender, gmspCmd.getMessages()[0], true);
|
||||
} else {
|
||||
Bukkit.getPlayer(args.getRaw(0)).setGameMode(GameMode.SPECTATOR);
|
||||
MessageUtil.sendMessage(sender, gmspCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(args.getRaw(0)));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class HealCommand {
|
||||
public static void register() {
|
||||
CommandWrapper healCmd = CommandProvider.getHealCommand();
|
||||
new CommandAPICommand(healCmd.getName())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(healCmd.getPermission().others())
|
||||
)
|
||||
.withPermission(healCmd.getPermission().base())
|
||||
.withFullDescription(healCmd.getDescription())
|
||||
.withShortDescription(healCmd.getDescription())
|
||||
.withUsage(healCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if(args.count() == 0) {
|
||||
sender.setHealth(20);
|
||||
sender.setFoodLevel(20);
|
||||
MessageUtil.sendMessage(sender, healCmd.getMessages()[0], true);
|
||||
}
|
||||
|
||||
if(args.count() == 1) {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if(target == null) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
}
|
||||
|
||||
target.setHealth(20);
|
||||
target.setFoodLevel(20);
|
||||
|
||||
MessageUtil.sendMessage(sender, healCmd.getMessages()[1], true,
|
||||
List.of("%player%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, healCmd.getMessages()[2], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.InvseeInventory;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class InvseeCommand {
|
||||
|
||||
public static void register() {
|
||||
CommandWrapper invseeCommand = CommandProvider.getInvseeCommand();
|
||||
new CommandAPICommand(invseeCommand.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withShortDescription(invseeCommand.getDescription())
|
||||
.withFullDescription(invseeCommand.getDescription())
|
||||
.withPermission(invseeCommand.getPermission().base())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player target = (Player) args.get(0);
|
||||
|
||||
if (target == null || !target.isOnline()) {
|
||||
MessageUtil.sendMessage(sender, "&cEse jugador no está conectado.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory copy = Bukkit.createInventory(sender, 54, "Inventario de " + target.getName());
|
||||
PlayerInventory tInv = target.getInventory();
|
||||
|
||||
for (int i = 0; i < 36; i++) copy.setItem(i, tInv.getItem(i));
|
||||
copy.setItem(36, tInv.getHelmet());
|
||||
copy.setItem(37, tInv.getChestplate());
|
||||
copy.setItem(38, tInv.getLeggings());
|
||||
copy.setItem(39, tInv.getBoots());
|
||||
copy.setItem(40, tInv.getItemInOffHand());
|
||||
|
||||
InvseeInventory.setInvForAdmin(sender, copy, target); // nueva forma
|
||||
|
||||
sender.openInventory(copy);
|
||||
|
||||
MessageUtil.sendMessage(sender, invseeCommand.getMessages()[0], true,
|
||||
List.of("%player%"), List.of(target.getName()));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class NightCommand {
|
||||
public static void register() {
|
||||
CommandWrapper nightCmd = CommandProvider.getNightCommand();
|
||||
new CommandAPICommand(nightCmd.getName())
|
||||
.withShortDescription(nightCmd.getDescription())
|
||||
.withFullDescription(nightCmd.getDescription())
|
||||
.withPermission(nightCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
sender.getWorld().setTime(13000);
|
||||
MessageUtil.sendMessage(sender, nightCmd.getMessages()[0], true);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class OpMeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper opMeCmd = CommandProvider.getOpMeCommand();
|
||||
new CommandAPICommand(opMeCmd.getName())
|
||||
.withFullDescription(opMeCmd.getDescription())
|
||||
.withShortDescription(opMeCmd.getDescription())
|
||||
.withPermission(opMeCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if(!sender.isOp()) {
|
||||
sender.setOp(true);
|
||||
MessageUtil.sendMessage(sender, opMeCmd.getMessages()[0], true);
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, opMeCmd.getMessages()[1], true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class RainCommand {
|
||||
public static void register() {
|
||||
CommandWrapper rainCmd = CommandProvider.getRainCommand();
|
||||
new CommandAPICommand(rainCmd.getName())
|
||||
.withShortDescription(rainCmd.getDescription())
|
||||
.withFullDescription(rainCmd.getDescription())
|
||||
.withPermission(rainCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
sender.getWorld().setStorm(true);
|
||||
sender.getWorld().setThundering(false);
|
||||
MessageUtil.sendMessage(sender, rainCmd.getMessages()[0], true);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class SpecialItemCommand {
|
||||
public static void register() {
|
||||
CommandWrapper specialItemCmd = CommandProvider.getSpecialItemCommand();
|
||||
new CommandAPICommand(specialItemCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.items())
|
||||
.withFullDescription(specialItemCmd.getDescription())
|
||||
.withPermission(specialItemCmd.getPermission().base())
|
||||
.withShortDescription(specialItemCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
String itemName = args.getRaw(0);
|
||||
Recipe specialItem = Bukkit.getServer().getRecipe(new NamespacedKey(MKernel.PLUGIN, itemName));
|
||||
if (specialItem != null) {
|
||||
sender.getInventory().addItem(specialItem.getResult());
|
||||
MessageUtil.sendMessage(sender, specialItemCmd.getMessages()[0], true,
|
||||
List.of("%item%"), List.of(itemName));
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.itemNotFound(), true,
|
||||
List.of("%item%"), List.of(itemName));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.SPY_KEY;
|
||||
|
||||
public class SpyCommand {
|
||||
public static void register() {
|
||||
CommandWrapper spyCmd = CommandProvider.getSpyCommand();
|
||||
new CommandAPICommand(spyCmd.getName())
|
||||
.withFullDescription(spyCmd.getDescription())
|
||||
.withShortDescription(spyCmd.getDescription())
|
||||
.withPermission(spyCmd.getPermission().base())
|
||||
.executesPlayer((sender, args) -> {
|
||||
PersistentDataContainer data = sender.getPersistentDataContainer();
|
||||
boolean canSpy = Boolean.TRUE.equals(data.get(SPY_KEY, PersistentDataType.BOOLEAN));
|
||||
|
||||
if (canSpy) {
|
||||
unsetSpy(sender);
|
||||
MessageUtil.sendMessage(sender, spyCmd.getMessages()[1], true);
|
||||
} else {
|
||||
setSpy(sender);
|
||||
MessageUtil.sendMessage(sender, spyCmd.getMessages()[0], true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
private static void setSpy(Player player) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
data.set(SPY_KEY, PersistentDataType.BOOLEAN, true);
|
||||
}
|
||||
|
||||
private static void unsetSpy(Player player) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
data.set(SPY_KEY, PersistentDataType.BOOLEAN, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class SunCommand {
|
||||
public static void register() {
|
||||
CommandWrapper sunCmd = CommandProvider.getSunCommand();
|
||||
new CommandAPICommand(sunCmd.getName())
|
||||
.withShortDescription(sunCmd.getDescription())
|
||||
.withFullDescription(sunCmd.getDescription())
|
||||
.withPermission(sunCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
sender.getWorld().setStorm(false);
|
||||
sender.getWorld().setThundering(false);
|
||||
MessageUtil.sendMessage(sender, sunCmd.getMessages()[0], true);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
public class ThunderCommand {
|
||||
public static void register() {
|
||||
CommandWrapper thunderCmd = CommandProvider.getThunderCommand();
|
||||
new CommandAPICommand(thunderCmd.getName())
|
||||
.withShortDescription(thunderCmd.getDescription())
|
||||
.withFullDescription(thunderCmd.getDescription())
|
||||
.withPermission(thunderCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
sender.getWorld().setStorm(true);
|
||||
sender.getWorld().setThundering(true);
|
||||
MessageUtil.sendMessage(sender, thunderCmd.getMessages()[0], true);
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.miarma.mkernel.commands.admin;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.VANISH_KEY;
|
||||
|
||||
public class VanishCommand {
|
||||
public static void register() {
|
||||
CommandWrapper vanishCmd = CommandProvider.getVanishCommand();
|
||||
new CommandAPICommand(vanishCmd.getName())
|
||||
.withAliases("v")
|
||||
.withFullDescription(vanishCmd.getDescription())
|
||||
.withShortDescription(vanishCmd.getDescription())
|
||||
.withPermission(vanishCmd.getPermission().base())
|
||||
.executesPlayer((sender,args) -> {
|
||||
PersistentDataContainer data = sender.getPersistentDataContainer();
|
||||
boolean isVanished = Boolean.TRUE.equals(data.get(VANISH_KEY, PersistentDataType.BOOLEAN));
|
||||
data.set(VANISH_KEY, PersistentDataType.BOOLEAN, !isVanished);
|
||||
|
||||
if(isVanished) {
|
||||
unsetVanish(sender);
|
||||
MessageUtil.sendMessage(sender,
|
||||
vanishCmd.getMessages()[1], true);
|
||||
} else {
|
||||
setVanish(sender);
|
||||
MessageUtil.sendMessage(sender,
|
||||
vanishCmd.getMessages()[0], true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
|
||||
private static void setVanish(Player player) {
|
||||
player.setInvisible(true);
|
||||
player.setCanPickupItems(false);
|
||||
}
|
||||
|
||||
private static void unsetVanish(Player player) {
|
||||
player.setInvisible(false);
|
||||
player.setCanPickupItems(true);
|
||||
}
|
||||
}
|
||||
106
src/main/java/net/miarma/mkernel/commands/base/BaseCommand.java
Normal file
106
src/main/java/net/miarma/mkernel/commands/base/BaseCommand.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package net.miarma.mkernel.commands.base;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
|
||||
import com.github.stefvanschie.inventoryframework.pane.OutlinePane;
|
||||
import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.ItemUtil;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BaseCommand {
|
||||
public static void register() {
|
||||
CommandWrapper baseCmd = CommandProvider.getBaseCommand();
|
||||
CommandWrapper reloadSubCmd = baseCmd.getSubcommands()[0];
|
||||
CommandWrapper configSubCmd = baseCmd.getSubcommands()[1];
|
||||
new CommandAPICommand(baseCmd.getName())
|
||||
.withAliases(baseCmd.getAliases())
|
||||
.withPermission(baseCmd.getPermission().base())
|
||||
.withFullDescription(baseCmd.getDescription())
|
||||
.withShortDescription(baseCmd.getDescription())
|
||||
.withUsage(baseCmd.getUsage())
|
||||
.executes((sender, args) -> {
|
||||
MessageUtil.sendMessage(sender, baseCmd.getMessages()[0], true);
|
||||
})
|
||||
.withSubcommand(
|
||||
new CommandAPICommand(reloadSubCmd.getName())
|
||||
.withPermission(reloadSubCmd.getPermission().base())
|
||||
.withFullDescription(reloadSubCmd.getDescription())
|
||||
.withShortDescription(reloadSubCmd.getDescription())
|
||||
.withUsage(reloadSubCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
try {
|
||||
MKernel.CONFIG.reload();
|
||||
MessageUtil.sendMessage(sender, reloadSubCmd.getMessages()[0],true);
|
||||
} catch(Exception e) {
|
||||
MessageUtil.sendMessage(sender, reloadSubCmd.getMessages()[1],true);
|
||||
}
|
||||
})
|
||||
)
|
||||
.withSubcommand(
|
||||
new CommandAPICommand(configSubCmd.getName())
|
||||
.withPermission(configSubCmd.getPermission().base())
|
||||
.withFullDescription(configSubCmd.getDescription())
|
||||
.withShortDescription(configSubCmd.getDescription())
|
||||
.withUsage(configSubCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Section confSec = MKernel.CONFIG.getConfig().getSection("config.modules");
|
||||
Map<String,Object> values = confSec.getStringRouteMappedValues(false);
|
||||
|
||||
int booleans = (int) values.values().stream()
|
||||
.filter(value -> value instanceof Boolean)
|
||||
.count();
|
||||
int numberOfRows = (booleans / 9) + (booleans % 9 > 0 ? 1 : 0);
|
||||
|
||||
ChestGui gui = new ChestGui(numberOfRows,
|
||||
MessageUtil.parseColors(MessageProvider.Inventories.getConfigMenuTitle()));
|
||||
OutlinePane pane = new OutlinePane(0, 0, 9, numberOfRows);
|
||||
|
||||
List<String> configItemsDisplayNames = values.entrySet().stream()
|
||||
.filter(x -> x.getValue() instanceof Boolean)
|
||||
.map(x -> MessageUtil.parseColors(MessageProvider.Inventories.getConfigMenuValueName())
|
||||
+ x.getKey())
|
||||
.toList();
|
||||
List<String> configItemsLores = values.values().stream()
|
||||
.filter(o -> o instanceof Boolean)
|
||||
.map(o -> MessageUtil.parseColors(MessageProvider.Inventories.getConfigMenuValueLore())
|
||||
+ o)
|
||||
.toList();
|
||||
List<ItemStack> configItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < booleans; i++) {
|
||||
ItemStack item = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(configItemsDisplayNames.get(i));
|
||||
itemMeta.setLore(List.of(configItemsLores.get(i)));
|
||||
item.setItemMeta(itemMeta);
|
||||
configItems.add(item);
|
||||
}
|
||||
for (int i = 0; i < configItems.size(); i++) {
|
||||
GuiItem guiItem = new GuiItem(configItems.get(i), event -> {
|
||||
event.setCancelled(true);
|
||||
ItemUtil.reloadConfigItem(event);
|
||||
});
|
||||
|
||||
pane.addItem(guiItem);
|
||||
}
|
||||
|
||||
gui.addPane(pane);
|
||||
gui.show(sender);
|
||||
})
|
||||
|
||||
)
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider.Arguments;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class DegreeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper degreeCmd = CommandProvider.getDegreeCommand();
|
||||
new CommandAPICommand(degreeCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.titulaciones())
|
||||
.withFullDescription(degreeCmd.getDescription())
|
||||
.withPermission(degreeCmd.getPermission().base())
|
||||
.withShortDescription(degreeCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() > 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<LuckPerms> provider =
|
||||
Bukkit.getServicesManager().getRegistration(LuckPerms.class);
|
||||
if (provider != null) {
|
||||
LuckPerms api = provider.getProvider();
|
||||
|
||||
if (args.count() == 0) {
|
||||
api.getUserManager().loadUser(sender.getUniqueId())
|
||||
.thenCompose(user -> {
|
||||
String grupo = user.getNodes(NodeType.INHERITANCE).stream()
|
||||
.map(InheritanceNode::getGroupName)
|
||||
.findFirst().orElse("Inmigrante");
|
||||
return CompletableFuture.completedFuture(grupo);
|
||||
})
|
||||
.thenApply(grupo -> {
|
||||
MessageUtil.sendMessage(sender, degreeCmd.getMessages()[1], true,
|
||||
List.of("%titulacion%"), List.of(grupo));
|
||||
return grupo;
|
||||
}).join();
|
||||
} else {
|
||||
String titulacion = args.getRaw(0).toLowerCase();
|
||||
if (Arguments.TITULACIONES.stream()
|
||||
.map(String::toLowerCase)
|
||||
.noneMatch(t -> t.equals(titulacion))) {
|
||||
MessageUtil.sendMessage(sender, degreeCmd.getMessages()[3], true);
|
||||
return;
|
||||
}
|
||||
|
||||
api.getUserManager().loadUser(sender.getUniqueId())
|
||||
.thenCompose(user -> {
|
||||
DataMutateResult res = user.setPrimaryGroup(titulacion);
|
||||
|
||||
if (res != DataMutateResult.SUCCESS) {
|
||||
MessageUtil.sendMessage(sender, degreeCmd.getMessages()[2], true);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
return api.getUserManager().saveUser(user)
|
||||
.thenRun(() -> {
|
||||
MessageUtil.sendMessage(sender, degreeCmd.getMessages()[0], true,
|
||||
List.of("%titulacion%"), List.of(titulacion.toUpperCase()));
|
||||
})
|
||||
.exceptionally(ex -> {
|
||||
MessageUtil.sendMessage(sender, degreeCmd.getMessages()[2], true);
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.DisposalInventory;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class DisposalCommand {
|
||||
public static void register() {
|
||||
CommandWrapper disposalCmd = CommandProvider.getDisposalCommand();
|
||||
new CommandAPICommand(disposalCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
disposalCmd.getPermission().others()
|
||||
))
|
||||
.withFullDescription(disposalCmd.getDescription())
|
||||
.withPermission(disposalCmd.getPermission().base())
|
||||
.withShortDescription(disposalCmd.getDescription())
|
||||
.executesPlayer((sender,args) -> {
|
||||
if (args.count() > 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
} else if (args.count() == 0) {
|
||||
Player player = sender;
|
||||
player.openInventory(DisposalInventory.getInv());
|
||||
} else if (args.count() == 1) {
|
||||
Player player = Bukkit.getServer().getPlayer(args.getRaw(0));
|
||||
player.openInventory(DisposalInventory.getInv());
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.GlobalChest;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class GlobalChestCommand {
|
||||
public static void register() {
|
||||
CommandWrapper globalChestCmd = CommandProvider.getGlobalChestCommand();
|
||||
new CommandAPICommand(globalChestCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
globalChestCmd.getPermission().others()
|
||||
))
|
||||
.withFullDescription(globalChestCmd.getDescription())
|
||||
.withAliases(globalChestCmd.getAliases())
|
||||
.withPermission(globalChestCmd.getPermission().base())
|
||||
.withShortDescription(globalChestCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() > 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
} else if (args.count() == 0) {
|
||||
Player player = sender;
|
||||
player.openInventory(GlobalChest.getInv());
|
||||
} else if (args.count() == 1) {
|
||||
Player player = Bukkit.getServer().getPlayer(args.getRaw(0));
|
||||
player.openInventory(GlobalChest.getInv());
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import static net.miarma.mkernel.MKernel.HOME_CONFIG;
|
||||
|
||||
public class HomeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper homeCmd = CommandProvider.getHomeCommand();
|
||||
new CommandAPICommand(homeCmd.getName())
|
||||
.withPermission(homeCmd.getPermission().base())
|
||||
.withFullDescription(homeCmd.getDescription())
|
||||
.withShortDescription(homeCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
String path = "homes." + sender.getName();
|
||||
if(HOME_CONFIG.getConfig().contains(path)) {
|
||||
World world = Bukkit.getWorld(HOME_CONFIG.getConfig().getString(path + ".world"));
|
||||
double x = HOME_CONFIG.getConfig().getDouble(path + ".x");
|
||||
double y = HOME_CONFIG.getConfig().getDouble(path + ".y");
|
||||
double z = HOME_CONFIG.getConfig().getDouble(path + ".z");
|
||||
float yaw = (float) HOME_CONFIG.getConfig().getDouble(path + ".yaw");
|
||||
float pitch = (float) HOME_CONFIG.getConfig().getDouble(path + ".pitch");
|
||||
Location loc = new Location(world, x, y, z, yaw, pitch);
|
||||
sender.teleport(loc);
|
||||
MessageUtil.sendMessage(sender, homeCmd.getMessages()[0], true);
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, homeCmd.getMessages()[1], true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.ConfigProvider;
|
||||
import net.miarma.mkernel.util.FileUtil;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class InventoryRecoveryCommand {
|
||||
public static void register() {
|
||||
CommandWrapper recInvCmd = CommandProvider.getRecInvCommand();
|
||||
new CommandAPICommand(recInvCmd.getName())
|
||||
.withPermission(recInvCmd.getPermission().base())
|
||||
.withShortDescription(recInvCmd.getDescription())
|
||||
.withFullDescription(recInvCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
int xpLevels = sender.getLevel();
|
||||
int requiredLevels = ConfigProvider.Values.getRecInvRequiredLevel();
|
||||
|
||||
if (xpLevels < requiredLevels) {
|
||||
MessageUtil.sendMessage(sender, recInvCmd.getMessages()[1], true,
|
||||
List.of("%required%"), List.of(String.valueOf(requiredLevels)));
|
||||
return;
|
||||
}
|
||||
|
||||
int items;
|
||||
try {
|
||||
items = FileUtil.restoreInventory(sender);
|
||||
if(items == 0) {
|
||||
MessageUtil.sendMessage(sender, recInvCmd.getMessages()[2], true);
|
||||
return;
|
||||
}
|
||||
MessageUtil.sendMessage(sender, recInvCmd.getMessages()[0], true,
|
||||
List.of("%items%"), List.of(String.valueOf(items)));
|
||||
sender.setLevel(xpLevels - requiredLevels);
|
||||
FileUtil.clearInventory(sender);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.ConfigProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class LobbyCommand {
|
||||
public static void register() {
|
||||
CommandWrapper lobbyCmd = CommandProvider.getLobbyCommand();
|
||||
new CommandAPICommand(lobbyCmd.getName())
|
||||
.withFullDescription(lobbyCmd.getDescription())
|
||||
.withShortDescription(lobbyCmd.getDescription())
|
||||
.withPermission(lobbyCmd.getPermission().base())
|
||||
.withOptionalArguments(
|
||||
CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
lobbyCmd.getPermission().others()
|
||||
)
|
||||
)
|
||||
.executesPlayer((sender,args) -> {
|
||||
boolean lobbyExists = Bukkit.getServer().getWorlds().stream()
|
||||
.map(World::getName)
|
||||
.map(String::toLowerCase)
|
||||
.anyMatch(w -> w.contains(ConfigProvider.Worlds.getLobby().name()));
|
||||
|
||||
if(lobbyExists) {
|
||||
String name = ConfigProvider.Worlds.getLobby().name();
|
||||
double x = ConfigProvider.Worlds.getLobby().x();
|
||||
double y = ConfigProvider.Worlds.getLobby().y();
|
||||
double z = ConfigProvider.Worlds.getLobby().z();
|
||||
int yaw = ConfigProvider.Worlds.getLobby().yaw();
|
||||
int pitch = ConfigProvider.Worlds.getLobby().pitch();
|
||||
Location lobbyCoords = new Location(Bukkit.getWorld(name), x, y, z, yaw, pitch);
|
||||
|
||||
if (args.count() == 0) {
|
||||
sender.teleport(lobbyCoords);
|
||||
MessageUtil.sendMessage(sender, lobbyCmd.getMessages()[0], true);
|
||||
} else if (args.count() >= 1) {
|
||||
Player victim = Bukkit.getServer().getPlayer(args.getRaw(0));
|
||||
victim.teleport(lobbyCoords);
|
||||
MessageUtil.sendMessage(sender, lobbyCmd.getMessages()[1], true,
|
||||
List.of("%victim%"), List.of(victim.getName()));
|
||||
MessageUtil.sendMessage(victim, lobbyCmd.getMessages()[2], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
}
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.lobbyDoesNotExist(), true);
|
||||
MKernel.LOGGER.warning(MessageUtil.formatMessageConsole(
|
||||
MessageProvider.Errors.lobbyDoesNotExist(), true));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class PayXpCommand {
|
||||
public static void register() {
|
||||
CommandWrapper payXpCmd = CommandProvider.getPayXpCommand();
|
||||
new CommandAPICommand(payXpCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg(), CommandProvider.Arguments.levels())
|
||||
.withFullDescription(payXpCmd.getDescription())
|
||||
.withPermission(payXpCmd.getPermission().base())
|
||||
.withShortDescription(payXpCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player victim = Bukkit.getPlayer(args.getRaw(0));
|
||||
Integer cantidad = Integer.valueOf(args.getRaw(1));
|
||||
|
||||
if(args.count() > 2) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
}
|
||||
|
||||
if(sender.getLevel()>0) {
|
||||
sender.setLevel(sender.getLevel()-cantidad);
|
||||
victim.setLevel(victim.getLevel()+cantidad);
|
||||
MessageUtil.sendMessage(sender, payXpCmd.getMessages()[0], true,
|
||||
List.of("%target%", "%amount%"),
|
||||
List.of(victim.getName(), cantidad.toString()));
|
||||
MessageUtil.sendMessage(victim, payXpCmd.getMessages()[1], true,
|
||||
List.of("%sender%", "%amount%"),
|
||||
List.of(sender.getName(), cantidad.toString()));
|
||||
sender.playSound(sender, Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1);
|
||||
victim.playSound(victim, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.notEnoughLevels(), true);
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class SendCoordsCommand {
|
||||
public static void register() {
|
||||
CommandWrapper sendCoordsCmd = CommandProvider.getSendCoordsCommand();
|
||||
new CommandAPICommand(sendCoordsCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withFullDescription(sendCoordsCmd.getDescription())
|
||||
.withPermission(sendCoordsCmd.getPermission().base())
|
||||
.withShortDescription(sendCoordsCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if (args.count() > 1) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.tooManyArguments(), true);
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args.getRaw(0));
|
||||
Location loc = sender.getLocation();
|
||||
List<String> coords = List.of(String.valueOf(loc.getBlockX()),
|
||||
String.valueOf(loc.getBlockY()),
|
||||
String.valueOf(loc.getBlockZ()));
|
||||
|
||||
MessageUtil.sendMessage(sender, sendCoordsCmd.getMessages()[0], true,
|
||||
List.of("%target%"), List.of(player.getName()));
|
||||
MessageUtil.sendMessage(player, sendCoordsCmd.getMessages()[1], true,
|
||||
List.of("%sender%", "%x%", "%y%", "%z%"),
|
||||
List.of(sender.getName(), coords.get(0), coords.get(1), coords.get(2)));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import static net.miarma.mkernel.MKernel.HOME_CONFIG;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SetHomeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper setHomeCmd = CommandProvider.getSetHomeCommand();
|
||||
new CommandAPICommand(setHomeCmd.getName())
|
||||
.withPermission(setHomeCmd.getPermission().base())
|
||||
.withFullDescription(setHomeCmd.getDescription())
|
||||
.withShortDescription(setHomeCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Location loc = sender.getLocation();
|
||||
String path = "homes." + sender.getName();
|
||||
HOME_CONFIG.getConfig().set(path + ".world", loc.getWorld().getName());
|
||||
HOME_CONFIG.getConfig().set(path + ".x", loc.getX());
|
||||
HOME_CONFIG.getConfig().set(path + ".y", loc.getY());
|
||||
HOME_CONFIG.getConfig().set(path + ".z", loc.getZ());
|
||||
HOME_CONFIG.getConfig().set(path + ".yaw", loc.getYaw());
|
||||
HOME_CONFIG.getConfig().set(path + ".pitch", loc.getPitch());
|
||||
HOME_CONFIG.saveConfig();
|
||||
MessageUtil.sendMessage(sender, setHomeCmd.getMessages()[0], true,
|
||||
List.of("%x%", "%y%", "%z%"),
|
||||
List.of((int)loc.getX()+"", (int)loc.getY()+"", (int)loc.getZ()+""));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class SpawnCommand {
|
||||
public static void register() {
|
||||
CommandWrapper spawnCmd = CommandProvider.getSpawnCommand();
|
||||
new CommandAPICommand(spawnCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.playersOptArg().withPermission(
|
||||
spawnCmd.getPermission().others()
|
||||
))
|
||||
.withFullDescription(spawnCmd.getDescription())
|
||||
.withPermission(spawnCmd.getPermission().base())
|
||||
.withShortDescription(spawnCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
|
||||
double xSpawn = sender.getWorld().getSpawnLocation().getBlockX() + 0.500;
|
||||
double ySpawn = sender.getWorld().getSpawnLocation().getBlockY();
|
||||
double zSpawn = sender.getWorld().getSpawnLocation().getBlockZ() + 0.500;
|
||||
|
||||
if (args.count() == 0) {
|
||||
Location spawnCoords = new Location(sender.getWorld(), xSpawn, ySpawn, zSpawn);
|
||||
sender.teleport(spawnCoords);
|
||||
MessageUtil.sendMessage(sender, spawnCmd.getMessages()[0], true);
|
||||
} else if (args.count() >= 1) {
|
||||
Player victim = Bukkit.getServer().getPlayer(args.getRaw(0));
|
||||
Location spawnCoords = new Location(victim.getWorld(), xSpawn, ySpawn, zSpawn, victim.getLocation().getYaw(), victim.getLocation().getPitch());
|
||||
victim.teleport(spawnCoords);
|
||||
|
||||
MessageUtil.sendMessage(sender, spawnCmd.getMessages()[1], true,
|
||||
List.of("%victim%"), List.of(victim.getName()));
|
||||
MessageUtil.sendMessage(victim, spawnCmd.getMessages()[2], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
131
src/main/java/net/miarma/mkernel/commands/misc/WarpCommand.java
Normal file
131
src/main/java/net/miarma/mkernel/commands/misc/WarpCommand.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package net.miarma.mkernel.commands.misc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.Warp;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.ConfigProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class WarpCommand {
|
||||
public static void register() {
|
||||
CommandWrapper warpCmd = CommandProvider.getWarpCommand();
|
||||
CommandWrapper addSubCmd = warpCmd.getSubcommands()[0];
|
||||
CommandWrapper removeSubCmd = warpCmd.getSubcommands()[1];
|
||||
new CommandAPICommand(warpCmd.getName())
|
||||
.withPermission(warpCmd.getPermission().base())
|
||||
.withFullDescription(warpCmd.getDescription())
|
||||
.withShortDescription(warpCmd.getDescription())
|
||||
.withUsage(warpCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "warps/"
|
||||
+ sender.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
Set<Warp> warps = c.getKeys(false).stream()
|
||||
.map(alias -> Warp.fromFile(c, alias))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (warps.isEmpty()) {
|
||||
MessageUtil.sendMessage(sender, warpCmd.getMessages()[0], true);
|
||||
} else {
|
||||
String warpList = warps.stream()
|
||||
.map(Warp::toFormattedMessage)
|
||||
.collect(Collectors.joining("\n"));
|
||||
warpList = MessageUtil.formatMessage(warpList, false);
|
||||
|
||||
MessageUtil.sendMessage(sender, warpCmd.getMessages()[1], true,
|
||||
List.of("%warps%"), List.of(warpList));
|
||||
}
|
||||
|
||||
})
|
||||
.withSubcommand(
|
||||
new CommandAPICommand(addSubCmd.getName())
|
||||
.withPermission(addSubCmd.getPermission().base())
|
||||
.withFullDescription(addSubCmd.getDescription())
|
||||
.withShortDescription(addSubCmd.getDescription())
|
||||
.withArguments(CommandProvider.Arguments.warpName())
|
||||
.withUsage(addSubCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "warps/"
|
||||
+ sender.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
if (c.getKeys(false).size() >= ConfigProvider.Values.getMaxWarps()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.maxWarpsReached(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(c.contains(args.getRaw(0))) {
|
||||
MessageUtil.sendMessage(sender, addSubCmd.getMessages()[1], true,
|
||||
List.of("%warp%"), List.of(args.getRaw(0)));
|
||||
return;
|
||||
}
|
||||
|
||||
String warpName = args.getRaw(0);
|
||||
Location loc = sender.getLocation();
|
||||
World world = sender.getWorld();
|
||||
Warp warp = Warp.of(
|
||||
warpName,
|
||||
Math.round(loc.getX()),
|
||||
Math.round(loc.getY()),
|
||||
Math.round(loc.getZ()),
|
||||
world.getName()
|
||||
);
|
||||
Warp.toFile(c, warp);
|
||||
|
||||
try {
|
||||
c.save(f);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(sender, addSubCmd.getMessages()[0], true,
|
||||
List.of("%warp%"), List.of(warpName));
|
||||
})
|
||||
)
|
||||
.withSubcommand(
|
||||
new CommandAPICommand(removeSubCmd.getName())
|
||||
.withPermission(removeSubCmd.getPermission().base())
|
||||
.withFullDescription(removeSubCmd.getDescription())
|
||||
.withShortDescription(removeSubCmd.getDescription())
|
||||
.withArguments(CommandProvider.Arguments.warps())
|
||||
.withUsage(removeSubCmd.getUsage())
|
||||
.executes((sender, args) -> {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "warps/"
|
||||
+ sender.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
|
||||
String warpName = args.getRaw(0);
|
||||
if (c.contains(warpName)) {
|
||||
c.set(warpName, null);
|
||||
try {
|
||||
c.save(f);
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error al guardar el archivo de warps de " + sender.getName());
|
||||
}
|
||||
MessageUtil.sendMessage(sender, removeSubCmd.getMessages()[0], true,
|
||||
List.of("%warp%"), List.of(warpName));
|
||||
} else {
|
||||
MessageUtil.sendMessage(sender, removeSubCmd.getMessages()[1], true,
|
||||
List.of("%warp%"), List.of(warpName));
|
||||
}
|
||||
})
|
||||
)
|
||||
.register();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.miarma.mkernel.commands.roleplay;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.PlayerUtil;
|
||||
|
||||
public class DoCommand {
|
||||
public static void register() {
|
||||
CommandWrapper doCmd = CommandProvider.getDoCommand();
|
||||
new CommandAPICommand(doCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.message())
|
||||
.withFullDescription(doCmd.getDescription())
|
||||
.withPermission(doCmd.getPermission().base())
|
||||
.withShortDescription(doCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
String joinedArgs = Arrays.stream(args.rawArgs()).collect(Collectors.joining(" "));
|
||||
String msg = "§9(" + sender.getName() + ") [Do] §7" + joinedArgs;
|
||||
Bukkit.getServer().getOnlinePlayers().stream()
|
||||
.filter(p -> (p.getWorld() == sender.getWorld()) && (PlayerUtil.distance(sender, p) < 25 || sender.equals(p)))
|
||||
.forEach(p -> p.sendMessage(msg));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.miarma.mkernel.commands.roleplay;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.PlayerUtil;
|
||||
|
||||
public class MeCommand {
|
||||
public static void register() {
|
||||
CommandWrapper meCmd = CommandProvider.getMeCommand();
|
||||
new CommandAPICommand(meCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.message())
|
||||
.withFullDescription(meCmd.getDescription())
|
||||
.withPermission(meCmd.getPermission().base())
|
||||
.withShortDescription(meCmd.getDescription())
|
||||
.executesPlayer((sender, args) -> {
|
||||
String joinedArgs = Arrays.stream(args.rawArgs()).collect(Collectors.joining(" "));
|
||||
String msg = "§6(" + sender.getName() + ") [Me] §7" + joinedArgs;
|
||||
Bukkit.getServer().getOnlinePlayers().stream()
|
||||
.filter(p -> (p.getWorld() == sender.getWorld()) && (PlayerUtil.distance(sender, p) < 25 || sender.equals(p)))
|
||||
.forEach(p -> p.sendMessage(msg));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.miarma.mkernel.commands.tp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequest;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequests;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class TpDenyCommand {
|
||||
public static void register() {
|
||||
CommandWrapper tpDenyCmd = CommandProvider.getTpDenyCommand();
|
||||
new CommandAPICommand(tpDenyCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.playersOptArg())
|
||||
.withPermission(tpDenyCmd.getPermission().base())
|
||||
.withFullDescription(tpDenyCmd.getDescription())
|
||||
.withShortDescription(tpDenyCmd.getDescription())
|
||||
.withUsage(tpDenyCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if(args.count() == 0) {
|
||||
Optional<TpaRequest> optTpaRequest = TpaRequests.getInstance().getRequests().stream()
|
||||
.filter(r -> r.from().equals(sender))
|
||||
.findFirst();
|
||||
|
||||
Optional<TpaRequest> optTpaHereRequest = TpaRequests.getInstance().getRequests().stream()
|
||||
.filter(r -> r.to().equals(sender))
|
||||
.findFirst();
|
||||
|
||||
if(optTpaRequest.isEmpty() && optTpaHereRequest.isEmpty()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.noRequestFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequest request;
|
||||
request = optTpaRequest.orElseGet(optTpaHereRequest::get);
|
||||
TpaRequests.getInstance().removeRequest(request);
|
||||
|
||||
Player target = Bukkit.getPlayer(request.from().getName());
|
||||
|
||||
MessageUtil.sendMessage(sender, tpDenyCmd.getMessages()[0], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, tpDenyCmd.getMessages()[1], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
|
||||
} else {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if (target == null || !target.isOnline()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequest request;
|
||||
if(TpaRequests.getInstance().getTpaRequest(target, sender) != null) {
|
||||
request = TpaRequests.getInstance().getTpaRequest(target, sender);
|
||||
} else {
|
||||
request = TpaRequests.getInstance().getTpaHereRequest(sender, target);
|
||||
}
|
||||
|
||||
if (request == null) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.noRequestFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequests.getInstance().removeRequest(request);
|
||||
|
||||
MessageUtil.sendMessage(sender, tpDenyCmd.getMessages()[0], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, tpDenyCmd.getMessages()[1], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package net.miarma.mkernel.commands.tp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequest;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequests;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaType;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class TpaAcceptCommand {
|
||||
public static void register() {
|
||||
CommandWrapper tpaAcceptCmd = CommandProvider.getTpaAcceptCommand();
|
||||
new CommandAPICommand(tpaAcceptCmd.getName())
|
||||
.withOptionalArguments(CommandProvider.Arguments.playersOptArg())
|
||||
.withPermission(tpaAcceptCmd.getPermission().base())
|
||||
.withFullDescription(tpaAcceptCmd.getDescription())
|
||||
.withShortDescription(tpaAcceptCmd.getDescription())
|
||||
.withUsage(tpaAcceptCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
if(args.count() == 0) {
|
||||
Optional<TpaRequest> optTpaRequest = TpaRequests.getInstance().getRequests().stream()
|
||||
.filter(r -> r.from().equals(sender))
|
||||
.findFirst();
|
||||
|
||||
Optional<TpaRequest> optTpaHereRequest = TpaRequests.getInstance().getRequests().stream()
|
||||
.filter(r -> r.to().equals(sender))
|
||||
.findFirst();
|
||||
|
||||
if(optTpaRequest.isEmpty() && optTpaHereRequest.isEmpty()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.noRequestFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequest request;
|
||||
request = optTpaRequest.orElseGet(optTpaHereRequest::get);
|
||||
TpaRequests.getInstance().removeRequest(request);
|
||||
|
||||
Player target = Bukkit.getPlayer(request.from().getName());
|
||||
|
||||
if (request.type() == TpaType.TPA) {
|
||||
request.from().teleport(sender.getLocation());
|
||||
} else if (request.type() == TpaType.TPA_HERE) {
|
||||
sender.teleport(request.to().getLocation());
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(target, tpaAcceptCmd.getMessages()[1], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
MessageUtil.sendMessage(sender, tpaAcceptCmd.getMessages()[0], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
|
||||
} else {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if (target == null || !target.isOnline()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequest request;
|
||||
if(TpaRequests.getInstance().getTpaRequest(target, sender) != null) {
|
||||
request = TpaRequests.getInstance().getTpaRequest(target, sender);
|
||||
} else {
|
||||
request = TpaRequests.getInstance().getTpaHereRequest(sender, target);
|
||||
}
|
||||
|
||||
if (request == null) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.noRequestFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequests.getInstance().removeRequest(request);
|
||||
|
||||
if (request.type() == TpaType.TPA) {
|
||||
target.teleport(sender.getLocation());
|
||||
} else if (request.type() == TpaType.TPA_HERE) {
|
||||
sender.teleport(target.getLocation());
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(target, tpaAcceptCmd.getMessages()[1], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
MessageUtil.sendMessage(sender, tpaAcceptCmd.getMessages()[0], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
}
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
65
src/main/java/net/miarma/mkernel/commands/tp/TpaCommand.java
Normal file
65
src/main/java/net/miarma/mkernel/commands/tp/TpaCommand.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package net.miarma.mkernel.commands.tp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequests;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaType;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class TpaCommand {
|
||||
public static void register() {
|
||||
CommandWrapper tpaCmd = CommandProvider.getTpaCommand();
|
||||
new CommandAPICommand(tpaCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withPermission(tpaCmd.getPermission().base())
|
||||
.withFullDescription(tpaCmd.getDescription())
|
||||
.withShortDescription(tpaCmd.getDescription())
|
||||
.withUsage(tpaCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if (target == null || !target.isOnline()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.equals(sender)) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.cantTeleportToYourself(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean requestExists = TpaRequests.getInstance().getTpaRequest(sender, target) != null;
|
||||
if (requestExists) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.requestAlreadySent(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
/*boolean onCooldown = TpaRequests.getInstance().getCooldowns().containsKey(sender);
|
||||
if(onCooldown) {
|
||||
MessageUtils.sendMessage(sender, MessageProvider.Errors.cooldownHasNotExpired(), true,
|
||||
List.of("%time%"), List.of(
|
||||
String.valueOf((ConfigProvider.Values.getTpCooldown() -
|
||||
(System.currentTimeMillis() -
|
||||
TpaRequests.getInstance().getCooldowns().get(sender))) / 1000)));
|
||||
return;
|
||||
}*/
|
||||
|
||||
TpaRequests.getInstance().addRequest(sender, target, TpaType.TPA);
|
||||
MKernel.LOGGER.info(TpaRequests.getInstance().toString());
|
||||
|
||||
MessageUtil.sendMessage(sender, tpaCmd.getMessages()[1], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, tpaCmd.getMessages()[0], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package net.miarma.mkernel.commands.tp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequests;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaType;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class TpaHereCommand {
|
||||
public static void register() {
|
||||
CommandWrapper tpaHereCmd = CommandProvider.getTpaHereCommand();
|
||||
new CommandAPICommand(tpaHereCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withPermission(tpaHereCmd.getPermission().base())
|
||||
.withFullDescription(tpaHereCmd.getDescription())
|
||||
.withShortDescription(tpaHereCmd.getDescription())
|
||||
.withUsage(tpaHereCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
|
||||
if (target == null || !target.isOnline()) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.playerNotFound(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.equals(sender)) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.cantTeleportToYourself(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean requestExists = TpaRequests.getInstance().getTpaHereRequest(target, sender) != null;
|
||||
|
||||
if (requestExists) {
|
||||
MessageUtil.sendMessage(sender, MessageProvider.Errors.requestAlreadySent(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
TpaRequests.getInstance().addRequest(target, sender, TpaType.TPA_HERE);
|
||||
MKernel.LOGGER.info(TpaRequests.getInstance().toString());
|
||||
|
||||
MessageUtil.sendMessage(sender, tpaHereCmd.getMessages()[1], true,
|
||||
List.of("%target%"), List.of(target.getName()));
|
||||
MessageUtil.sendMessage(target, tpaHereCmd.getMessages()[0], true,
|
||||
List.of("%sender%"), List.of(sender.getName()));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.miarma.mkernel.commands.troll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.providers.CommandProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class LaunchCommand {
|
||||
public static void register() {
|
||||
CommandWrapper launchCmd = CommandProvider.getLaunchCommand();
|
||||
new CommandAPICommand(launchCmd.getName())
|
||||
.withArguments(CommandProvider.Arguments.playerArg())
|
||||
.withPermission(launchCmd.getPermission().base())
|
||||
.withFullDescription(launchCmd.getDescription())
|
||||
.withShortDescription(launchCmd.getDescription())
|
||||
.withUsage(launchCmd.getUsage())
|
||||
.executesPlayer((sender, args) -> {
|
||||
Player target = Bukkit.getPlayer(args.getRaw(0));
|
||||
target.setVelocity(target.getVelocity().setY(3));
|
||||
MessageUtil.sendMessage(sender, launchCmd.getMessages()[0], true,
|
||||
List.of("%player%"), List.of(target.getName()));
|
||||
})
|
||||
.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.miarma.mkernel.common.minecraft;
|
||||
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksPlugin;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class MinepacksAccessor {
|
||||
public MinepacksAccessor() {
|
||||
}
|
||||
|
||||
public static MinepacksPlugin getMinepacks() {
|
||||
Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks");
|
||||
if (!isLoaded()) {
|
||||
MKernel.PLUGIN.getLogger().severe("Error trying to hook Minepacks, it's not available or installed!");
|
||||
return null;
|
||||
} else {
|
||||
return (MinepacksPlugin)bukkitPlugin;
|
||||
}
|
||||
}
|
||||
|
||||
public static Inventory getPlayerBackpackInventory(Player player) {
|
||||
Backpack bp = getMinepacks().getBackpackCachedOnly(player);
|
||||
return bp == null ? null : bp.getInventory();
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
boolean res = false;
|
||||
Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks");
|
||||
if (bukkitPlugin instanceof MinepacksPlugin) {
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
102
src/main/java/net/miarma/mkernel/common/minecraft/Warp.java
Normal file
102
src/main/java/net/miarma/mkernel/common/minecraft/Warp.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package net.miarma.mkernel.common.minecraft;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Warp implements Comparable<Warp> {
|
||||
private String alias;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private String world;
|
||||
|
||||
public Warp(String alias, double x, double y, double z, String world) {
|
||||
this.alias = alias;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public static Warp of(String alias, double x, double y, double z, String world) {
|
||||
return new Warp(alias, x, y, z, world);
|
||||
}
|
||||
|
||||
public static Warp fromFile(FileConfiguration c, String alias) {
|
||||
return Warp.of(alias, c.getDouble(alias + ".x"),
|
||||
c.getDouble(alias + ".y"),
|
||||
c.getDouble(alias + ".z"),
|
||||
c.getString(alias + ".world"));
|
||||
}
|
||||
|
||||
public static void toFile(FileConfiguration c, Warp warp) {
|
||||
c.set(warp.getAlias() + ".x", warp.getX());
|
||||
c.set(warp.getAlias() + ".y", warp.getY());
|
||||
c.set(warp.getAlias() + ".z", warp.getZ());
|
||||
c.set(warp.getAlias() + ".world", warp.getWorld());
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Alias: " + alias + ", X: " + x + ", Y: " + y + ", Z: " + z + ", World: " + world;
|
||||
}
|
||||
|
||||
public String toFormattedMessage() {
|
||||
return "&b&l" + alias + ": &r\n" +
|
||||
"&aCoordenadas: &r" + x + ", " + y + ", " + z + "\n" +
|
||||
"&aMundo: &r" + world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Warp warp = (Warp) o;
|
||||
return Double.compare(x, warp.x) == 0 && Double.compare(y, warp.y) == 0 && Double.compare(z, warp.z) == 0 && Objects.equals(world, warp.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Double.hashCode(x);
|
||||
result = 31 * result + Double.hashCode(y);
|
||||
result = 31 * result + Double.hashCode(z);
|
||||
result = 31 * result + Objects.hashCode(world);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Warp o) {
|
||||
int res = Double.compare(x, o.x);
|
||||
if (res == 0) {
|
||||
res = Double.compare(y, o.y);
|
||||
if (res == 0) {
|
||||
res = Double.compare(z, o.z);
|
||||
if (res == 0) {
|
||||
res = world.compareTo(o.world);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.miarma.mkernel.common.minecraft.inventories;
|
||||
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
|
||||
public class DisposalInventory {
|
||||
private static Inventory inv;
|
||||
|
||||
public DisposalInventory() {
|
||||
}
|
||||
|
||||
public static Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
static {
|
||||
inv = Bukkit.createInventory(null, 54,
|
||||
MessageUtil.parseColors(MessageProvider.Inventories.getDisposalTitle()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.miarma.mkernel.common.minecraft.inventories;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GlobalChest {
|
||||
private static File itemsFile;
|
||||
private static FileConfiguration items;
|
||||
private static Inventory inv;
|
||||
|
||||
public GlobalChest() {
|
||||
}
|
||||
|
||||
public static File getItemsFile() {
|
||||
return itemsFile;
|
||||
}
|
||||
|
||||
public static FileConfiguration getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public static Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public static void loadChest() {
|
||||
ConfigurationSection inventorySection = items.getConfigurationSection("inventory");
|
||||
if (inventorySection != null && inventorySection.getList("items") != null) {
|
||||
inv.setContents(inventorySection.getList("items").toArray(value -> new ItemStack[value]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void saveChest() {
|
||||
ConfigurationSection inventorySection = items.createSection("inventory");
|
||||
inventorySection.set("items", inv.getContents());
|
||||
|
||||
try {
|
||||
items.save(itemsFile);
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error saving items.yml file!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
itemsFile = new File(MKernel.PLUGIN.getDataFolder(), "items.yml");
|
||||
items = YamlConfiguration.loadConfiguration(itemsFile);
|
||||
}
|
||||
|
||||
static {
|
||||
inv = Bukkit.createInventory(null, 54,
|
||||
MessageUtil.parseColors(MessageProvider.Inventories.getGlobalChestTitle()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.miarma.mkernel.common.minecraft.inventories;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InvseeInventory {
|
||||
|
||||
public static final Map<Player, Player> adminPlayerMap = new HashMap<>();
|
||||
public static final Map<Player, Inventory> activeInvseeInventories = new HashMap<>();
|
||||
|
||||
public static void setInvForAdmin(Player admin, Inventory inv, Player target) {
|
||||
adminPlayerMap.put(admin, target);
|
||||
activeInvseeInventories.put(admin, inv);
|
||||
}
|
||||
|
||||
public static Inventory getInvForAdmin(Player admin) {
|
||||
return activeInvseeInventories.get(admin);
|
||||
}
|
||||
|
||||
public static boolean isInvseeInventory(Inventory inv) {
|
||||
return activeInvseeInventories.containsValue(inv);
|
||||
}
|
||||
|
||||
public static void removeInv(Player admin) {
|
||||
adminPlayerMap.remove(admin);
|
||||
activeInvseeInventories.remove(admin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.miarma.mkernel.common.minecraft.inventories;
|
||||
|
||||
public enum SourceInventory {
|
||||
INVENTORY, BACKPACK
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.miarma.mkernel.common.minecraft.teleport;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public record TpaRequest(Player from, Player to, TpaType type, long timestamp) {
|
||||
public TpaRequest(Player from, Player to, TpaType type) {
|
||||
this(from, to, type, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package net.miarma.mkernel.common.minecraft.teleport;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TpaRequests {
|
||||
private List<TpaRequest> requests = new ArrayList<>();
|
||||
//private HashMap<Player,Long> cooldowns = new HashMap<>();
|
||||
private static TpaRequests instance;
|
||||
|
||||
private TpaRequests() {}
|
||||
|
||||
public static TpaRequests getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new TpaRequests();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addRequest(Player from, Player to, TpaType type) {
|
||||
TpaRequest existingRequest;
|
||||
if (type.equals(TpaType.TPA)) {
|
||||
existingRequest = getTpaRequest(from, to);
|
||||
} else {
|
||||
existingRequest = getTpaHereRequest(from, to);
|
||||
}
|
||||
|
||||
/*if(!cooldowns.containsKey(from)) {
|
||||
cooldowns.put(from, System.currentTimeMillis());
|
||||
}*/
|
||||
|
||||
if (existingRequest == null) {
|
||||
requests.addFirst(new TpaRequest(from, to, type));
|
||||
}
|
||||
}
|
||||
|
||||
public TpaRequest getTpaRequest(Player from, Player to) {
|
||||
return requests.stream()
|
||||
.filter(request -> request.from().equals(from) && request.to().equals(to) && request.type().equals(TpaType.TPA))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public TpaRequest getTpaHereRequest(Player from, Player to) {
|
||||
return requests.stream()
|
||||
.filter(request -> request.from().equals(from) && request.to().equals(to) && request.type().equals(TpaType.TPA_HERE))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public List<TpaRequest> getRequests() {
|
||||
return requests;
|
||||
}
|
||||
|
||||
/*public HashMap<Player,Long> getCooldowns() {
|
||||
return cooldowns;
|
||||
}
|
||||
|
||||
public void removeCooldown(Player player) {
|
||||
cooldowns.remove(player);
|
||||
}
|
||||
|
||||
public void getCooldown(Player player) {
|
||||
cooldowns.get(player);
|
||||
}*/
|
||||
|
||||
public void removeRequest(TpaRequest request) {
|
||||
requests.remove(request);
|
||||
}
|
||||
|
||||
public void clearRequests() {
|
||||
requests.clear();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (TpaRequest request : requests) {
|
||||
sb.append(request.from().getName())
|
||||
.append(" -> ")
|
||||
.append(request.to().getName())
|
||||
.append(" (")
|
||||
.append(request.type())
|
||||
.append(")\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.miarma.mkernel.common.minecraft.teleport;
|
||||
|
||||
public enum TpaType {
|
||||
TPA, TPA_HERE
|
||||
}
|
||||
115
src/main/java/net/miarma/mkernel/config/CommandWrapper.java
Normal file
115
src/main/java/net/miarma/mkernel/config/CommandWrapper.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package net.miarma.mkernel.config;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CommandWrapper {
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String[] aliases;
|
||||
private final String usage;
|
||||
private final PermissionWrapper permission;
|
||||
private final String[] messages;
|
||||
private final CommandWrapper[] subcommands;
|
||||
|
||||
private CommandWrapper(Builder builder) {
|
||||
this.name = builder.name;
|
||||
this.description = builder.description;
|
||||
this.aliases = builder.aliases;
|
||||
this.usage = builder.usage;
|
||||
this.permission = builder.permission;
|
||||
this.messages = builder.messages;
|
||||
this.subcommands = builder.subcommands;
|
||||
}
|
||||
|
||||
public static Builder command(String name) {
|
||||
return new Builder(name);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final String name;
|
||||
private String description;
|
||||
private String[] aliases;
|
||||
private String usage;
|
||||
private PermissionWrapper permission;
|
||||
private String[] messages;
|
||||
private CommandWrapper[] subcommands;
|
||||
|
||||
private Builder(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Builder withDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withAliases(String... aliases) {
|
||||
this.aliases = aliases;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withUsage(String usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withPermission(PermissionWrapper permission) {
|
||||
this.permission = permission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withMessages(String... messages) {
|
||||
this.messages = messages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withSubcommands(CommandWrapper... subcommands) {
|
||||
this.subcommands = subcommands;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapper build() {
|
||||
return new CommandWrapper(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<String> usageOptional() {
|
||||
return Optional.ofNullable(usage);
|
||||
}
|
||||
|
||||
public Optional<String[]> messagesOptional() {
|
||||
return Optional.ofNullable(messages);
|
||||
}
|
||||
|
||||
public Optional<CommandWrapper[]> subcommandsOptional() {
|
||||
return Optional.ofNullable(subcommands);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String[] getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public PermissionWrapper getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public String[] getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public CommandWrapper[] getSubcommands() {
|
||||
return subcommands;
|
||||
}
|
||||
}
|
||||
68
src/main/java/net/miarma/mkernel/config/ConfigWrapper.java
Normal file
68
src/main/java/net/miarma/mkernel/config/ConfigWrapper.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package net.miarma.mkernel.config;
|
||||
|
||||
import dev.dejvokep.boostedyaml.YamlDocument;
|
||||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
|
||||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigWrapper {
|
||||
private YamlDocument config;
|
||||
|
||||
public ConfigWrapper() {
|
||||
}
|
||||
|
||||
public YamlDocument getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
try {
|
||||
this.config = YamlDocument.create(new File(MKernel.PLUGIN.getDataFolder(), "config.yml"),
|
||||
MKernel.PLUGIN.getResource("config.yml"),
|
||||
GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(),
|
||||
DumperSettings.DEFAULT, UpdaterSettings.builder().setVersioning(new BasicVersioning("file-version"))
|
||||
.build());
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error loading config.yml file!");
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
try {
|
||||
config.reload();
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error reloading config.yml file!");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
config.save();
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error saving config.yml file!");
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String route) {
|
||||
return config.getString(route);
|
||||
}
|
||||
|
||||
public Boolean getBoolean(String route) {
|
||||
return config.getBoolean(route);
|
||||
}
|
||||
|
||||
public Integer getInt(String route) {
|
||||
return config.getInt(route);
|
||||
}
|
||||
|
||||
public List<String> getList(String route){
|
||||
return config.getStringList(route);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.miarma.mkernel.config;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CustomConfigManager {
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private File configFile;
|
||||
private FileConfiguration config;
|
||||
|
||||
public CustomConfigManager(JavaPlugin plugin, String fileName) {
|
||||
this.plugin = plugin;
|
||||
this.configFile = new File(plugin.getDataFolder(), fileName);
|
||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfig() {
|
||||
try {
|
||||
YamlConfiguration.loadConfiguration(configFile);
|
||||
} catch(Exception e) {
|
||||
MKernel.LOGGER.severe(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
public void saveDefaultConfig() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.saveResource(configFile.getName(), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Métodos adicionales para obtener datos específicos de la configuración si es necesario
|
||||
|
||||
public String getString(String path) {
|
||||
return config.getString(path);
|
||||
}
|
||||
|
||||
public int getInt(String path) {
|
||||
return config.getInt(path);
|
||||
}
|
||||
|
||||
public boolean getBoolean(String path) {
|
||||
return config.getBoolean(path);
|
||||
}
|
||||
|
||||
// Otros métodos según tus necesidades
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.miarma.mkernel.config;
|
||||
|
||||
public record PermissionWrapper(String base, String others) {
|
||||
public static PermissionWrapper of(String base) {
|
||||
return new PermissionWrapper(base, null);
|
||||
}
|
||||
public static PermissionWrapper of(String base, String others) {
|
||||
return new PermissionWrapper(base, others);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.miarma.mkernel.config;
|
||||
|
||||
public record WorldWrapper(String name, double x, double y, double z, int yaw, int pitch) {
|
||||
public WorldWrapper {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Name cannot be null");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,604 @@
|
||||
package net.miarma.mkernel.config.providers;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.Warp;
|
||||
import net.miarma.mkernel.config.CommandWrapper;
|
||||
import net.miarma.mkernel.config.PermissionWrapper;
|
||||
import net.miarma.mkernel.util.ItemUtil;
|
||||
import net.miarma.mkernel.util.PlayerUtil;
|
||||
import dev.jorel.commandapi.arguments.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.RECIPES;
|
||||
|
||||
public class CommandProvider {
|
||||
public static class Arguments {
|
||||
public static final Set<String> TITULACIONES = Set.of("IC", "IS", "TI", "SA", "IA");
|
||||
|
||||
public static Argument<?> passwordArg() {
|
||||
return new GreedyStringArgument(MKernel.CONFIG.getString("arguments.password"));
|
||||
}
|
||||
|
||||
public static Argument<?> playerArg() {
|
||||
return new PlayerProfileArgument(MKernel.CONFIG.getString("arguments.player"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(info ->
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.toList()
|
||||
.toArray(new String[0])
|
||||
));
|
||||
}
|
||||
|
||||
public static Argument<?> playersOptArg() {
|
||||
return new PlayerProfileArgument(MKernel.CONFIG.getString("arguments.player"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(info ->
|
||||
Bukkit.getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.toList()
|
||||
.toArray(new String[0])
|
||||
));
|
||||
}
|
||||
|
||||
public static Argument<?> levels() {
|
||||
return new IntegerArgument(MKernel.CONFIG.getString("arguments.levels"));
|
||||
}
|
||||
|
||||
public static Argument<?> worlds() {
|
||||
return new StringArgument(MKernel.CONFIG.getString("arguments.world"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(info ->
|
||||
Bukkit.getWorlds().stream()
|
||||
.map(x -> x.getName())
|
||||
.toList()
|
||||
.toArray(new String[0])
|
||||
));
|
||||
}
|
||||
|
||||
public static Argument<?> message() {
|
||||
return new GreedyStringArgument(MKernel.CONFIG.getString("arguments.message"));
|
||||
}
|
||||
|
||||
public static Argument<?> warpName() {
|
||||
return new GreedyStringArgument(MKernel.CONFIG.getString("arguments.warpName"));
|
||||
}
|
||||
|
||||
public static Argument<?> warps() {
|
||||
return new StringArgument(MKernel.CONFIG.getString("arguments.warp"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(info -> {
|
||||
Player p = (Player) info.sender();
|
||||
List<Warp> warps = PlayerUtil.getWarps(p);
|
||||
return warps.stream().map(Warp::getAlias).toList().toArray(new String[0]);
|
||||
}));
|
||||
}
|
||||
|
||||
public static Argument<?> items() {
|
||||
return new StringArgument(MKernel.CONFIG.getString("arguments.item"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(info ->
|
||||
RECIPES.stream()
|
||||
.map(ItemUtil::getKey)
|
||||
.toList()
|
||||
.toArray(new String[0])
|
||||
));
|
||||
}
|
||||
|
||||
public static Argument<?> titulaciones() {
|
||||
return new StringArgument(MKernel.CONFIG.getString("arguments.titulacion"))
|
||||
.replaceSuggestions(ArgumentSuggestions.strings(TITULACIONES));
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandWrapper getBaseCommand() {
|
||||
return CommandWrapper.command("mkernel")
|
||||
.withDescription(MKernel.CONFIG.getString("commands.mkernel.description"))
|
||||
.withAliases("mk")
|
||||
.withUsage(MKernel.CONFIG.getString("commands.mkernel.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.mkernel.permission")))
|
||||
.withMessages("[P] Desarrollado por ca268&lGallardo7761&r para ca268&lMiarmaCraft&r")
|
||||
.withSubcommands(
|
||||
CommandWrapper.command(MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.messages.success"),
|
||||
MKernel.CONFIG.getString("commands.mkernel.subcommands.reload.messages.error")
|
||||
)
|
||||
.build(),
|
||||
CommandWrapper.command(MKernel.CONFIG.getString("commands.mkernel.subcommands.config.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.mkernel.subcommands.config.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.mkernel.subcommands.config.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.mkernel.subcommands.config.permission")))
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static CommandWrapper getTpaCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.tpa.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.tpa.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.tpa.permission")))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.tpa.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.tpa.messages.tpaFromPlayer"),
|
||||
MKernel.CONFIG.getString("commands.tpa.messages.tpaToPlayer")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getTpaHereCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.tpahere.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.tpahere.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.tpahere.permission")))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.tpahere.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.tpahere.messages.tpaFromPlayer"),
|
||||
MKernel.CONFIG.getString("commands.tpahere.messages.tpaToPlayer")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getTpaAcceptCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.tpaccept.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.tpaccept.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.tpaccept.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.tpaccept.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.tpaccept.messages.accepted"),
|
||||
MKernel.CONFIG.getString("commands.tpaccept.messages.acceptedToTarget")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getTpDenyCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.tpdeny.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.tpdeny.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.tpdeny.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.tpdeny.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.tpdeny.messages.denied"),
|
||||
MKernel.CONFIG.getString("commands.tpdeny.messages.deniedToTarget")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getSpawnCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.spawn.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.spawn.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.spawn.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.spawn.permissions.others")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.spawn.messages.teleported"),
|
||||
MKernel.CONFIG.getString("commands.spawn.messages.spawnYouOthers"),
|
||||
MKernel.CONFIG.getString("commands.spawn.messages.spawnOthersYou")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getLobbyCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.lobby.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.lobby.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.lobby.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.lobby.permissions.others")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.lobby.messages.teleported"),
|
||||
MKernel.CONFIG.getString("commands.lobby.messages.lobbyYouOthers"),
|
||||
MKernel.CONFIG.getString("commands.lobby.messages.lobbyOthersYou")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getSendCoordsCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.sendcoords.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.sendcoords.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.sendcoords.permission")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.sendcoords.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.sendcoords.messages.sent"),
|
||||
MKernel.CONFIG.getString("commands.sendcoords.messages.coordsMsg")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getBlockWorldCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.blockworld.name"))
|
||||
.withAliases(
|
||||
MKernel.CONFIG.getConfig().getStringList("commands.blockworld.aliases").toArray(new String[0])
|
||||
)
|
||||
.withDescription(MKernel.CONFIG.getString("commands.blockworld.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.blockworld.permission")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.blockworld.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.blockworld.messages.worldHasBeenBlocked"),
|
||||
MKernel.CONFIG.getString("commands.blockworld.messages.worldHasBeenUnblocked")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getPayXpCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.payxp.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.payxp.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.payxp.permission")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.payxp.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.payxp.messages.payYouOthers"),
|
||||
MKernel.CONFIG.getString("commands.payxp.messages.payOthersYou")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getSpecialItemCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.specialitem.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.specialitem.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.specialitem.permission")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.specialitem.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.specialitem.messages.itemReceived")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getOpMeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.opme.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.opme.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.opme.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.opme.messages.opped"),
|
||||
MKernel.CONFIG.getString("commands.opme.messages.alreadyOp")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getDeopMeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.deopme.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.deopme.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.deopme.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.deopme.messages.deOpped"),
|
||||
MKernel.CONFIG.getString("commands.deopme.messages.youAreNotOp")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getDisposalCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.disposal.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.disposal.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.disposal.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.disposal.permissions.others")
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getGlobalChestCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.globalchest.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.globalchest.description"))
|
||||
.withAliases(
|
||||
MKernel.CONFIG.getConfig().getStringList("commands.globalchest.aliases").toArray(new String[0])
|
||||
)
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.globalchest.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.globalchest.permissions.others")
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getDoCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.do.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.do.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.do.permission")
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getMeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.me.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.me.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.me.permission")
|
||||
))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getSetHomeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.sethome.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.sethome.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.sethome.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.sethome.messages.homeSet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getHomeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.home.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.home.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.home.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.home.messages.teleported"),
|
||||
MKernel.CONFIG.getString("commands.home.messages.homeDoesNotExist")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getRecInvCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.recinv.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.recinv.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.recinv.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.recinv.messages.inventoryRecovered"),
|
||||
MKernel.CONFIG.getString("commands.recinv.messages.notEnoughLevels"),
|
||||
MKernel.CONFIG.getString("commands.recinv.messages.noItemsToRecover")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getGmcCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.gmc.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.gmc.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.gmc.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.gmc.permissions.others")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.gmc.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.gmc.messages.self"),
|
||||
MKernel.CONFIG.getString("commands.gmc.messages.others")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getGmsCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.gms.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.gms.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.gms.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.gms.permissions.others")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.gms.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.gms.messages.self"),
|
||||
MKernel.CONFIG.getString("commands.gms.messages.others")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getGmspCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.gmsp.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.gmsp.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.gmsp.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.gmsp.permissions.others")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.gmsp.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.gmsp.messages.self"),
|
||||
MKernel.CONFIG.getString("commands.gmsp.messages.others")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getGmaCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.gma.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.gma.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.gma.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.gma.permissions.others")
|
||||
))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.gma.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.gma.messages.self"),
|
||||
MKernel.CONFIG.getString("commands.gma.messages.others")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getVanishCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.vanish.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.vanish.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.vanish.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.vanish.messages.vanished"),
|
||||
MKernel.CONFIG.getString("commands.vanish.messages.unvanished")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getWarpCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.warp.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.warp.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.warp.permission")))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.warp.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.warp.messages.noWarpsStored"),
|
||||
MKernel.CONFIG.getString("commands.warp.messages.warpList")
|
||||
)
|
||||
.withSubcommands(
|
||||
CommandWrapper.command(MKernel.CONFIG.getString("commands.warp.subcommands.add.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.warp.subcommands.add.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.warp.subcommands.add.permission")))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.warp.subcommands.add.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.warp.subcommands.add.messages.warpAdded"),
|
||||
MKernel.CONFIG.getString("commands.warp.subcommands.add.messages.warpAlreadyExists")
|
||||
)
|
||||
.build(),
|
||||
CommandWrapper.command(MKernel.CONFIG.getString("commands.warp.subcommands.remove.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.warp.subcommands.remove.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.warp.subcommands.remove.permission")))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.warp.subcommands.remove.usage"))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.warp.subcommands.remove.messages.warpRemoved"),
|
||||
MKernel.CONFIG.getString("commands.warp.subcommands.remove.messages.warpNotFound")
|
||||
)
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public static CommandWrapper getSpyCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.spy.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.spy.description"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.spy.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.spy.messages.enabled"),
|
||||
MKernel.CONFIG.getString("commands.spy.messages.disabled")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getFreezeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.freeze.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.freeze.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.freeze.usage"))
|
||||
.withPermission(PermissionWrapper.of(MKernel.CONFIG.getString("commands.freeze.permission")))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.freeze.messages.frozen"),
|
||||
MKernel.CONFIG.getString("commands.freeze.messages.unfrozen"),
|
||||
MKernel.CONFIG.getString("commands.freeze.messages.beenFrozen"),
|
||||
MKernel.CONFIG.getString("commands.freeze.messages.beenUnfrozen")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getHealCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.heal.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.heal.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.heal.usage"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.heal.permissions.base"),
|
||||
MKernel.CONFIG.getString("commands.heal.permissions.others")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.heal.messages.healedSelf"),
|
||||
MKernel.CONFIG.getString("commands.heal.messages.healedPlayer"),
|
||||
MKernel.CONFIG.getString("commands.heal.messages.beenHealed")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getLaunchCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.launch.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.launch.description"))
|
||||
.withUsage(MKernel.CONFIG.getString("commands.launch.usage"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.launch.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.launch.messages.launched")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getSunCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.sun.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.sun.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.sun.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.sun.messages.sunSet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getRainCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.rain.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.rain.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.rain.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.rain.messages.rainSet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getThunderCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.thunder.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.thunder.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.thunder.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.thunder.messages.thunderSet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getDayCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.day.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.day.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.day.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.day.messages.daySet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getNightCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.night.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.night.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.night.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.night.messages.nightSet")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getInvseeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.invsee.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.invsee.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.invsee.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.invsee.messages.opened")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandWrapper getDegreeCommand() {
|
||||
return CommandWrapper.command(MKernel.CONFIG.getString("commands.titulacion.name"))
|
||||
.withDescription(MKernel.CONFIG.getString("commands.titulacion.description"))
|
||||
.withPermission(PermissionWrapper.of(
|
||||
MKernel.CONFIG.getString("commands.titulacion.permission")
|
||||
))
|
||||
.withMessages(
|
||||
MKernel.CONFIG.getString("commands.titulacion.messages.success"),
|
||||
MKernel.CONFIG.getString("commands.titulacion.messages.getCurrent"),
|
||||
MKernel.CONFIG.getString("commands.titulacion.messages.fail"),
|
||||
MKernel.CONFIG.getString("commands.titulacion.messages.invalid")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package net.miarma.mkernel.config.providers;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.WorldWrapper;
|
||||
import net.miarma.mkernel.util.ConversionUtil;
|
||||
|
||||
public class ConfigProvider {
|
||||
public static class Permissions {
|
||||
public static String getChatFormatPermission() {
|
||||
return MKernel.CONFIG.getString("config.permissions.chatFormat");
|
||||
}
|
||||
public static String getAdminChatPermission() {
|
||||
return MKernel.CONFIG.getString("config.permissions.adminChat");
|
||||
}
|
||||
public static String getMentionsPermission() {
|
||||
return MKernel.CONFIG.getString("config.permissions.mentions");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Values {
|
||||
public static int getRottenFleshCookTime() {
|
||||
return MKernel.CONFIG.getInt("config.values.rottenFleshCookTime");
|
||||
}
|
||||
public static int getZombificationPotionTime() {
|
||||
return MKernel.CONFIG.getInt("config.values.zombificationPotionTime");
|
||||
}
|
||||
public static int getSpawnerBreakerProbability() {
|
||||
return MKernel.CONFIG.getInt("config.values.spawnerBreakerProbability");
|
||||
}
|
||||
public static int getRecInvRequiredLevel() {
|
||||
return MKernel.CONFIG.getInt("config.values.recInvRequiredLevel");
|
||||
}
|
||||
public static float getXpLossOnDeath() {
|
||||
return MKernel.CONFIG.getConfig().getFloat("config.values.xpLossOnDeath");
|
||||
}
|
||||
public static long getTpCooldown() {
|
||||
return ConversionUtil.cooldownToMillis(MKernel.CONFIG.getString("config.values.tpCooldown"));
|
||||
}
|
||||
public static int getMaxWarps() {
|
||||
return MKernel.CONFIG.getInt("config.values.maxWarps");
|
||||
}
|
||||
public static int getRecInvPlayerRadius() {
|
||||
return MKernel.CONFIG.getInt("config.values.recInvPlayerRadius");
|
||||
}
|
||||
public static int getRecInvSpawnDistance() {
|
||||
return MKernel.CONFIG.getInt("config.values.recInvSpawnDistance");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Modules {
|
||||
public static boolean isJoinTitleEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.joinTitle");
|
||||
}
|
||||
public static boolean isLeaveTitleEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.leaveTitle");
|
||||
}
|
||||
public static boolean isDeathTitleEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.deathTitle");
|
||||
}
|
||||
public static boolean isHarvestOnRightClickEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.harvestOnRightClick");
|
||||
}
|
||||
public static boolean isAutoItemRefillEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.autoItemRefill");
|
||||
}
|
||||
public static boolean isAdminChatEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.adminChat");
|
||||
}
|
||||
public static boolean isChatFormatEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.chatFormat");
|
||||
}
|
||||
public static boolean isMentionsEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.mentions");
|
||||
}
|
||||
public static boolean isBookColorsEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.bookColors");
|
||||
}
|
||||
public static boolean isSpawnAtLobbyEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.spawnAtLobby");
|
||||
}
|
||||
public static boolean isRecoverInventoryEnabled() {
|
||||
return MKernel.CONFIG.getBoolean("config.modules.recoverInventory");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Worlds {
|
||||
public static WorldWrapper getLobby() {
|
||||
String name = MKernel.CONFIG.getString("config.worlds.lobby.name");
|
||||
double x = MKernel.CONFIG.getConfig().getDouble("config.worlds.lobby.x");
|
||||
double y = MKernel.CONFIG.getConfig().getDouble("config.worlds.lobby.y");
|
||||
double z = MKernel.CONFIG.getConfig().getDouble("config.worlds.lobby.z");
|
||||
int yaw = MKernel.CONFIG.getConfig().getInt("config.worlds.lobby.yaw");
|
||||
int pitch = MKernel.CONFIG.getConfig().getInt("config.worlds.lobby.pitch");
|
||||
return new WorldWrapper(name, x, y, z, yaw, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package net.miarma.mkernel.config.providers;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
|
||||
public class MessageProvider {
|
||||
public static String getPrefix() {
|
||||
return MKernel.CONFIG.getString("language.prefix");
|
||||
}
|
||||
public static String getAdminPrefix() {
|
||||
return MKernel.CONFIG.getString("language.adminPrefix");
|
||||
}
|
||||
|
||||
public static class Inventories {
|
||||
public static String getGlobalChestTitle() {
|
||||
return MKernel.CONFIG.getString("language.inventories.globalChest.title");
|
||||
}
|
||||
public static String getDisposalTitle() {
|
||||
return MKernel.CONFIG.getString("language.inventories.disposal.title");
|
||||
}
|
||||
public static String getInvseeTitle() {
|
||||
return MKernel.CONFIG.getString("language.inventories.invsee.title");
|
||||
}
|
||||
public static String getConfigMenuTitle() {
|
||||
return MKernel.CONFIG.getString("language.inventories.configMenu.title");
|
||||
}
|
||||
public static String getConfigMenuValueName() {
|
||||
return MKernel.CONFIG.getString("language.inventories.configMenu.valueName");
|
||||
}
|
||||
public static String getConfigMenuValueLore() {
|
||||
return MKernel.CONFIG.getString("language.inventories.configMenu.valueLore");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Titles {
|
||||
public static String getTitleFormat() {
|
||||
return MKernel.CONFIG.getString("language.titles.titleFormat");
|
||||
}
|
||||
public static String getJoinSubtitle() {
|
||||
return MKernel.CONFIG.getString("language.titles.subtitles.join");
|
||||
}
|
||||
public static String getLeaveSubtitle() {
|
||||
return MKernel.CONFIG.getString("language.titles.subtitles.leave");
|
||||
}
|
||||
public static String getDeathSubtitle() {
|
||||
return MKernel.CONFIG.getString("language.titles.subtitles.death");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Events {
|
||||
public static String getOnMentionFormat() {
|
||||
return MKernel.CONFIG.getString("language.events.onMention.format");
|
||||
}
|
||||
public static String getOnMentionMessage() {
|
||||
return MKernel.CONFIG.getString("language.events.onMention.youWereMentioned");
|
||||
}
|
||||
public static String getOnDeathLostLevelsItems() {
|
||||
return MKernel.CONFIG.getString("language.events.onDeath.lostLevelsItems");
|
||||
}
|
||||
public static String getOnDeathItemsNotRecovered() {
|
||||
return MKernel.CONFIG.getString("language.events.onDeath.itemsNotRecovered");
|
||||
}
|
||||
public static String getOnCommandSpyMessage() {
|
||||
return MKernel.CONFIG.getString("language.events.onCommand.spyMessage");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Items {
|
||||
public static String getScissorsName() {
|
||||
return MKernel.CONFIG.getString("language.items.scissors.name");
|
||||
}
|
||||
public static String getScissorsLore() {
|
||||
return MKernel.CONFIG.getString("language.items.scissors.lore");
|
||||
}
|
||||
public static String getAdminStickName() {
|
||||
return MKernel.CONFIG.getString("language.items.adminStick.name");
|
||||
}
|
||||
public static String getAdminStickLore() {
|
||||
return MKernel.CONFIG.getString("language.items.adminStick.lore");
|
||||
}
|
||||
public static String getSpawnerBreakerName() {
|
||||
return MKernel.CONFIG.getString("language.items.spawnerBreaker.name");
|
||||
}
|
||||
public static String getSpawnerBreakerLore() {
|
||||
return MKernel.CONFIG.getString("language.items.spawnerBreaker.lore");
|
||||
}
|
||||
public static String getZombificationPotionName() {
|
||||
return MKernel.CONFIG.getString("language.items.zombificationPotion.name");
|
||||
}
|
||||
public static String getZombificationPotionLore() {
|
||||
return MKernel.CONFIG.getString("language.items.zombificationPotion.lore");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Errors {
|
||||
public static String failedCreatingLangs() {
|
||||
return MKernel.CONFIG.getString("language.errors.langs");
|
||||
}
|
||||
public static String notConsoleCommand() {
|
||||
return MKernel.CONFIG.getString("language.errors.notConsoleCommand");
|
||||
}
|
||||
public static String onlyPlayerCommand() {
|
||||
return MKernel.CONFIG.getString("language.errors.onlyPlayerCommand");
|
||||
}
|
||||
public static String playerNotFound() {
|
||||
return MKernel.CONFIG.getString("language.errors.playerNotFound");
|
||||
}
|
||||
public static String cantTeleportToYourself() {
|
||||
return MKernel.CONFIG.getString("language.errors.cantTeleportToYourself");
|
||||
}
|
||||
public static String requestAlreadySent() {
|
||||
return MKernel.CONFIG.getString("language.errors.requestAlreadySent");
|
||||
}
|
||||
public static String noRequestFound() {
|
||||
return MKernel.CONFIG.getString("language.errors.noRequestFound");
|
||||
}
|
||||
public static String noPermission() {
|
||||
return MKernel.CONFIG.getString("language.errors.noPermission");
|
||||
}
|
||||
public static String tooManyArguments() {
|
||||
return MKernel.CONFIG.getString("language.errors.tooManyArguments");
|
||||
}
|
||||
public static String playerRequired() {
|
||||
return MKernel.CONFIG.getString("language.errors.playerRequired");
|
||||
}
|
||||
public static String invalidArgument() {
|
||||
return MKernel.CONFIG.getString("language.errors.invalidArgument");
|
||||
}
|
||||
public static String temporarilyDisabled() {
|
||||
return MKernel.CONFIG.getString("language.errors.temporarilyDisabled");
|
||||
}
|
||||
public static String itemNotFound() {
|
||||
return MKernel.CONFIG.getString("language.errors.itemNotFound");
|
||||
}
|
||||
public static String lobbyDoesNotExist() {
|
||||
return MKernel.CONFIG.getString("language.errors.lobbyDoesNotExist");
|
||||
}
|
||||
public static String worldIsBlocked() {
|
||||
return MKernel.CONFIG.getString("language.errors.worldIsBlocked");
|
||||
}
|
||||
public static String notEnoughLevels() {
|
||||
return MKernel.CONFIG.getString("language.errors.notEnoughLevels");
|
||||
}
|
||||
public static String cooldownHasNotExpired() {
|
||||
return MKernel.CONFIG.getString("language.errors.cooldownHasNotExpired");
|
||||
}
|
||||
public static String maxWarpsReached() {
|
||||
return MKernel.CONFIG.getString("language.errors.maxWarpsReached");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package net.miarma.mkernel.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BlockEventHelper {
|
||||
private Player player;
|
||||
private Block block;
|
||||
|
||||
private BlockEventHelper(Player player, Block block) {
|
||||
this.player = player;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public static BlockEventHelper of(Player player, Block block) {
|
||||
return new BlockEventHelper(player, block);
|
||||
}
|
||||
|
||||
public void handleWheat() {
|
||||
if (block.getBlockData().getAsString().contains("age=7")) {
|
||||
int n = (int) ((Math.random() + 1) * 2.25);
|
||||
block.setBlockData(Bukkit.createBlockData("minecraft:wheat[age=0]"));
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.WHEAT, n));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePotatoes() {
|
||||
if (block.getBlockData().getAsString().contains("age=7")) {
|
||||
int n = (int) ((Math.random() + 1) * 2.25);
|
||||
block.setBlockData(Bukkit.createBlockData("minecraft:potatoes[age=0]"));
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.POTATO, n));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCarrots() {
|
||||
if (block.getBlockData().getAsString().contains("age=7")) {
|
||||
int n = (int) ((Math.random() + 1) * 2.25);
|
||||
block.setBlockData(Bukkit.createBlockData("minecraft:carrots[age=0]"));
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.CARROT, n));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleBeetroots() {
|
||||
if (block.getBlockData().getAsString().contains("age=3")) {
|
||||
int n = (int) ((Math.random() + 1) * 2.75);
|
||||
block.setBlockData(Bukkit.createBlockData("minecraft:beetroots[age=0]"));
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.BEETROOT, n));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCocoa() {
|
||||
if (block.getBlockData().getAsString().contains("age=2")) {
|
||||
int n = (int) ((Math.random() + 1) * 2.25);
|
||||
block.setBlockData(Bukkit.createBlockData("minecraft:cocoa[age=0]"));
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.COCOA_BEANS, n));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleTorchflower() {
|
||||
if (block.getBlockData().getAsString().contains("age=1")) {
|
||||
block.setType(Material.AIR);
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.TORCHFLOWER, 1));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePitcher() {
|
||||
if (block.getBlockData().getAsString().contains("age=4")) {
|
||||
block.setType(Material.AIR);
|
||||
player.getWorld().dropItemNaturally(block.getLocation(), new ItemStack(Material.PITCHER_PLANT, 1));
|
||||
player.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
180
src/main/java/net/miarma/mkernel/events/EntityEventHelper.java
Normal file
180
src/main/java/net/miarma/mkernel/events/EntityEventHelper.java
Normal file
@@ -0,0 +1,180 @@
|
||||
package net.miarma.mkernel.events;
|
||||
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class EntityEventHelper {
|
||||
|
||||
private Player player;
|
||||
private Entity entity;
|
||||
private ItemStack itemStack;
|
||||
private ItemMeta itemMeta;
|
||||
private int damage = 0;
|
||||
private Damageable dMeta;
|
||||
private int maxDamage;
|
||||
private int amount;
|
||||
|
||||
private EntityEventHelper(PlayerInteractEntityEvent event) {
|
||||
player = event.getPlayer();
|
||||
entity = event.getRightClicked();
|
||||
itemStack = player.getItemInHand();
|
||||
itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta instanceof Damageable) {
|
||||
dMeta = (Damageable) itemMeta;
|
||||
damage = dMeta.getDamage();
|
||||
}
|
||||
maxDamage = itemStack.getType().getMaxDurability();
|
||||
amount = itemStack.getAmount();
|
||||
}
|
||||
|
||||
public static EntityEventHelper of(PlayerInteractEntityEvent event) {
|
||||
return new EntityEventHelper(event);
|
||||
}
|
||||
|
||||
public void handleScissorsOnCreeper() {
|
||||
double r = Math.random();
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
if (r < 0.10) {
|
||||
this.entity.remove();
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
this.player.playEffect(EntityEffect.FIREWORK_EXPLODE);
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.VINE, n));
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.GUNPOWDER, n));
|
||||
double r2 = Math.random();
|
||||
if (r2 < 0.30) {
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.CREEPER_HEAD, 1));
|
||||
}
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
} else {
|
||||
if (damage + 1 <= maxDamage) {
|
||||
dMeta.setDamage(damage + 1);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleScissorsOnPig() {
|
||||
double r = Math.random();
|
||||
if(r < 0.30) {
|
||||
if (((Ageable) this.entity).isAdult()) {
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
((Ageable) this.entity).setBaby();
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.PORKCHOP, n));
|
||||
|
||||
}
|
||||
}
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void handleScissorsOnCow() {
|
||||
double r = Math.random();
|
||||
if(r < 0.30) {
|
||||
if (((Ageable) this.entity).isAdult()) {
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
((Ageable) this.entity).setBaby();
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.BEEF, n));
|
||||
}
|
||||
}
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleScissorsOnRabbit() {
|
||||
double r = Math.random();
|
||||
if(r < 0.30) {
|
||||
if (((Ageable) this.entity).isAdult()) {
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
((Ageable) this.entity).setBaby();
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.RABBIT, n));
|
||||
}
|
||||
}
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleScissorsOnChicken() {
|
||||
double r = Math.random();
|
||||
if(r < 0.30) {
|
||||
if (((Ageable) this.entity).isAdult()) {
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
((Ageable) this.entity).setBaby();
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.CHICKEN, n));
|
||||
}
|
||||
}
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleScissorsOnZombie() {
|
||||
double r = Math.random();
|
||||
if (r < 0.5) {
|
||||
if (((Ageable) this.entity).isAdult()) {
|
||||
int n = (int) ((Math.random() + 1) * 1.25);
|
||||
this.player.playSound(this.player.getLocation(), Sound.ENTITY_SHEEP_SHEAR, 1, 1);
|
||||
this.entity.remove();
|
||||
Skeleton skeleton = (Skeleton) this.entity.getLocation().getWorld().spawnEntity(this.entity.getLocation(),
|
||||
EntityType.SKELETON);
|
||||
EntityEquipment equipment = skeleton.getEquipment();
|
||||
equipment.setItemInMainHand(null);
|
||||
this.player.getWorld().dropItemNaturally(this.entity.getLocation(), new ItemStack(Material.ROTTEN_FLESH, n));
|
||||
if (damage + 2 <= this.maxDamage) {
|
||||
dMeta.setDamage(damage + 2);
|
||||
this.itemStack.setItemMeta(dMeta);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleRottenFleshOnSkeleton() {
|
||||
int r = (int) (Math.random() * 100.);
|
||||
if(r >= 50) {
|
||||
if(this.amount >= 15) {
|
||||
this.entity.remove();
|
||||
this.itemStack.setAmount(amount - 15);
|
||||
Zombie zombie = (Zombie) this.entity.getLocation().getWorld()
|
||||
.spawnEntity(this.entity.getLocation(), EntityType.ZOMBIE);
|
||||
EntityEquipment equipment = zombie.getEquipment();
|
||||
equipment.setItemInMainHand(new ItemStack(Material.BOW));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleTotemOnPillager() {
|
||||
this.itemStack.setAmount(0);
|
||||
double n = Math.random();
|
||||
if (n < 0.15) {
|
||||
this.entity.remove();
|
||||
Villager villager = (Villager) this.entity.getLocation().getWorld()
|
||||
.spawnEntity(this.entity.getLocation(),
|
||||
EntityType.VILLAGER);
|
||||
villager.setBaby();
|
||||
this.player.playSound(this.player.getLocation(), Sound.ITEM_TOTEM_USE, 1, 1);
|
||||
this.player.playEffect(EntityEffect.TOTEM_RESURRECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
686
src/main/java/net/miarma/mkernel/events/EventListener.java
Normal file
686
src/main/java/net/miarma/mkernel/events/EventListener.java
Normal file
@@ -0,0 +1,686 @@
|
||||
package net.miarma.mkernel.events;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.ADMIN_STICK_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.FROZEN_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SCISSORS_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SPAWNER_BREAKER_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
import static net.miarma.mkernel.util.Constants.SPY_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.VANISH_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.ZOMBIFICATION_POTION_KEY;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockCookEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.CampfireStartEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEditBookEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemBreakEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.MinepacksAccessor;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.DisposalInventory;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.GlobalChest;
|
||||
import net.miarma.mkernel.common.minecraft.inventories.InvseeInventory;
|
||||
import net.miarma.mkernel.config.CustomConfigManager;
|
||||
import net.miarma.mkernel.config.providers.ConfigProvider;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.tasks.LocationTrackerTask;
|
||||
import net.miarma.mkernel.util.FileUtil;
|
||||
import net.miarma.mkernel.util.InventoryUtil;
|
||||
import net.miarma.mkernel.util.ItemUtil;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
import net.miarma.mkernel.util.PlayerUtil;
|
||||
|
||||
public class EventListener {
|
||||
public static void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (event.getInventory().equals(GlobalChest.getInv())) {
|
||||
GlobalChest.loadChest();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getInventory().equals(GlobalChest.getInv())) {
|
||||
GlobalChest.saveChest();
|
||||
} else if(event.getInventory().equals(DisposalInventory.getInv())) {
|
||||
DisposalInventory.getInv().clear();
|
||||
} else if(InvseeInventory.isInvseeInventory(event.getInventory())) {
|
||||
Player admin = (Player) event.getPlayer();
|
||||
|
||||
if (!InvseeInventory.adminPlayerMap.containsKey(admin)) return;
|
||||
|
||||
Player target = InvseeInventory.adminPlayerMap.remove(admin);
|
||||
Inventory view = event.getInventory();
|
||||
PlayerInventory tInv = target.getInventory();
|
||||
|
||||
for (int i = 0; i < 36; i++) {
|
||||
tInv.setItem(i, view.getItem(i));
|
||||
}
|
||||
|
||||
tInv.setHelmet(view.getItem(36));
|
||||
tInv.setChestplate(view.getItem(37));
|
||||
tInv.setLeggings(view.getItem(38));
|
||||
tInv.setBoots(view.getItem(39));
|
||||
tInv.setItemInOffHand(view.getItem(40));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) throws IOException {
|
||||
Player player = event.getEntity();
|
||||
int playerLevel = player.getLevel();
|
||||
float playerExp = player.getExp();
|
||||
|
||||
if (ConfigProvider.Modules.isDeathTitleEnabled()) {
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
for (Player p : players) {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_WITHER_DEATH, 1, 1);
|
||||
p.sendTitle(MessageUtil.parseColors(
|
||||
MessageUtil.parsePlaceholders(
|
||||
MessageProvider.Titles.getDeathSubtitle(),
|
||||
List.of("%player%"), List.of(player.getName()))),
|
||||
"", 30, 30, 30);
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigProvider.Modules.isRecoverInventoryEnabled()) {
|
||||
Location deathLocation = player.getLocation();
|
||||
List<String> deathCoords = List.of(String.valueOf(deathLocation.getBlockX()),
|
||||
String.valueOf(deathLocation.getBlockY()), String.valueOf(deathLocation.getBlockZ()));
|
||||
Location playerSpawnPoint = player.getRespawnLocation();
|
||||
if (playerSpawnPoint == null) {
|
||||
playerSpawnPoint = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
|
||||
Collection<Player> players = (Collection<Player>) Bukkit.getOnlinePlayers();
|
||||
if(deathLocation.distance(playerSpawnPoint) <= ConfigProvider.Values.getRecInvSpawnDistance() ||
|
||||
PlayerUtil.playersNearRadius(player, players, ConfigProvider.Values.getRecInvPlayerRadius())) {
|
||||
MessageUtil.sendMessage(player, MessageProvider.Events.getOnDeathItemsNotRecovered(), true,
|
||||
List.of("%x%", "%y%", "%z%"), deathCoords);
|
||||
} else {
|
||||
FileUtil.saveInventory(player);
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
event.setKeepInventory(true);
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
|
||||
float xpLossOnDeath = ConfigProvider.Values.getXpLossOnDeath();
|
||||
int levelsToLose = Math.round(playerLevel * xpLossOnDeath);
|
||||
int newLevel = Math.max(0, playerLevel - levelsToLose);
|
||||
|
||||
event.setNewLevel(newLevel);
|
||||
event.setNewExp((int) playerExp);
|
||||
|
||||
MessageUtil.sendMessage(player, MessageProvider.Events.getOnDeathLostLevelsItems(), true,
|
||||
List.of("%levels%"), List.of(String.valueOf(levelsToLose)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(ConfigProvider.Modules.isSpawnAtLobbyEnabled()) {
|
||||
if(Bukkit.getServer().getWorlds().stream()
|
||||
.map(World::getName)
|
||||
.map(String::toLowerCase)
|
||||
.anyMatch(w -> w.contains(ConfigProvider.Worlds.getLobby().name()))) {
|
||||
player.teleport(
|
||||
new Location(
|
||||
Bukkit.getWorld(ConfigProvider.Worlds.getLobby().name()),
|
||||
ConfigProvider.Worlds.getLobby().x(),
|
||||
ConfigProvider.Worlds.getLobby().y(),
|
||||
ConfigProvider.Worlds.getLobby().z(),
|
||||
ConfigProvider.Worlds.getLobby().yaw(),
|
||||
ConfigProvider.Worlds.getLobby().pitch()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
MKernel.getPlugin(MKernel.class).getLogger()
|
||||
.log(Level.SEVERE, MessageUtil.formatMessageConsole(
|
||||
MessageProvider.Errors.lobbyDoesNotExist(), true));
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigProvider.Modules.isJoinTitleEnabled()) {
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
for (Player p : players) {
|
||||
p.sendTitle(
|
||||
MessageUtil.parseColors(MessageProvider.Titles.getTitleFormat())
|
||||
+ player.getName(),
|
||||
MessageUtil.parseColors(MessageProvider.Titles.getJoinSubtitle()), 30,
|
||||
30, 30);
|
||||
}
|
||||
}
|
||||
|
||||
player.getPersistentDataContainer().set(VANISH_KEY, PersistentDataType.BOOLEAN, false);
|
||||
|
||||
File f1 = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "warps/"
|
||||
+ event.getPlayer().getName() + ".yml");
|
||||
File f2 = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "inventories/"
|
||||
+ event.getPlayer().getName() + ".yml");
|
||||
|
||||
try {
|
||||
f1.createNewFile();
|
||||
f2.createNewFile();
|
||||
} catch (IOException e) {
|
||||
MKernel.LOGGER.severe("Error creating file for " + event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent event) {
|
||||
if (ConfigProvider.Modules.isLeaveTitleEnabled()) {
|
||||
Player player = event.getPlayer();
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
for (Player p : players) {
|
||||
p.sendTitle(
|
||||
MessageUtil.parseColors(MessageProvider.Titles.getTitleFormat())
|
||||
+ player.getName(),
|
||||
MessageUtil.parseColors(MessageProvider.Titles.getLeaveSubtitle()), 30,
|
||||
30, 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRightClick(PlayerInteractEvent event) {
|
||||
if (!ConfigProvider.Modules.isHarvestOnRightClickEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Block block = event.getClickedBlock();
|
||||
Player player = event.getPlayer();
|
||||
if (block != null) {
|
||||
BlockEventHelper helper = BlockEventHelper.of(player, block);
|
||||
Material blockType = block.getType();
|
||||
switch (blockType) {
|
||||
case WHEAT: helper.handleWheat(); break;
|
||||
case POTATOES: helper.handlePotatoes(); break;
|
||||
case CARROTS: helper.handleCarrots(); break;
|
||||
case BEETROOTS: helper.handleBeetroots(); break;
|
||||
case COCOA: helper.handleCocoa(); break;
|
||||
case TORCHFLOWER_CROP: helper.handleTorchflower(); break;
|
||||
case PITCHER_CROP: helper.handlePitcher(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityRightClick(PlayerInteractEntityEvent event) {
|
||||
Entity e = event.getRightClicked();
|
||||
EquipmentSlot h = event.getHand();
|
||||
EntityEventHelper helper = EntityEventHelper.of(event);
|
||||
ItemStack item = event.getPlayer().getItemInHand();
|
||||
if(item == null || item.getType().equals(Material.AIR) || item.getAmount() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
AtomicReference<String> specialType = new AtomicReference<>();
|
||||
NBT.get(item, nbt -> {
|
||||
specialType.set(nbt.getString(SPECIAL_ITEM_TAG));
|
||||
});
|
||||
|
||||
if(h.equals(EquipmentSlot.HAND)) {
|
||||
switch(e.getType()) {
|
||||
case PIG:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnPig();
|
||||
}
|
||||
break;
|
||||
case COW:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnCow();
|
||||
}
|
||||
break;
|
||||
case RABBIT:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnRabbit();
|
||||
}
|
||||
break;
|
||||
case CHICKEN:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnChicken();
|
||||
}
|
||||
break;
|
||||
case CREEPER:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnCreeper();
|
||||
}
|
||||
break;
|
||||
case ZOMBIE:
|
||||
if(SCISSORS_KEY.equals(specialType.get())) {
|
||||
helper.handleScissorsOnZombie();
|
||||
}
|
||||
break;
|
||||
case SKELETON:
|
||||
if(item.getType().equals(Material.ROTTEN_FLESH)) {
|
||||
helper.handleRottenFleshOnSkeleton();
|
||||
}
|
||||
break;
|
||||
case PILLAGER:
|
||||
if(item.getType().equals(Material.TOTEM_OF_UNDYING)) {
|
||||
helper.handleTotemOnPillager();
|
||||
}
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityLeftClick(EntityDamageByEntityEvent event) {
|
||||
if (event.getDamager() instanceof Player player) {
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
Material material = itemStack.getType();
|
||||
|
||||
AtomicReference<String> specialType = new AtomicReference<>();
|
||||
NBT.get(itemStack, nbt -> {
|
||||
specialType.set(nbt.getString(SPECIAL_ITEM_TAG));
|
||||
});
|
||||
|
||||
if (material.equals(Material.STICK) &&
|
||||
ADMIN_STICK_KEY.equals(specialType.get()) &&
|
||||
event.getEntity() instanceof LivingEntity) {
|
||||
((LivingEntity) event.getEntity()).setHealth(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCampfireCook(BlockCookEvent event) {
|
||||
if (event.getBlock().getType() == Material.CAMPFIRE) {
|
||||
if (event.getSource().getType() == Material.ROTTEN_FLESH) {
|
||||
event.setResult(new ItemStack(ItemUtil.getBeefBoneWithProb()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockedWorldEnter(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String world = player.getWorld().getName();
|
||||
|
||||
CustomConfigManager worldBlockerConfigManager = new CustomConfigManager(MKernel.PLUGIN, "blockedWorlds.yml");
|
||||
worldBlockerConfigManager.reloadConfig();
|
||||
|
||||
List<String> blockedWorlds = worldBlockerConfigManager.getConfig().getStringList("blockedWorlds");
|
||||
|
||||
if (blockedWorlds.contains(world)) {
|
||||
Location loc = LocationTrackerTask.getPlayerRealTimeLocation(player);
|
||||
player.teleport(new Location(loc.getWorld(), loc.getX()-2, loc.getY(), loc.getZ()-2));
|
||||
|
||||
MessageUtil.sendMessage(player, MessageProvider.Errors.worldIsBlocked(), true,
|
||||
List.of("%world%"), List.of(world));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChatMessage(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
|
||||
if(ConfigProvider.Modules.isChatFormatEnabled()) {
|
||||
if(player.hasPermission(ConfigProvider.Permissions.getChatFormatPermission())) {
|
||||
event.setMessage(MessageUtil.parseColors(event.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String message = event.getMessage();
|
||||
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
|
||||
|
||||
for(Player p:players) {
|
||||
PersistentDataContainer data = p.getPersistentDataContainer();
|
||||
boolean canSpy = Boolean.TRUE.equals(data.get(SPY_KEY, PersistentDataType.BOOLEAN));
|
||||
if(canSpy && !player.equals(p)) {
|
||||
MessageUtil.sendMessage(p, MessageProvider.Events.getOnCommandSpyMessage(), false,
|
||||
List.of("%player%", "%message%"), List.of(player.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAdminMessage(AsyncPlayerChatEvent event) {
|
||||
if(ConfigProvider.Modules.isAdminChatEnabled()) {
|
||||
if(event.getMessage().startsWith("#") &&
|
||||
event.getPlayer().hasPermission(ConfigProvider.Permissions.getAdminChatPermission())) {
|
||||
String msg = event.getMessage()
|
||||
.replaceFirst("#",
|
||||
MessageUtil.parseColors(MessageProvider.getAdminPrefix()+" "+
|
||||
"&7" + event.getPlayer().getName() + "&b: &r"))
|
||||
.replace(" ", " ");
|
||||
event.setCancelled(true);
|
||||
for(Player p:Bukkit.getOnlinePlayers()) {
|
||||
if(p.hasPermission(ConfigProvider.Permissions.getAdminChatPermission())) {
|
||||
p.sendRawMessage(msg);
|
||||
}
|
||||
}
|
||||
} else if(event.getMessage().startsWith("#") &&
|
||||
!event.getPlayer().hasPermission(ConfigProvider.Permissions.getAdminChatPermission())) {
|
||||
event.setCancelled(true);
|
||||
MessageUtil.sendMessage(event.getPlayer(), MessageProvider.Errors.noPermission(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMention(AsyncPlayerChatEvent event) {
|
||||
if(ConfigProvider.Modules.isMentionsEnabled()) {
|
||||
List<String> players = Bukkit.getServer().getOnlinePlayers().stream().map(Player::getName).toList();
|
||||
boolean containsPlayer = false;
|
||||
if(event.getPlayer().hasPermission(
|
||||
ConfigProvider.Permissions.getMentionsPermission()
|
||||
)) {
|
||||
Player victim = null;
|
||||
for(String s:players) {
|
||||
if(event.getMessage().contains("@"+s)) {
|
||||
victim = Bukkit.getServer().getPlayer(s);
|
||||
containsPlayer = true;
|
||||
}
|
||||
}
|
||||
if (victim != null && containsPlayer){
|
||||
String formattedMention = MessageUtil.parseColors(MessageProvider.Events.getOnMentionFormat()+victim.getName())+ChatColor.RESET;
|
||||
event.setMessage(event.getMessage().replace(victim.getName(), formattedMention));
|
||||
|
||||
MessageUtil.sendMessage(victim, MessageProvider.Events.getOnMentionMessage(), true,
|
||||
List.of("%player%"), List.of(event.getPlayer().getName()));
|
||||
|
||||
victim.playSound(victim, Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (ConfigProvider.Modules.isAutoItemRefillEnabled()) {
|
||||
ItemStack item = event.getItemInHand();
|
||||
Material material = event.getBlockPlaced().getType();
|
||||
Inventory playerInventory = event.getPlayer().getInventory();
|
||||
Inventory playerBackpack;
|
||||
|
||||
if (item.getAmount() == 1) {
|
||||
int itemCountInInventory = InventoryUtil.getItemCount(playerInventory, material);
|
||||
|
||||
if (itemCountInInventory > 1) {
|
||||
InventoryUtil.refillItem(event.getPlayer(), material, event.getHand());
|
||||
} else {
|
||||
if(MinepacksAccessor.isLoaded()) {
|
||||
playerBackpack = MinepacksAccessor.getPlayerBackpackInventory(event.getPlayer());
|
||||
if (!(playerBackpack == null) && !playerBackpack.isEmpty()) {
|
||||
for (ItemStack i : playerBackpack.getContents()) {
|
||||
if (i != null && i.getType().equals(material)) {
|
||||
InventoryUtil.refillItemFromMinepack(event.getPlayer(), material, event.getHand());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
ItemStack item = p.getItemInHand();
|
||||
|
||||
if(item == null)
|
||||
return;
|
||||
if(item.getType().equals(Material.AIR))
|
||||
return;
|
||||
if(item.getAmount() == 0)
|
||||
return;
|
||||
|
||||
PlayerInventory inv = p.getInventory();
|
||||
Block block = event.getBlock();
|
||||
AtomicReference<String> specialType = new AtomicReference<>();
|
||||
NBT.get(item, nbt -> {
|
||||
specialType.set(nbt.getString(SPECIAL_ITEM_TAG));
|
||||
});
|
||||
|
||||
if(specialType != null && SPAWNER_BREAKER_KEY.equals(specialType.get())) {
|
||||
int prob = (int) (Math.random() * 100);
|
||||
if(prob > ConfigProvider.Values.getSpawnerBreakerProbability()) {
|
||||
event.setCancelled(true);
|
||||
for(int i = 0; i < inv.getSize(); i++) {
|
||||
ItemStack invItem = inv.getItem(i);
|
||||
if (invItem != null &&
|
||||
invItem.getType() != Material.AIR &&
|
||||
invItem.getAmount() != 0) {
|
||||
AtomicReference<String> specialTypeInv = new AtomicReference<>();
|
||||
NBT.get(invItem, nbt -> {
|
||||
specialTypeInv.set(nbt.getString(SPECIAL_ITEM_TAG));
|
||||
});
|
||||
if (specialType.get().equals(specialTypeInv.get())) {
|
||||
p.playSound(p, Sound.ENTITY_ITEM_BREAK, 1, 1);
|
||||
inv.clear(p.getInventory().getHeldItemSlot());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof CreatureSpawner) {
|
||||
CreatureSpawner spawner = (CreatureSpawner) state;
|
||||
ItemStack spawnerItem = new ItemStack(Material.SPAWNER);
|
||||
BlockStateMeta meta = (BlockStateMeta) spawnerItem.getItemMeta();
|
||||
meta.setBlockState(spawner);
|
||||
spawnerItem.setItemMeta(meta);
|
||||
block.getWorld().dropItem(block.getLocation(), spawnerItem);
|
||||
block.setType(Material.AIR); // Remove the spawner block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemBreak(PlayerItemBreakEvent event) {
|
||||
if(ConfigProvider.Modules.isAutoItemRefillEnabled()) {
|
||||
ItemStack item = event.getBrokenItem();
|
||||
Material material = item.getType();
|
||||
PlayerInventory playerInventory = event.getPlayer().getInventory();
|
||||
Inventory playerBackpack;
|
||||
EquipmentSlot hand = (playerInventory.getItemInMainHand().getType().equals(Material.AIR) ||
|
||||
!playerInventory.getItemInMainHand().getType().equals(item.getType())) ?
|
||||
EquipmentSlot.OFF_HAND : EquipmentSlot.HAND;
|
||||
|
||||
if(item.getAmount() == 1) {
|
||||
int itemCountInInventory = InventoryUtil.getItemCount(playerInventory, material);
|
||||
if (itemCountInInventory > 1) {
|
||||
InventoryUtil.refillItem(event.getPlayer(), material, hand);
|
||||
} else {
|
||||
if(MinepacksAccessor.isLoaded()) {
|
||||
playerBackpack = MinepacksAccessor.getPlayerBackpackInventory(event.getPlayer());
|
||||
if(!(playerBackpack == null) && !playerBackpack.isEmpty()) {
|
||||
for (ItemStack i : playerBackpack.getContents()) {
|
||||
if (i != null && i.getType().equals(material)) {
|
||||
InventoryUtil.refillItemFromMinepack(event.getPlayer(), material, hand);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCampfireCook(CampfireStartEvent event) {
|
||||
if(!event.getBlock().getBlockData().getMaterial().equals(Material.SOUL_CAMPFIRE)) {
|
||||
event.setTotalCookTime((int)Math.floor(1.5*event.getTotalCookTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
Player p = event.getEntity().getKiller();
|
||||
if(p == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack i = p.getItemInHand();
|
||||
if (i == null || !i.hasItemMeta() || i.getItemMeta().getEnchants().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Enchantment ench = i.getEnchantments().entrySet().stream()
|
||||
.map(entry -> entry.getKey())
|
||||
.filter(e -> e == Enchantment.LOOTING)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if(ench == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntityType().equals(EntityType.ZOMBIE) ||
|
||||
event.getEntityType().equals(EntityType.ZOMBIE_VILLAGER)) {
|
||||
int prob = (int) (Math.random() * 100);
|
||||
if(p.getItemInHand().getEnchantments().keySet().stream()
|
||||
.anyMatch(e -> e.equals(ench))) {
|
||||
if (prob < 70) {
|
||||
event.getEntity().getWorld()
|
||||
.dropItem(event.getEntity().getLocation(), new ItemStack(Material.ZOMBIE_HEAD,1));
|
||||
}
|
||||
} else {
|
||||
if (prob < 50) {
|
||||
event.getEntity().getWorld()
|
||||
.dropItem(event.getEntity().getLocation(), new ItemStack(Material.ZOMBIE_HEAD,1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPotionSplash(PotionSplashEvent event) {
|
||||
ItemStack potion = event.getPotion().getItem();
|
||||
AtomicReference<String> specialType = new AtomicReference<>();
|
||||
NBT.get(potion, nbt -> {
|
||||
specialType.set(nbt.getString(SPECIAL_ITEM_TAG));
|
||||
});
|
||||
if(ZOMBIFICATION_POTION_KEY.equals(specialType.get())) {
|
||||
Collection<LivingEntity> entities = event.getAffectedEntities();
|
||||
int r = (int) (Math.random() * 100.);
|
||||
for(LivingEntity le : entities) {
|
||||
if(le instanceof Villager v) {
|
||||
if(r >= 30) {
|
||||
v.zombify();
|
||||
} else {
|
||||
v.setHealth(0.);
|
||||
}
|
||||
}
|
||||
if(le instanceof Player p) {
|
||||
p.addPotionEffect(
|
||||
new PotionEffect(PotionEffectType.POISON, 60*20, 3)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBookWrite(PlayerEditBookEvent event) {
|
||||
if(ConfigProvider.Modules.isBookColorsEnabled()) {
|
||||
var bookMeta = event.getNewBookMeta();
|
||||
var pages = bookMeta.getPages();
|
||||
var newPages = new ArrayList<String>();
|
||||
for (String page : pages) {
|
||||
newPages.add(page.replace('&', '§'));
|
||||
}
|
||||
bookMeta.setPages(newPages);
|
||||
event.setNewBookMeta(bookMeta);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location loc = player.getLocation();
|
||||
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
boolean isFrozen = Boolean.TRUE.equals(data.get(FROZEN_KEY, PersistentDataType.BOOLEAN));
|
||||
|
||||
if(isFrozen) {
|
||||
event.setCancelled(true);
|
||||
double x = loc.getX();
|
||||
double y = loc.getY();
|
||||
double z = loc.getZ();
|
||||
Location newLoc = new Location(loc.getWorld(), x, y, z);
|
||||
player.teleport(newLoc);
|
||||
}
|
||||
}
|
||||
|
||||
}, MKernel.PLUGIN);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
src/main/java/net/miarma/mkernel/recipes/RecipeManager.java
Normal file
35
src/main/java/net/miarma/mkernel/recipes/RecipeManager.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package net.miarma.mkernel.recipes;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.ADMIN_STICK_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.ROTTEN_CAMFIRE_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SCISSORS_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SPAWNER_BREAKER_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.ZOMBIFICATION_POTION_KEY;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.recipes.misc.RottenFleshCampfireRecipe;
|
||||
import net.miarma.mkernel.recipes.potions.ZombificationPotionRecipe;
|
||||
import net.miarma.mkernel.recipes.tools.AdminStickRecipe;
|
||||
import net.miarma.mkernel.recipes.tools.ScissorsRecipe;
|
||||
import net.miarma.mkernel.recipes.tools.SpawnerBreakerRecipe;
|
||||
|
||||
public class RecipeManager {
|
||||
public static void onEnable() {
|
||||
Bukkit.getServer().addRecipe(AdminStickRecipe.get());
|
||||
Bukkit.getServer().addRecipe(ScissorsRecipe.get());
|
||||
Bukkit.getServer().addRecipe(RottenFleshCampfireRecipe.get());
|
||||
Bukkit.getServer().addRecipe(SpawnerBreakerRecipe.get());
|
||||
Bukkit.getServer().addRecipe(ZombificationPotionRecipe.get());
|
||||
}
|
||||
|
||||
public static void onDisable() {
|
||||
Bukkit.getServer().removeRecipe(new NamespacedKey(MKernel.PLUGIN, ADMIN_STICK_KEY));
|
||||
Bukkit.getServer().removeRecipe(new NamespacedKey(MKernel.PLUGIN, SCISSORS_KEY));
|
||||
Bukkit.getServer().removeRecipe(new NamespacedKey(MKernel.PLUGIN, ROTTEN_CAMFIRE_KEY));
|
||||
Bukkit.getServer().removeRecipe(new NamespacedKey(MKernel.PLUGIN, SPAWNER_BREAKER_KEY));
|
||||
Bukkit.getServer().removeRecipe(new NamespacedKey(MKernel.PLUGIN, ZOMBIFICATION_POTION_KEY));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.miarma.mkernel.recipes.misc;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.*;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.ConfigProvider;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.CampfireRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.recipe.CookingBookCategory;
|
||||
|
||||
public class RottenFleshCampfireRecipe {
|
||||
public static CampfireRecipe get() {
|
||||
NamespacedKey rottenRecipeKey = new NamespacedKey(MKernel.PLUGIN, ROTTEN_CAMFIRE_KEY);
|
||||
CampfireRecipe rottenRecipe = new CampfireRecipe(
|
||||
rottenRecipeKey,
|
||||
new ItemStack(Material.BEEF),
|
||||
Material.ROTTEN_FLESH,
|
||||
0, ConfigProvider.Values.getRottenFleshCookTime() * 20);
|
||||
rottenRecipe.setCategory(CookingBookCategory.FOOD);
|
||||
return rottenRecipe;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.miarma.mkernel.recipes.potions;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.RECIPES;
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
import static net.miarma.mkernel.util.Constants.ZOMBIFICATION_POTION_KEY;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class ZombificationPotionRecipe {
|
||||
private static ItemStack crear() {
|
||||
ItemStack potion = new ItemStack(Material.SPLASH_POTION);
|
||||
Component name = Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getZombificationPotionName()));
|
||||
List<Component> lore = List.of(
|
||||
Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getZombificationPotionLore())
|
||||
)
|
||||
);
|
||||
|
||||
NBT.modify(potion, nbt -> {
|
||||
nbt.setString(SPECIAL_ITEM_TAG, ZOMBIFICATION_POTION_KEY);
|
||||
nbt.modifyMeta((readOnlyNbt, meta) ->{
|
||||
meta.displayName(name);
|
||||
meta.lore(lore);
|
||||
meta.addEnchant(Enchantment.MENDING, 1, false);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
});
|
||||
});
|
||||
|
||||
RECIPES.add(potion);
|
||||
return potion;
|
||||
}
|
||||
|
||||
public static ShapedRecipe get() {
|
||||
ItemStack potion = crear();
|
||||
|
||||
NamespacedKey zombificationKey = new NamespacedKey(MKernel.PLUGIN, ZOMBIFICATION_POTION_KEY);
|
||||
ShapedRecipe recipe = new ShapedRecipe(zombificationKey, potion);
|
||||
recipe.shape(
|
||||
" Z ",
|
||||
" P ",
|
||||
" ");
|
||||
recipe.setIngredient('Z', Material.ZOMBIE_HEAD);
|
||||
recipe.setIngredient('P', Material.SPLASH_POTION);
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.miarma.mkernel.recipes.tools;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.ADMIN_STICK_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.RECIPES;
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class AdminStickRecipe {
|
||||
public static ItemStack crear() {
|
||||
ItemStack stick = new ItemStack(Material.STICK);
|
||||
Component name = Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getAdminStickName()));
|
||||
List<Component> lore = List.of(
|
||||
Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getAdminStickLore())
|
||||
)
|
||||
);
|
||||
|
||||
NBT.modify(stick, nbt -> {
|
||||
nbt.setString(SPECIAL_ITEM_TAG, ADMIN_STICK_KEY);
|
||||
nbt.modifyMeta((readOnlyNbt, meta) ->{
|
||||
meta.displayName(name);
|
||||
meta.lore(lore);
|
||||
});
|
||||
});
|
||||
|
||||
RECIPES.add(stick);
|
||||
return stick;
|
||||
}
|
||||
|
||||
public static ShapedRecipe get() {
|
||||
ItemStack palo = crear();
|
||||
NamespacedKey paloRecipeKey = new NamespacedKey(MKernel.PLUGIN, ADMIN_STICK_KEY);
|
||||
ShapedRecipe paloRecipe = new ShapedRecipe(paloRecipeKey, palo);
|
||||
paloRecipe.shape(
|
||||
"DDD",
|
||||
"DSD",
|
||||
"DDD");
|
||||
paloRecipe.setIngredient('D', Material.BEDROCK);
|
||||
paloRecipe.setIngredient('S', Material.STICK);
|
||||
return paloRecipe;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.miarma.mkernel.recipes.tools;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.RECIPES;
|
||||
import static net.miarma.mkernel.util.Constants.SCISSORS_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class ScissorsRecipe {
|
||||
private static ItemStack crear() {
|
||||
ItemStack scissors = new ItemStack(Material.SHEARS);
|
||||
Component name = Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getScissorsName()));
|
||||
List<Component> lore = List.of(
|
||||
Component.text(
|
||||
MessageUtil.parseColors(
|
||||
MessageProvider.Items.getScissorsLore())
|
||||
)
|
||||
);
|
||||
|
||||
NBT.modify(scissors, nbt -> {
|
||||
nbt.setString(SPECIAL_ITEM_TAG, SCISSORS_KEY);
|
||||
nbt.modifyMeta((readOnlyNbt, meta) ->{
|
||||
meta.displayName(name);
|
||||
meta.lore(lore);
|
||||
meta.addEnchant(Enchantment.UNBREAKING, 1, false);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
});
|
||||
});
|
||||
|
||||
RECIPES.add(scissors);
|
||||
return scissors;
|
||||
}
|
||||
|
||||
public static ShapedRecipe get() {
|
||||
ItemStack scissors = crear();
|
||||
NamespacedKey scissorsRecipeKey = new NamespacedKey(MKernel.PLUGIN, SCISSORS_KEY);
|
||||
ShapedRecipe scissorsRecipe = new ShapedRecipe(scissorsRecipeKey, scissors);
|
||||
scissorsRecipe.shape(
|
||||
" D ",
|
||||
"DSD",
|
||||
" D ");
|
||||
scissorsRecipe.setIngredient('D', Material.DIAMOND);
|
||||
scissorsRecipe.setIngredient('S', Material.SHEARS);
|
||||
return scissorsRecipe;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.miarma.mkernel.recipes.tools;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.RECIPES;
|
||||
import static net.miarma.mkernel.util.Constants.SPAWNER_BREAKER_KEY;
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.miarma.mkernel.util.MessageUtil;
|
||||
|
||||
public class SpawnerBreakerRecipe {
|
||||
private static ItemStack crear() {
|
||||
ItemStack spawnerBreaker = new ItemStack(Material.GOLDEN_PICKAXE);
|
||||
Component name = Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getSpawnerBreakerName()));
|
||||
List<Component> lore = List.of(
|
||||
Component.text(MessageUtil.parseColors(
|
||||
MessageProvider.Items.getSpawnerBreakerLore())
|
||||
)
|
||||
);
|
||||
|
||||
NBT.modify(spawnerBreaker, nbt -> {
|
||||
nbt.setString(SPECIAL_ITEM_TAG, SPAWNER_BREAKER_KEY);
|
||||
nbt.modifyMeta((readOnlyNbt, meta) ->{
|
||||
meta.displayName(name);
|
||||
meta.lore(lore);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
});
|
||||
});
|
||||
|
||||
RECIPES.add(spawnerBreaker);
|
||||
return spawnerBreaker;
|
||||
}
|
||||
|
||||
public static ShapedRecipe get() {
|
||||
ItemStack spawnerBreaker = crear();
|
||||
NamespacedKey spawnerBreakerRecipeKey = new NamespacedKey(MKernel.PLUGIN, SPAWNER_BREAKER_KEY);
|
||||
ShapedRecipe spawnerBreakerRecipe = new ShapedRecipe(spawnerBreakerRecipeKey, spawnerBreaker);
|
||||
spawnerBreakerRecipe.shape(
|
||||
" N ",
|
||||
" P ",
|
||||
" D ");
|
||||
spawnerBreakerRecipe.setIngredient('N', Material.NETHERITE_INGOT);
|
||||
spawnerBreakerRecipe.setIngredient('P', Material.GOLDEN_PICKAXE);
|
||||
spawnerBreakerRecipe.setIngredient('D', Material.DIAMOND);
|
||||
return spawnerBreakerRecipe;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.miarma.mkernel.tasks;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LocationTrackerTask {
|
||||
private static Map<Player, Location> LOCATIONS = new HashMap<>();
|
||||
|
||||
public static void start() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(player.getWorld().getName().equals(Bukkit.getServer().getWorlds().get(0).getName())) {
|
||||
Location currentLocation = player.getLocation();
|
||||
LOCATIONS.put(player, currentLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(MKernel.PLUGIN, 0, 20);
|
||||
}
|
||||
|
||||
public static Location getPlayerRealTimeLocation(Player player) {
|
||||
return LOCATIONS.get(player);
|
||||
}
|
||||
}
|
||||
23
src/main/java/net/miarma/mkernel/util/Constants.java
Normal file
23
src/main/java/net/miarma/mkernel/util/Constants.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.teleport.TpaRequests;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Constants {
|
||||
public static TpaRequests TPA_REQUESTS = TpaRequests.getInstance();
|
||||
public static List<ItemStack> RECIPES = new ArrayList<>();
|
||||
public static NamespacedKey VANISH_KEY = new NamespacedKey(MKernel.PLUGIN, "vanish");
|
||||
public static NamespacedKey SPY_KEY = new NamespacedKey(MKernel.PLUGIN, "spy");
|
||||
public static NamespacedKey FROZEN_KEY = new NamespacedKey(MKernel.PLUGIN, "frozen");
|
||||
public static String SPECIAL_ITEM_TAG = "specialItem";
|
||||
public static String ZOMBIFICATION_POTION_KEY = "zombification_potion";
|
||||
public static String SPAWNER_BREAKER_KEY = "spawner_breaker";
|
||||
public static String ADMIN_STICK_KEY = "admin_stick";
|
||||
public static String SCISSORS_KEY = "scissors";
|
||||
public static String ROTTEN_CAMFIRE_KEY = "rotten_campfire";
|
||||
}
|
||||
29
src/main/java/net/miarma/mkernel/util/ConversionUtil.java
Normal file
29
src/main/java/net/miarma/mkernel/util/ConversionUtil.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
public class ConversionUtil {
|
||||
public static long cooldownToMillis(String s) {
|
||||
if(s.contains("s"))
|
||||
return Long.parseLong(s.replace("s", "")) * 1000;
|
||||
if(s.contains("m"))
|
||||
return Long.parseLong(s.replace("m", "")) * 60 * 1000;
|
||||
if(s.contains("h"))
|
||||
return Long.parseLong(s.replace("h", "")) * 3600 * 1000;
|
||||
if(s.contains("d"))
|
||||
return Long.parseLong(s.replace("d", "")) * 86400 * 1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String millisToCooldown(long millis) {
|
||||
long seconds = millis / 1000;
|
||||
long minutes = seconds / 60;
|
||||
long hours = minutes / 60;
|
||||
long days = hours / 24;
|
||||
if(days > 0)
|
||||
return days + "d";
|
||||
if(hours > 0)
|
||||
return hours + "h";
|
||||
if(minutes > 0)
|
||||
return minutes + "m";
|
||||
return seconds + "s";
|
||||
}
|
||||
}
|
||||
79
src/main/java/net/miarma/mkernel/util/FileUtil.java
Normal file
79
src/main/java/net/miarma/mkernel/util/FileUtil.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUtil {
|
||||
public static void copyResourceToFile(String resourceName, String destinationPath) throws IOException {
|
||||
ClassLoader classLoader = MessageUtil.class.getClassLoader();
|
||||
try (InputStream inputStream = classLoader.getResourceAsStream(resourceName);
|
||||
FileOutputStream outputStream = new FileOutputStream(destinationPath)) {
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while (true) {
|
||||
assert inputStream != null;
|
||||
if ((length = inputStream.read(buffer)) == -1) break;
|
||||
outputStream.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void createLangs(String fileName) {
|
||||
try {
|
||||
File langs = new File(MKernel.PLUGIN.getDataFolder(), fileName);
|
||||
langs.createNewFile();
|
||||
copyResourceToFile(fileName, new File(MKernel.PLUGIN.getDataFolder(), fileName).getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
MKernel.PLUGIN.getLogger().severe(MessageProvider.Errors.failedCreatingLangs());
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveInventory(Player p) throws IOException{
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "inventories/"
|
||||
+ p.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
c.set("inventory", p.getInventory().getContents());
|
||||
c.save(f);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static int restoreInventory(Player p) throws IOException {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "inventories/"
|
||||
+ p.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
ItemStack[] contents;
|
||||
if(c.get("inventory") != null) {
|
||||
contents = ((List<ItemStack>) c.get("inventory")).toArray(new ItemStack[0]);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Arrays.stream(contents)
|
||||
.filter(item -> item != null && item.getType() != Material.AIR)
|
||||
.forEach(item -> p.getInventory().addItem(item));
|
||||
return Arrays.stream(contents)
|
||||
.filter(item -> item != null && item.getType() != Material.AIR)
|
||||
.mapToInt(ItemStack::getAmount)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public static void clearInventory(Player p) throws IOException {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "inventories/"
|
||||
+ p.getName() + ".yml");
|
||||
Files.delete(f.toPath());
|
||||
}
|
||||
}
|
||||
66
src/main/java/net/miarma/mkernel/util/InventoryUtil.java
Normal file
66
src/main/java/net/miarma/mkernel/util/InventoryUtil.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import net.miarma.mkernel.common.minecraft.MinepacksAccessor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InventoryUtil {
|
||||
public static void refillItem(Player player, Material material, EquipmentSlot hand) {
|
||||
ItemStack[] items = player.getInventory().getStorageContents();
|
||||
|
||||
for (int i = 0; i < 36; ++i) {
|
||||
if (items[i] != null && isValidSlot(i, player) && items[i].getType().equals(material)) {
|
||||
if (hand.equals(EquipmentSlot.HAND)) {
|
||||
player.getInventory().setItemInMainHand(items[i]);
|
||||
player.getInventory().setItem(i, null);
|
||||
break;
|
||||
}
|
||||
|
||||
if (hand.equals(EquipmentSlot.OFF_HAND)) {
|
||||
player.getInventory().setItemInOffHand(items[i]);
|
||||
player.getInventory().setItem(i, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void refillItemFromMinepack(Player player, Material material, EquipmentSlot hand) {
|
||||
Inventory backpack = MinepacksAccessor.getPlayerBackpackInventory(player);
|
||||
|
||||
if (backpack != null) {
|
||||
ItemStack[] contents = backpack.getContents();
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack itemStack = contents[i];
|
||||
if (itemStack != null && isValidSlot(i, player) && itemStack.getType() == material) {
|
||||
if (hand == EquipmentSlot.HAND) {
|
||||
player.getInventory().setItemInMainHand(itemStack);
|
||||
} else if (hand == EquipmentSlot.OFF_HAND) {
|
||||
player.getInventory().setItemInOffHand(itemStack);
|
||||
}
|
||||
contents[i] = null;
|
||||
backpack.setContents(contents);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValidSlot(int i, Player player) {
|
||||
return i != player.getInventory().getHeldItemSlot() && i != 40;
|
||||
}
|
||||
|
||||
public static int getItemCount(Inventory inventory, Material material) {
|
||||
int count = 0;
|
||||
for (ItemStack item : inventory.getContents()) {
|
||||
if (item != null && item.getType() == material) {
|
||||
count += item.getAmount();
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
110
src/main/java/net/miarma/mkernel/util/ItemUtil.java
Normal file
110
src/main/java/net/miarma/mkernel/util/ItemUtil.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.miarma.mkernel.util.Constants.SPECIAL_ITEM_TAG;
|
||||
|
||||
public class ItemUtil {
|
||||
public static String getKey(ItemStack item) {
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
if (nbtItem.getString(SPECIAL_ITEM_TAG) != null) {
|
||||
return nbtItem.getString(SPECIAL_ITEM_TAG);
|
||||
}
|
||||
|
||||
List<Recipe> matchingRecipes = Bukkit.getRecipesFor(item);
|
||||
for (Recipe recipe : matchingRecipes) {
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
return ((ShapedRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof ShapelessRecipe) {
|
||||
return ((ShapelessRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof FurnaceRecipe) {
|
||||
return ((FurnaceRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof BlastingRecipe) {
|
||||
return ((BlastingRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof CampfireRecipe) {
|
||||
return ((CampfireRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof SmokingRecipe) {
|
||||
return ((SmokingRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof StonecuttingRecipe) {
|
||||
return ((StonecuttingRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof SmithingRecipe) {
|
||||
return ((SmithingRecipe) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
if (recipe instanceof CookingRecipe) {
|
||||
return ((CookingRecipe<?>) recipe).getKey().getKey();
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void reloadConfigItem(InventoryClickEvent event) {
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
if (clickedItem == null || clickedItem.getType() != Material.PAPER) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = clickedItem.getItemMeta();
|
||||
if (itemMeta == null || !itemMeta.hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String displayName = itemMeta.getDisplayName();
|
||||
String configKey = "config.modules." + ChatColor.stripColor(displayName);
|
||||
|
||||
boolean currentValue = MKernel.CONFIG.getBoolean(configKey);
|
||||
boolean newValue = !currentValue;
|
||||
|
||||
MKernel.CONFIG.getConfig().set(configKey, newValue);
|
||||
MKernel.CONFIG.save();
|
||||
|
||||
itemMeta.setLore(List.of(MessageUtil.parseColors(
|
||||
MessageProvider.Inventories.getConfigMenuValueLore()) + newValue));
|
||||
clickedItem.setItemMeta(itemMeta);
|
||||
|
||||
if (event.getWhoClicked() instanceof Player player) {
|
||||
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getInventory().setItem(event.getSlot(), clickedItem);
|
||||
}
|
||||
|
||||
public static Material getBeefBoneWithProb() {
|
||||
double n = Math.random();
|
||||
Material res;
|
||||
if(n>0.40) {
|
||||
res = Material.BEEF;
|
||||
} else {
|
||||
res = Material.BONE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
95
src/main/java/net/miarma/mkernel/util/MessageUtil.java
Normal file
95
src/main/java/net/miarma/mkernel/util/MessageUtil.java
Normal file
@@ -0,0 +1,95 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import net.miarma.mkernel.config.providers.MessageProvider;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MessageUtil {
|
||||
|
||||
// Método para parsear placeholders
|
||||
public static String parsePlaceholders(String message, List<String> placeholders, List<String> values) {
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
message = message.replace(placeholders.get(i), values.get(i));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
// Método para convertir códigos de colores y parsear HEX
|
||||
public static String parseColors(String message) {
|
||||
return parseHexColors(message).replace('&', '§');
|
||||
}
|
||||
|
||||
// Parser para códigos HEX
|
||||
public static String parseHexColors(String input) {
|
||||
String hexPattern = "&#[0-9A-Fa-f]{6}";
|
||||
Matcher matcher = Pattern.compile(hexPattern).matcher(input);
|
||||
while (matcher.find()) {
|
||||
String hexColor = matcher.group();
|
||||
input = input.replace(hexColor, convertHexToMinecraftColor(hexColor));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
// Conversión de HEX a formato de color de Minecraft
|
||||
private static String convertHexToMinecraftColor(String hexColor) {
|
||||
StringBuilder minecraftColor = new StringBuilder("&x");
|
||||
for (char c : hexColor.substring(2).toCharArray()) {
|
||||
minecraftColor.append("&").append(c);
|
||||
}
|
||||
return minecraftColor.toString();
|
||||
}
|
||||
|
||||
// Formateo básico de mensajes sin colores
|
||||
public static String formatMessageNoColors(String message, boolean prefix) {
|
||||
if (prefix) {
|
||||
message = addPrefix(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
// Formateo básico de mensajes para consola
|
||||
public static String formatMessageConsole(String message, boolean removePrefix) {
|
||||
if (removePrefix) {
|
||||
message = message.replace("[P]", "");
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
// Formateo básico de mensajes con placeholders
|
||||
public static String formatMessageNoColors(String message, boolean prefix, List<String> placeholders, List<String> values) {
|
||||
message = formatMessageNoColors(message, prefix);
|
||||
return parsePlaceholders(message, placeholders, values);
|
||||
}
|
||||
|
||||
// Formateo con colores y prefijo
|
||||
public static String formatMessage(String message, boolean prefix) {
|
||||
if (prefix) {
|
||||
message = addPrefix(message);
|
||||
}
|
||||
return parseColors(message);
|
||||
}
|
||||
|
||||
// Formateo con colores, prefijo y placeholders
|
||||
public static String formatMessage(String message, boolean prefix, List<String> placeholders, List<String> values) {
|
||||
message = formatMessage(message, prefix);
|
||||
return parsePlaceholders(message, placeholders, values);
|
||||
}
|
||||
|
||||
// Método para añadir el prefijo
|
||||
private static String addPrefix(String message) {
|
||||
return message.replace("[P]", MessageProvider.getPrefix());
|
||||
}
|
||||
|
||||
// Envío de mensajes
|
||||
public static void sendMessage(CommandSender sender, String message, boolean prefix) {
|
||||
sender.sendMessage(formatMessage(message, prefix));
|
||||
}
|
||||
|
||||
// Envío de mensajes con placeholders
|
||||
public static void sendMessage(CommandSender sender, String message, boolean prefix, List<String> placeholders, List<String> values) {
|
||||
sender.sendMessage(formatMessage(message, prefix, placeholders, values));
|
||||
}
|
||||
}
|
||||
30
src/main/java/net/miarma/mkernel/util/PlayerUtil.java
Normal file
30
src/main/java/net/miarma/mkernel/util/PlayerUtil.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package net.miarma.mkernel.util;
|
||||
|
||||
import net.miarma.mkernel.MKernel;
|
||||
import net.miarma.mkernel.common.minecraft.Warp;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerUtil {
|
||||
public static double distance(Player p1, Player p2) {
|
||||
return p1.getLocation().distance(p2.getLocation());
|
||||
}
|
||||
|
||||
public static boolean playersNearRadius(Player player, Collection<Player> players, int radius) {
|
||||
return players.stream().anyMatch(p -> distance(p, player) <= radius && !p.equals(player));
|
||||
}
|
||||
|
||||
public static List<Warp> getWarps(Player p) {
|
||||
File f = new File(MKernel.PLUGIN.getDataFolder().getAbsolutePath(), "warps/"
|
||||
+ p.getName() + ".yml");
|
||||
FileConfiguration c = YamlConfiguration.loadConfiguration(f);
|
||||
return c.getKeys(false).stream()
|
||||
.map(alias -> Warp.fromFile(c, alias))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
504
src/main/resources/config.yml
Normal file
504
src/main/resources/config.yml
Normal file
@@ -0,0 +1,504 @@
|
||||
#############################################################
|
||||
# __ __ ___ #
|
||||
# /'\_/`\/\ \/\ \ /\_ \ #
|
||||
# /\ \ \ \/'/' __ _ __ ___ __\//\ \ #
|
||||
# \ \ \__\ \ \ , < /'__`\/\`'__\/' _ `\ /'__`\\ \ \ #
|
||||
# \ \ \_/\ \ \ \\`\ /\ __/\ \ \/ /\ \/\ \/\ __/ \_\ \_ #
|
||||
# \ \_\\ \_\ \_\ \_\ \____\\ \_\ \ \_\ \_\ \____\/\____\ #
|
||||
# \/_/ \/_/\/_/\/_/\/____/ \/_/ \/_/\/_/\/____/\/____/ #
|
||||
# by Gallardo7761 v1.4.2 #
|
||||
#############################################################
|
||||
# [ R ] = full restart for applying #
|
||||
#############################################################
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Plugin Configuration [ R ]
|
||||
# -----------------------------------------------------------
|
||||
API_BASE: "https://api.miarma.net/miarmacraft"
|
||||
|
||||
config:
|
||||
permissions:
|
||||
chatFormat: "mkernel.events.chatFormat"
|
||||
adminChat: "mkernel.events.adminchat"
|
||||
mentions: "mkernel.events.mentions"
|
||||
|
||||
values:
|
||||
rottenFleshCookTime: 60
|
||||
zombificationPotionTime: 180
|
||||
spawnerBreakerProbability: 30
|
||||
recInvRequiredLevel: 10
|
||||
xpLossOnDeath: 0.7
|
||||
tpCooldown: "5m"
|
||||
maxWarps: 3
|
||||
recInvPlayerRadius: 10
|
||||
recInvSpawnDistance: 150
|
||||
|
||||
modules:
|
||||
joinTitle: true
|
||||
leaveTitle: true
|
||||
deathTitle: true
|
||||
harvestOnRightClick: true
|
||||
autoItemRefill: true
|
||||
adminChat: true
|
||||
chatFormat: true
|
||||
mentions: true
|
||||
bookColors: true
|
||||
spawnAtLobby: true
|
||||
recoverInventory: true
|
||||
|
||||
worlds:
|
||||
lobby:
|
||||
name: "lobby"
|
||||
coords:
|
||||
x: 0.5
|
||||
y: 65
|
||||
z: 0.5
|
||||
yaw: 180
|
||||
pitch: 0
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Command Configuration [ R ]
|
||||
# -----------------------------------------------------------
|
||||
|
||||
arguments:
|
||||
reload: "recargar"
|
||||
password: "contraseña"
|
||||
player: "jugador"
|
||||
levels: "niveles"
|
||||
times: "veces"
|
||||
world: "mundo"
|
||||
message: "mensaje"
|
||||
item: "item"
|
||||
inventoryIndex: "índice de inventario"
|
||||
warpName: "nombre warp"
|
||||
warp: "warp"
|
||||
titulacion: "titulación"
|
||||
|
||||
commands:
|
||||
mkernel:
|
||||
description: "Muestra la información de mkernel"
|
||||
permission: "mkernel.command"
|
||||
usage: "/mkernel [subcomando]"
|
||||
subcommands:
|
||||
reload:
|
||||
name: "reload"
|
||||
description: "Recarga mkernel"
|
||||
permission: "mkernel.command.reload"
|
||||
usage: "/mkernel reload"
|
||||
messages:
|
||||
success: "[P] mkernel ha sido recargado correctamente"
|
||||
error: "[P] Ha ocurrido un error al recargar mkernel"
|
||||
config:
|
||||
name: "config"
|
||||
description: "Abre el menú de configuración"
|
||||
permission: "mkernel.command.config"
|
||||
usage: "/mkernel config"
|
||||
|
||||
tpa:
|
||||
name: "tpa"
|
||||
description: "Envía una petición de teletransporte"
|
||||
permission: "mkernel.command.tpa"
|
||||
usage: "/tpa <jugador>"
|
||||
messages:
|
||||
tpaFromPlayer: "[P] &7El jugador &a%sender% &7te ha enviado una petición de teletransporte &c[%sender% -> Tú]"
|
||||
tpaToPlayer: "[P] &7Has enviado una petición de teletransporte a &a%target% &c[Tú -> %target%]"
|
||||
|
||||
tpahere:
|
||||
name: "tpahere"
|
||||
description: "Envía una petición de teletransporte a un jugador"
|
||||
permission: "mkernel.command.tpahere"
|
||||
usage: "/tpahere <jugador>"
|
||||
messages:
|
||||
tpaFromPlayer: "[P] &7El jugador &a%sender% &7te ha enviado una petición de teletransporte &c[Tú -> %sender%]"
|
||||
tpaToPlayer: "[P] &7Has enviado una petición de teletransporte a &a%target% &c[%target% -> Tú]"
|
||||
|
||||
tpaccept:
|
||||
name: "tpaccept"
|
||||
description: "Acepta una petición de teletransporte"
|
||||
permission: "mkernel.command.tpaccept"
|
||||
usage: "/tpaccept <jugador>"
|
||||
messages:
|
||||
accepted: "[P] &7Has aceptado la petición de teletransporte"
|
||||
acceptedToTarget: "[P] &7El jugador &a%sender% &7ha aceptado tu petición de teletransporte"
|
||||
|
||||
tpdeny:
|
||||
name: "tpdeny"
|
||||
description: "Rechaza una petición de teletransporte"
|
||||
permission: "mkernel.command.tpdeny"
|
||||
usage: "/tpdeny <jugador>"
|
||||
messages:
|
||||
denied: "[P] &7Has rechazado la petición de teletransporte"
|
||||
deniedToTarget: "[P] &7El jugador &a%sender% &7ha rechazado tu petición de teletransporte"
|
||||
|
||||
spawn:
|
||||
name: "spawn"
|
||||
description: "Teletransportate a ti o a otro jugador al spawn"
|
||||
permissions:
|
||||
base: "mkernel.command.spawn"
|
||||
others: "mkernel.command.spawn.others"
|
||||
messages:
|
||||
teleported: "[P] &7Has sido teletransportado al spawn"
|
||||
spawnYouOthers: "[P] &7Has teletransportado a &a%victim% &7al spawn"
|
||||
spawnOthersYou: "[P] &7Has sido teletransportado al spawn por &a%sender%"
|
||||
|
||||
lobby:
|
||||
name: "lobby"
|
||||
description: "Teletransportate al lobby"
|
||||
permissions:
|
||||
base: "mkernel.command.lobby"
|
||||
others: "mkernel.command.lobby.others"
|
||||
messages:
|
||||
teleported: "[P] &7Has sido teletransportado al lobby"
|
||||
lobbyYouOthers: "[P] &7Has teletransportado a &a%victim% &7al lobby"
|
||||
lobbyOthersYou: "[P] &7Has sido teletransportado al lobby por &a%sender%"
|
||||
|
||||
sendcoords:
|
||||
name: "sendcoords"
|
||||
description: "Envía tus coordenadas a otro jugador"
|
||||
permission: "mkernel.command.sendcoords"
|
||||
usage: "/sendcoords <jugador>"
|
||||
messages:
|
||||
sent: "[P] &7Tus coordenadas han sido enviadas a &a%target%"
|
||||
coordsMsg: "&8[&c%sender%&8 -> &cTú&8] &7Mis coordenadas son:\n&aX: &7%x%\n&aY: &7%y%\n&aZ: &7%z%"
|
||||
|
||||
blockworld:
|
||||
name: "blockworld"
|
||||
aliases: ["bworld", "bw"]
|
||||
description: "Bloquea un mundo"
|
||||
permission: "mkernel.command.blockworld"
|
||||
usage: "/blockworld | /bworld | /bw <mundo>"
|
||||
messages:
|
||||
worldHasBeenBlocked: "[P] &7El mundo &a%world% &7ha sido bloqueado"
|
||||
worldHasBeenUnblocked: "[P] &7El mundo &a%world% &7ha sido desbloqueado"
|
||||
|
||||
payxp:
|
||||
name: "payxp"
|
||||
description: "Paga niveles de XP a otro jugador"
|
||||
permission: "mkernel.command.payxp"
|
||||
usage: "/payxp <jugador> <niveles>"
|
||||
messages:
|
||||
payYouOthers: "[P] &7Has pagado &a%amount% &7niveles de XP a &a%target%"
|
||||
payOthersYou: "[P] &7El jugador &a%sender% &7te ha dado &a%amount% &7niveles de XP"
|
||||
|
||||
specialitem:
|
||||
name: "specialitem"
|
||||
description: "Obtiene un item especial de mkernel"
|
||||
permission: "mkernel.command.specialitem"
|
||||
usage: "/specialitem <item>"
|
||||
messages:
|
||||
itemReceived: "[P] &7Has obtenido &a%item%"
|
||||
|
||||
opme:
|
||||
name: "opme"
|
||||
description: "Te da el op"
|
||||
permission: "mkernel.command.opme"
|
||||
messages:
|
||||
opped: "[P] &7Ahora eres &a&nop"
|
||||
alreadyOp: "[P] &cYa eres op"
|
||||
|
||||
deopme:
|
||||
name: "deopme"
|
||||
description: "Te quita el op"
|
||||
permission: "mkernel.command.deopme"
|
||||
messages:
|
||||
deOpped: "[P] &7Ya no eres &a&nop"
|
||||
youAreNotOp: "[P] &cNo eres op"
|
||||
|
||||
disposal:
|
||||
name: "disposal"
|
||||
description: "Abre el disposal"
|
||||
permissions:
|
||||
base: "mkernel.command.disposal"
|
||||
others: "mkernel.command.disposal.others"
|
||||
|
||||
globalchest:
|
||||
name: "globalchest"
|
||||
description: "Abre el cofre global"
|
||||
aliases: ["gc"]
|
||||
permissions:
|
||||
base: "mkernel.command.globalchest"
|
||||
others: "mkernel.command.globalchest.others"
|
||||
|
||||
do:
|
||||
name: "do"
|
||||
description: "Acciones de entorno"
|
||||
permission: "mkernel.command.do"
|
||||
|
||||
me:
|
||||
name: "me"
|
||||
description: "Acciones de personaje"
|
||||
permission: "mkernel.command.me"
|
||||
|
||||
sethome:
|
||||
name: "sethome"
|
||||
description: "Establece tu home"
|
||||
permission: "mkernel.command.sethome"
|
||||
messages:
|
||||
homeSet: "[P] &7Hogar establecido en &a%x% %y% %z%&r"
|
||||
|
||||
home:
|
||||
name: "home"
|
||||
description: "Teletransportate a tu hogar"
|
||||
permission: "mkernel.command.home"
|
||||
messages:
|
||||
teleported: "[P] &7Has sido teletransportado a tu hogar"
|
||||
homeDoesNotExist: "[P] &cNo tienes ningún hogar establecido"
|
||||
|
||||
recinv:
|
||||
name: "recinv"
|
||||
description: "Recupera tu inventario"
|
||||
permission: "mkernel.command.recinv"
|
||||
messages:
|
||||
inventoryRecovered: "[P] &7Has recuperado &a%items% &7items"
|
||||
notEnoughLevels: "[P] &cNo tienes suficientes niveles. Necesitas &a%required%"
|
||||
noItemsToRecover: "[P] &cNo hay items que recuperar"
|
||||
|
||||
gmc:
|
||||
name: "gmc"
|
||||
description: "Cambia tu modo de juego a creativo"
|
||||
permissions:
|
||||
base: "mkernel.command.gmc"
|
||||
others: "mkernel.command.gmc.others"
|
||||
usage: "/gmc [jugador]"
|
||||
messages:
|
||||
self: "[P] &7Tu modo de juego ha sido cambiado a &aCreativo"
|
||||
others: "[P] &7El modo de juego de &a%player% &7ha sido cambiado a &aCreativo"
|
||||
|
||||
gms:
|
||||
name: "gms"
|
||||
description: "Cambia tu modo de juego a supervivencia"
|
||||
permissions:
|
||||
base: "mkernel.command.gms"
|
||||
others: "mkernel.command.gms.others"
|
||||
usage: "/gms [jugador]"
|
||||
messages:
|
||||
self: "[P] &7Tu modo de juego ha sido cambiado a &aSupervivencia"
|
||||
others: "[P] &7El modo de juego de &a%player% &7ha sido cambiado a &aSupervivencia"
|
||||
|
||||
gmsp:
|
||||
name: "gmsp"
|
||||
description: "Cambia tu modo de juego a espectador"
|
||||
permissions:
|
||||
base: "mkernel.command.gmsp"
|
||||
others: "mkernel.command.gmsp.others"
|
||||
usage: "/gmsp [jugador]"
|
||||
messages:
|
||||
self: "[P] &7Tu modo de juego ha sido cambiado a &aEspectador"
|
||||
others: "[P] &7El modo de juego de &a%player% &7ha sido cambiado a &aEspectador"
|
||||
|
||||
gma:
|
||||
name: "gma"
|
||||
description: "Cambia tu modo de juego a aventura"
|
||||
permissions:
|
||||
base: "mkernel.command.gma"
|
||||
others: "mkernel.command.gma.others"
|
||||
usage: "/gma [jugador]"
|
||||
messages:
|
||||
self: "[P] &7Tu modo de juego ha sido cambiado a &aAventura"
|
||||
others: "[P] &7El modo de juego de &a%player% &7ha sido cambiado a &aAventura"
|
||||
|
||||
vanish:
|
||||
name: "vanish"
|
||||
description: "Desaparece"
|
||||
permission: "mkernel.command.vanish"
|
||||
messages:
|
||||
vanished: "[P] &7Te has hecho invisible"
|
||||
unvanished: "[P] &7Ahora eres visible de nuevo"
|
||||
|
||||
warp:
|
||||
name: "warp"
|
||||
description: "Muestra un warp de la lista"
|
||||
permission: "mkernel.command.warp"
|
||||
usage: "/warp {add/remove} <nombre warp>"
|
||||
messages:
|
||||
noWarpsStored: "[P] &cNo tienes warps almacenados"
|
||||
warpList: |
|
||||
[P] &7Warps almacenados:&r
|
||||
%warps%
|
||||
subcommands:
|
||||
add:
|
||||
name: "add"
|
||||
description: "Añade un warp"
|
||||
permission: "mkernel.command.warp.add"
|
||||
usage: "/warp add <nombre>"
|
||||
messages:
|
||||
warpAdded: "[P] &7Warp &a%warp% &7añadido correctamente"
|
||||
warpAlreadyExists: "[P] &cEl warp &a%warp% &cya existe"
|
||||
remove:
|
||||
name: "remove"
|
||||
description: "Elimina un warp"
|
||||
permission: "mkernel.command.warp.remove"
|
||||
usage: "/warp remove <nombre>"
|
||||
messages:
|
||||
warpRemoved: "[P] &7Warp &a%warp% &7eliminado correctamente"
|
||||
warpNotFound: "[P] &cEl warp &a%warp% &cno existe"
|
||||
|
||||
spy:
|
||||
name: "spy"
|
||||
description: "Espía los mensajes de chat"
|
||||
permission: "mkernel.command.spy"
|
||||
messages:
|
||||
enabled: "[P] &7Modo espía &aactivado"
|
||||
disabled: "[P] &7Modo espía &adesactivado"
|
||||
|
||||
freeze:
|
||||
name: "freeze"
|
||||
description: "Congela a un jugador"
|
||||
permission: "mkernel.command.freeze"
|
||||
usage: "/freeze <jugador>"
|
||||
messages:
|
||||
frozen: "[P] &7El jugador &a%player% &7ha sido &bcongelado"
|
||||
unfrozen: "[P] &7El jugador &a%player% &7ha sido &bdescongelado"
|
||||
beenFrozen: "[P] &7Has sido &bcongelado por &a%sender%"
|
||||
beenUnfrozen: "[P] &7Has sido &bdescongelado por &a%sender%"
|
||||
|
||||
heal:
|
||||
name: "heal"
|
||||
description: "Cura a un jugador"
|
||||
permissions:
|
||||
base: "mkernel.command.heal"
|
||||
others: "mkernel.command.heal.others"
|
||||
usage: "/heal <jugador>"
|
||||
messages:
|
||||
healedSelf: "[P] &7Te has curado"
|
||||
healedPlayer: "[P] &7Has curado a &a%player%"
|
||||
beenHealed: "[P] &7Has sido curado por &a%sender%"
|
||||
|
||||
launch:
|
||||
name: "launch"
|
||||
description: "Lanza a un jugador"
|
||||
permission: "mkernel.command.launch"
|
||||
usage: "/launch <jugador>"
|
||||
messages:
|
||||
launched: "[P] &7Has lanzado a &a%player%"
|
||||
|
||||
sun:
|
||||
name: "sun"
|
||||
description: "Cambia el clima a soleado"
|
||||
permission: "mkernel.command.sun"
|
||||
messages:
|
||||
sunSet: "[P] &7Se ha cambiado el clima a &asoleado"
|
||||
|
||||
rain:
|
||||
name: "rain"
|
||||
description: "Cambia el clima a lluvioso"
|
||||
permission: "mkernel.command.rain"
|
||||
messages:
|
||||
rainSet: "[P] &7Se ha cambiado el clima a &alluvioso"
|
||||
|
||||
thunder:
|
||||
name: "thunder"
|
||||
description: "Cambia el clima a tormentoso"
|
||||
permission: "mkernel.command.thunder"
|
||||
messages:
|
||||
thunderSet: "[P] &7Se ha cambiado el clima a &atormentoso"
|
||||
|
||||
day:
|
||||
name: "day"
|
||||
description: "Pone el tiempo a día"
|
||||
permission: "mkernel.command.day"
|
||||
messages:
|
||||
daySet: "[P] &7Ahora es de &adía"
|
||||
|
||||
night:
|
||||
name: "night"
|
||||
description: "Pone el tiempo a noche"
|
||||
permission: "mkernel.command.night"
|
||||
messages:
|
||||
nightSet: "[P] &7Ahora es de &anoche"
|
||||
|
||||
invsee:
|
||||
name: "invsee"
|
||||
description: "Mira el inventario de un jugador"
|
||||
permission: "mkernel.command.invsee"
|
||||
usage: "/invsee <jugador>"
|
||||
messages:
|
||||
opened: "[P] &7Has abierto el inventario de &a%player%"
|
||||
|
||||
titulacion:
|
||||
name: "titulacion"
|
||||
description: "Especifica tu titulación"
|
||||
permission: "mkernel.command.titulacion"
|
||||
usage: "/titulacion <titulacion>"
|
||||
messages:
|
||||
success: "[P] &7Tu titulación se ha establecido a &a%titulacion% &7correctamente"
|
||||
getCurrent: "[P] &7Perteneces a &a%titulacion%"
|
||||
fail: "[P] &cHubo un error estableciendo tu titulación. Contacta con un administrador."
|
||||
invalid: "[P] &cEsta titulación no existe."
|
||||
|
||||
# -----------------------------------------------------------
|
||||
# Message Configuration
|
||||
# -----------------------------------------------------------
|
||||
|
||||
language:
|
||||
prefix: "ca268&lMKernel &8»&r"
|
||||
adminPrefix: 'ca268&lAdminChat &e&l»&r'
|
||||
|
||||
inventories:
|
||||
globalChest:
|
||||
title: "ca268Cofre global"
|
||||
disposal:
|
||||
title: "ca268Basura"
|
||||
invsee:
|
||||
title: "&8Inventario de %player%"
|
||||
configMenu:
|
||||
title: "ca268Configuración"
|
||||
valueName: "ca268&l"
|
||||
valueLore: "&7Valor: ca268"
|
||||
|
||||
titles:
|
||||
titleFormat: "&a&l"
|
||||
subtitles:
|
||||
join: "&aHa entrado al servidor!"
|
||||
leave: "&cSe ha ido del servidor!"
|
||||
death: "&c%player% ha muerto"
|
||||
|
||||
events:
|
||||
onMention:
|
||||
format: "&a&l@"
|
||||
youWereMentioned: "[P] &e%player% &7te ha mencionado!"
|
||||
onDeath:
|
||||
lostLevelsItems: "[P] &7Has perdido &atus items &7y &a%levels% niveles de XP &7al morir. Puedes recuperar tus items con &a/recinv"
|
||||
itemsNotRecovered: "[P] &7Tus items no se han recuperado porque has muerto muy cerca del spawn/point o había jugadores cerca tuya. Los puedes recuperar en: &a%x% %y% %z%"
|
||||
onCommand:
|
||||
spyMessage: "&7&o[Spy] %player%: %message%"
|
||||
|
||||
items:
|
||||
scissors:
|
||||
name: "&e&lTijeras"
|
||||
lore: "&7Vacas, cerdos, zombies"
|
||||
adminStick:
|
||||
name: "&c&lADMIN STICK"
|
||||
lore: "&dUn palo para dominarlos a todos!"
|
||||
spawnerBreaker:
|
||||
name: "&6&lRompe-Spawners"
|
||||
lore: "&d50% de romper el spawner o romperse"
|
||||
zombificationPotion:
|
||||
name: "f7d48&lPoción de Zombificación"
|
||||
lore: "&bConvierte a un aldeano en zombie"
|
||||
bolsita:
|
||||
name: "&eBolsita"
|
||||
lore: "&7Mete tus items aquí"
|
||||
|
||||
errors:
|
||||
langs: "[P] &cError creando los archivos de lenguaje"
|
||||
notConsoleCommand: "[P] &cEste comando no se puede ejecutar desde la consola"
|
||||
onlyPlayerCommand: "[P] &cEste comando sólo lo puede ejecutar un jugador"
|
||||
playerNotFound: "[P] &cEl jugador no se ha encontrado o no está conectado"
|
||||
cantTeleportToYourself: "[P] &cNo puedes teletransportarte a ti mismo"
|
||||
requestAlreadySent: "[P] &cYa has enviado una petición de teletransporte a este jugador"
|
||||
noRequestFound: "[P] &cNo tienes ninguna petición de teletransporte"
|
||||
noPermission: "[P] &cNo tienes permisos para eso"
|
||||
tooManyArguments: "[P] &cDemasiados argumentos"
|
||||
playerRequired: "[P] &cDebes especificar un jugador"
|
||||
invalidArgument: "[P] &cArgumento no válido"
|
||||
temporarilyDisabled: "[P] &cEste comando está temporalmente desactivado"
|
||||
itemNotFound: "[P] &cNo se ha encontrado el item"
|
||||
lobbyDoesNotExist: "[P] ERROR: El lobby definido en el config no existe"
|
||||
worldIsBlocked: "[P] &7El mundo &a%world% &7está bloqueado"
|
||||
notEnoughLevels: "[P] &cNo tienes suficientes niveles para esto"
|
||||
cooldownHasNotExpired: "[P] &cDebes esperar %time% segundos para volver a usar este comando"
|
||||
maxWarpsReached: "[P] &cHas alcanzado el límite de warps almacenados"
|
||||
|
||||
# ⚠️ Do not modify this line ⚠️
|
||||
file-version: 3
|
||||
80
src/main/resources/lang.yml
Normal file
80
src/main/resources/lang.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
#############################################################
|
||||
# __ __ ___ #
|
||||
# /'\_/`\/\ \/\ \ /\_ \ #
|
||||
# /\ \ \ \/'/' __ _ __ ___ __\//\ \ #
|
||||
# \ \ \__\ \ \ , < /'__`\/\`'__\/' _ `\ /'__`\\ \ \ #
|
||||
# \ \ \_/\ \ \ \\`\ /\ __/\ \ \/ /\ \/\ \/\ __/ \_\ \_ #
|
||||
# \ \_\\ \_\ \_\ \_\ \____\\ \_\ \ \_\ \_\ \____\/\____\ #
|
||||
# \/_/ \/_/\/_/\/_/\/____/ \/_/ \/_/\/_/\/____/\/____/ #
|
||||
# by Gallardo7761 v1.4.1 #
|
||||
#############################################################
|
||||
# ┌┬┐┬─┐┌─┐┌┐┌┌─┐┬ ┌─┐┌┬┐┬┌─┐┌┐┌┌─┐ #
|
||||
# │ ├┬┘├─┤│││└─┐│ ├─┤ │ ││ ││││└─┐ #
|
||||
# ┴ ┴└─┴ ┴┘└┘└─┘┴─┘┴ ┴ ┴ ┴└─┘┘└┘└─┘ #
|
||||
#############################################################
|
||||
|
||||
# ███████ ███████ ███████ ███████
|
||||
# ██ ██ ██ ██
|
||||
# █████ ███████ █████ ███████
|
||||
# ██ ██ ██ ██
|
||||
# ███████ ███████ ███████ ███████ ███████
|
||||
|
||||
language:
|
||||
prefix: "ca268&lMKernel &8»&r"
|
||||
adminPrefix: 'ca268&lAdminChat &e&l»&r'
|
||||
|
||||
inventories:
|
||||
globalChest:
|
||||
title: "ca268Cofre global"
|
||||
disposal:
|
||||
title: "ca268Basura"
|
||||
configMenu:
|
||||
title: "ca268Configuración"
|
||||
valueName: "ca268&l"
|
||||
valueLore: "&7Valor: ca268"
|
||||
|
||||
titles:
|
||||
titleFormat: "&a&l"
|
||||
subtitles:
|
||||
join: "&aHa entrado al servidor!"
|
||||
leave: "&cSe ha ido del servidor!"
|
||||
death: "&c%player% ha muerto"
|
||||
|
||||
mentions:
|
||||
format: "&a&l"
|
||||
youWereMentioned: "[P] &e%player% &7te ha mencionado!"
|
||||
|
||||
items:
|
||||
scissors:
|
||||
name: "&e&lTijeras"
|
||||
lore: "&7Vacas, cerdos, zombies"
|
||||
adminStick:
|
||||
name: "&c&lADMIN STICK"
|
||||
lore: "&dUn palo para dominarlos a todos!"
|
||||
spawnerBreaker:
|
||||
name: "&6&lRompe-Spawners"
|
||||
lore: "&d50% de romper el spawner o romperse"
|
||||
zombificationPotion:
|
||||
name: "f7d48&lPoción de Zombificación"
|
||||
lore: "&bConvierte a un aldeano en zombie"
|
||||
bolsita:
|
||||
name: "&eBolsita"
|
||||
lore: "&7Mete tus items aquí"
|
||||
|
||||
errors:
|
||||
langs: "[P] &cError creando los archivos de lenguaje"
|
||||
notConsoleCommand: "[P] &cEste comando no se puede ejecutar desde la consola"
|
||||
onlyPlayerCommand: "[P] &cEste comando sólo lo puede ejecutar un jugador"
|
||||
playerNotFound: "[P] &cEl jugador no se ha encontrado o no está conectado"
|
||||
cantTeleportToYourself: "[P] &cNo puedes teletransportarte a ti mismo"
|
||||
requestAlreadySent: "[P] &cYa has enviado una petición de teletransporte a este jugador"
|
||||
noRequestFound: "[P] &cNo tienes ninguna petición de teletransporte"
|
||||
noPermission: "[P] &cNo tienes permisos para eso"
|
||||
tooManyArguments: "[P] &cDemasiados argumentos"
|
||||
playerRequired: "[P] &cDebes especificar un jugador"
|
||||
invalidArgument: "[P] &cArgumento no válido"
|
||||
temporarilyDisabled: "[P] &cEste comando está temporalmente desactivado"
|
||||
itemNotFound: "[P] &cNo se ha encontrado el item"
|
||||
lobbyDoesNotExist: "[P] ERROR: El lobby definido en el config no existe"
|
||||
worldIsBlocked: "[P] &7El mundo &a%world% &7está bloqueado"
|
||||
notEnoughLevels: "[P] &cNo tienes suficientes niveles para esto"
|
||||
202
src/main/resources/paper-plugin.yml
Normal file
202
src/main/resources/paper-plugin.yml
Normal file
@@ -0,0 +1,202 @@
|
||||
name: MKernel
|
||||
version: '1.4.2'
|
||||
main: net.miarma.mkernel.MKernel
|
||||
api-version: '1.21.9'
|
||||
website: https://github.com/Gallardo7761/mkernel
|
||||
authors: [Gallardo7761, elpapuu1333 (Contributor & tester)]
|
||||
dependencies:
|
||||
server:
|
||||
NBTAPI:
|
||||
load: BEFORE
|
||||
required: true
|
||||
join-classpath: true
|
||||
LuckPerms:
|
||||
load: BEFORE
|
||||
required: true
|
||||
join-classpath: true
|
||||
permissions:
|
||||
mkernel.command:
|
||||
description: Permite al usuario ejecutar comandos de MKernel
|
||||
default: true
|
||||
mkernel.command.reload:
|
||||
description: Permite al usuario recargar la configuración de MKernel
|
||||
default: op
|
||||
mkernel.command.config:
|
||||
description: Permite al usuario configurar los módulos de MKernel
|
||||
default: op
|
||||
mkernel.command.tpa:
|
||||
description: Permite al usuario enviar una petición de teletransporte
|
||||
default: true
|
||||
mkernel.command.tpahere:
|
||||
description: Permite al usuario enviar una petición de teletransporte a otro jugador
|
||||
default: true
|
||||
mkernel.command.tpaccept:
|
||||
description: Permite al usuario aceptar una petición de teletransporte
|
||||
default: true
|
||||
mkernel.command.tpdeny:
|
||||
description: Permite al usuario rechazar una petición de teletransporte
|
||||
default: true
|
||||
mkernel.globalchest:
|
||||
description: Permite al usuario abrir el cofre global
|
||||
default: true
|
||||
mkernel.globalchest.others:
|
||||
description: Permite al usuario abrir el cofre global de otro jugador
|
||||
default: op
|
||||
mkernel.disposal:
|
||||
description: Permite al usuario abrir el contenedor de basura
|
||||
default: true
|
||||
mkernel.disposal.others:
|
||||
description: Permite al usuario abrir el contenedor de basura de otro jugador
|
||||
default: op
|
||||
mkernel.command.sendcoords:
|
||||
description: Permite al usuario enviar sus coordenadas a otro jugador
|
||||
default: true
|
||||
mkernel.command.spawn:
|
||||
description: Permite al usuario teletransportarse al punto de spawn
|
||||
default: true
|
||||
mkernel.command.spawn.others:
|
||||
description: Permite al usuario teletransportar a otro jugador al punto de spawn
|
||||
default: op
|
||||
mkernel.command.lobby:
|
||||
description: Permite al usuario teletransportarse al lobby
|
||||
default: true
|
||||
mkernel.command.lobby.others:
|
||||
description: Permite al usuario teletransportar a otro jugador al lobby
|
||||
default: op
|
||||
mkernel.command.opme:
|
||||
description: Permite al usuario hacerse op
|
||||
default: op
|
||||
mkernel.command.deopme:
|
||||
description: Permite al usuario quitarse el op
|
||||
default: op
|
||||
mkernel.command.specialitem:
|
||||
description: Permite al usuario obtener un item especial
|
||||
default: op
|
||||
mkernel.command.blockworld:
|
||||
description: Permite al usuario bloquear un mundo
|
||||
default: op
|
||||
mkernel.command.home:
|
||||
description: Permite al usuario teletransportarse a su casa
|
||||
default: true
|
||||
mkernel.command.sethome:
|
||||
description: Permite al usuario establecer su casa
|
||||
default: true
|
||||
mkernel.command.recinv:
|
||||
description: Permite recuperar tu inventario
|
||||
default: true
|
||||
mkernel.command.gmc:
|
||||
description: Permite al usuario cambiar su modo de juego a creativo
|
||||
default: op
|
||||
mkernel.command.gms:
|
||||
description: Permite al usuario cambiar su modo de juego a supervivencia
|
||||
default: op
|
||||
mkernel.command.gma:
|
||||
description: Permite al usuario cambiar su modo de juego a aventura
|
||||
default: op
|
||||
mkernel.command.gmsp:
|
||||
description: Permite al usuario cambiar su modo de juego a espectador
|
||||
default: op
|
||||
mkernel.command.vanish:
|
||||
description: Permite al usuario volverse invisible
|
||||
default: op
|
||||
mkernel.command.warp:
|
||||
description: Permite al usuario teletransportarse a un warp
|
||||
default: true
|
||||
mkernel.command.warp.add:
|
||||
description: Permite al usuario añadir un warp
|
||||
default: true
|
||||
mkernel.command.warp.remove:
|
||||
description: Permite al usuario eliminar un warp
|
||||
default: true
|
||||
mkernel.command.spy:
|
||||
description: Permite al usuario espiar a otro jugador
|
||||
default: op
|
||||
mkernel.command.freeze:
|
||||
description: Permite al usuario congelar a otro jugador
|
||||
default: op
|
||||
mkernel.command.heal:
|
||||
description: Permite al usuario curarse
|
||||
default: true
|
||||
mkernel.command.heal.others:
|
||||
description: Permite al usuario curar a otro jugador
|
||||
default: op
|
||||
mkernel.command.launch:
|
||||
description: Permite al usuario lanzar a otro jugador
|
||||
default: op
|
||||
mkernel.command.invsee:
|
||||
description: Abre el inventario de otro jugador
|
||||
default: op
|
||||
mkernel.command.titulacion:
|
||||
description: Elige titulacion
|
||||
default: op
|
||||
|
||||
mkernel.events.chatformat:
|
||||
description: Permite al usuario usar formatos y colores en los mensajes de chat
|
||||
default: true
|
||||
mkernel.events.adminchat:
|
||||
description: Permite al usuario usar el chat de administración
|
||||
default: op
|
||||
mkernel.events.mentions:
|
||||
description: Permite al usuario usar menciones
|
||||
default: true
|
||||
|
||||
mkernel.admin:
|
||||
description: Permite al usuario ejecutar comandos de administrador
|
||||
default: op
|
||||
children:
|
||||
mkernel.command.reload: true
|
||||
mkernel.command.config: true
|
||||
mkernel.command.opme: true
|
||||
mkernel.command.deopme: true
|
||||
mkernel.command.globalchest.others: true
|
||||
mkernel.command.disposal.others: true
|
||||
mkernel.command.spawn.others: true
|
||||
mkernel.command.lobby.others: true
|
||||
mkernel.command.specialitem: true
|
||||
mkernel.command.blockworld: true
|
||||
mkernel.command.gmc: true
|
||||
mkernel.command.gms: true
|
||||
mkernel.command.gma: true
|
||||
mkernel.command.gmsp: true
|
||||
mkernel.command.vanish: true
|
||||
mkernel.command.spy: true
|
||||
mkernel.command.freeze: true
|
||||
mkernel.command.heal: true
|
||||
mkernel.command.heal.others: true
|
||||
mkernel.command.launch: true
|
||||
mkernel.command.invsee: true
|
||||
mkernel.events.adminchat: true
|
||||
mkernel.player: true
|
||||
|
||||
mkernel.player:
|
||||
description: Permite al usuario ejecutar comandos de jugador
|
||||
default: true
|
||||
children:
|
||||
mkernel.command.tpa: true
|
||||
mkernel.command.tpahere: true
|
||||
mkernel.command.tpaccept: true
|
||||
mkernel.command.tpdeny: true
|
||||
mkernel.command.globalchest: true
|
||||
mkernel.command.disposal: true
|
||||
mkernel.command.sendcoords: true
|
||||
mkernel.command.spawn: true
|
||||
mkernel.command.lobby: true
|
||||
mkernel.command.home: true
|
||||
mkernel.command.sethome: true
|
||||
mkernel.events.chatformat: true
|
||||
mkernel.events.mentions: true
|
||||
mkernel.command.recinv: true
|
||||
mkernel.command.warp: true
|
||||
mkernel.command.warp.add: true
|
||||
mkernel.command.warp.remove: true
|
||||
mkernel.command.me: true
|
||||
mkernel.command.do: true
|
||||
mkernel.command.payxp: true
|
||||
mkernel.command.titulacion: true
|
||||
|
||||
mkernel.*:
|
||||
description: Permite al usuario ejecutar todos los comandos de MKernel
|
||||
default: op
|
||||
children:
|
||||
mkernel.admin: true
|
||||
mkernel.player: true
|
||||
Reference in New Issue
Block a user