1.14 support, fixes #105
3 changed files with 27 additions and 10 deletions
|
@ -33,8 +33,8 @@
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.17.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.17.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.17.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.17.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.17.1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.17.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TownyAdvanced:Towny:0.94.0.9" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.palmergames.bukkit.towny:Towny:0.95.0.0" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-af0353b1d7-1" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-4c248aad62-1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.10" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -199,9 +199,9 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TownyAdvanced</groupId>
|
<groupId>com.palmergames.bukkit.towny</groupId>
|
||||||
<artifactId>Towny</artifactId>
|
<artifactId>Towny</artifactId>
|
||||||
<version>0.94.0.9</version>
|
<version>0.95.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>
|
<!-- <dependency> <groupId>au.com.mineauz</groupId> <artifactId>Minigames</artifactId>
|
||||||
|
|
|
@ -7,10 +7,10 @@ import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.core.Appender;
|
|
||||||
import org.apache.logging.log4j.core.Filter;
|
import org.apache.logging.log4j.core.Filter;
|
||||||
import org.apache.logging.log4j.core.LogEvent;
|
import org.apache.logging.log4j.core.LogEvent;
|
||||||
import org.apache.logging.log4j.core.Logger;
|
import org.apache.logging.log4j.core.Logger;
|
||||||
|
import org.apache.logging.log4j.core.LoggerContext;
|
||||||
import org.apache.logging.log4j.core.appender.AbstractAppender;
|
import org.apache.logging.log4j.core.appender.AbstractAppender;
|
||||||
import org.apache.logging.log4j.core.filter.LevelRangeFilter;
|
import org.apache.logging.log4j.core.filter.LevelRangeFilter;
|
||||||
import org.apache.logging.log4j.core.layout.PatternLayout;
|
import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||||
|
@ -19,13 +19,14 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class TownyAnnouncer {
|
public class TownyAnnouncer {
|
||||||
private static final Pattern LOG_TYPE_PATTERN = Pattern.compile("\\[(\\w+) (?:Msg|Message)](?: (\\w+):)?");
|
private static final Pattern LOG_TYPE_PATTERN = Pattern.compile("\\[(\\w+) (?:Msg|Message)](?: (\\w+):)?");
|
||||||
private static final Appender HANDLER = new AbstractAppender(TownyAnnouncer.class.getSimpleName(),
|
private static final String APPENDER_NAME = "Chroma";
|
||||||
LevelRangeFilter.createFilter(Level.INFO, Level.INFO, Filter.Result.ACCEPT, Filter.Result.DENY),
|
private static final AbstractAppender HANDLER = new AbstractAppender(APPENDER_NAME,
|
||||||
|
LevelRangeFilter.createFilter(Level.INFO, Level.INFO, Filter.Result.ACCEPT, Filter.Result.ACCEPT),
|
||||||
PatternLayout.createDefaultLayout()) {
|
PatternLayout.createDefaultLayout()) {
|
||||||
@Override
|
@Override
|
||||||
public void append(LogEvent logRecord) {
|
public void append(LogEvent logRecord) {
|
||||||
if (logRecord.getMessage() == null) return;
|
if (logRecord.getMessage() == null) return;
|
||||||
String message = logRecord.getMessage().toString();
|
String message = logRecord.getMessage().getFormattedMessage();
|
||||||
val m = LOG_TYPE_PATTERN.matcher(message);
|
val m = LOG_TYPE_PATTERN.matcher(message);
|
||||||
if (!m.find()) return;
|
if (!m.find()) return;
|
||||||
String groupID = m.group(2); //The group ID is correctly cased
|
String groupID = m.group(2); //The group ID is correctly cased
|
||||||
|
@ -59,7 +60,23 @@ public class TownyAnnouncer {
|
||||||
target = TBMCSystemChatEvent.BroadcastTarget.add("towny");
|
target = TBMCSystemChatEvent.BroadcastTarget.add("towny");
|
||||||
TownyAnnouncer.townChannel = townChannel;
|
TownyAnnouncer.townChannel = townChannel;
|
||||||
TownyAnnouncer.nationChannel = nationChannel;
|
TownyAnnouncer.nationChannel = nationChannel;
|
||||||
|
/*System.out.println(LogManager.getLogger("com.palmergames.bukkit.towny"));
|
||||||
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().getConfiguration().addAppender(HANDLER);
|
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().getConfiguration().addAppender(HANDLER);
|
||||||
|
System.out.println(((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getAppenders());
|
||||||
|
((LoggerContext)LogManager.getContext(false)).updateLoggers();
|
||||||
|
System.out.println(((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getAppenders());
|
||||||
|
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().updateLoggers();
|
||||||
|
System.out.println(((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getAppenders());*/
|
||||||
|
val lc = (LoggerContext) LogManager.getContext(false);
|
||||||
|
HANDLER.start();
|
||||||
|
lc.getConfiguration().addAppender(HANDLER);
|
||||||
|
Logger logger = lc.getLogger("com.palmergames.bukkit.towny");
|
||||||
|
//System.out.println(logger);
|
||||||
|
//System.out.println(lc.getConfiguration().<Appender>getAppender(HANDLER.getName())); //T defaults to String because of the context which results in a cast exception
|
||||||
|
logger.addAppender(lc.getConfiguration().getAppender(HANDLER.getName()));
|
||||||
|
logger.get().addAppender(HANDLER, Level.INFO, HANDLER.getFilter());
|
||||||
|
lc.updateLoggers();
|
||||||
|
//System.out.println(logger.getAppenders());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setdown() {
|
public static void setdown() {
|
||||||
|
@ -67,6 +84,6 @@ public class TownyAnnouncer {
|
||||||
target = null;
|
target = null;
|
||||||
TownyAnnouncer.townChannel = null;
|
TownyAnnouncer.townChannel = null;
|
||||||
TownyAnnouncer.nationChannel = null;
|
TownyAnnouncer.nationChannel = null;
|
||||||
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().getConfiguration().getAppenders().remove(TownyAnnouncer.class.getSimpleName());
|
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getAppenders().remove(APPENDER_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue