Skip to content

Commit

Permalink
Revert "update"
Browse files Browse the repository at this point in the history
This reverts commit d4f61da.
  • Loading branch information
needkg committed Jul 3, 2024
1 parent d4f61da commit 60f057e
Show file tree
Hide file tree
Showing 45 changed files with 1,232 additions and 662 deletions.
13 changes: 13 additions & 0 deletions DayNightPvP.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<java.version>17</java.version>
<spigot.prefix>${project.name}</spigot.prefix>
<spigot.main>${project.groupId}.daynightpvp.DayNightPvP</spigot.main>
</properties>
Expand All @@ -38,8 +38,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>16</source>
<target>16</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>

Expand Down
90 changes: 45 additions & 45 deletions src/main/java/org/callvdois/daynightpvp/DayNightPvP.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.callvdois.daynightpvp.Listeners.ListenersHandler;
import org.callvdois.daynightpvp.commands.CommandHandler;
import org.callvdois.daynightpvp.files.ConfigFile;
import org.callvdois.daynightpvp.files.LangFile;
import org.callvdois.daynightpvp.metrics.MetricsHandler;
import org.callvdois.daynightpvp.placeholder.PlaceholderHandler;
import org.callvdois.daynightpvp.runnables.RunnableHandler;
import org.callvdois.daynightpvp.commands.CommandManager;
import org.callvdois.daynightpvp.config.FilesManager;
import org.callvdois.daynightpvp.events.EventsManager;
import org.callvdois.daynightpvp.metrics.MetricsManager;
import org.callvdois.daynightpvp.placeholder.PlaceholderManager;
import org.callvdois.daynightpvp.service.ServiceManager;
import org.callvdois.daynightpvp.utils.ConsoleUtils;
import org.callvdois.daynightpvp.utils.PluginUtils;
import org.callvdois.daynightpvp.worldguard.FlagHandler;
import org.callvdois.daynightpvp.worldguard.WorldGuardManager;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,30 +23,24 @@ public class DayNightPvP extends JavaPlugin {
public static boolean placeHolderIsPresent;
public static List<BukkitTask> serviceTasks = new ArrayList<>();
private static DayNightPvP instance;
private final ConsoleUtils consoleUtils;
private final ConfigFile configFile;
private final LangFile langFile;
private final CommandHandler commandHandler;
private final ListenersHandler listenersHandler;
private final PlaceholderHandler placeholderHandler;
private final FlagHandler flagHandler;
private final RunnableHandler runnableHandler;
private final MetricsHandler metricsHandler;
private final PluginUtils pluginUtils;
private final FilesManager filesManager;
private final CommandManager commandManager;
private final EventsManager eventsManager;
private final PlaceholderManager placeholderManager;
private final WorldGuardManager worldGuardManager;
private final ServiceManager serviceManager;
private final MetricsManager metricsManager;

public DayNightPvP() {
instance = this;

consoleUtils = new ConsoleUtils();
configFile = new ConfigFile();
langFile = new LangFile();
commandHandler = new CommandHandler();
listenersHandler = new ListenersHandler();
placeholderHandler = new PlaceholderHandler();
flagHandler = new FlagHandler();
runnableHandler = new RunnableHandler();
metricsHandler = new MetricsHandler();
pluginUtils = new PluginUtils();
filesManager = new FilesManager();
commandManager = new CommandManager();
eventsManager = new EventsManager();
placeholderManager = new PlaceholderManager();
worldGuardManager = new WorldGuardManager();
serviceManager = new ServiceManager();
metricsManager = new MetricsManager();

}

Expand All @@ -57,42 +50,49 @@ public static DayNightPvP getInstance() {

@Override
public void onLoad() {
load();
}

@Override
public void onEnable() {
enable();
}

private void load() {

verifyCompatibilityPlugins();

if (worldGuardIsPresent) {
flagHandler.register();
worldGuardManager.register();
}
}

@Override
public void onEnable() {
consoleUtils.sendStartupMessage();
private void enable() {
ConsoleUtils.startMessage();

metricsHandler.start();
filesManager.createFiles();

configFile.createFile();
langFile.createFile();
commandManager.register();

commandHandler.register();
eventsManager.register();

listenersHandler.register();
placeholderManager.register();

placeholderHandler.register();
serviceManager.startServices();

runnableHandler.startAllRunnables();
metricsManager.register();
}


private void verifyCompatibilityPlugins() {
vaultIsPresent = pluginUtils.isPluginInstalled("Vault");
worldGuardIsPresent = pluginUtils.isPluginInstalled("WorldGuard");
griefIsPresent = pluginUtils.isPluginInstalled("GriefPrevention");
placeHolderIsPresent = pluginUtils.isPluginInstalled("PlaceholderAPI");
vaultIsPresent = PluginUtils.isPluginInstalled("Vault");
worldGuardIsPresent = PluginUtils.isPluginInstalled("WorldGuard");
griefIsPresent = PluginUtils.isPluginInstalled("GriefPrevention");
placeHolderIsPresent = PluginUtils.isPluginInstalled("PlaceholderAPI");
}

@Override
public void onDisable() {
runnableHandler.stopAllRunnables();
serviceManager.stopServices();
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.callvdois.daynightpvp.commands;

import org.callvdois.daynightpvp.DayNightPvP;
import org.callvdois.daynightpvp.commands.dnp.DnpCommand;

public class CommandHandler {

public class CommandManager {
public void register() {

DayNightPvP.getInstance().getCommand("daynightpvp").setExecutor(new DnpCommand());
DayNightPvP.getInstance().getCommand("daynightpvp").setTabCompleter(new DnpCommand());
DayNightPvP.getInstance().getCommand("daynightpvp").setTabCompleter(new DnpTabCompleter());
}
}
55 changes: 55 additions & 0 deletions src/main/java/org/callvdois/daynightpvp/commands/DnpCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.callvdois.daynightpvp.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.callvdois.daynightpvp.DayNightPvP;
import org.callvdois.daynightpvp.config.FilesManager;
import org.callvdois.daynightpvp.config.LangManager;
import org.callvdois.daynightpvp.gui.MainGui;
import org.callvdois.daynightpvp.utils.PlayerUtils;
import org.jetbrains.annotations.NotNull;

public class DnpCommand implements CommandExecutor {

private final MainGui mainGui;
private final FilesManager filesManager;
private final LangManager langManager;

public DnpCommand() {
mainGui = new MainGui();
filesManager = new FilesManager();
langManager = new LangManager();
}

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (sender instanceof Player player) {
if (sender.hasPermission("dnp.admin")) {
if (args.length == 0) {
mainGui.open(player);
return true;
}
if (args.length == 1) {
if (args[0].equals("reload")) {
filesManager.reloadPlugin();
PlayerUtils.sendMessageToPlayer(player, langManager.getFeedbackReloadPlugin());
return true;
} else {
PlayerUtils.sendMessageToPlayer(player, langManager.getFeedbackNonExistentCommand());
return false;
}
}
return false;
} else {
PlayerUtils.sendMessageToPlayer(player, "§8[§e☀§8] §9DayNightPvP §8- §7v" + DayNightPvP.getInstance().getDescription().getVersion());
return false;
}
} else {
sender.sendMessage("This command can only be executed by players.");
return false;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.callvdois.daynightpvp.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;

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

public class DnpTabCompleter implements TabCompleter {

@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
return Collections.emptyList();
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 60f057e

Please sign in to comment.