mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Send condition messages to action bar
This commit is contained in:
parent
17e8510335
commit
33474fbc5c
@ -31,6 +31,7 @@ import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
|
|||||||
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
|
||||||
import me.blackvein.quests.item.QuestJournal;
|
import me.blackvein.quests.item.QuestJournal;
|
||||||
import me.blackvein.quests.module.ICustomObjective;
|
import me.blackvein.quests.module.ICustomObjective;
|
||||||
|
import me.blackvein.quests.nms.ActionBarProvider;
|
||||||
import me.blackvein.quests.nms.TitleProvider;
|
import me.blackvein.quests.nms.TitleProvider;
|
||||||
import me.blackvein.quests.player.IQuester;
|
import me.blackvein.quests.player.IQuester;
|
||||||
import me.blackvein.quests.quests.BukkitObjective;
|
import me.blackvein.quests.quests.BukkitObjective;
|
||||||
@ -5014,8 +5015,8 @@ public class Quester implements IQuester {
|
|||||||
} else if (giveReason) {
|
} else if (giveReason) {
|
||||||
if (System.currentTimeMillis() - lastNotifiedCondition > (plugin.getSettings().getConditionInterval()
|
if (System.currentTimeMillis() - lastNotifiedCondition > (plugin.getSettings().getConditionInterval()
|
||||||
* 1000L)) {
|
* 1000L)) {
|
||||||
getPlayer().sendMessage(ChatColor.YELLOW + Lang.get(getPlayer(), "conditionFailRetry")
|
ActionBarProvider.sendActionBar(getPlayer(), ChatColor.YELLOW + Lang.get(getPlayer(),
|
||||||
.replace("<quest>", quest.getName()));
|
"conditionFailRetry").replace("<quest>", quest.getName()));
|
||||||
lastNotifiedCondition = System.currentTimeMillis();
|
lastNotifiedCondition = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.nms;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class ActionBarProvider {
|
||||||
|
|
||||||
|
private static ActionBarProvider loaded;
|
||||||
|
|
||||||
|
static {
|
||||||
|
final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||||
|
try {
|
||||||
|
final String packageName = ActionBarProvider.class.getPackage().getName();
|
||||||
|
if (internalsName.startsWith("v1_8_R")) {
|
||||||
|
loaded = (ActionBarProvider) Class.forName(packageName + ".ActionBarProvider_" + internalsName)
|
||||||
|
.newInstance();
|
||||||
|
} else {
|
||||||
|
loaded = new ActionBarProvider_Bukkit();
|
||||||
|
}
|
||||||
|
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
|
||||||
|
| ClassCastException exception) {
|
||||||
|
Bukkit.getLogger().severe("[Quests] No valid action bar implementation for version " + internalsName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void sendActionBarPacket(Player player, String message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the action bar to the player.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* The player to send the action bar to.
|
||||||
|
* @param message
|
||||||
|
* The message,
|
||||||
|
*/
|
||||||
|
public static void sendActionBar(final Player player, final String message) {
|
||||||
|
loaded.sendActionBarPacket(player, message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.nms;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
class ActionBarProvider_Bukkit extends ActionBarProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void sendActionBarPacket(final Player player, String message) {
|
||||||
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ allow-command-questing: true
|
|||||||
allow-command-quests-with-npcs: false
|
allow-command-quests-with-npcs: false
|
||||||
allow-pranks: true
|
allow-pranks: true
|
||||||
clickable-prompts: true
|
clickable-prompts: true
|
||||||
condition-interval: 8
|
condition-interval: 10
|
||||||
confirm-abandon: true
|
confirm-abandon: true
|
||||||
confirm-accept: true
|
confirm-accept: true
|
||||||
console-logging: 2
|
console-logging: 2
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.nms;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R1.ChatComponentText;
|
||||||
|
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActionBarProvider_v1_8_R1 extends ActionBarProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void sendActionBarPacket(final Player player, final String message) {
|
||||||
|
final CraftPlayer craft = (CraftPlayer) player;
|
||||||
|
|
||||||
|
final PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(message), (byte)2);
|
||||||
|
|
||||||
|
craft.getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.nms;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R2.ChatComponentText;
|
||||||
|
import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActionBarProvider_v1_8_R2 extends ActionBarProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void sendActionBarPacket(final Player player, final String message) {
|
||||||
|
final CraftPlayer craft = (CraftPlayer) player;
|
||||||
|
|
||||||
|
final PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(message), (byte)2);
|
||||||
|
|
||||||
|
craft.getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||||
|
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.blackvein.quests.nms;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActionBarProvider_v1_8_R3 extends ActionBarProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void sendActionBarPacket(final Player player, final String message) {
|
||||||
|
final CraftPlayer craft = (CraftPlayer) player;
|
||||||
|
|
||||||
|
final PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(message), (byte)2);
|
||||||
|
|
||||||
|
craft.getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user