-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,364 additions
and
2,887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
.DS_Store | ||
|
||
# intellij | ||
dependency-reduced-pom.xml | ||
*.iml | ||
*.ipr | ||
*.iws | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.callv2.daynightpvp; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.callv2.daynightpvp.bstats.BStatsHandler; | ||
import org.callv2.daynightpvp.commands.CommandHandler; | ||
import org.callv2.daynightpvp.files.ConfigFile; | ||
import org.callv2.daynightpvp.files.LangFile; | ||
import org.callv2.daynightpvp.listeners.ListenersHandler; | ||
import org.callv2.daynightpvp.placeholder.PlaceholderHandler; | ||
import org.callv2.daynightpvp.runnables.RunnableHandler; | ||
import org.callv2.daynightpvp.utils.ConsoleUtils; | ||
import org.callv2.daynightpvp.utils.PluginUtils; | ||
import org.callv2.daynightpvp.vault.LoseMoneyOnDeath; | ||
import org.callv2.daynightpvp.worldguard.FlagHandler; | ||
|
||
public class DayNightPvP extends JavaPlugin { | ||
|
||
public static boolean vaultIsPresent; | ||
public static boolean griefIsPresent; | ||
public static boolean worldGuardIsPresent; | ||
public static boolean placeHolderIsPresent; | ||
|
||
private static DayNightPvP instance; | ||
|
||
private final ConfigFile configFile; | ||
private final LangFile langFile; | ||
private final CommandHandler commandHandler; | ||
private final ListenersHandler listenersHandler; | ||
private final PlaceholderHandler placeholderHandler; | ||
private final RunnableHandler runnableHandler; | ||
private final BStatsHandler bStatsHandler; | ||
|
||
public DayNightPvP() { | ||
instance = this; | ||
|
||
configFile = new ConfigFile(); | ||
langFile = new LangFile(configFile); | ||
|
||
runnableHandler = new RunnableHandler(configFile, langFile); | ||
|
||
LoseMoneyOnDeath loseMoneyOnDeath = new LoseMoneyOnDeath(configFile, langFile); | ||
|
||
commandHandler = new CommandHandler(langFile, loseMoneyOnDeath, runnableHandler); | ||
listenersHandler = new ListenersHandler(configFile, langFile, loseMoneyOnDeath); | ||
placeholderHandler = new PlaceholderHandler(langFile, configFile); | ||
bStatsHandler = new BStatsHandler(); | ||
|
||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
verifyCompatibilityPlugins(); | ||
|
||
if (worldGuardIsPresent) { | ||
FlagHandler.register(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
ConsoleUtils.sendStartupMessage(); | ||
|
||
configFile.createFile(); | ||
langFile.createFile(); | ||
|
||
bStatsHandler.start(); | ||
|
||
commandHandler.register(); | ||
|
||
listenersHandler.register(); | ||
|
||
placeholderHandler.register(); | ||
|
||
runnableHandler.startAllRunnables(); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
runnableHandler.stopAllRunnables(); | ||
} | ||
|
||
public static DayNightPvP getInstance() { | ||
return instance; | ||
} | ||
|
||
private void verifyCompatibilityPlugins() { | ||
vaultIsPresent = PluginUtils.isPluginInstalled("Vault"); | ||
worldGuardIsPresent = PluginUtils.isPluginInstalled("WorldGuard"); | ||
griefIsPresent = PluginUtils.isPluginInstalled("GriefPrevention"); | ||
placeHolderIsPresent = PluginUtils.isPluginInstalled("PlaceholderAPI"); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/callv2/daynightpvp/bstats/BStatsHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.callv2.daynightpvp.bstats; | ||
|
||
import org.bstats.bukkit.Metrics; | ||
import org.callv2.daynightpvp.DayNightPvP; | ||
|
||
public class BStatsHandler { | ||
|
||
public void start() { | ||
int bStatsID = 19067; | ||
new Metrics(DayNightPvP.getInstance(), bStatsID); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/callv2/daynightpvp/commands/CommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.callv2.daynightpvp.commands; | ||
|
||
import org.callv2.daynightpvp.DayNightPvP; | ||
import org.callv2.daynightpvp.files.LangFile; | ||
import org.callv2.daynightpvp.runnables.RunnableHandler; | ||
import org.callv2.daynightpvp.vault.LoseMoneyOnDeath; | ||
|
||
public class CommandHandler { | ||
|
||
private final LangFile langFile; | ||
private final LoseMoneyOnDeath loseMoneyOnDeath; | ||
private final RunnableHandler runnableHandler; | ||
|
||
public CommandHandler(LangFile langFile, LoseMoneyOnDeath loseMoneyOnDeath, RunnableHandler runnableHandler) { | ||
this.langFile = langFile; | ||
this.loseMoneyOnDeath = loseMoneyOnDeath; | ||
this.runnableHandler = runnableHandler; | ||
} | ||
|
||
public void register() { | ||
|
||
DnpCommand dnpCommand = new DnpCommand(langFile, loseMoneyOnDeath, runnableHandler); | ||
|
||
DayNightPvP.getInstance().getCommand("daynightpvp").setExecutor(dnpCommand); | ||
DayNightPvP.getInstance().getCommand("daynightpvp").setTabCompleter(dnpCommand); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package org.callv2.daynightpvp.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.callv2.daynightpvp.commands.subcommands.ReloadSubCommand; | ||
import org.callv2.daynightpvp.files.LangFile; | ||
import org.callv2.daynightpvp.runnables.RunnableHandler; | ||
import org.callv2.daynightpvp.services.PluginServices; | ||
import org.callv2.daynightpvp.utils.PlayerUtils; | ||
import org.callv2.daynightpvp.vault.LoseMoneyOnDeath; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.*; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
public class DnpCommand implements CommandExecutor, TabCompleter { | ||
|
||
private final LangFile langFile; | ||
private final LoseMoneyOnDeath loseMoneyOnDeath; | ||
private final RunnableHandler runnableHandler; | ||
|
||
private final Map<String, ISubCommand> subCommands = new HashMap<>(); | ||
|
||
public DnpCommand(LangFile langFile, LoseMoneyOnDeath loseMoneyOnDeath, RunnableHandler runnableHandler) { | ||
this.langFile = langFile; | ||
this.loseMoneyOnDeath = loseMoneyOnDeath; | ||
this.runnableHandler = runnableHandler; | ||
|
||
registerSubCommands(); | ||
} | ||
|
||
private void registerSubCommands() { | ||
subCommands.put("reload", new ReloadSubCommand(langFile, new PluginServices(loseMoneyOnDeath, runnableHandler))); | ||
} | ||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) { | ||
|
||
if (args.length == 0) { | ||
|
||
PlayerUtils.sendMessage(sender, ""); | ||
PlayerUtils.sendMessage(sender,"§7§l* §a§lCommands§7:"); | ||
PlayerUtils.sendMessage(sender,""); | ||
PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp §8-> §7Show all available commands."); | ||
PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp reload §8-> §7Reload the plugin."); | ||
return true; | ||
} | ||
|
||
ISubCommand dnpSubCommand = subCommands.get(args[0]); | ||
|
||
if (dnpSubCommand == null) { | ||
PlayerUtils.sendMessage(sender, langFile.getFeedbackNonExistentCommand()); | ||
return true; | ||
} | ||
|
||
dnpSubCommand.executeCommand(sender, command, commandLabel, args); | ||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { | ||
if (args.length < 1) return null; | ||
|
||
if (args.length == 1) { | ||
return this.subCommands.keySet().stream() | ||
.filter(subCmd -> sender.hasPermission("dnp.admin")) | ||
.filter(subCmd -> subCmd.contains(args[0]) || subCmd.equalsIgnoreCase(args[0])) | ||
.sorted() | ||
.collect(toList()); | ||
} | ||
|
||
String cmdName = this.subCommands.keySet().stream() | ||
.filter(subCmd -> subCmd.equalsIgnoreCase(args[0])) | ||
.findFirst().orElse(null); | ||
|
||
if (cmdName == null) return new ArrayList<>(); | ||
|
||
if (this.subCommands.containsKey(cmdName)) { | ||
return this.subCommands.get(cmdName).tabComplete(sender, command, alias, Arrays.asList(args).subList(1, args.length)); | ||
} | ||
|
||
return new ArrayList<>(); | ||
} | ||
|
||
} |
Oops, something went wrong.