1.14 support, fixes #105

Merged
NorbiPeti merged 21 commits from dev into master 2019-10-30 18:35:43 +00:00
8 changed files with 42 additions and 42 deletions
Showing only changes of commit bd656015bf - Show all commits

View file

@ -11,9 +11,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:8d3b6b6" level="project" />
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:8d3b6b6" level="project" />
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
@ -50,6 +47,7 @@
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
</component>
</module>

10
pom.xml
View file

@ -249,13 +249,13 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<!-- Included in vanilla minecraft's JAR -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<artifactId>ButtonChat</artifactId>
<organization>

View file

@ -269,6 +269,7 @@ public class ChatProcessing {
StringBuilder nicksb = new StringBuilder("(?i)(");
boolean addNickFormatter = false;
for (Player p : Bukkit.getOnlinePlayers()) {
if (!canSee.test(p)) continue;
final String nick = PlayerListener.nicknames.inverse().get(p.getUniqueId());
if (nick != null) {
nicksb.append(nick).append("|");

View file

@ -19,7 +19,7 @@ public final class HelpCommand extends UCommandBase {
public boolean def(CommandSender sender, @Command2.TextArg @Command2.OptionalArg String topicOrCommand) {
if (topicOrCommand == null) {
sender.sendMessage(new String[]{
"§6---- Thorpe Help ----",
"§6---- Chroma Help ----",
"Do /u help <topic> for more info",
"Do /u help <commandname> [subcommands] for more info about a command",
"Topics:",

View file

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
@CommandClass(helpText = {
"Reload",
"Reloads Thorpe-Chat"
"Reloads the config"
}, modOnly = true)
public class ReloadCommand extends UCommandBase {
@Command2.Subcommand

View file

@ -7,6 +7,7 @@ import buttondevteam.lib.player.TBMCPlayer;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.Optional;
@CommandClass(path = "u c", helpText = {
"Rainbow mode",
@ -18,7 +19,7 @@ public class CCommand extends ICommand2MC {
public boolean def(Player player, @Command2.OptionalArg String color) {
ChatPlayer p = TBMCPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class);
if (color == null) {
if (PluginMain.permission.has(player, "thorpe.color.rainbow")) {
if (PluginMain.permission.has(player, "chroma.color.rainbow")) {
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
p.OtherColorMode = null;
if (p.RainbowPresserColorMode)
@ -30,20 +31,23 @@ public class CCommand extends ICommand2MC {
return true;
}
} else {
if (PluginMain.permission.has(player, "thorpe.color.custom")) {
p.RainbowPresserColorMode = false;
p.OtherColorMode = null;
try {
String x = color.toLowerCase();
p.OtherColorMode = Arrays.stream(Color.values()).filter(c -> c.getName().equals(x)).findAny().orElse(null);
} catch (Exception e) {
if (PluginMain.permission.has(player, "chroma.color.custom")) {
String x = color.toLowerCase();
if ("off".equals(x)) {
p.OtherColorMode = null;
player.sendMessage("§eMessage color reset.");
return true;
}
Optional<Color> oc = Arrays.stream(Color.values()).filter(c -> c.getName().equals(x)).findAny();
if (!oc.isPresent()) {
player.sendMessage("§cUnknown message color: " + color);
player.sendMessage("§cUse color names, like blue, or dark_aqua");
player.sendMessage("§cOr use 'off' to disable");
return true;
}
if (p.OtherColorMode != null)
player.sendMessage(String.format("§eMessage color set to %s", p.OtherColorMode));
else
player.sendMessage("§eMessage color reset.");
p.RainbowPresserColorMode = false;
p.OtherColorMode = oc.get();
player.sendMessage(String.format("§eMessage color set to %s", p.OtherColorMode));
} else {
player.sendMessage("§cYou don't have permission for this command.");
return true;

View file

@ -139,7 +139,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
if (ht.getName().equalsIgnoreCase(cmd))
return;
}
if (PluginMain.permission.has(event.getSender(), "thorpe.unanything")) {
if (PluginMain.permission.has(event.getSender(), "chroma.unanything")) {
event.setCancelled(true);
int index = cmd.lastIndexOf(' ');
if (index == -1) {

View file

@ -5,18 +5,25 @@ import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCSystemChatEvent;
import buttondevteam.lib.chat.TBMCChatAPI;
import lombok.val;
import org.apache.log4j.Appender;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.LogManager;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.Level;
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.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.filter.LevelRangeFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
import java.util.regex.Pattern;
public class TownyAnnouncer {
private static final Pattern LOG_TYPE_PATTERN = Pattern.compile("\\[(\\w+) (?:Msg|Message)](?: (\\w+):)?");
private static final Appender HANDLER = new AppenderSkeleton() {
private static final Appender HANDLER = new AbstractAppender(TownyAnnouncer.class.getSimpleName(),
LevelRangeFilter.createFilter(Level.INFO, Level.INFO, Filter.Result.ACCEPT, Filter.Result.DENY),
PatternLayout.createDefaultLayout()) {
@Override
public void append(LoggingEvent logRecord) {
public void append(LogEvent logRecord) {
if (logRecord.getMessage() == null) return;
String message = logRecord.getMessage().toString();
val m = LOG_TYPE_PATTERN.matcher(message);
@ -42,16 +49,6 @@ public class TownyAnnouncer {
break;
}
}
@Override
public void close() throws SecurityException {
}
@Override
public boolean requiresLayout() {
return false;
}
};
private static TBMCSystemChatEvent.BroadcastTarget target;
@ -62,7 +59,7 @@ public class TownyAnnouncer {
target = TBMCSystemChatEvent.BroadcastTarget.add("towny");
TownyAnnouncer.townChannel = townChannel;
TownyAnnouncer.nationChannel = nationChannel;
LogManager.getLogger("com.palmergames.bukkit.towny").addAppender(HANDLER);
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().getConfiguration().addAppender(HANDLER);
}
public static void setdown() {
@ -70,6 +67,6 @@ public class TownyAnnouncer {
target = null;
TownyAnnouncer.townChannel = null;
TownyAnnouncer.nationChannel = null;
LogManager.getLogger("com.palmergames.bukkit.towny").removeAppender(HANDLER);
((Logger) LogManager.getLogger("com.palmergames.bukkit.towny")).getContext().getConfiguration().getAppenders().remove(TownyAnnouncer.class.getSimpleName());
}
}