Fix player data plugin name, Spotbugs fixes

Also set the version
This commit is contained in:
Norbi Peti 2020-10-28 00:28:15 +01:00
parent 8e9989caee
commit 7646db4487
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
10 changed files with 45 additions and 104 deletions

112
pom.xml
View file

@ -1,32 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId> <groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>CorePOM</artifactId> <artifactId>CorePOM</artifactId>
<version>master-SNAPSHOT</version> <version>master-SNAPSHOT</version>
</parent> </parent>
<version>0.0.1-SNAPSHOT</version> <version>v${noprefix.version}-SNAPSHOT</version>
<name>Chroma-Chat Plugin</name> <name>Chroma-Chat Plugin</name>
<description>Chroma-Chat Plugin</description> <description>Chroma-Chat Plugin</description>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
<resources> <resources>
<resource> <resource>
<directory>src</directory> <directory>src</directory>
<excludes> <excludes>
<exclude>**/*.java</exclude> <exclude>**/*.java</exclude>
</excludes> </excludes>
</resource> </resource>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<includes> <includes>
<include>*.properties</include> <include>*.properties</include>
<include>*.yml</include> <include>*.yml</include>
<include>*.csv</include> <include>*.csv</include>
<include>*.txt</include> <include>*.txt</include>
</includes> </includes>
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<finalName>Chroma-Chat</finalName> <finalName>Chroma-Chat</finalName>
@ -72,49 +72,6 @@
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 --> </useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
</configuration> </configuration>
</plugin> </plugin>
<!-- <plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.5</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
*NOTE*: The default phase of revision is initialize, but in case you want to change it, you can do so by adding the phase here
<phase>initialize</phase>
<configuration>
<injectAllReactorProjects>true</injectAllReactorProjects>
</configuration>
</execution>
<execution>
<id>validate-the-git-infos</id>
<goals>
<goal>validateRevision</goal>
</goals>
*NOTE*: The default phase of validateRevision is verify, but in case you want to change it, you can do so by adding the phase here
<phase>package</phase>
<configuration>
<validationProperties>
- <validationProperty>
<name>validating git dirty</name>
<value>${git.branch}</value>
<shouldMatchTo>dev</shouldMatchTo>
</validationProperty> -
</validationProperties>
</configuration>
</execution>
</executions>
<configuration>
<injectAllReactorProjects>true</injectAllReactorProjects>
<verbose>true</verbose>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
</configuration>
</plugin> -->
<!-- <plugin> <groupId>org.basepom.maven</groupId> <artifactId>duplicate-finder-maven-plugin</artifactId>
<version>1.2.1</version> <executions> <execution> <goals> <goal>check</goal>
</goals> </execution> </executions> </plugin> -->
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<executions> <executions>
@ -170,7 +127,7 @@
<dependency> <dependency>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId> <groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>Chroma-Core</artifactId> <artifactId>Chroma-Core</artifactId>
<version>${branch}-SNAPSHOT</version> <version>v1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.ess3</groupId> <groupId>net.ess3</groupId>
@ -204,7 +161,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- <dependency> <!-- <dependency>
@ -254,23 +211,6 @@
<!-- github server corresponds to entry in ~/.m2/settings.xml --> <!-- github server corresponds to entry in ~/.m2/settings.xml -->
<github.global.server>githubo</github.global.server> <github.global.server>githubo</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<branch> <noprefix.version>1.0.0</noprefix.version>
master
</branch> <!-- Should be master if building ButtonCore locally - the CI will overwrite it (see below) -->
</properties> </properties>
<profiles>
<profile>
<id>ci</id>
<activation>
<property>
<name>env.TRAVIS_BRANCH</name>
</property>
</activation>
<properties>
<!-- Override only if necessary -->
<branch>${env.TRAVIS_BRANCH}</branch>
</properties>
</profile>
</profiles>
</project> </project>

View file

