mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2025-01-15 20:32:24 +01:00
Fixed signs using SpigotAdapter instead of BukkitAdapter
This commit is contained in:
parent
f32a3e7c5e
commit
bdde2d36be
@ -17,6 +17,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
@ -229,4 +230,30 @@ public class BukkitAdapter implements BukkitInterface {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getLine(line);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.setLine(line, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
@ -75,4 +76,10 @@ public interface BukkitInterface {
|
||||
|
||||
public ItemStack getChiseledBookshelfBook(BlockState blockState, PlayerInteractEvent event);
|
||||
|
||||
public String getLine(Sign sign, int line);
|
||||
|
||||
public void setLine(Sign sign, int line, String string);
|
||||
|
||||
public boolean isSignFront(SignChangeEvent event);
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.ChiseledBookshelf;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -151,4 +152,33 @@ public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getSide(Side.FRONT).getLine(line);
|
||||
}
|
||||
else {
|
||||
return sign.getSide(Side.BACK).getLine(line - 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.getSide(Side.FRONT).setLine(line, string);
|
||||
}
|
||||
else {
|
||||
sign.getSide(Side.BACK).setLine(line - 4, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return event.getSide().equals(Side.FRONT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.spigot.SpigotAdapter;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
public class SignStatement {
|
||||
@ -85,14 +84,14 @@ public class SignStatement {
|
||||
boolean backGlowing = Util.isSideGlowing(false, data);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, true, frontGlowing);
|
||||
BukkitAdapter.ADAPTER.setGlowing(sign, false, backGlowing);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 0, line1);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 1, line2);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 2, line3);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 3, line4);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 4, line5);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 5, line6);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 6, line7);
|
||||
SpigotAdapter.ADAPTER.setLine(sign, 7, line8);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 0, line1);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 1, line2);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 2, line3);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 3, line4);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 4, line5);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 5, line6);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 6, line7);
|
||||
BukkitAdapter.ADAPTER.setLine(sign, 7, line8);
|
||||
BukkitAdapter.ADAPTER.setWaxed(sign, isWaxed);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.paper.PaperAdapter;
|
||||
import net.coreprotect.spigot.SpigotAdapter;
|
||||
|
||||
public final class SignChangeListener extends Queue implements Listener {
|
||||
|
||||
@ -41,7 +40,7 @@ public final class SignChangeListener extends Queue implements Listener {
|
||||
boolean frontGlowing = false;
|
||||
boolean backGlowing = false;
|
||||
boolean isWaxed = false;
|
||||
boolean isFront = SpigotAdapter.ADAPTER.isSignFront(event);
|
||||
boolean isFront = BukkitAdapter.ADAPTER.isSignFront(event);
|
||||
boolean existingText = false;
|
||||
|
||||
if (blockState instanceof Sign) {
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.spigot.SpigotAdapter;
|
||||
|
||||
public class PaperAdapter implements PaperInterface {
|
||||
|
||||
@ -66,7 +65,7 @@ public class PaperAdapter implements PaperInterface {
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
return SpigotAdapter.ADAPTER.getLine(sign, line);
|
||||
return BukkitAdapter.ADAPTER.getLine(sign, line);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,9 +2,7 @@ package net.coreprotect.spigot;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import net.coreprotect.bukkit.BukkitAdapter;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
@ -43,11 +41,9 @@ public class SpigotAdapter implements SpigotInterface {
|
||||
case SPIGOT_V1_17:
|
||||
case SPIGOT_V1_18:
|
||||
case SPIGOT_V1_19:
|
||||
SpigotAdapter.ADAPTER = new Spigot_v1_16();
|
||||
break;
|
||||
case SPIGOT_V1_20:
|
||||
default:
|
||||
SpigotAdapter.ADAPTER = new Spigot_v1_20();
|
||||
SpigotAdapter.ADAPTER = new Spigot_v1_16();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -86,31 +82,4 @@ public class SpigotAdapter implements SpigotInterface {
|
||||
|
||||
Chat.sendMessage(sender, message.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getLine(line);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.setLine(line, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package net.coreprotect.spigot;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public interface SpigotInterface {
|
||||
|
||||
@ -12,10 +10,4 @@ public interface SpigotInterface {
|
||||
|
||||
public void sendComponent(CommandSender sender, String string, String bypass);
|
||||
|
||||
public String getLine(Sign sign, int line);
|
||||
|
||||
public void setLine(Sign sign, int line, String string);
|
||||
|
||||
public boolean isSignFront(SignChangeEvent event);
|
||||
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
package net.coreprotect.spigot;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class Spigot_v1_20 extends Spigot_v1_16 implements SpigotInterface {
|
||||
|
||||
@Override
|
||||
public String getLine(Sign sign, int line) {
|
||||
if (line < 4) {
|
||||
return sign.getSide(Side.FRONT).getLine(line);
|
||||
}
|
||||
else {
|
||||
return sign.getSide(Side.BACK).getLine(line - 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(Sign sign, int line, String string) {
|
||||
if (string == null) {
|
||||
string = "";
|
||||
}
|
||||
|
||||
if (line < 4) {
|
||||
sign.getSide(Side.FRONT).setLine(line, string);
|
||||
}
|
||||
else {
|
||||
sign.getSide(Side.BACK).setLine(line - 4, string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSignFront(SignChangeEvent event) {
|
||||
return event.getSide().equals(Side.FRONT);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user