mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-02 08:50:17 +01:00
Reformatting and cleaning.
This commit is contained in:
parent
bef3dbc6f4
commit
d0be0780fd
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.bukkit;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.listeners.*;
|
import com.github.intellectualsites.plotsquared.bukkit.listeners.*;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle_111;
|
import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.*;
|
import com.github.intellectualsites.plotsquared.bukkit.util.*;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue;
|
import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.uuid.*;
|
import com.github.intellectualsites.plotsquared.bukkit.uuid.*;
|
||||||
@ -727,7 +727,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
+ " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
+ " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||||
Settings.TITLES = false;
|
Settings.TITLES = false;
|
||||||
} else {
|
} else {
|
||||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_111();
|
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
||||||
if (wrapper instanceof DefaultUUIDWrapper
|
if (wrapper instanceof DefaultUUIDWrapper
|
||||||
|| wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
|| wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
|
||||||
Settings.UUID.NATIVE_UUID_PROVIDER = true;
|
Settings.UUID.NATIVE_UUID_PROVIDER = true;
|
||||||
|
@ -12,7 +12,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
@SuppressWarnings("unused") public class WorldEvents implements Listener {
|
@SuppressWarnings("unused")
|
||||||
|
public class WorldEvents implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onWorldInit(WorldInitEvent event) {
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
|
@ -282,6 +282,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
this.dataByte = (byte) 0;
|
this.dataByte = (byte) 0;
|
||||||
}
|
}
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
|
return;
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
default:
|
default:
|
||||||
PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
||||||
@ -317,8 +318,9 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
if (this.lived.leashed) {
|
if (this.lived.leashed) {
|
||||||
// TODO leashes
|
// TODO leashes
|
||||||
// World world = entity.getWorld();
|
// World world = entity.getWorld();
|
||||||
// Entity leash = world.spawnEntity(new Location(world, Math.floor(x) + lived.leashX, Math.floor(y) + lived.leashY, Math
|
// Entity leash = world.spawnEntity(new Location(world, Math.floor(x) +
|
||||||
// .floor(z) + lived.leashZ), EntityType.LEASH_HITCH);
|
// lived.leashX, Math.floor(y) + lived.leashY, Math.floor(z) + lived.leashZ),
|
||||||
|
// EntityType.LEASH_HITCH);
|
||||||
// entity.setLeashHolder(leash);
|
// entity.setLeashHolder(leash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,7 +345,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void storeLiving(LivingEntity lived) {
|
private void storeLiving(LivingEntity lived) {
|
||||||
this.lived = new LivingEntityStats();
|
this.lived = new LivingEntityStats();
|
||||||
this.lived.potions = lived.getActivePotionEffects();
|
this.lived.potions = lived.getActivePotionEffects();
|
||||||
this.lived.loot = lived.getCanPickupItems();
|
this.lived.loot = lived.getCanPickupItems();
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.bukkit.titles;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DefaultTitle extends AbstractTitle {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
||||||
|
try {
|
||||||
|
final Player playerObj = ((BukkitPlayer) player).player;
|
||||||
|
TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out);
|
||||||
|
title.send(playerObj);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -44,19 +44,17 @@ public class DefaultTitleManager extends TitleManager {
|
|||||||
Object[] actions = this.packetActions.getEnumConstants();
|
Object[] actions = this.packetActions.getEnumConstants();
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||||
Object packet = this.packetTitle
|
Object packet = this.packetTitle
|
||||||
.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE,
|
.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE,
|
||||||
Integer.TYPE, Integer.TYPE)
|
Integer.TYPE).newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
|
||||||
.newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
|
this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
|
||||||
this.stayTime * (this.ticks ? 1 : 20),
|
|
||||||
this.fadeOutTime * (this.ticks ? 1 : 20));
|
|
||||||
// Send if set
|
// Send if set
|
||||||
if (this.fadeInTime != -1 && this.fadeOutTime != -1 && this.stayTime != -1) {
|
if (this.fadeInTime != -1 && this.fadeOutTime != -1 && this.stayTime != -1) {
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
|
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:"
|
||||||
+ "\",color:" + this.titleColor.name().toLowerCase() + '}');
|
+ this.titleColor.name().toLowerCase() + '}');
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
|
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
|
||||||
.newInstance(actions[0], serialized);
|
.newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.titles;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public class DefaultTitle_111 extends AbstractTitle {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
|
||||||
try {
|
|
||||||
final Player playerObj = ((BukkitPlayer) player).player;
|
|
||||||
TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out);
|
|
||||||
title.send(playerObj);
|
|
||||||
return;
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.titles;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
|
|
||||||
|
|
||||||
public class HackTitle extends AbstractTitle {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
|
|
||||||
try {
|
|
||||||
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
|
||||||
title.send(((BukkitPlayer) player).player);
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
PlotSquared.debug("&cYour server version does not support titles!");
|
|
||||||
Settings.TITLES = false;
|
|
||||||
AbstractTitle.TITLE_CLASS = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +0,0 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.titles;
|
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.chat.Reflection;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class HackTitleManager extends TitleManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new 1.8 title.
|
|
||||||
*
|
|
||||||
* @param title Title text
|
|
||||||
* @param subtitle Subtitle text
|
|
||||||
* @param fadeInTime Fade in time
|
|
||||||
* @param stayTime Stay on screen time
|
|
||||||
* @param fadeOutTime Fade out time
|
|
||||||
*/
|
|
||||||
HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
|
||||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load spigot and NMS classes.
|
|
||||||
*/
|
|
||||||
@Override void loadClasses() {
|
|
||||||
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
|
||||||
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
|
||||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void send(Player player)
|
|
||||||
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
|
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
|
|
||||||
// First reset previous settings
|
|
||||||
resetTitle(player);
|
|
||||||
// Send timings first
|
|
||||||
Object handle = getHandle(player);
|
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
|
||||||
Object packet = this.packetTitle
|
|
||||||
.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE)
|
|
||||||
.newInstance(actions[2], this.fadeInTime * (this.ticks ? 1 : 20),
|
|
||||||
this.stayTime * (this.ticks ? 1 : 20),
|
|
||||||
this.fadeOutTime * (this.ticks ? 1 : 20));
|
|
||||||
// Send if set
|
|
||||||
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
|
|
||||||
sendPacket.invoke(connection, packet);
|
|
||||||
}
|
|
||||||
// Send title
|
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
|
|
||||||
+ "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
|
||||||
packet = this.packetTitle
|
|
||||||
.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
|
||||||
.newInstance(actions[0], serialized);
|
|
||||||
sendPacket.invoke(connection, packet);
|
|
||||||
if (!this.getSubtitle().isEmpty()) {
|
|
||||||
// Send subtitle if present
|
|
||||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
|
||||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
|
|
||||||
+ "\",color:" + this.subtitleColor.name().toLowerCase() + "}");
|
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions,
|
|
||||||
Reflection.getNMSClass("IChatBaseComponent"))
|
|
||||||
.newInstance(actions[1], serialized);
|
|
||||||
sendPacket.invoke(connection, packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void clearTitle(Player player)
|
|
||||||
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
|
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
|
||||||
// Send timings first
|
|
||||||
Object handle = getHandle(player);
|
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
|
||||||
Object packet =
|
|
||||||
this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
|
|
||||||
sendPacket.invoke(connection, packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void resetTitle(Player player)
|
|
||||||
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
|
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
|
||||||
// Send timings first
|
|
||||||
Object handle = getHandle(player);
|
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
|
||||||
Object packet =
|
|
||||||
this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
|
|
||||||
sendPacket.invoke(connection, packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the protocol version of the player.
|
|
||||||
*
|
|
||||||
* @param player Player
|
|
||||||
* @return Protocol version
|
|
||||||
* @throws IllegalArgumentException
|
|
||||||
* @throws ReflectiveOperationException
|
|
||||||
* @throws SecurityException
|
|
||||||
*/
|
|
||||||
private int getProtocolVersion(Player player)
|
|
||||||
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
|
|
||||||
Object handle = getHandle(player);
|
|
||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
|
||||||
Object networkManager = getValue("networkManager", connection);
|
|
||||||
return (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if running spigot.
|
|
||||||
*
|
|
||||||
* @return Spigot
|
|
||||||
*/
|
|
||||||
private boolean isSpigot() {
|
|
||||||
return Bukkit.getVersion().contains("Spigot");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get class by url.
|
|
||||||
*
|
|
||||||
* @param namespace Namespace url
|
|
||||||
* @return Class
|
|
||||||
*/
|
|
||||||
private Class<?> getClass(String namespace) {
|
|
||||||
try {
|
|
||||||
return Class.forName(namespace);
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Field getField(String name, Class<?> clazz)
|
|
||||||
throws NoSuchFieldException, SecurityException {
|
|
||||||
return clazz.getDeclaredField(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object getValue(String name, Object obj)
|
|
||||||
throws ReflectiveOperationException, SecurityException, IllegalArgumentException {
|
|
||||||
Field f = getField(name, obj.getClass());
|
|
||||||
f.setAccessible(true);
|
|
||||||
return f.get(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Field getField(Class<?> clazz, String name) {
|
|
||||||
try {
|
|
||||||
Field field = clazz.getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return field;
|
|
||||||
} catch (SecurityException | NoSuchFieldException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
|
||||||
for (Method m : clazz.getMethods()) {
|
|
||||||
if (m.getName().equals(name) && ((args.length == 0) || classListEqual(args,
|
|
||||||
m.getParameterTypes()))) {
|
|
||||||
m.setAccessible(true);
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -23,9 +23,9 @@ public abstract class TitleManager {
|
|||||||
int fadeOutTime = -1;
|
int fadeOutTime = -1;
|
||||||
boolean ticks = false;
|
boolean ticks = false;
|
||||||
/* Title text and color */
|
/* Title text and color */
|
||||||
private String title = "";
|
private String title;
|
||||||
/* Subtitle text and color */
|
/* Subtitle text and color */
|
||||||
private String subtitle = "";
|
private String subtitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title.
|
* Create a new 1.8 title.
|
||||||
|
@ -50,7 +50,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
*/
|
*/
|
||||||
@ -72,7 +72,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy 1.8 title
|
* Copy 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
*/
|
*/
|
||||||
@ -90,7 +90,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new 1.8 title
|
* Create a new 1.8 title.
|
||||||
*
|
*
|
||||||
* @param title Title text
|
* @param title Title text
|
||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
@ -117,7 +117,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load spigot and NMS classes
|
* Load spigot and NMS classes.
|
||||||
*/
|
*/
|
||||||
private void loadClasses() {
|
private void loadClasses() {
|
||||||
if (packetTitle == null) {
|
if (packetTitle == null) {
|
||||||
@ -135,7 +135,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title text
|
* Gets the title text.
|
||||||
*
|
*
|
||||||
* @return Title text
|
* @return Title text
|
||||||
*/
|
*/
|
||||||
@ -144,7 +144,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title text
|
* Sets the title text.
|
||||||
*
|
*
|
||||||
* @param title Title
|
* @param title Title
|
||||||
*/
|
*/
|
||||||
@ -153,7 +153,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subtitle text
|
* Gets the subtitle text.
|
||||||
*
|
*
|
||||||
* @return Subtitle text
|
* @return Subtitle text
|
||||||
*/
|
*/
|
||||||
@ -162,7 +162,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set subtitle text
|
* Sets the subtitle text.
|
||||||
*
|
*
|
||||||
* @param subtitle Subtitle text
|
* @param subtitle Subtitle text
|
||||||
*/
|
*/
|
||||||
@ -171,21 +171,21 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set timings to ticks
|
* Sets timings to ticks.
|
||||||
*/
|
*/
|
||||||
public void setTimingsToTicks() {
|
public void setTimingsToTicks() {
|
||||||
ticks = true;
|
ticks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set timings to seconds
|
* Sets timings to seconds.
|
||||||
*/
|
*/
|
||||||
public void setTimingsToSeconds() {
|
public void setTimingsToSeconds() {
|
||||||
ticks = false;
|
ticks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the title to a player
|
* Sends the title to a player.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
*/
|
*/
|
||||||
@ -210,8 +210,8 @@ public class TitleManager_1_11 {
|
|||||||
Object serialized;
|
Object serialized;
|
||||||
if (!subtitle.equals("")) {
|
if (!subtitle.equals("")) {
|
||||||
// Send subtitle if present
|
// Send subtitle if present
|
||||||
serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
|
serialized = nmsChatSerializer.getConstructor(String.class)
|
||||||
subtitleColor + ChatColor.translateAlternateColorCodes('&', subtitle));
|
.newInstance(subtitleColor + ChatColor.translateAlternateColorCodes('&', subtitle));
|
||||||
packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
|
packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
|
||||||
.newInstance(actions[1], serialized);
|
.newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
@ -239,8 +239,7 @@ public class TitleManager_1_11 {
|
|||||||
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent, Integer.TYPE,
|
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent, Integer.TYPE,
|
||||||
Integer.TYPE, Integer.TYPE})
|
Integer.TYPE, Integer.TYPE})
|
||||||
.newInstance(actions[3], null, this.fadeInTime * (this.ticks ? 1 : 20),
|
.newInstance(actions[3], null, this.fadeInTime * (this.ticks ? 1 : 20),
|
||||||
this.stayTime * (this.ticks ? 1 : 20),
|
this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
|
||||||
this.fadeOutTime * (this.ticks ? 1 : 20));
|
|
||||||
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
|
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
@ -257,10 +256,10 @@ public class TitleManager_1_11 {
|
|||||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||||
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
||||||
Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
|
Object serialized = nmsChatSerializer.getConstructor(String.class)
|
||||||
titleColor + ChatColor.translateAlternateColorCodes('&', this.title));
|
.newInstance(titleColor + ChatColor.translateAlternateColorCodes('&', this.title));
|
||||||
Object packet = TitleManager_1_11.packetTitle.getConstructor(
|
Object packet = TitleManager_1_11.packetTitle
|
||||||
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
|
.getConstructor(new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
|
||||||
.newInstance(actions[0], serialized);
|
.newInstance(actions[0], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -277,8 +276,8 @@ public class TitleManager_1_11 {
|
|||||||
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
|
||||||
Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
|
Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
|
||||||
subtitleColor + ChatColor.translateAlternateColorCodes('&', this.subtitle));
|
subtitleColor + ChatColor.translateAlternateColorCodes('&', this.subtitle));
|
||||||
Object packet = TitleManager_1_11.packetTitle.getConstructor(
|
Object packet = TitleManager_1_11.packetTitle
|
||||||
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
|
.getConstructor(new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
|
||||||
.newInstance(actions[1], serialized);
|
.newInstance(actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -288,7 +287,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast the title to all players
|
* Broadcasts the title to all players.
|
||||||
*/
|
*/
|
||||||
public void broadcast() {
|
public void broadcast() {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
@ -297,7 +296,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the title
|
* Clears the title from the players screen.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
*/
|
*/
|
||||||
@ -316,7 +315,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the title settings
|
* Resets the title settings.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
*/
|
*/
|
||||||
@ -369,8 +368,7 @@ public class TitleManager_1_11 {
|
|||||||
|
|
||||||
private String getVersion() {
|
private String getVersion() {
|
||||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
String version = name.substring(name.lastIndexOf('.') + 1) + ".";
|
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getNMSClass(String className) {
|
private Class<?> getNMSClass(String className) {
|
||||||
@ -418,10 +416,10 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||||
boolean equal = true;
|
|
||||||
if (l1.length != l2.length) {
|
if (l1.length != l2.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
boolean equal = true;
|
||||||
for (int i = 0; i < l1.length; i++) {
|
for (int i = 0; i < l1.length; i++) {
|
||||||
if (l1[i] != l2[i]) {
|
if (l1[i] != l2[i]) {
|
||||||
equal = false;
|
equal = false;
|
||||||
@ -436,7 +434,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the title color
|
* Sets the title color.
|
||||||
*
|
*
|
||||||
* @param color Chat color
|
* @param color Chat color
|
||||||
*/
|
*/
|
||||||
@ -449,7 +447,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the subtitle color
|
* Sets the subtitle color.
|
||||||
*
|
*
|
||||||
* @param color Chat color
|
* @param color Chat color
|
||||||
*/
|
*/
|
||||||
@ -462,7 +460,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title fade in time
|
* Sets the fade in time for the title.
|
||||||
*
|
*
|
||||||
* @param time Time
|
* @param time Time
|
||||||
*/
|
*/
|
||||||
@ -470,14 +468,19 @@ public class TitleManager_1_11 {
|
|||||||
this.fadeInTime = time;
|
this.fadeInTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fade out time for the title.
|
||||||
|
*
|
||||||
|
* @return the time to fade out
|
||||||
|
*/
|
||||||
public int getFadeOutTime() {
|
public int getFadeOutTime() {
|
||||||
return fadeOutTime;
|
return fadeOutTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title fade out time
|
* Sets the fade out time for the title.
|
||||||
*
|
*
|
||||||
* @param time Time
|
* @param time fade-out time
|
||||||
*/
|
*/
|
||||||
public void setFadeOutTime(int time) {
|
public void setFadeOutTime(int time) {
|
||||||
this.fadeOutTime = time;
|
this.fadeOutTime = time;
|
||||||
@ -488,7 +491,7 @@ public class TitleManager_1_11 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title stay time
|
* Sets the title stay time.
|
||||||
*
|
*
|
||||||
* @param time Time
|
* @param time Time
|
||||||
*/
|
*/
|
||||||
|
@ -275,8 +275,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||||
RegionWrapper currentPlotClear =
|
|
||||||
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
|
||||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||||
AugmentedUtils
|
AugmentedUtils
|
||||||
.bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.x, chunk.z));
|
.bypass(ignoreAugment, () -> queue.regenChunkSafe(chunk.x, chunk.z));
|
||||||
@ -341,6 +339,8 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (checkX2 && checkZ2) {
|
if (checkX2 && checkZ2) {
|
||||||
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
|
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
|
||||||
}
|
}
|
||||||
|
RegionWrapper currentPlotClear =
|
||||||
|
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||||
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
||||||
AugmentedUtils.bypass(ignoreAugment,
|
AugmentedUtils.bypass(ignoreAugment,
|
||||||
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
||||||
@ -611,11 +611,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveEntitiesIn(Chunk chunk, RegionWrapper region) {
|
void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
||||||
saveEntitiesIn(chunk, region, 0, 0, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
|
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
Location loc = BukkitUtil.getLocation(entity);
|
Location loc = BukkitUtil.getLocation(entity);
|
||||||
int x = loc.getX();
|
int x = loc.getX();
|
||||||
@ -632,7 +628,11 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
|
void saveEntitiesIn(Chunk chunk, RegionWrapper region) {
|
||||||
|
saveEntitiesIn(chunk, region, 0, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
|
||||||
boolean delete) {
|
boolean delete) {
|
||||||
for (Entity entity : chunk.getEntities()) {
|
for (Entity entity : chunk.getEntities()) {
|
||||||
Location loc = BukkitUtil.getLocation(entity);
|
Location loc = BukkitUtil.getLocation(entity);
|
||||||
@ -657,7 +657,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreEntities(World world, int xOffset, int zOffset) {
|
void restoreEntities(World world, int xOffset, int zOffset) {
|
||||||
for (EntityWrapper entity : this.entities) {
|
for (EntityWrapper entity : this.entities) {
|
||||||
try {
|
try {
|
||||||
entity.spawn(world, xOffset, zOffset);
|
entity.spawn(world, xOffset, zOffset);
|
||||||
@ -670,8 +670,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//todo optimize maxY
|
//todo optimize maxY
|
||||||
public void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX,
|
void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX, int offsetZ) {
|
||||||
int offsetZ) {
|
|
||||||
maxY = Math.min(255, maxY);
|
maxY = Math.min(255, maxY);
|
||||||
BaseBlock[] ids;
|
BaseBlock[] ids;
|
||||||
ids = new BaseBlock[maxY + 1];
|
ids = new BaseBlock[maxY + 1];
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.events.*;
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotHelperEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotAutoMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotChangeOwnerEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotClearEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotComponentSetEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotDeleteEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagAddEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotFlagRemoveEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotMergeEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotRateEvent;
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.events.PlotUnlinkEvent;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -16,7 +37,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for handling Bukkit {@link Event events}
|
* Utility class for handling Bukkit Events.
|
||||||
*/
|
*/
|
||||||
public final class BukkitEventUtil extends EventUtil {
|
public final class BukkitEventUtil extends EventUtil {
|
||||||
|
|
||||||
@ -61,13 +82,11 @@ public final class BukkitEventUtil extends EventUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean callMerge(Plot plot, int dir, int max) {
|
@Override public boolean callMerge(Plot plot, int dir, int max) {
|
||||||
return callEvent(
|
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
|
||||||
new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, dir, max));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
|
@Override public boolean callAutoMerge(Plot plot, List<PlotId> plots) {
|
||||||
return callEvent(
|
return callEvent(new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||||
new PlotAutoMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
|
@Override public boolean callUnlink(PlotArea area, List<PlotId> plots) {
|
||||||
|
@ -21,32 +21,6 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
public class BukkitInventoryUtil extends InventoryUtil {
|
public class BukkitInventoryUtil extends InventoryUtil {
|
||||||
|
|
||||||
public static ItemStack getItem(PlotItemStack item) {
|
|
||||||
if (item == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ItemStack stack = new ItemStack(BukkitUtil.getMaterial(item.getPlotBlock()), item.amount);
|
|
||||||
ItemMeta meta = null;
|
|
||||||
if (item.name != null) {
|
|
||||||
meta = stack.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', item.name));
|
|
||||||
}
|
|
||||||
if (item.lore != null) {
|
|
||||||
if (meta == null) {
|
|
||||||
meta = stack.getItemMeta();
|
|
||||||
}
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
for (String entry : item.lore) {
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', entry));
|
|
||||||
}
|
|
||||||
meta.setLore(lore);
|
|
||||||
}
|
|
||||||
if (meta != null) {
|
|
||||||
stack.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void open(PlotInventory inv) {
|
@Override public void open(PlotInventory inv) {
|
||||||
BukkitPlayer bp = (BukkitPlayer) inv.player;
|
BukkitPlayer bp = (BukkitPlayer) inv.player;
|
||||||
Inventory inventory = Bukkit.createInventory(null, inv.size * 9, inv.getTitle());
|
Inventory inventory = Bukkit.createInventory(null, inv.size * 9, inv.getTitle());
|
||||||
@ -78,18 +52,44 @@ public class BukkitInventoryUtil extends InventoryUtil {
|
|||||||
bp.player.updateInventory();
|
bp.player.updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ItemStack getItem(PlotItemStack item) {
|
||||||
|
if (item == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ItemStack stack = new ItemStack(BukkitUtil.getMaterial(item.getPlotBlock()), item.amount);
|
||||||
|
ItemMeta meta = null;
|
||||||
|
if (item.name != null) {
|
||||||
|
meta = stack.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', item.name));
|
||||||
|
}
|
||||||
|
if (item.lore != null) {
|
||||||
|
if (meta == null) {
|
||||||
|
meta = stack.getItemMeta();
|
||||||
|
}
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
for (String entry : item.lore) {
|
||||||
|
lore.add(ChatColor.translateAlternateColorCodes('&', entry));
|
||||||
|
}
|
||||||
|
meta.setLore(lore);
|
||||||
|
}
|
||||||
|
if (meta != null) {
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
public PlotItemStack getItem(ItemStack item) {
|
public PlotItemStack getItem(ItemStack item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// int id = item.getTypeId();
|
// int id = item.getTypeId();
|
||||||
Material id = item.getType();
|
Material id = item.getType();
|
||||||
short data = item.getDurability();
|
ItemMeta meta = item.getItemMeta();
|
||||||
int amount = item.getAmount();
|
int amount = item.getAmount();
|
||||||
String name = null;
|
String name = null;
|
||||||
String[] lore = null;
|
String[] lore = null;
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
ItemMeta meta = item.getItemMeta();
|
assert meta != null;
|
||||||
if (meta.hasDisplayName()) {
|
if (meta.hasDisplayName()) {
|
||||||
name = meta.getDisplayName();
|
name = meta.getDisplayName();
|
||||||
}
|
}
|
||||||
@ -114,7 +114,11 @@ public class BukkitInventoryUtil extends InventoryUtil {
|
|||||||
}
|
}
|
||||||
BukkitPlayer bp = (BukkitPlayer) plotInventory.player;
|
BukkitPlayer bp = (BukkitPlayer) plotInventory.player;
|
||||||
InventoryView opened = bp.player.getOpenInventory();
|
InventoryView opened = bp.player.getOpenInventory();
|
||||||
return plotInventory.isOpen() && opened.getType() == InventoryType.CRAFTING
|
if (plotInventory.isOpen()) {
|
||||||
&& opened.getTitle() == null;
|
if (opened.getType() == InventoryType.CRAFTING) {
|
||||||
|
opened.getTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user