@ -9,7 +9,7 @@ import buttondevteam.lib.player.TBMCPlayerBase;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@PlayerClass(pluginname = "Button1Chat") @PlayerClass(pluginname = "Chroma-Chat")
public class ChatPlayer extends TBMCPlayerBase { public class ChatPlayer extends TBMCPlayerBase {
public final ConfigData<String> UserName = getConfig().getData("UserName", ""); public final ConfigData<String> UserName = getConfig().getData("UserName", "");

View file

@ -122,7 +122,7 @@ public class ChatProcessing {
mp = e.getUser().getAs(ChatPlayer.class); //May be null mp = e.getUser().getAs(ChatPlayer.class); //May be null
if (mp != null) { if (mp != null) {
if (System.nanoTime() - mp.LastMessageTime < 1000 * 1000 * component.minTimeBetweenMessages.get()) { //0.1s by default if (System.nanoTime() - mp.LastMessageTime < 1000L * 1000L * component.minTimeBetweenMessages.get()) { //0.1s by default
sender.sendMessage("§cYou are sending messages too quickly!"); sender.sendMessage("§cYou are sending messages too quickly!");
return true; return true;
} }

View file

@ -6,9 +6,9 @@ import java.io.Serializable;
public final class TellrawEvent<T extends TellrawEvent.Action> implements Serializable { public final class TellrawEvent<T extends TellrawEvent.Action> implements Serializable {
private static final long serialVersionUID = -1681364161210561505L; private static final long serialVersionUID = -1681364161210561505L;
private transient boolean hoverEvent; private final transient boolean hoverEvent;
private T action; private final T action;
private Object value; private final Object value;
private TellrawEvent(T action, String value) { private TellrawEvent(T action, String value) {
this.hoverEvent = action instanceof HoverAction; this.hoverEvent = action instanceof HoverAction;
@ -44,7 +44,7 @@ public final class TellrawEvent<T extends TellrawEvent.Action> implements Serial
public enum ClickAction implements Action { public enum ClickAction implements Action {
OPEN_URL("open_url"), RUN_COMMAND("run_command"), SUGGEST_COMMAND("suggest_command"); OPEN_URL("open_url"), RUN_COMMAND("run_command"), SUGGEST_COMMAND("suggest_command");
private String action; private final String action;
ClickAction(String action) { ClickAction(String action) {
this.action = action; this.action = action;
@ -58,8 +58,8 @@ public final class TellrawEvent<T extends TellrawEvent.Action> implements Serial
public enum HoverAction implements Action { public enum HoverAction implements Action {
SHOW_TEXT("show_text"), SHOW_ITEM("show_item"), SHOW_ACHIEVEMENT("show_achievement"), SHOW_ENTITY( SHOW_TEXT("show_text"), SHOW_ITEM("show_item"), SHOW_ACHIEVEMENT("show_achievement"), SHOW_ENTITY(
"show_entity"); "show_entity");
private String action; private final String action;
HoverAction(String action) { HoverAction(String action) {
this.action = action; this.action = action;

View file

@ -40,6 +40,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
private UnlolCommand command; private UnlolCommand command;
private TBMCSystemChatEvent.BroadcastTarget unlolTarget; private TBMCSystemChatEvent.BroadcastTarget unlolTarget;
private TBMCSystemChatEvent.BroadcastTarget fTarget; private TBMCSystemChatEvent.BroadcastTarget fTarget;
private final Random random = new Random();
/** /**
* The strings that count as laughs, see unlol. * The strings that count as laughs, see unlol.
@ -66,7 +67,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
val pc = new PressCommand(); val pc = new PressCommand();
registerCommand(pc); registerCommand(pc);
registerListener(pc); registerListener(pc);
registerCommand(command=new UnlolCommand(unlolTarget)); registerCommand(command = new UnlolCommand(unlolTarget));
registerListener(this); registerListener(this);
registerCommand(new FTopCommand()); registerCommand(new FTopCommand());
registerCommand(new OpmeCommand()); registerCommand(new OpmeCommand());
@ -106,7 +107,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent e) { public void onPlayerDeath(PlayerDeathEvent e) {
// MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity()); // MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity());
if (e.getDeathMessage().length() > 0 && respect.get() && new Random().nextBoolean()) { // Don't store Fs for NPCs if (e.getDeathMessage().length() > 0 && respect.get() && random.nextBoolean()) { // Don't store Fs for NPCs
Runnable tt = () -> { Runnable tt = () -> {
if (ActiveF) { if (ActiveF) {
ActiveF = false; ActiveF = false;

View file

@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
"This command allows setting a color for a town.", // "This command allows setting a color for a town.", //
"The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", // "The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", //
"The colors will split the name evenly but residents can override that with /u ncolor.", // "The colors will split the name evenly but residents can override that with /u ncolor.", //
}) // TODO: /u u when annotation not present })
@RequiredArgsConstructor @RequiredArgsConstructor
public class TownColorCommand extends UCommandBase { public class TownColorCommand extends UCommandBase {
private final TownColorComponent component; private final TownColorComponent component;

View file

@ -44,22 +44,22 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
/** /**
* Names lowercased * Names lowercased
*/ */
public static Map<String, Color[]> TownColors = new HashMap<>(); public static final Map<String, Color[]> TownColors = new HashMap<>();
/** /**
* Names lowercased - nation color gets added to town colors when needed * Names lowercased - nation color gets added to town colors when needed
*/ */
public static Map<String, Color> NationColor = new HashMap<>(); public static final Map<String, Color> NationColor = new HashMap<>();
/** /**
* The amount of town colors allowed. If more than one is used, players can change how many letters to be in a specific color using /u ncolor. * The amount of town colors allowed. If more than one is used, players can change how many letters to be in a specific color using /u ncolor.
*/ */
public ConfigData<Byte> colorCount = getConfig().getData("colorCount", (byte) 1, cc -> ((Integer) cc).byteValue(), Byte::intValue); public final ConfigData<Byte> colorCount = getConfig().getData("colorCount", (byte) 1, cc -> ((Integer) cc).byteValue(), Byte::intValue);
/** /**
* If enabled, players will have a nation-defined color in addition to town colors, white by default. * If enabled, players will have a nation-defined color in addition to town colors, white by default.
* They can change how much of each color they want with this as well. * They can change how much of each color they want with this as well.
*/ */
public ConfigData<Boolean> useNationColors = getConfig().getData("useNationColors", true); public final ConfigData<Boolean> useNationColors = getConfig().getData("useNationColors", true);
@Getter @Getter
private static TownColorComponent component; private static TownColorComponent component;

View file

@ -26,7 +26,7 @@ import java.util.stream.Collectors;
"The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", // "The town will be shown with this color on Dynmap and all players in the town will appear in chat with these colors.", //
"The colors will split the name evenly.", // "The colors will split the name evenly.", //
}) })
public class TownColorCommand extends AdminCommandBase { //TODO: Command path aliases public class TownColorCommand extends AdminCommandBase {
@Command2.Subcommand @Command2.Subcommand
public boolean def(CommandSender sender, String town, String... colornames) { public boolean def(CommandSender sender, String town, String... colornames) {
if (!TownyComponent.dataSource.hasTown(town)) { if (!TownyComponent.dataSource.hasTown(town)) {

View file

@ -50,7 +50,7 @@ public class PlayerJoinLeaveListener implements Listener {
nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), ""); nwithoutformatting = nwithoutformatting.replace("§" + nwithoutformatting.charAt(index + 1), "");
} else } else
nwithoutformatting = p.getName(); nwithoutformatting = p.getName();
PlayerListener.nicknames.forcePut(nwithoutformatting.toLowerCase(), p.getUniqueId()); //TODO: FormatterComponent PlayerListener.nicknames.forcePut(nwithoutformatting.toLowerCase(), p.getUniqueId());
if (PluginMain.Instance.storeChatHistory.get()) if (PluginMain.Instance.storeChatHistory.get())
HistoryCommand.showHistory(e.getPlayer(), null); HistoryCommand.showHistory(e.getPlayer(), null);

View file

@ -31,7 +31,7 @@ public class PlayerListener implements Listener {
/** /**
* Does not contain format codes, lowercased * Does not contain format codes, lowercased
*/ */
public static BiMap<String, UUID> nicknames = HashBiMap.create(); public static final BiMap<String, UUID> nicknames = HashBiMap.create();
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {