Redoing stuff.
This commit is contained in:
parent
375f46fe93
commit
303cd6b63a
@ -1,6 +1,5 @@
|
|||||||
package nl.Steffion.BlockHunt;
|
package nl.Steffion.BlockHunt;
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.Listeners.PlayerListener;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.CommandC;
|
import nl.Steffion.BlockHunt.Managers.CommandC;
|
||||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||||
@ -19,8 +18,9 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
W.newFiles();
|
W.newFiles();
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(this),
|
// getServer().getPluginManager().registerEvents(new
|
||||||
this);
|
// PlayerListener(this),
|
||||||
|
// this);
|
||||||
MessageM.sendFMessage(null, ConfigC.log_Enabled, true, "name-"
|
MessageM.sendFMessage(null, ConfigC.log_Enabled, true, "name-"
|
||||||
+ W.pluginName, "version-" + W.pluginVersion, "autors-"
|
+ W.pluginName, "version-" + W.pluginVersion, "autors-"
|
||||||
+ W.pluginAutors);
|
+ W.pluginAutors);
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
package nl.Steffion.BlockHunt.Commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.W;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CMDlist extends DefaultCMD {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exectue(Player player, Command cmd, String label,
|
|
||||||
String[] args) {
|
|
||||||
if (PlayerM.hasPerm(player, PermsC.list, true)) {
|
|
||||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
|
|
||||||
"header-" + W.pluginName);
|
|
||||||
File arenaworldFolder = new File("plugins/" + W.pluginName
|
|
||||||
+ "/defaultArenas/");
|
|
||||||
ArrayList<String> arenas = new ArrayList<String>();
|
|
||||||
for (String file : arenaworldFolder.list()) {
|
|
||||||
File arenaCheck = new File(arenaworldFolder, file);
|
|
||||||
if (arenaCheck.isDirectory()) {
|
|
||||||
arenas.add(arenaCheck.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (arenas.size() >= 1) {
|
|
||||||
for (String arena : arenas) {
|
|
||||||
MessageM.sendMessage(player, "%A" + arena, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MessageM.sendMessage(player, "&7&oNo arenas available...",
|
|
||||||
false);
|
|
||||||
MessageM.sendMessage(player, "&7&oAdd arenas in the '"
|
|
||||||
+ W.pluginName + "/defaultArenas/' folder.", false);
|
|
||||||
}
|
|
||||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
|
|
||||||
"header-&oArenas list");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAnArena(String worldname) {
|
|
||||||
File arenaworldFolder = new File("plugins/" + W.pluginName
|
|
||||||
+ "/defaultArenas/");
|
|
||||||
|
|
||||||
ArrayList<String> arenas = new ArrayList<String>();
|
|
||||||
for (String file : arenaworldFolder.list()) {
|
|
||||||
File arenaCheck = new File(arenaworldFolder, file);
|
|
||||||
if (arenaCheck.isDirectory()) {
|
|
||||||
arenas.add(arenaCheck.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arenas.contains(worldname)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package nl.Steffion.BlockHunt.Commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.W;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.CommandC;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.FileM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class CMDpreview extends DefaultCMD {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exectue(Player player, Command cmd, String label,
|
|
||||||
String[] args) {
|
|
||||||
if (PlayerM.hasPerm(player, PermsC.preview, true)) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments,
|
|
||||||
true, "syntax-" + CommandC.PREVIEW.usage);
|
|
||||||
} else {
|
|
||||||
File arenaworldFolder = new File("plugins/" + W.pluginName
|
|
||||||
+ "/defaultArenas/" + args[1]);
|
|
||||||
if (!arenaworldFolder.exists()) {
|
|
||||||
MessageM.sendFMessage(player, ConfigC.error_noArena, true,
|
|
||||||
"name-" + args[1]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean notFound = true;
|
|
||||||
int subID = 1;
|
|
||||||
while (notFound) {
|
|
||||||
File destFolder = new File("plugins/" + W.pluginName
|
|
||||||
+ "/loadedArenas/" + args[1] + "_" + subID);
|
|
||||||
if (!destFolder.exists()) {
|
|
||||||
MessageM.sendFMessage(player,
|
|
||||||
ConfigC.normal_previewWorld, true);
|
|
||||||
try {
|
|
||||||
FileM.copyFolder(arenaworldFolder, destFolder);
|
|
||||||
W.previewWorlds.add(destFolder.getPath());
|
|
||||||
MessageM.broadcastMessage(destFolder.getPath(),
|
|
||||||
false);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldCreator wc = new WorldCreator(destFolder.getPath());
|
|
||||||
Bukkit.getServer().createWorld(wc);
|
|
||||||
|
|
||||||
World world = Bukkit.getWorld(destFolder.getPath());
|
|
||||||
player.teleport(world.getSpawnLocation());
|
|
||||||
|
|
||||||
notFound = false;
|
|
||||||
|
|
||||||
MessageM.sendFMessage(player,
|
|
||||||
ConfigC.normal_previewWorldDone, true);
|
|
||||||
} else {
|
|
||||||
subID = subID + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +1,38 @@
|
|||||||
package nl.Steffion.BlockHunt.Listeners;
|
package nl.Steffion.BlockHunt.Listeners;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.BlockHunt;
|
|
||||||
import nl.Steffion.BlockHunt.W;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.FileM;
|
|
||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
private BlockHunt plugin;
|
// private BlockHunt plugin;
|
||||||
|
//
|
||||||
|
// public PlayerListener (BlockHunt plugin) {
|
||||||
|
// this.plugin = plugin;
|
||||||
|
// }
|
||||||
|
|
||||||
public PlayerListener (BlockHunt plugin) {
|
// @EventHandler(priority = EventPriority.MONITOR)
|
||||||
this.plugin = plugin;
|
// public void onPlayerTeleportEvent(final PlayerTeleportEvent event) {
|
||||||
}
|
// final Player player = event.getPlayer();
|
||||||
|
// if (W.previewWorlds.contains(event.getFrom().getWorld().getName())) {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
// if (!event.getFrom().getWorld().getName()
|
||||||
public void onPlayerTeleportEvent(final PlayerTeleportEvent event) {
|
// .equals(event.getTo().getWorld().getName())) {
|
||||||
final Player player = event.getPlayer();
|
// final String worldLoc = event.getFrom().getWorld().getName();
|
||||||
if (W.previewWorlds.contains(event.getFrom().getWorld().getName())) {
|
// boolean unload = true;
|
||||||
if (!event.getFrom().getWorld().getName()
|
//
|
||||||
.equals(event.getTo().getWorld().getName())) {
|
// for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||||
final String worldLoc = event.getFrom().getWorld().getName();
|
// if (pl.getLocation().getWorld().getName().equals(worldLoc)) {
|
||||||
boolean unload = true;
|
// if (!pl.equals(player)) {
|
||||||
|
// unload = false;
|
||||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
// }
|
||||||
if (pl.getLocation().getWorld().getName().equals(worldLoc)) {
|
// }
|
||||||
if (!pl.equals(player)) {
|
// }
|
||||||
unload = false;
|
//
|
||||||
}
|
// if (unload) {
|
||||||
}
|
// ArenaHandler ah = new ArenaHandler(this.plugin);
|
||||||
}
|
// ah.unLoadArena(worldLoc, player);
|
||||||
|
// W.previewWorlds.remove(worldLoc);
|
||||||
if (unload) {
|
// }
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(
|
// }
|
||||||
this.plugin, new Runnable() {
|
// }
|
||||||
@Override
|
// }
|
||||||
public void run() {
|
|
||||||
Bukkit.unloadWorld(
|
|
||||||
Bukkit.getWorld(worldLoc), true);
|
|
||||||
MessageM.sendFMessage(
|
|
||||||
player,
|
|
||||||
ConfigC.normal_previewWorldUnloaded,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(
|
|
||||||
this.plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
String[] worldPlace = event.getFrom()
|
|
||||||
.getWorld().getName()
|
|
||||||
.split("/");
|
|
||||||
String[] worldName = worldPlace[worldPlace.length - 1]
|
|
||||||
.split("_");
|
|
||||||
File destFolder = new File("plugins/"
|
|
||||||
+ W.pluginName
|
|
||||||
+ "/defaultArenas/"
|
|
||||||
+ worldName[0]);
|
|
||||||
if (destFolder.exists()) {
|
|
||||||
FileM.delete(destFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileM.copyFolder(new File(worldLoc),
|
|
||||||
destFolder);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 40);
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(
|
|
||||||
this.plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
FileM.delete(new File(worldLoc));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageM.sendFMessage(player,
|
|
||||||
ConfigC.normal_previewWorldDeleted,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, 60);
|
|
||||||
W.previewWorlds
|
|
||||||
.remove(event.getFrom().getWorld().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,22 +42,6 @@ public enum CommandC {
|
|||||||
ConfigC.help_reload,
|
ConfigC.help_reload,
|
||||||
1,
|
1,
|
||||||
W.pluginName + " <reload|r>"),
|
W.pluginName + " <reload|r>"),
|
||||||
LIST ("BlockHunt%list_",
|
|
||||||
"BlockHunt%l_",
|
|
||||||
new CMDlist(),
|
|
||||||
ConfigC.commandEnabled_list,
|
|
||||||
PermsC.list,
|
|
||||||
ConfigC.help_list,
|
|
||||||
1,
|
|
||||||
W.pluginName + " <list|l>"),
|
|
||||||
PREVIEW ("BlockHunt%preview_",
|
|
||||||
"BlockHunt%p_",
|
|
||||||
new CMDpreview(),
|
|
||||||
ConfigC.commandEnabled_preview,
|
|
||||||
PermsC.preview,
|
|
||||||
ConfigC.help_preview,
|
|
||||||
1,
|
|
||||||
W.pluginName + " <preview|p> <arenaname>"),
|
|
||||||
NOT_FOUND ("%_",
|
NOT_FOUND ("%_",
|
||||||
"%_",
|
"%_",
|
||||||
new CMDnotfound(),
|
new CMDnotfound(),
|
||||||
|
@ -18,8 +18,6 @@ public enum ConfigC {
|
|||||||
commandEnabled_info (true, W.config),
|
commandEnabled_info (true, W.config),
|
||||||
commandEnabled_help (true, W.config),
|
commandEnabled_help (true, W.config),
|
||||||
commandEnabled_reload (true, W.config),
|
commandEnabled_reload (true, W.config),
|
||||||
commandEnabled_list (true, W.config),
|
|
||||||
commandEnabled_preview (true, W.config),
|
|
||||||
|
|
||||||
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
||||||
W.messages),
|
W.messages),
|
||||||
@ -29,18 +27,8 @@ public enum ConfigC {
|
|||||||
help_info ("%NDisplays the plugin's info.", W.messages),
|
help_info ("%NDisplays the plugin's info.", W.messages),
|
||||||
help_help ("%NShows a list of commands.", W.messages),
|
help_help ("%NShows a list of commands.", W.messages),
|
||||||
help_reload ("%NReloads all configs.", W.messages),
|
help_reload ("%NReloads all configs.", W.messages),
|
||||||
help_list ("%NDisplays a list of available arenas.", W.messages),
|
|
||||||
help_preview ("%NMakes a copy of an arena to make changes in your arena.",
|
|
||||||
W.messages),
|
|
||||||
|
|
||||||
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
normal_reloadedConfigs ("&aReloaded all configs!", W.messages),
|
||||||
normal_previewWorld ("%NMaking a preview world for you...", W.messages),
|
|
||||||
normal_previewWorldDone ("%NYour preview world has been created! Sending you...",
|
|
||||||
W.messages),
|
|
||||||
normal_previewWorldUnloaded ("%NYour preview world has been %Eunloaded%N!",
|
|
||||||
W.messages),
|
|
||||||
normal_previewWorldDeleted ("%NYour preview world has been %Edeleted%N!",
|
|
||||||
W.messages),
|
|
||||||
|
|
||||||
error_noPermission ("%EYou don't have the permissions to do that!",
|
error_noPermission ("%EYou don't have the permissions to do that!",
|
||||||
W.messages),
|
W.messages),
|
||||||
|
@ -17,11 +17,8 @@ public class W {
|
|||||||
public static String pluginMainPermission = pluginName + ".";
|
public static String pluginMainPermission = pluginName + ".";
|
||||||
|
|
||||||
public static ArrayList<String> newFiles = new ArrayList<String>();
|
public static ArrayList<String> newFiles = new ArrayList<String>();
|
||||||
public static ArrayList<String> previewWorlds = new ArrayList<String>();
|
|
||||||
public static ConfigM config = new ConfigM("config", "");
|
public static ConfigM config = new ConfigM("config", "");
|
||||||
public static ConfigM messages = new ConfigM("messages", "");
|
public static ConfigM messages = new ConfigM("messages", "");
|
||||||
public static ConfigM note1 = new ConfigM("PLACE WORLD FOLDERS HERE!",
|
|
||||||
"defaultArenas/");
|
|
||||||
|
|
||||||
public static void newFiles() {
|
public static void newFiles() {
|
||||||
ConfigM.setDefaults();
|
ConfigM.setDefaults();
|
||||||
|
@ -4,6 +4,7 @@ version: 1.0.0
|
|||||||
authors:
|
authors:
|
||||||
- Steffion
|
- Steffion
|
||||||
description: Description here.
|
description: Description here.
|
||||||
|
softdepend: [DisguiseCraft, Multiverse-Core]
|
||||||
commands:
|
commands:
|
||||||
BlockHunt:
|
BlockHunt:
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user