mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-18 01:25:45 +00:00
portals remove fix + flashback messages and saving/loading
This commit is contained in:
parent
9b3d16faab
commit
231ab44da4
@ -1,6 +1,7 @@
|
|||||||
package me.SuperRonanCraft.BetterRTPAddons;
|
package me.SuperRonanCraft.BetterRTPAddons;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTPAddons.addons.extraEffects.AddonExtraEffects;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.flashback.AddonFlashback;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.flashback.AddonFlashback;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.interfaces.AddonInterface;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.interfaces.AddonInterface;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.logger.AddonLogger;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.logger.AddonLogger;
|
||||||
@ -36,11 +37,12 @@ public class AddonsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum Addons {
|
enum Addons {
|
||||||
LOGGER(new AddonLogger()),
|
LOGGER(new AddonLogger()), //Does this thing work?
|
||||||
FLASH_BACK(new AddonFlashback()),
|
FLASH_BACK(new AddonFlashback()), //Never get lost adventuring
|
||||||
PORTALS(new AddonPortals()),
|
PORTALS(new AddonPortals()), //Fancy walk-in portals
|
||||||
//INTERFACES(new AddonInterface())
|
//INTERFACES(new AddonInterface())
|
||||||
MAGICSTICK(new AddonMagicStick()),
|
MAGICSTICK(new AddonMagicStick()), //Handy teleport want
|
||||||
|
EXTRAEFFECTS(new AddonExtraEffects()), //New cosmetica!
|
||||||
;
|
;
|
||||||
|
|
||||||
Addon addon;
|
Addon addon;
|
||||||
|
@ -3,9 +3,13 @@ package me.SuperRonanCraft.BetterRTPAddons.addons.extraEffects;
|
|||||||
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportEvent;
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportEvent;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.util.Files;
|
import me.SuperRonanCraft.BetterRTPAddons.util.Files;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
//Teleport the player VERY high into the sky
|
//Teleport the player VERY high into the sky
|
||||||
public class ExtraEffectsEffect_Skyhigh implements ExtraEffectsEffect, Listener {
|
public class ExtraEffectsEffect_Skyhigh implements ExtraEffectsEffect, Listener {
|
||||||
@ -32,5 +36,27 @@ public class ExtraEffectsEffect_Skyhigh implements ExtraEffectsEffect, Listener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
void tpEvent(RTP_TeleportEvent e) {
|
void tpEvent(RTP_TeleportEvent e) {
|
||||||
e.changeLocation(e.getLocation().add(0, offset, 0));
|
e.changeLocation(e.getLocation().add(0, offset, 0));
|
||||||
|
new PlayerFalling(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PlayerFalling implements Listener {
|
||||||
|
Player p;
|
||||||
|
|
||||||
|
PlayerFalling(Player p) {
|
||||||
|
this.p = p;
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, Main.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void event(EntityDamageEvent e) {
|
||||||
|
if (e.getEntityType() == EntityType.PLAYER && e.getEntity() == p) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void unload() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,12 @@ import me.SuperRonanCraft.BetterRTPAddons.Addon;
|
|||||||
import me.SuperRonanCraft.BetterRTPAddons.util.Files;
|
import me.SuperRonanCraft.BetterRTPAddons.util.Files;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -51,6 +54,8 @@ public class AddonFlashback implements Addon, Listener {
|
|||||||
"invalid! Please make sure to format [- INTEGER: 'Message']");
|
"invalid! Please make sure to format [- INTEGER: 'Message']");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
loadPlayer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long getLong(String str) throws NumberFormatException {
|
private Long getLong(String str) throws NumberFormatException {
|
||||||
@ -68,6 +73,30 @@ public class AddonFlashback implements Addon, Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
void onTeleport(RTP_TeleportPostEvent e) { //Create a timer to teleport player back
|
void onTeleport(RTP_TeleportPostEvent e) { //Create a timer to teleport player back
|
||||||
if (e.getType() != RTP_TYPE.ADDON_PORTAL)
|
if (e.getType() != RTP_TYPE.ADDON_PORTAL)
|
||||||
players.add(new FlashbackPlayer(this, e.getPlayer(), e.getOldLocation(), time));
|
players.add(new FlashbackPlayer(this, e.getPlayer(), e.getOldLocation(), time, warnings));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onJoin(PlayerJoinEvent e) {
|
||||||
|
loadPlayer(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void onLeave(PlayerQuitEvent e) {
|
||||||
|
for (FlashbackPlayer fbp : players)
|
||||||
|
if (fbp.p == e.getPlayer())
|
||||||
|
fbp.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadPlayer(Player p) {
|
||||||
|
FlashbackPlayerInfo info = database.getPlayer(p);
|
||||||
|
if (info != null) {
|
||||||
|
long _time = (System.currentTimeMillis() - info.getTime()) / 1000;
|
||||||
|
if (_time < 0) { //Still has time to go back
|
||||||
|
_time *= -1;
|
||||||
|
players.add(new FlashbackPlayer(this, p, info.getLocation(), _time, warnings));
|
||||||
|
} else //Overdue! Teleport them back NOW!
|
||||||
|
players.add(new FlashbackPlayer(this, p, info.getLocation(), 0L, warnings));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ public class FlashbackDatabase extends Database {
|
|||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
Location loc = LocSerialization.getLocationFromString(rs.getString(Columns.LOCATION_OLD.name));
|
Location loc = LocSerialization.getLocationFromString(rs.getString(Columns.LOCATION_OLD.name));
|
||||||
return new FlashbackPlayerInfo(p, loc);
|
Long time = rs.getLong(Columns.TIME_GOAL.name);
|
||||||
|
return new FlashbackPlayerInfo(p, loc, time);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
@ -120,4 +121,23 @@ public class FlashbackDatabase extends Database {
|
|||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player p) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
//boolean success = true;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement("DELETE FROM " + table +
|
||||||
|
" WHERE " + Columns.UUID.name + " = ?");
|
||||||
|
UUID id = p.getUniqueId();
|
||||||
|
ps.setString(1, id.toString());
|
||||||
|
ps.executeUpdate();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
//success = false;
|
||||||
|
} finally {
|
||||||
|
close(ps, null, conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,37 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class FlashbackPlayer {
|
public class FlashbackPlayer {
|
||||||
Player p;
|
Player p;
|
||||||
Location oldLoc;
|
Location oldLoc;
|
||||||
AddonFlashback plugin;
|
AddonFlashback plugin;
|
||||||
BukkitTask task;
|
List<BukkitTask> tasks = new ArrayList<>();
|
||||||
|
|
||||||
public FlashbackPlayer(AddonFlashback plugin, Player p, Location oldLoc, Long seconds) {
|
public FlashbackPlayer(AddonFlashback plugin, Player p, Location oldLoc, Long seconds, HashMap<Long, String> warnings) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.p = p;
|
this.p = p;
|
||||||
this.oldLoc = oldLoc;
|
this.oldLoc = oldLoc;
|
||||||
this.task = Bukkit.getScheduler().runTaskLater(Main.getInstance(), getTimedFlash(seconds), 20L * seconds);
|
if (warnings != null)
|
||||||
|
createTimers(seconds, orderMap(warnings));
|
||||||
|
tasks.add(Bukkit.getScheduler().runTaskLater(Main.getInstance(), runFlashback(seconds), 20L * seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getTimedFlash(Long seconds) {
|
void createTimers(Long seconds, TreeMap<Long, String> warnings) {
|
||||||
|
for (Map.Entry<Long, String> entry : warnings.entrySet()) {
|
||||||
|
String str = entry.getValue();
|
||||||
|
long time = seconds - entry.getKey();
|
||||||
|
if (time >= 0)
|
||||||
|
tasks.add(Bukkit.getScheduler().runTaskLater(Main.getInstance(), runWarning(str), 20L * time));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TreeMap<Long, String> orderMap(HashMap<Long, String> warnings) {
|
||||||
|
return new TreeMap<>(warnings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable runFlashback(Long seconds) {
|
||||||
if (!plugin.database.setPlayer(p, oldLoc, System.currentTimeMillis() + (seconds * 1000)))
|
if (!plugin.database.setPlayer(p, oldLoc, System.currentTimeMillis() + (seconds * 1000)))
|
||||||
p.sendMessage("A Database error has occurred!");
|
p.sendMessage("A Database error has occurred!");
|
||||||
return () -> {
|
return () -> {
|
||||||
@ -30,11 +47,17 @@ public class FlashbackPlayer {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Runnable runWarning(String msg) {
|
||||||
|
return () -> plugin.msgs.sms(p, msg);
|
||||||
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
for (BukkitTask task : tasks)
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void completed() {
|
private void completed() {
|
||||||
plugin.players.remove(this);
|
plugin.players.remove(this);
|
||||||
|
plugin.database.removePlayer(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,12 @@ public class FlashbackPlayerInfo {
|
|||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final Location location;
|
private final Location location;
|
||||||
|
private final Long time;
|
||||||
|
|
||||||
public FlashbackPlayerInfo(Player player, Location location) {
|
public FlashbackPlayerInfo(Player player, Location location, Long time) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
@ -20,4 +22,8 @@ public class FlashbackPlayerInfo {
|
|||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package me.SuperRonanCraft.BetterRTPAddons.addons.magicStick;
|
package me.SuperRonanCraft.BetterRTPAddons.addons.magicStick;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CancelledEvent;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.magicStick.cmds.MagicStickCommand;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.magicStick.cmds.MagicStickCommand;
|
||||||
@ -41,7 +43,7 @@ public class MagicStickEvents implements Listener {
|
|||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(BetterRTP.getInstance().getText().color(title));
|
meta.setDisplayName(BetterRTP.getInstance().getText().color(title));
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
lore.forEach((str) -> {lore.set(lore.indexOf(str), BetterRTP.getInstance().getText().color(str)); });
|
lore.forEach((str) -> lore.set(lore.indexOf(str), BetterRTP.getInstance().getText().color(str)));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
this.take = file.getBoolean("MagicStick.Take");
|
this.take = file.getBoolean("MagicStick.Take");
|
||||||
@ -88,9 +90,10 @@ public class MagicStickEvents implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void tp(RTP_TeleportPostEvent e) {
|
void tp(RTP_TeleportPostEvent e) {
|
||||||
if (e.getPlayer() == p && e.getType() == RTP_TYPE.ADDON_MAGICSTICK) {
|
if (e.getPlayer() == p) {
|
||||||
teleportingPlayers.remove(this);
|
if (e.getType() == RTP_TYPE.ADDON_MAGICSTICK)
|
||||||
e.getPlayer().getInventory().removeItem(item);
|
e.getPlayer().getInventory().removeItem(item);
|
||||||
|
teleportingPlayers.remove(this);
|
||||||
this.unload();
|
this.unload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,6 +103,14 @@ public class MagicStickEvents implements Listener {
|
|||||||
if (e.getPlayer() == p)
|
if (e.getPlayer() == p)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void cancelled(RTP_CancelledEvent e) {
|
||||||
|
if (e.getPlayer() == p) {
|
||||||
|
teleportingPlayers.remove(this);
|
||||||
|
this.unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class MagicStickMessages implements AddonsMessages {
|
|||||||
|
|
||||||
//Give
|
//Give
|
||||||
public void getGive(CommandSender sendi, String name) {
|
public void getGive(CommandSender sendi, String name) {
|
||||||
sms(sendi, getLang().getString(preM + "Give").replace("%name%", name));
|
sms(sendi, getLang().getString(preM + "Give").replace("%player%", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getGiven(CommandSender sendi) {
|
public void getGiven(CommandSender sendi) {
|
||||||
|
@ -23,14 +23,14 @@ public class MagicStickCommand_Give implements MagicStickCommands {
|
|||||||
} else {
|
} else {
|
||||||
Player p = null;
|
Player p = null;
|
||||||
for (Player plr : Bukkit.getOnlinePlayers()) {
|
for (Player plr : Bukkit.getOnlinePlayers()) {
|
||||||
if (plr.getName().startsWith(args[2])) {
|
if (plr.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||||
p = plr;
|
p = plr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
p.getInventory().addItem(addon.events.item.clone());
|
p.getInventory().addItem(addon.events.item.clone());
|
||||||
addon.msgs.getGiven(sendi);
|
addon.msgs.getGiven(p);
|
||||||
addon.msgs.getGive(sendi, p.getName());
|
addon.msgs.getGive(sendi, p.getName());
|
||||||
} else
|
} else
|
||||||
addon.msgs.getPlayerError(sendi, args[2]);
|
addon.msgs.getPlayerError(sendi, args[2]);
|
||||||
|
@ -92,19 +92,9 @@ public class PortalsDatabase extends Database {
|
|||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement("INSERT INTO " + table + "(" +
|
ps = conn.prepareStatement("DELETE FROM " + table +
|
||||||
Columns.NAME.name + ", " +
|
" WHERE " + Columns.NAME.name + " = ?");
|
||||||
Columns.LOCATION_1.name + ", " +
|
|
||||||
Columns.LOCATION_2.name + ") VALUES (?, ?, ?) "
|
|
||||||
+ "ON CONFLICT(" + Columns.NAME.name + ") DO UPDATE SET " +
|
|
||||||
Columns.LOCATION_1.name + " = + ?, " + Columns.LOCATION_2.name + " = ?");
|
|
||||||
ps.setString(1, portal.getName());
|
ps.setString(1, portal.getName());
|
||||||
String serialLocation_1 = LocSerialization.getStringFromLocation(portal.getLoc1());
|
|
||||||
String serialLocation_2 = LocSerialization.getStringFromLocation(portal.getLoc2());
|
|
||||||
ps.setString(2, serialLocation_1);
|
|
||||||
ps.setString(3, serialLocation_2);
|
|
||||||
ps.setString(4, serialLocation_1);
|
|
||||||
ps.setString(5, serialLocation_2);
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
@ -2,6 +2,7 @@ package me.SuperRonanCraft.BetterRTPAddons.addons.portals;
|
|||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CancelledEvent;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
import me.SuperRonanCraft.BetterRTPAddons.Main;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.region.PortalsRegionInfo;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.region.PortalsRegionInfo;
|
||||||
@ -67,4 +68,9 @@ public class PortalsEvents implements Listener {
|
|||||||
void teleport(RTP_TeleportPostEvent e) {
|
void teleport(RTP_TeleportPostEvent e) {
|
||||||
playerPortaling.remove(e.getPlayer());
|
playerPortaling.remove(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
void cancelled(RTP_CancelledEvent e) {
|
||||||
|
playerPortaling.remove(e.getPlayer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,18 @@ public class PortalsCommand implements RTPCommand, RTPCommandHelpable {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
if (args.length == 2)
|
if (args.length == 2) {
|
||||||
for (subCmd subCmd : subCmd.values()) {
|
for (subCmd cmd : subCmd.values()) {
|
||||||
if (subCmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
list.add(subCmd.name().toLowerCase());
|
list.add(cmd.name().toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (args.length >= 3) {
|
||||||
|
for (subCmd cmd : subCmd.values()) {
|
||||||
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
if (cmd.cmd instanceof PortalsCommandsTabable)
|
||||||
|
list.addAll(((PortalsCommandsTabable) cmd.cmd).tabComplete(sendi, args, pl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package me.SuperRonanCraft.BetterRTPAddons.addons.portals.cmds;
|
package me.SuperRonanCraft.BetterRTPAddons.addons.portals.cmds;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.AddonPortals;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.AddonPortals;
|
||||||
|
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.region.PortalsCache;
|
||||||
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.region.PortalsRegionInfo;
|
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.region.PortalsRegionInfo;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PortalsCommand_Remove implements PortalsCommands {
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PortalsCommand_Remove implements PortalsCommands, PortalsCommandsTabable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sendi, String label, String[] args, AddonPortals addonPortals) {
|
public void execute(CommandSender sendi, String label, String[] args, AddonPortals addonPortals) {
|
||||||
@ -26,4 +30,16 @@ public class PortalsCommand_Remove implements PortalsCommands {
|
|||||||
//None found
|
//None found
|
||||||
addonPortals.msgs.getRemoveNone(sendi, portalName);
|
addonPortals.msgs.getRemoveNone(sendi, portalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args, AddonPortals addonPortals) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 3) {
|
||||||
|
for (PortalsRegionInfo portal : addonPortals.getPortals().getRegisteredPortals()) {
|
||||||
|
if (portal.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(portal.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTPAddons.addons.portals.cmds;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTPAddons.addons.portals.AddonPortals;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface PortalsCommandsTabable {
|
||||||
|
|
||||||
|
List<String> tabComplete(CommandSender sendi, String[] args, AddonPortals addonPortals);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTPAddons.packets;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.EnumWrappers.SoundCategory;
|
||||||
|
|
||||||
|
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
|
||||||
|
public static final PacketType TYPE =
|
||||||
|
PacketType.Play.Server.NAMED_SOUND_EFFECT;
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect() {
|
||||||
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
|
handle.getModifier().writeDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect(PacketContainer packet) {
|
||||||
|
super(packet, TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sound getSoundEffect() {
|
||||||
|
return handle.getSoundEffects().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoundEffect(Sound value) {
|
||||||
|
handle.getSoundEffects().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SoundCategory getSoundCategory() {
|
||||||
|
return handle.getSoundCategories().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoundCategory(SoundCategory value) {
|
||||||
|
handle.getSoundCategories().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Effect position X.
|
||||||
|
* <p>
|
||||||
|
* Notes: effect X multiplied by 8
|
||||||
|
*
|
||||||
|
* @return The current Effect position X
|
||||||
|
*/
|
||||||
|
public int getEffectPositionX() {
|
||||||
|
return handle.getIntegers().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Effect position X.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionX(int value) {
|
||||||
|
handle.getIntegers().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Effect position Y.
|
||||||
|
* <p>
|
||||||
|
* Notes: effect Y multiplied by 8
|
||||||
|
*
|
||||||
|
* @return The current Effect position Y
|
||||||
|
*/
|
||||||
|
public int getEffectPositionY() {
|
||||||
|
return handle.getIntegers().read(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Effect position Y.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionY(int value) {
|
||||||
|
handle.getIntegers().write(1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Effect position Z.
|
||||||
|
* <p>
|
||||||
|
* Notes: effect Z multiplied by 8
|
||||||
|
*
|
||||||
|
* @return The current Effect position Z
|
||||||
|
*/
|
||||||
|
public int getEffectPositionZ() {
|
||||||
|
return handle.getIntegers().read(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Effect position Z.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionZ(int value) {
|
||||||
|
handle.getIntegers().write(2, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Volume.
|
||||||
|
* <p>
|
||||||
|
* Notes: 1 is 100%, can be more
|
||||||
|
*
|
||||||
|
* @return The current Volume
|
||||||
|
*/
|
||||||
|
public float getVolume() {
|
||||||
|
return handle.getFloat().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Volume.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setVolume(float value) {
|
||||||
|
handle.getFloat().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve Pitch.
|
||||||
|
* <p>
|
||||||
|
* Notes: 63 is 100%, can be more
|
||||||
|
*
|
||||||
|
* @return The current Pitch
|
||||||
|
*/
|
||||||
|
public float getPitch() {
|
||||||
|
return handle.getFloat().read(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Pitch.
|
||||||
|
*
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setPitch(float value) {
|
||||||
|
handle.getFloat().write(1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,10 +4,11 @@ Language-File: 'en.yml'
|
|||||||
Flashback:
|
Flashback:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Timer:
|
Timer:
|
||||||
Delay: 15 #In Seconds
|
Delay: 600 #In Seconds
|
||||||
Warnings: #Warning messages to send to a player when X amount of time is left
|
Warnings: #Warning messages to send to a player when X amount of time is left
|
||||||
- 5: "&eYou have 5 seconds left! Grab all your materials quick!"
|
- 600: "&cYou have 10 minutes here, collect and explore and much as you can!"
|
||||||
- 1: "&eHang on!"
|
- 60: "&eYou have 60 seconds left! Grab all your materials quick!"
|
||||||
|
- 1: "&eHang on! It's going to get bumpy!"
|
||||||
|
|
||||||
##Addon Logger
|
##Addon Logger
|
||||||
Logger:
|
Logger:
|
||||||
|
12
pom.xml
12
pom.xml
@ -114,6 +114,11 @@
|
|||||||
<id>residence-repo</id>
|
<id>residence-repo</id>
|
||||||
<url>file:${project.basedir}/LocalJars/Residence4.9.1.9.jar</url>
|
<url>file:${project.basedir}/LocalJars/Residence4.9.1.9.jar</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<!-- ProtocolLib Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!--Spigot API-->
|
<!--Spigot API-->
|
||||||
@ -205,5 +210,12 @@
|
|||||||
<version>LATEST</version>
|
<version>LATEST</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- ProtocolLib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>4.5.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -142,7 +142,7 @@ public class Commands {
|
|||||||
|
|
||||||
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType, boolean ignoreCooldown, boolean ignoreDelay) {
|
public void tp(Player player, CommandSender sendi, String world, List<String> biomes, RTP_TYPE rtpType, boolean ignoreCooldown, boolean ignoreDelay) {
|
||||||
if (checkRTPing(player, sendi)) { //Is RTP'ing
|
if (checkRTPing(player, sendi)) { //Is RTP'ing
|
||||||
if (!ignoreCooldown || checkCooldown(sendi, player)) { //Is Cooling down
|
if (ignoreCooldown || checkCooldown(sendi, player)) { //Is Cooling down
|
||||||
boolean delay = false;
|
boolean delay = false;
|
||||||
if (!ignoreDelay && sendi == player) //Forced?
|
if (!ignoreDelay && sendi == player) //Forced?
|
||||||
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
|
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CancelledEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -61,6 +62,7 @@ class RTPDelay implements Listener {
|
|||||||
//getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
|
//getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
|
||||||
getPl().getCmd().cooldowns.remove(rtp.getPlayer().getUniqueId());
|
getPl().getCmd().cooldowns.remove(rtp.getPlayer().getUniqueId());
|
||||||
getPl().getCmd().rtping.put(rtp.getPlayer().getUniqueId(), false);
|
getPl().getCmd().rtping.put(rtp.getPlayer().getUniqueId(), false);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_CancelledEvent(rtp.getPlayer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +1,61 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.packets.WrapperPlayServerNamedSoundEffect;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RTPSounds {
|
public class RTPSounds {
|
||||||
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private Sound
|
private String soundTeleport, soundDelay;
|
||||||
soundTeleport,
|
|
||||||
soundDelay;
|
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||||
enabled = config.getBoolean("Sounds.Enabled");
|
enabled = config.getBoolean("Sounds.Enabled");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
soundTeleport = getSound(config.getString("Sounds.Success"));
|
soundTeleport = config.getString("Sounds.Success");
|
||||||
soundDelay = getSound(config.getString("Sounds.Delay"));
|
soundDelay = config.getString("Sounds.Delay");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void playTeleport(Player p) {
|
void playTeleport(Player p) {
|
||||||
if (!enabled) return;
|
if (!enabled)
|
||||||
if (soundTeleport != null)
|
return;
|
||||||
p.playSound(p.getLocation(), soundTeleport, 1F, 1F);
|
if (soundTeleport != null) {
|
||||||
|
playSound(p.getLocation(), p, soundTeleport);
|
||||||
|
//p.playSound(p.getLocation(), soundTeleport, 1F, 1F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void playDelay(Player p) {
|
void playDelay(Player p) {
|
||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
if (soundDelay != null)
|
if (soundDelay != null) {
|
||||||
p.playSound(p.getLocation(), soundDelay, 1F, 1F);
|
playSound(p.getLocation(), p, soundDelay);
|
||||||
|
//p.playSound(p.getLocation(), soundDelay, 1F, 1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void playSound(Location loc, Player p, String sound) {
|
||||||
|
try {
|
||||||
|
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
|
||||||
|
WrapperPlayServerNamedSoundEffect packet = new WrapperPlayServerNamedSoundEffect(pm.createPacket(PacketType.Play.Server.NAMED_SOUND_EFFECT));
|
||||||
|
packet.setSoundName(sound);
|
||||||
|
packet.setEffectPositionX(loc.getBlockX());
|
||||||
|
packet.setEffectPositionY(loc.getBlockY());
|
||||||
|
packet.setEffectPositionZ(loc.getBlockZ());
|
||||||
|
packet.sendPacket(p);
|
||||||
|
} catch (Exception e) {
|
||||||
|
p.playSound(p.getLocation(), getSound(sound), 1F, 1F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Sound getSound(String sound) {
|
private Sound getSound(String sound) {
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public abstract class AbstractPacket {
|
||||||
|
// The packet we will be modifying
|
||||||
|
protected PacketContainer handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new strongly typed wrapper for the given packet.
|
||||||
|
*
|
||||||
|
* @param handle - handle to the raw packet data.
|
||||||
|
* @param type - the packet type.
|
||||||
|
*/
|
||||||
|
protected AbstractPacket(PacketContainer handle, PacketType type) {
|
||||||
|
// Make sure we're given a valid packet
|
||||||
|
if (handle == null)
|
||||||
|
throw new IllegalArgumentException("Packet handle cannot be NULL.");
|
||||||
|
if (!Objects.equal(handle.getType(), type))
|
||||||
|
throw new IllegalArgumentException(handle.getHandle()
|
||||||
|
+ " is not a packet of type " + type);
|
||||||
|
|
||||||
|
this.handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a handle to the raw packet data.
|
||||||
|
*
|
||||||
|
* @return Raw packet data.
|
||||||
|
*/
|
||||||
|
public PacketContainer getHandle() {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current packet to the given receiver.
|
||||||
|
*
|
||||||
|
* @param receiver - the receiver.
|
||||||
|
* @throws RuntimeException If the packet cannot be sent.
|
||||||
|
*/
|
||||||
|
public void sendPacket(Player receiver) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
|
||||||
|
getHandle());
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
throw new RuntimeException("Cannot send packet.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current packet to all online players.
|
||||||
|
*/
|
||||||
|
public void broadcastPacket() {
|
||||||
|
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate receiving the current packet from the given sender.
|
||||||
|
*
|
||||||
|
* @param sender - the sender.
|
||||||
|
* @throws RuntimeException If the packet cannot be received.
|
||||||
|
* @deprecated Misspelled. recieve to receive
|
||||||
|
* @see #receivePacket(Player)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void recievePacket(Player sender) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
|
||||||
|
getHandle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot recieve packet.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate receiving the current packet from the given sender.
|
||||||
|
*
|
||||||
|
* @param sender - the sender.
|
||||||
|
* @throws RuntimeException if the packet cannot be received.
|
||||||
|
*/
|
||||||
|
public void receivePacket(Player sender) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
|
||||||
|
getHandle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot receive packet.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,350 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.packets;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
|
||||||
|
public static final PacketType TYPE = PacketType.Play.Server.NAMED_SOUND_EFFECT;
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect() {
|
||||||
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
|
handle.getModifier().writeDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect(PacketContainer packet) {
|
||||||
|
super(packet, TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all the named sound effects in Minecraft.
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public static class NamedSoundEffects {
|
||||||
|
public static final String AMBIENT_WEATHER_RAIN = "ambient.weather.rain";
|
||||||
|
public static final String AMBIENT_WEATHER_THUNDER = "ambient.weather.thunder";
|
||||||
|
public static final String DAMAGE_FALL_BIG = "damage.fallbig";
|
||||||
|
public static final String DAMAGE_FALL_SMALL = "damage.fallsmall";
|
||||||
|
public static final String FIRE_ACTIVE = "fire.fire";
|
||||||
|
public static final String FIRE_IGNITE = "fire.ignite";
|
||||||
|
public static final String LIQUID_LAVA = "liquid.lava";
|
||||||
|
public static final String LIQUID_LAVA_POP = "liquid.lavapop";
|
||||||
|
public static final String LIQUID_SPLASH = "liquid.splash";
|
||||||
|
public static final String LIQUID_WATER = "liquid.water";
|
||||||
|
public static final String MOB_BLAZE_BREATHE = "mob.blaze.breathe";
|
||||||
|
public static final String MOB_BLAZE_DEATH = "mob.blaze.death";
|
||||||
|
public static final String MOB_BLAZE_HIT = "mob.blaze.hit";
|
||||||
|
public static final String MOB_CAT_HISS = "mob.cat.hiss";
|
||||||
|
public static final String MOB_CAT_HITT = "mob.cat.hitt";
|
||||||
|
public static final String MOB_CAT_MEOW = "mob.cat.meow";
|
||||||
|
public static final String MOB_CAT_PURR = "mob.cat.purr";
|
||||||
|
public static final String MOB_CAT_PURREOW = "mob.cat.purreow";
|
||||||
|
public static final String MOB_CHICKEN_HURT = "mob.chicken.hurt";
|
||||||
|
public static final String MOB_CHICKEN_PLOP = "mob.chicken.plop";
|
||||||
|
public static final String MOB_COW_HURT = "mob.cow.hurt";
|
||||||
|
public static final String MOB_CREEPER = "mob.creeper";
|
||||||
|
public static final String MOB_CREEPER_DEATH = "mob.creeperdeath";
|
||||||
|
public static final String MOB_ENDERMEN_DEATH = "mob.endermen.death";
|
||||||
|
public static final String MOB_ENDERMEN_HIT = "mob.endermen.hit";
|
||||||
|
public static final String MOB_ENDERMEN_IDLE = "mob.endermen.idle";
|
||||||
|
public static final String MOB_ENDERMEN_PORTAL = "mob.endermen.portal";
|
||||||
|
public static final String MOB_ENDERMEN_SCREAM = "mob.endermen.scream";
|
||||||
|
public static final String MOB_ENDERMEN_STARE = "mob.endermen.stare";
|
||||||
|
public static final String MOB_GHAST_AFFECTIONATE_SCREAM = "mob.ghast.affectionate scream";
|
||||||
|
public static final String MOB_GHAST_CHARGE = "mob.ghast.charge";
|
||||||
|
public static final String MOB_GHAST_DEATH = "mob.ghast.death";
|
||||||
|
public static final String MOB_GHAST_FIREBALL = "mob.ghast.fireball";
|
||||||
|
public static final String MOB_GHAST_MOAN = "mob.ghast.moan";
|
||||||
|
public static final String MOB_GHAST_SCREAM = "mob.ghast.scream";
|
||||||
|
public static final String MOB_IRONGOLEM_DEATH = "mob.irongolem.death";
|
||||||
|
public static final String MOB_IRONGOLEM_HIT = "mob.irongolem.hit";
|
||||||
|
public static final String MOB_IRONGOLEM_THROW = "mob.irongolem.throw";
|
||||||
|
public static final String MOB_IRONGOLEM_WALK = "mob.irongolem.walk";
|
||||||
|
public static final String MOB_MAGMACUBE_BIG = "mob.magmacube.big";
|
||||||
|
public static final String MOB_MAGMACUBE_JUMP = "mob.magmacube.jump";
|
||||||
|
public static final String MOB_MAGMACUBE_SMALL = "mob.magmacube.small";
|
||||||
|
public static final String MOB_PIGDEATH = "mob.pig.death";
|
||||||
|
public static final String MOB_SILVERFISH_HIT = "mob.silverfish.hit";
|
||||||
|
public static final String MOB_SILVERFISH_KILL = "mob.silverfish.kill";
|
||||||
|
public static final String MOB_SILVERFISH_SAY = "mob.silverfish.say";
|
||||||
|
public static final String MOB_SILVERFISH_STEP = "mob.silverfish.step";
|
||||||
|
public static final String MOB_SKELETON_DEATH = "mob.skeleton.death";
|
||||||
|
public static final String MOB_SKELETON_HURT = "mob.skeleton.hurt";
|
||||||
|
public static final String MOB_SLIMEATTACK = "mob.slime.attack";
|
||||||
|
public static final String MOB_SPIDER_DEATH = "mob.spider.death";
|
||||||
|
public static final String MOB_WOLF_BARK = "mob.wolf.bark";
|
||||||
|
public static final String MOB_WOLF_DEATH = "mob.wolf.death";
|
||||||
|
public static final String MOB_WOLF_GROWL = "mob.wolf.growl";
|
||||||
|
public static final String MOB_WOLF_HOWL = "mob.wolf.howl";
|
||||||
|
public static final String MOB_WOLF_HURT = "mob.wolf.hurt";
|
||||||
|
public static final String MOB_WOLF_PANTING = "mob.wolf.panting";
|
||||||
|
public static final String MOB_WOLF_SHAKE = "mob.wolf.shake";
|
||||||
|
public static final String MOB_WOLF_WHINE = "mob.wolf.whine";
|
||||||
|
public static final String MOB_ZOMBIE_METAL = "mob.zombie.metal";
|
||||||
|
public static final String MOB_ZOMBIE_WOOD = "mob.zombie.wood";
|
||||||
|
public static final String MOB_ZOMBIE_WOODBREAK = "mob.zombie.woodbreak";
|
||||||
|
public static final String MOB_ZOMBIE = "mob.zombie";
|
||||||
|
public static final String MOB_ZOMBIEDEATH = "mob.zombie.death";
|
||||||
|
public static final String MOB_ZOMBIEHURT = "mob.zombie.hurt";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIG = "mob.zombiepig.zpig";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGANGRY = "mob.zombiepig.zpigangry";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGDEATH = "mob.zombiepig.zpigdeath";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGHURT = "mob.zombiepig.zpighurt";
|
||||||
|
public static final String NOTE_BASS = "note.bass";
|
||||||
|
public static final String NOTE_BASS_ATTACK = "note.bassattack";
|
||||||
|
public static final String NOTE_BD = "note.bd";
|
||||||
|
public static final String NOTE_HARP = "note.harp";
|
||||||
|
public static final String NOTE_HAT = "note.hat";
|
||||||
|
public static final String NOTE_PLING = "note.pling";
|
||||||
|
public static final String NOTE_SNARE = "note.snare";
|
||||||
|
public static final String PORTAL_NEAR = "portal.portal";
|
||||||
|
public static final String PORTAL_TRAVEL = "portal.travel";
|
||||||
|
public static final String PORTAL_TRIGGER = "portal.trigger";
|
||||||
|
public static final String RANDOM_BOW = "random.bow";
|
||||||
|
public static final String RANDOM_BOWHIT = "random.bowhit";
|
||||||
|
public static final String RANDOM_BREAK = "random.break";
|
||||||
|
public static final String RANDOM_BREATH = "random.breath";
|
||||||
|
public static final String RANDOM_BURP = "random.burp";
|
||||||
|
public static final String RANDOM_CHESTCLOSED = "random.chestclosed";
|
||||||
|
public static final String RANDOM_CHESTOPEN = "random.chestopen";
|
||||||
|
public static final String RANDOM_CLICK = "random.click";
|
||||||
|
public static final String RANDOM_DOOR_CLOSE = "random.door_close";
|
||||||
|
public static final String RANDOM_DOOR_OPEN = "random.door_open";
|
||||||
|
public static final String RANDOM_DRINK = "random.drink";
|
||||||
|
public static final String RANDOM_EAT = "random.eat";
|
||||||
|
public static final String RANDOM_EXPLODE = "random.explode";
|
||||||
|
public static final String RANDOM_FIZZ = "random.fizz";
|
||||||
|
public static final String RANDOM_FUSE = "random.fuse";
|
||||||
|
public static final String RANDOM_GLASS = "random.glass";
|
||||||
|
public static final String RANDOM_LEVELUP = "random.levelup";
|
||||||
|
public static final String RANDOM_OLD_EXPLODE = "random.old_explode";
|
||||||
|
public static final String RANDOM_ORB = "random.orb";
|
||||||
|
public static final String RANDOM_POP = "random.pop";
|
||||||
|
public static final String RANDOM_SPLASH = "random.splash";
|
||||||
|
public static final String RANDOM_WOOD_CLICK = "random.wood click";
|
||||||
|
public static final String STEP_CLOTH = "step.cloth";
|
||||||
|
public static final String STEP_GRASS = "step.grass";
|
||||||
|
public static final String STEP_GRAVEL = "step.gravel";
|
||||||
|
public static final String STEP_SAND = "step.sand";
|
||||||
|
public static final String STEP_SNOW = "step.snow";
|
||||||
|
public static final String STEP_STONE = "step.stone";
|
||||||
|
public static final String STEP_WOOD = "step.wood";
|
||||||
|
public static final String TILE_PISTON_IN = "tile.piston.in";
|
||||||
|
public static final String TILE_PISTON_OUT = "tile.piston.out";
|
||||||
|
public static final String DAMAGE_HIT = "damage.hit";
|
||||||
|
public static final String DIG_CLOTH = "dig.cloth";
|
||||||
|
public static final String DIG_GRASS = "dig.grass";
|
||||||
|
public static final String DIG_GRAVEL = "dig.gravel";
|
||||||
|
public static final String DIG_SAND = "dig.sand";
|
||||||
|
public static final String DIG_SNOW = "dig.snow";
|
||||||
|
public static final String DIG_STONE = "dig.stone";
|
||||||
|
public static final String DIG_WOOD = "dig.wood";
|
||||||
|
public static final String LIQUID_SWIM = "liquid.swim";
|
||||||
|
public static final String MINECART_BASE = "minecart.base";
|
||||||
|
public static final String MINECART_INSIDE = "minecart.inside";
|
||||||
|
public static final String MOB_CHICKEN_SAY = "mob.chicken.say";
|
||||||
|
public static final String MOB_CHICKEN_STEP = "mob.chicken.step";
|
||||||
|
public static final String MOB_COW_SAY = "mob.cow.say";
|
||||||
|
public static final String MOB_COW_STEP = "mob.cow.step";
|
||||||
|
public static final String MOB_CREEPER_SAY = "mob.creeper.say";
|
||||||
|
public static final String MOB_PIG_DEATH = "mob.pig.death";
|
||||||
|
public static final String MOB_PIG_SAY = "mob.pig.say";
|
||||||
|
public static final String MOB_PIG_STEP = "mob.pig.step";
|
||||||
|
public static final String MOB_SHEEP_SAY = "mob.sheep.say";
|
||||||
|
public static final String MOB_SHEEP_SHEAR = "mob.sheep.shear";
|
||||||
|
public static final String MOB_SHEEP_STEP = "mob.sheep.step";
|
||||||
|
public static final String MOB_SKELETON_SAY = "mob.skeleton.say";
|
||||||
|
public static final String MOB_SKELETON_STEP = "mob.skeleton.step";
|
||||||
|
public static final String MOB_SLIME_ATTACK = "mob.slime.attack";
|
||||||
|
public static final String MOB_SLIME_BIG = "mob.slime.big";
|
||||||
|
public static final String MOB_SLIME_SMALL = "mob.slime.small";
|
||||||
|
public static final String MOB_SPIDER_SAY = "mob.spider.say";
|
||||||
|
public static final String MOB_SPIDER_STEP = "mob.spider.step";
|
||||||
|
public static final String MOB_WOLF_STEP = "mob.wolf.step";
|
||||||
|
public static final String MOB_ZOMBIE_DEATH = "mob.zombie.death";
|
||||||
|
public static final String MOB_ZOMBIE_HURT = "mob.zombie.hurt";
|
||||||
|
public static final String MOB_ZOMBIE_SAY = "mob.zombie.say";
|
||||||
|
public static final String MOB_ZOMBIE_STEP = "mob.zombie.step";
|
||||||
|
public static final String RANDOM_CLASSIC_HURT = "random.classic_hurt";
|
||||||
|
public static final String STEP_LADDER = "step.ladder";
|
||||||
|
public static final String MOB_BAT_DEATH = "mob.bat.death";
|
||||||
|
public static final String MOB_BAT_HURT = "mob.bat.hurt";
|
||||||
|
public static final String MOB_BAT_IDLE = "mob.bat.idle";
|
||||||
|
public static final String MOB_BAT_TAKEOFF = "mob.bat.takeoff";
|
||||||
|
public static final String MOB_ENDERDRAGON_END = "mob.enderdragon.end";
|
||||||
|
public static final String MOB_ENDERDRAGON_GROWL = "mob.enderdragon.growl";
|
||||||
|
public static final String MOB_ENDERDRAGON_HIT = "mob.enderdragon.hit";
|
||||||
|
public static final String MOB_ENDERDRAGON_WINGS = "mob.enderdragon.wings";
|
||||||
|
public static final String MOB_WITHER_DEATH = "mob.wither.death";
|
||||||
|
public static final String MOB_WITHER_HURT = "mob.wither.hurt";
|
||||||
|
public static final String MOB_WITHER_IDLE = "mob.wither.idle";
|
||||||
|
public static final String MOB_WITHER_SHOOT = "mob.wither.shoot";
|
||||||
|
public static final String MOB_WITHER_SPAWN = "mob.wither.spawn";
|
||||||
|
public static final String MOB_ZOMBIE_INFECT = "mob.zombie.infect";
|
||||||
|
public static final String MOB_ZOMBIE_REMEDY = "mob.zombie.remedy";
|
||||||
|
public static final String MOB_ZOMBIE_UNFECT = "mob.zombie.unfect";
|
||||||
|
public static final String RANDOM_ANVIL_BREAK = "random.anvil_break";
|
||||||
|
public static final String RANDOM_ANVIL_LAND = "random.anvil_land";
|
||||||
|
public static final String RANDOM_ANVIL_USE = "random.anvil_use";
|
||||||
|
|
||||||
|
private static String[] values;
|
||||||
|
|
||||||
|
public static String[] values() {
|
||||||
|
if (values == null) {
|
||||||
|
List<String> result = Lists.newArrayList();
|
||||||
|
|
||||||
|
// Get all public fields
|
||||||
|
for (Field field : NamedSoundEffects.class.getFields()) {
|
||||||
|
try {
|
||||||
|
result.add((String) field.get(null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot read field.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
values = result.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the sound name.
|
||||||
|
* @see {@link NamedSoundEffects}.
|
||||||
|
* @return The current Sound name
|
||||||
|
*/
|
||||||
|
public String getSoundName() {
|
||||||
|
return handle.getStrings().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sound name.
|
||||||
|
* @see {@link NamedSoundEffects}.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setSoundName(String value) {
|
||||||
|
handle.getStrings().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the location of the effect.
|
||||||
|
* @param event - the current event.
|
||||||
|
* @return The effect location.
|
||||||
|
*/
|
||||||
|
public Location getEffectPosition(PacketEvent event) {
|
||||||
|
return getEffectPosition(event.getPlayer().getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the location of the effect.
|
||||||
|
* @param world - the current world.
|
||||||
|
* @return The effect location.
|
||||||
|
*/
|
||||||
|
public Location getEffectPosition(World world) {
|
||||||
|
return new Location(world, getEffectPositionX(), getEffectPositionY(), getEffectPositionZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the x coordinate of the effect.
|
||||||
|
* @return The current effect position X
|
||||||
|
*/
|
||||||
|
public double getEffectPositionX() {
|
||||||
|
return handle.getIntegers().read(0) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the x coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionX(double value) {
|
||||||
|
handle.getIntegers().write(0, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the y coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @return The current effect position Y
|
||||||
|
*/
|
||||||
|
public double getEffectPositionY() {
|
||||||
|
return handle.getIntegers().read(1) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the y coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionY(double value) {
|
||||||
|
handle.getIntegers().write(1, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the z coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @return The current effect position z
|
||||||
|
*/
|
||||||
|
public double getEffectPositionZ() {
|
||||||
|
return handle.getIntegers().read(2) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the z coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionZ(double value) {
|
||||||
|
handle.getIntegers().write(2, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the volumne.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be more.
|
||||||
|
* @return The current Volume
|
||||||
|
*/
|
||||||
|
public float getVolume() {
|
||||||
|
return handle.getFloat().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the volume.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be more.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setVolume(float value) {
|
||||||
|
handle.getFloat().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the pitch.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be up to 3.9.
|
||||||
|
* @return The current Pitch
|
||||||
|
*/
|
||||||
|
public float getPitch() {
|
||||||
|
return handle.getIntegers().read(3) / 63.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the pitch.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be up to 3.9.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setPitch(float value) {
|
||||||
|
handle.getIntegers().write(3, (int) (value * 63.0F));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class RTP_CancelledEvent extends Event {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
private static final HandlerList handler = new HandlerList();
|
||||||
|
|
||||||
|
public RTP_CancelledEvent(Player p) {
|
||||||
|
this.p = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ main: me.SuperRonanCraft.BetterRTP.BetterRTP
|
|||||||
version: '3.0.0'
|
version: '3.0.0'
|
||||||
name: BetterRTP
|
name: BetterRTP
|
||||||
author: SuperRonanCraft
|
author: SuperRonanCraft
|
||||||
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect, Lands, Residence]
|
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect, Lands, Residence, ProtocolLib]
|
||||||
api-version: '1.13'
|
api-version: '1.13'
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user