returnType, Class paramType, String name, TagRunnable.ObjectWithParamInterface runnable, String... variants) {
+ tagProcessor.registerTag(returnType, paramType, name, (attribute, object, param) -> {
+ if (!object.isOnline()) {
+ if (!attribute.hasAlternative()) {
+ attribute.echoError("Player is not online, but tag '" + attribute.getAttribute(1) + "' requires the player be online, for player: " + object.debuggable());
+ }
+ return null;
+ }
+ return runnable.run(attribute, object, param);
+ }, variants);
+ }
+
public static void registerOnlineOnlyMechanism(String name, Mechanism.GenericMechRunnerInterface runnable) {
tagProcessor.registerMechanism(name, false, (object, mechanism) -> {
if (!object.isOnline()) {
@@ -2924,17 +2949,17 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("window_property")) {
String[] split = mechanism.getValue().asString().split(",", 2);
if (split.length != 2) {
- Debug.echoError("Invalid input! Must be in the form PROPERTY,VALUE");
+ mechanism.echoError("Invalid input! Must be in the form PROPERTY,VALUE");
}
else {
try {
getPlayerEntity().setWindowProperty(InventoryView.Property.valueOf(split[0].toUpperCase()), Integer.parseInt(split[1]));
}
catch (NumberFormatException e) {
- Debug.echoError("Input value must be a number!");
+ mechanism.echoError("Input value must be a number!");
}
catch (IllegalArgumentException e) {
- Debug.echoError("Must specify a valid window property!");
+ mechanism.echoError("Must specify a valid window property!");
}
}
}
@@ -2966,7 +2991,7 @@ public void adjust(Mechanism mechanism) {
Advancement adv = AdvancementHelper.getAdvancement(mechanism.getValue().asString());
if (adv == null) {
if (mechanism.shouldDebug()) {
- Debug.echoError("Advancement '" + mechanism.getValue().asString() + "' does not exist.");
+ mechanism.echoError("Advancement '" + mechanism.getValue().asString() + "' does not exist.");
}
return;
}
@@ -2989,7 +3014,7 @@ public void adjust(Mechanism mechanism) {
Advancement adv = AdvancementHelper.getAdvancement(mechanism.getValue().asString());
if (adv == null) {
if (mechanism.shouldDebug()) {
- Debug.echoError("Advancement '" + mechanism.getValue().asString() + "' does not exist.");
+ mechanism.echoError("Advancement '" + mechanism.getValue().asString() + "' does not exist.");
}
return;
}
@@ -3065,7 +3090,7 @@ public void adjust(Mechanism mechanism) {
String hash = pack.substring(pipe + 1);
pack = pack.substring(0, pipe);
if (hash.length() != 40) {
- Debug.echoError("Invalid resource_pack hash. Should be 40 characters of hexadecimal data.");
+ mechanism.echoError("Invalid resource_pack hash. Should be 40 characters of hexadecimal data.");
return;
}
byte[] hashData = new byte[20];
@@ -3112,7 +3137,7 @@ public void adjust(Mechanism mechanism) {
getPlayerEntity().sendMap(map);
}
else {
- Debug.echoError("No map found for ID " + mechanism.getValue().asInt() + "!");
+ mechanism.echoError("No map found for ID " + mechanism.getValue().asInt() + "!");
}
}
@@ -3184,7 +3209,7 @@ public void adjust(Mechanism mechanism) {
if (mechanism.matches("flying") && mechanism.requireBoolean()) {
boolean doFly = mechanism.getValue().asBoolean();
if (doFly && !getPlayerEntity().getAllowFlight()) {
- Debug.echoError("Must adjust 'can_fly:true' before you can adjust 'flying:true'");
+ mechanism.echoError("Must adjust 'can_fly:true' before you can adjust 'flying:true'");
return;
}
getPlayerEntity().setFlying(doFly);
@@ -3378,18 +3403,18 @@ public void adjust(Mechanism mechanism) {
if (split.size() > 0 && new ElementTag(split.get(0)).matchesType(EntityTag.class)) {
EntityTag entity = EntityTag.valueOf(split.get(0), mechanism.context);
if (!entity.isSpawnedOrValidForTag()) {
- Debug.echoError("Can't hide the unspawned entity '" + split.get(0) + "'!");
+ mechanism.echoError("Can't hide the unspawned entity '" + split.get(0) + "'!");
}
else {
HideEntitiesHelper.hideEntity(getPlayerEntity(), entity.getBukkitEntity());
}
}
else {
- Debug.echoError("'" + split.get(0) + "' is not a valid entity!");
+ mechanism.echoError("'" + split.get(0) + "' is not a valid entity!");
}
}
else {
- Debug.echoError("Must specify an entity to hide!");
+ mechanism.echoError("Must specify an entity to hide!");
}
}
@@ -3519,7 +3544,7 @@ public void adjust(Mechanism mechanism) {
}
}
else {
- Debug.echoError("'" + split[0] + "' is not a valid decimal number!");
+ mechanism.echoError("'" + split[0] + "' is not a valid decimal number!");
}
}
else {
@@ -3633,11 +3658,11 @@ else if (slot.equals("BOOTS")) {
new ElementTag(split[2]).asType(ItemTag.class, mechanism.context).getItemStack());
}
else if (split.length > 2) {
- Debug.echoError("'" + split[2] + "' is not a valid ItemTag!");
+ mechanism.echoError("'" + split[2] + "' is not a valid ItemTag!");
}
}
else if (split.length > 1) {
- Debug.echoError("'" + split[1] + "' is not a valid slot; must be HAND, OFF_HAND, BOOTS, LEGS, CHEST, or HEAD!");
+ mechanism.echoError("'" + split[1] + "' is not a valid slot; must be HAND, OFF_HAND, BOOTS, LEGS, CHEST, or HEAD!");
}
else {
NMSHandler.packetHelper.resetEquipment(getPlayerEntity(),
@@ -3645,7 +3670,7 @@ else if (split.length > 1) {
}
}
else {
- Debug.echoError("'" + split[0] + "' is not a valid EntityTag!");
+ mechanism.echoError("'" + split[0] + "' is not a valid EntityTag!");
}
}
}
@@ -3919,11 +3944,11 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
PaperAPITools.instance.sendSignUpdate(getPlayerEntity(), location, lines.toArray(new String[4]));
}
else {
- Debug.echoError("Must specify a valid location and at least one sign line!");
+ mechanism.echoError("Must specify a valid location and at least one sign line!");
}
}
else {
- Debug.echoError("Must specify a valid location and at least one sign line!");
+ mechanism.echoError("Must specify a valid location and at least one sign line!");
}
}
@@ -3953,14 +3978,14 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
PatternType.valueOf(splitList.get(1).toUpperCase())));
}
catch (Exception e) {
- Debug.echoError("Could not apply pattern to banner: " + string);
+ mechanism.echoError("Could not apply pattern to banner: " + string);
}
}
LocationTag location = LocationTag.valueOf(split[0], mechanism.context);
NMSHandler.packetHelper.showBannerUpdate(getPlayerEntity(), location, patterns);
}
else {
- Debug.echoError("Must specify a valid location and pattern list!");
+ mechanism.echoError("Must specify a valid location and pattern list!");
}
}
}
@@ -4016,7 +4041,7 @@ else if (getPlayerEntity().getGameMode() == GameMode.SPECTATOR) {
if (mechanism.matches("name") && mechanism.hasValue()) {
String name = mechanism.getValue().asString();
if (name.length() > 16) {
- Debug.echoError("Must specify a name with no more than 16 characters.");
+ mechanism.echoError("Must specify a name with no more than 16 characters.");
}
else {
NMSHandler.instance.getProfileEditor().setPlayerName(getPlayerEntity(), mechanism.getValue().asString());
@@ -4094,7 +4119,7 @@ else if (bal > goal) {
// -->
if (mechanism.matches("chat_prefix")) {
if (Depends.chat == null) {
- Debug.echoError("Chat_Prefix mechanism invalid: No linked Chat plugin.");
+ mechanism.echoError("No chat system loaded! Have you installed Vault and a compatible chat plugin?");
return;
}
Depends.chat.setPlayerPrefix(getPlayerEntity(), mechanism.getValue().asString());
@@ -4113,7 +4138,7 @@ else if (bal > goal) {
// -->
if (mechanism.matches("chat_suffix")) {
if (Depends.chat == null) {
- Debug.echoError("Chat_Suffix mechanism invalid: No linked Chat plugin.");
+ mechanism.echoError("No chat system loaded! Have you installed Vault and a compatible chat plugin?");
return;
}
Depends.chat.setPlayerSuffix(getPlayerEntity(), mechanism.getValue().asString());
@@ -4165,7 +4190,7 @@ else if (bal > goal) {
// -->
if (mechanism.matches("send_to") && mechanism.hasValue()) {
if (!isOnline()) {
- Debug.echoError("Cannot use send_to on offline player.");
+ mechanism.echoError("Cannot use send_to on offline player.");
return;
}
Depends.bungeeSendPlayer(getPlayerEntity(), mechanism.getValue().asString());
@@ -4180,7 +4205,7 @@ else if (bal > goal) {
// -->
if (mechanism.matches("send_server_brand") && mechanism.hasValue()) {
if (!isOnline()) {
- Debug.echoError("Cannot use send_server_brand on offline player.");
+ mechanism.echoError("Cannot use send_server_brand on offline player.");
return;
}
NMSHandler.packetHelper.sendBrand(getPlayerEntity(), mechanism.getValue().asString());