Tried fixing double interact event, fixed not spawning scruff
This commit is contained in:
parent
f87cac8d52
commit
686925361a
|
|
@ -9,11 +9,11 @@ import com.alttd.altitudequests.events.TalkToQuest;
|
||||||
import com.alttd.altitudequests.util.Logger;
|
import com.alttd.altitudequests.util.Logger;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class AQuests extends JavaPlugin {
|
public final class AQuest extends JavaPlugin {
|
||||||
|
|
||||||
public static AQuests instance;
|
public static AQuest instance;
|
||||||
|
|
||||||
public static AQuests getInstance() {
|
public static AQuest getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.altitudequests.commands;
|
package com.alttd.altitudequests.commands;
|
||||||
|
|
||||||
import com.alttd.altitudequests.AQuests;
|
import com.alttd.altitudequests.AQuest;
|
||||||
import com.alttd.altitudequests.commands.subcommands.CommandCreateScruff;
|
import com.alttd.altitudequests.commands.subcommands.CommandCreateScruff;
|
||||||
import com.alttd.altitudequests.commands.subcommands.CommandHelp;
|
import com.alttd.altitudequests.commands.subcommands.CommandHelp;
|
||||||
import com.alttd.altitudequests.commands.subcommands.CommandReload;
|
import com.alttd.altitudequests.commands.subcommands.CommandReload;
|
||||||
|
|
@ -19,9 +19,9 @@ public class CommandManager implements CommandExecutor, TabExecutor {
|
||||||
private final List<SubCommand> subCommands;
|
private final List<SubCommand> subCommands;
|
||||||
|
|
||||||
public CommandManager() {
|
public CommandManager() {
|
||||||
AQuests aQuests = AQuests.getInstance();
|
AQuest aQuest = AQuest.getInstance();
|
||||||
|
|
||||||
PluginCommand command = aQuests.getCommand("aquest");
|
PluginCommand command = aQuest.getCommand("aquest");
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
subCommands = null;
|
subCommands = null;
|
||||||
Logger.severe("Unable to find AltitudeQuests command.");
|
Logger.severe("Unable to find AltitudeQuests command.");
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public abstract class SubCommand {
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
public String getPermission() {
|
public String getPermission() {
|
||||||
return "aquests." + getName();
|
return "aquest." + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<String> getTabComplete(CommandSender commandSender, String[] args);
|
public abstract List<String> getTabComplete(CommandSender commandSender, String[] args);
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,20 @@ public class CommandCreateScruff extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
if (args.length != 8) {
|
if (args.length != 7) {
|
||||||
commandSender.sendMiniMessage(getHelpMessage(), null);
|
commandSender.sendMiniMessage(getHelpMessage(), null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = Bukkit.getServer().getWorld(args[7]);
|
World world = Bukkit.getServer().getWorld(args[6]);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
commandSender.sendMiniMessage(getHelpMessage(), null);
|
commandSender.sendMiniMessage(getHelpMessage(), null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Location location;
|
Location location;
|
||||||
try {
|
try {
|
||||||
location = new Location(world, Double.parseDouble(args[2]), Double.parseDouble(args[3]), Double.parseDouble(args[4]),
|
location = new Location(world, Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]),
|
||||||
Float.parseFloat(args[5]), Float.parseFloat(args[6]));
|
Float.parseFloat(args[4]), Float.parseFloat(args[5]));
|
||||||
} catch (NumberFormatException exception) {
|
} catch (NumberFormatException exception) {
|
||||||
commandSender.sendMiniMessage("<red>Invalid arguments.</red>", null);
|
commandSender.sendMiniMessage("<red>Invalid arguments.</red>", null);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -48,11 +48,13 @@ public class CommandCreateScruff extends SubCommand {
|
||||||
wolf.setAI(false);
|
wolf.setAI(false);
|
||||||
wolf.setCollarColor(DyeColor.MAGENTA);
|
wolf.setCollarColor(DyeColor.MAGENTA);
|
||||||
wolf.setCustomNameVisible(true);
|
wolf.setCustomNameVisible(true);
|
||||||
wolf.customName(getMiniMessage().deserialize("Scruff"));
|
wolf.customName(getMiniMessage().deserialize("<magenta>Scruff</magenta>"));
|
||||||
|
wolf.setSitting(true);
|
||||||
|
|
||||||
UUID uuid = wolf.getUniqueId();
|
UUID uuid = wolf.getUniqueId();
|
||||||
|
|
||||||
LocalConfig.setActiveNPC(uuid);
|
LocalConfig.setActiveNPC(uuid);
|
||||||
|
commandSender.sendMiniMessage("<green>Spawned Scruff</green>", null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.altitudequests.config;
|
package com.alttd.altitudequests.config;
|
||||||
|
|
||||||
import com.alttd.altitudequests.AQuests;
|
import com.alttd.altitudequests.AQuest;
|
||||||
import com.alttd.altitudequests.util.Logger;
|
import com.alttd.altitudequests.util.Logger;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
@ -24,7 +24,7 @@ abstract class AbstractConfig {
|
||||||
YamlConfiguration yaml;
|
YamlConfiguration yaml;
|
||||||
|
|
||||||
AbstractConfig(String filename) {
|
AbstractConfig(String filename) {
|
||||||
init(new File(AQuests.getInstance().getDataFolder(), filename), filename);
|
init(new File(AQuest.getInstance().getDataFolder(), filename), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractConfig(File file, String filename) {
|
AbstractConfig(File file, String filename) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.altitudequests.database;
|
package com.alttd.altitudequests.database;
|
||||||
|
|
||||||
import com.alttd.altitudequests.AQuests;
|
import com.alttd.altitudequests.AQuest;
|
||||||
import com.alttd.altitudequests.config.DatabaseConfig;
|
import com.alttd.altitudequests.config.DatabaseConfig;
|
||||||
import com.alttd.altitudequests.util.Logger;
|
import com.alttd.altitudequests.util.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -75,7 +75,7 @@ public class Database {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Logger.severe("Error while trying to create user point table");
|
Logger.severe("Error while trying to create user point table");
|
||||||
Logger.severe("Shutting down AltitudeQuests");
|
Logger.severe("Shutting down AltitudeQuests");
|
||||||
Bukkit.getPluginManager().disablePlugin(AQuests.getInstance());
|
Bukkit.getPluginManager().disablePlugin(AQuest.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ public class QuestComplete implements Listener {
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onQuestComplete(QuestCompleteEvent event) {
|
public void onQuestComplete(QuestCompleteEvent event) {
|
||||||
event.getPlayer().sendMiniMessage("<green>You completed a quest gj.</green>", null);
|
event.getPlayer().sendMiniMessage("<green>You completed a quest gj. - DEBUG</green>", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.alttd.altitudequests.events;
|
package com.alttd.altitudequests.events;
|
||||||
|
|
||||||
import com.alttd.altitudequests.AQuests;
|
import com.alttd.altitudequests.AQuest;
|
||||||
import com.alttd.altitudequests.config.Config;
|
import com.alttd.altitudequests.config.Config;
|
||||||
import com.alttd.altitudequests.config.LocalConfig;
|
import com.alttd.altitudequests.config.LocalConfig;
|
||||||
import net.kyori.adventure.inventory.Book;
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
|
@ -14,24 +14,34 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TalkToQuest implements Listener {
|
public class TalkToQuest implements Listener {
|
||||||
|
|
||||||
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
|
private static final Set<UUID> tmp = new HashSet<>();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityInteract(PlayerInteractEntityEvent event) {
|
public void onEntityInteract(PlayerInteractEntityEvent event) {
|
||||||
if (LocalConfig.activeNPC == null || !LocalConfig.activeNPC.equals(event.getRightClicked().getUniqueId()))
|
if (LocalConfig.activeNPC == null || !LocalConfig.activeNPC.equals(event.getRightClicked().getUniqueId()))
|
||||||
return;
|
return;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
if (!tmp.remove(event.getPlayer().getUniqueId())) {
|
||||||
|
tmp.add(event.getPlayer().getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.getPlayer().sendMiniMessage("Interacted with scruff - DEBUG", null);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
event.getPlayer().openBook(getBook(event));
|
event.getPlayer().openBook(getBook(event));
|
||||||
}
|
}
|
||||||
}.runTaskTimerAsynchronously(AQuests.getInstance(), 0, 0);
|
}.runTaskTimerAsynchronously(AQuest.getInstance(), 0, 0);
|
||||||
//TODO make it so there can be one book config per quest
|
//TODO make it so there can be one book config per quest
|
||||||
//TODO make it so everything can be done with commands and just don't let them tab complete and do them through the book instead
|
//TODO make it so everything can be done with commands and just don't let them tab complete and do them through the book instead
|
||||||
//TODO in config allow a multitude of events to be prepared and randomly select from them at certain times of day?
|
//TODO in config allow a multitude of events to be prepared and randomly select from them at certain times of day?
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.alttd.altitudequests.util;
|
package com.alttd.altitudequests.util;
|
||||||
|
|
||||||
import com.alttd.altitudequests.AQuests;
|
import com.alttd.altitudequests.AQuest;
|
||||||
|
|
||||||
public class Logger {
|
public class Logger {
|
||||||
|
|
||||||
static private final java.util.logging.Logger logger;
|
static private final java.util.logging.Logger logger;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
logger = AQuests.getInstance().getLogger();
|
logger = AQuest.getInstance().getLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(String info, String... variables)
|
public static void info(String info, String... variables)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
name: AQuests
|
name: AQuests
|
||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: com.alttd.altitudequests.AQuests
|
main: com.alttd.altitudequests.AQuest
|
||||||
api-version: 1.18
|
api-version: 1.18
|
||||||
authors: [ Teriuihi ]
|
authors: [ Teriuihi ]
|
||||||
description: A plugin to run quests on a server
|
description: A plugin to run quests on a server
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user