Send 1.8 titles using packets, fixes #1903

This commit is contained in:
PikaMug 2022-03-22 23:44:07 -04:00
parent 945e06c33f
commit b25449f89f
18 changed files with 377 additions and 185 deletions

View File

@ -31,6 +31,7 @@ import me.blackvein.quests.events.quester.QuesterPostFailQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreChangeStageEvent;
import me.blackvein.quests.events.quester.QuesterPreCompleteQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreFailQuestEvent;
import me.blackvein.quests.nms.TitleProvider;
import me.blackvein.quests.player.IQuester;
import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.quests.BukkitPlanner;
@ -913,8 +914,9 @@ public class Quest implements IQuest {
Lang.send(p, ChatColor.GOLD + Lang.get(p, "questCompleteTitle").replace("<quest>",
ChatColor.YELLOW + name + ChatColor.GOLD));
if (plugin.getSettings().canShowQuestTitles()) {
p.sendTitle(ChatColor.GOLD + Lang.get(p, "quest") + " " + Lang.get(p, "complete"),
ChatColor.YELLOW + name);
final String title = ChatColor.GOLD + Lang.get(p, "quest") + " " + Lang.get(p, "complete");
final String subtitle = ChatColor.YELLOW + name;
TitleProvider.sendTitle(p, title, subtitle);
}
Lang.send(p, ChatColor.GREEN + Lang.get(p, "questRewardsTitle"));
if (!issuedReward) {

View File

@ -30,6 +30,7 @@ import me.blackvein.quests.events.quester.QuesterPreOpenGUIEvent;
import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import me.blackvein.quests.item.QuestJournal;
import me.blackvein.quests.nms.TitleProvider;
import me.blackvein.quests.player.IQuester;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.IQuest;
@ -769,8 +770,9 @@ public class Quester implements IQuester {
sendMessage(ChatColor.GREEN + accepted);
p.sendMessage("");
if (plugin.getSettings().canShowQuestTitles()) {
p.sendTitle(ChatColor.GOLD + Lang.get(p, "quest") + " " + Lang.get(p, "accepted"),
ChatColor.YELLOW + quest.getName());
final String title = ChatColor.GOLD + Lang.get(p, "quest") + " " + Lang.get(p, "accepted");
final String subtitle = ChatColor.YELLOW + quest.getName();
TitleProvider.sendTitle(p, title, subtitle);
}
}
}

View File

@ -272,7 +272,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
getServer().getPluginManager().registerEvents(getPartiesListener(), this);
}
if (hasBungeeEnabled()) {
getServer().getMessenger().registerIncomingPluginChannel(this, "quests:update", bungeeListener);
getServer().getMessenger().registerIncomingPluginChannel(this, "quests:update", getBungeeListener());
}
// 11 - Attempt to check for updates
@ -585,6 +585,10 @@ public class Quests extends JavaPlugin implements QuestsAPI {
return blockListener;
}
public BungeeListener getBungeeListener() {
return bungeeListener;
}
public ItemListener getItemListener() {
return itemListener;
}

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.particle;
package me.blackvein.quests.nms;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -24,9 +24,9 @@ public abstract class ParticleProvider {
private static ParticleProvider loaded;
static {
final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
try {
final String packageName = ParticleProvider.class.getPackage().getName();
final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
if (internalsName.startsWith("v1_8_R")) {
loaded = (ParticleProvider) Class.forName(packageName + ".ParticleProvider_" + internalsName)
.newInstance();
@ -35,7 +35,7 @@ public abstract class ParticleProvider {
}
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
| ClassCastException exception) {
Bukkit.getLogger().severe("[Quests] Could not find a valid implementation for this server version.");
Bukkit.getLogger().severe("[Quests] No valid particle implementation for version " + internalsName);
}
}

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.particle;
package me.blackvein.quests.nms;
import org.bukkit.Location;
import org.bukkit.Particle;

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.particle;
package me.blackvein.quests.nms;
import org.bukkit.util.Vector;

View File

@ -0,0 +1,53 @@
/*
* 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 TitleProvider {
private static TitleProvider loaded;
static {
final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
try {
final String packageName = TitleProvider.class.getPackage().getName();
if (internalsName.startsWith("v1_8_R")) {
loaded = (TitleProvider) Class.forName(packageName + ".TitleProvider_" + internalsName)
.newInstance();
} else {
loaded = new TitleProvider_Bukkit();
}
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
| ClassCastException exception) {
Bukkit.getLogger().severe("[Quests] No valid title implementation for version " + internalsName);
}
}
abstract void sendTitlePacket(Player player, String title, String subtitle);
/**
* Sends the title to the player.
*
* @param player
* The player to send the title to.
* @param title
* The title.
* @param subtitle
* The subtitle.
*/
public static void sendTitle(final Player player, final String title, final String subtitle) {
loaded.sendTitlePacket(player, title, subtitle);
}
}

View File

@ -0,0 +1,12 @@
package me.blackvein.quests.nms;
import org.bukkit.entity.Player;
class TitleProvider_Bukkit extends TitleProvider {
@SuppressWarnings("deprecation")
@Override
void sendTitlePacket(final Player player, final String title, final String subtitle) {
player.sendTitle(title, subtitle);
}
}

View File

@ -14,7 +14,7 @@ package me.blackvein.quests.tasks;
import me.blackvein.quests.player.IQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.particle.ParticleProvider;
import me.blackvein.quests.nms.ParticleProvider;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Location;
import org.bukkit.entity.Entity;

View File

@ -15,8 +15,8 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -1,56 +1,56 @@
/*
* 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.particle;
import net.minecraft.server.v1_8_R1.EnumParticle;
import net.minecraft.server.v1_8_R1.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R1 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
/*
* 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.EnumParticle;
import net.minecraft.server.v1_8_R1.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R1 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import net.minecraft.server.v1_8_R1.ChatSerializer;
import net.minecraft.server.v1_8_R1.EnumTitleAction;
import net.minecraft.server.v1_8_R1.IChatBaseComponent;
import net.minecraft.server.v1_8_R1.PacketPlayOutTitle;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class TitleProvider_v1_8_R1 extends TitleProvider {
@Override
void sendTitlePacket(final Player player, final String title, final String subtitle) {
final CraftPlayer craft = (CraftPlayer) player;
final String titleString = ComponentSerializer.toString(TextComponent.fromLegacyText(title));
final String titleSubtitle = ComponentSerializer.toString(TextComponent.fromLegacyText(subtitle));
final IChatBaseComponent titleJson = ChatSerializer.a(titleString);
final IChatBaseComponent subtitleJSON = ChatSerializer.a(titleSubtitle);
final PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJson);
final PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON);
craft.getHandle().playerConnection.sendPacket(titlePacket);
craft.getHandle().playerConnection.sendPacket(subtitlePacket);
}
}

View File

@ -15,8 +15,8 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -1,56 +1,56 @@
/*
* 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.particle;
import net.minecraft.server.v1_8_R2.EnumParticle;
import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R2 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
/*
* 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.EnumParticle;
import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R2 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -0,0 +1,39 @@
/*
* 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.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import net.minecraft.server.v1_8_R2.IChatBaseComponent;
import net.minecraft.server.v1_8_R2.PacketPlayOutTitle;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class TitleProvider_v1_8_R2 extends TitleProvider {
@Override
void sendTitlePacket(final Player player, final String title, final String subtitle) {
final CraftPlayer craft = (CraftPlayer) player;
final String titleString = ComponentSerializer.toString(TextComponent.fromLegacyText(title));
final String subtitleString = ComponentSerializer.toString(TextComponent.fromLegacyText(subtitle));
final IChatBaseComponent titleJson = IChatBaseComponent.ChatSerializer.a(titleString);
final IChatBaseComponent subtitleJSON = IChatBaseComponent.ChatSerializer.a(subtitleString);
final PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, titleJson);
final PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, subtitleJSON);
craft.getHandle().playerConnection.sendPacket(titlePacket);
craft.getHandle().playerConnection.sendPacket(subtitlePacket);
}
}

View File

@ -15,8 +15,8 @@
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -1,56 +1,56 @@
/*
* 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.particle;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R3 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
/*
* 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.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
public class ParticleProvider_v1_8_R3 extends ParticleProvider {
private static final Map<PreBuiltParticle, Object> PARTICLES = new HashMap<>();
static {
PARTICLES.put(PreBuiltParticle.ENCHANT, EnumParticle.ENCHANTMENT_TABLE);
PARTICLES.put(PreBuiltParticle.CRIT, EnumParticle.CRIT);
PARTICLES.put(PreBuiltParticle.SPELL, EnumParticle.SPELL_INSTANT);
PARTICLES.put(PreBuiltParticle.MAGIC_CRIT, EnumParticle.CRIT_MAGIC);
PARTICLES.put(PreBuiltParticle.MOB_SPELL, EnumParticle.SPELL_MOB);
PARTICLES.put(PreBuiltParticle.NOTE, EnumParticle.NOTE);
PARTICLES.put(PreBuiltParticle.PORTAL, EnumParticle.PORTAL);
PARTICLES.put(PreBuiltParticle.DUST, EnumParticle.REDSTONE);
PARTICLES.put(PreBuiltParticle.WITCH, EnumParticle.SPELL_WITCH);
PARTICLES.put(PreBuiltParticle.SNOWBALL, EnumParticle.SNOWBALL);
PARTICLES.put(PreBuiltParticle.SPLASH, EnumParticle.WATER_SPLASH);
PARTICLES.put(PreBuiltParticle.SMOKE, EnumParticle.TOWN_AURA);
}
@Override
Map<PreBuiltParticle, Object> getParticleMap() {
return PARTICLES;
}
@Override
void spawnParticle(final Player player, final Location location, final Object particle, final float offsetX,
final float offsetY, final float offsetZ, final float speed, final int count, final int[] data) {
final PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles((EnumParticle) particle, false,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ,
speed, count, data);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -0,0 +1,39 @@
/*
* 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.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class TitleProvider_v1_8_R3 extends TitleProvider {
@Override
void sendTitlePacket(final Player player, final String title, final String subtitle) {
final CraftPlayer craft = (CraftPlayer) player;
final String titleString = ComponentSerializer.toString(TextComponent.fromLegacyText(title));
final String subtitleString = ComponentSerializer.toString(TextComponent.fromLegacyText(subtitle));
final IChatBaseComponent titleJson = IChatBaseComponent.ChatSerializer.a(titleString);
final IChatBaseComponent subtitleJSON = IChatBaseComponent.ChatSerializer.a(subtitleString);
final PacketPlayOutTitle titlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, titleJson);
final PacketPlayOutTitle subtitlePacket = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, subtitleJSON);
craft.getHandle().playerConnection.sendPacket(titlePacket);
craft.getHandle().playerConnection.sendPacket(subtitlePacket);
}
}