Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improperly labeled mod warning

  • Loading branch information...
commit ae3c50552d8628ce9396beaf7f93447e536ac8c2 1 parent c50ad2f
Matt Baxter mbax authored
24 src/main/java/org/kitteh/tag/ModAuthorNagException.java
... ... @@ -0,0 +1,24 @@
  1 +/*
  2 + * Copyright 2012-2013 Matt Baxter
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http:www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.kitteh.tag;
  17 +
  18 +public class ModAuthorNagException extends RuntimeException {
  19 + private static final long serialVersionUID = -22222222222L;
  20 +
  21 + public ModAuthorNagException(String nag) {
  22 + super(nag);
  23 + }
  24 +}
12 src/main/java/org/kitteh/tag/TagAPI.java
@@ -21,6 +21,7 @@
21 21 import java.util.Set;
22 22 import java.util.concurrent.Callable;
23 23 import java.util.concurrent.Future;
  24 +import java.util.logging.Level;
24 25
25 26 import org.bukkit.entity.Player;
26 27 import org.bukkit.event.EventHandler;
@@ -235,6 +236,17 @@ public void onEnable() {
235 236 this.tickPeriod = tickPeriod;
236 237 this.debug("Storing main thread: " + TagAPI.mainThread.getName());
237 238
  239 + final String impName = this.getServer().getName();
  240 + if (impName.equals("CraftBukkit")) {
  241 + final String impVersion = this.getServer().getVersion();
  242 + if (!impVersion.startsWith("git-Bukkit")) {
  243 + this.getLogger().warning("Inconsistency found: Potential mod detected. TagAPI may not run properly.");
  244 + this.getLogger().log(Level.WARNING, "Report this to the mod author ASAP", new ModAuthorNagException("Mod claims to be \"CraftBukkit\" but is not. Report this error to the mod author so they can fix it ASAP.\nFound \"CraftBukkit\" \"" + impVersion + "\""));
  245 + }
  246 + } else {
  247 + this.getLogger().warning("Mod detected: \"" + impName + "\". TagAPI may not run properly.");
  248 + }
  249 +
238 250 String versionLoaded;
239 251
240 252 if (this.getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {

8 comments on commit ae3c505

mibby

@mbax

Ugly error using TagAPI jenkins build 114. Spigot is a very popular bukkit fork used by many large servers in conjunction with BungeeCord. Can it be added to the safe list of TagAPI?

2013-08-30 02:32:47 [WARNING] [TagAPI] Inconsistency found: Potential mod detected. TagAPI may not run properly.
2013-08-30 02:32:47 [WARNING] [TagAPI] Report this to the mod author ASAP
org.kitteh.tag.ModAuthorNagException: Mod claims to be "CraftBukkit" but is not. Report this error to the mod author so they can fix it ASAP.
Found "CraftBukkit" "git-Spigot-1088 (MC: 1.6.2)"
    at org.kitteh.tag.TagAPI.onEnable(TagAPI.java:244)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:382)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugin(CraftServer.java:286)
    at org.bukkit.craftbukkit.v1_6_R2.CraftServer.enablePlugins(CraftServer.java:268)
    at net.minecraft.server.v1_6_R2.MinecraftServer.l(MinecraftServer.java:319)
    at net.minecraft.server.v1_6_R2.MinecraftServer.f(MinecraftServer.java:296)
    at net.minecraft.server.v1_6_R2.MinecraftServer.a(MinecraftServer.java:256)
    at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:164)
    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:397)
    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
Matt Baxter
Owner

That problem should be reported to spigot. There is a method in the bukkit api called getName, which is supposed to reply with the implementation name of the server running. Apparently spigot is saying it is craftbukkit, when it should reply "Spigot" (because while it's a fork of craftbukkit it has it's own modifications and implementations). Perhaps my message in the log isn't clear enough to admins. Any advice on a clearer message?

edit: Tablet autocorrected some WEIRD WORDS.

mibby

@mbax

Perhaps instead of printing the entire nag exception in console, have it state something like the following? Of course you could change and word it however you would like, just the full print itself is ugly to see and could be indicated as an error to many server owners.

[WARNING] [TagAPI] A modification claiming to be CraftBukkit has been detected. TagAPI may not function properly 
and will not be officially supported. Found "CraftBukkit" "git-Spigot-1088 (MC: 1.6.2)"

Then perhaps have a config option to disable the warning / inconsistency check?

@md-5
Figured I'd ping you since he said it should be reported.

md-5

@mibby
There is no functional purpose to this commit, you may ignore the error message and proceed as normal.
This commit is merely designed to cause panic and confusion amongst users of Spigot and this plugin.

Matt Baxter
Owner

This commit wasn't even written with Spigot in mind. Please do not claim to know the purpose of this commit.

@mibby The problem is that implementations are claiming to be CraftBukkit when their implementation is no longer binary compatible. TagAPI has at times not worked with Spigot, and at times does not work with MCPC+ among other mods. However they all currently claim to be CraftBukkit in that method which they should not be doing.

The only reasoning against it is that currently PEX is written to expect CraftBukkit and panics if it isn't there. This is easily solvable and before even writing this code talked with him about the idea of fixing that and he seemed on board. I didn't plan to push this code to a release until a PEX build was ready or at least plenty of time was given.

Regardless, I don't suggest running dev builds of TagAPI unless I specifically say otherwise. I've pushed some weird stuff to the master branch before :3

Jacob Litewski

I honestly think this is how plugins that rely on NMS and OBC should go about it, with all the popular forks. I do agree with @mibby that it shouldn't throw the entire NagException, since it does look like something went wrong with the plugin.

zml

FYI PEX is already fixed to no longer specifically check for craftbukkit. I want to do a release today or tomorrow including that commit.

Jacob Litewski
Please sign in to comment.
Something went wrong with that request. Please try again.