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"
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>
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>
<parent>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>CorePOM</artifactId>
<version>master-SNAPSHOT</version>
</parent>
<version>0.0.1-SNAPSHOT</version>
<name>Chroma-Chat Plugin</name>
<description>Chroma-Chat Plugin</description>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.properties</include>
<include>*.yml</include>
<include>*.csv</include>
<include>*.txt</include>
</includes>
<filtering>true</filtering>
<version>v${noprefix.version}-SNAPSHOT</version>
<name>Chroma-Chat Plugin</name>
<description>Chroma-Chat Plugin</description>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.properties</include>
<include>*.yml</include>
<include>*.csv</include>
<include>*.txt</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<finalName>Chroma-Chat</finalName>
@ -72,49 +72,6 @@
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
</configuration>
</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>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
@ -170,7 +127,7 @@
<dependency>
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
<artifactId>Chroma-Core</artifactId>
<version>${branch}-SNAPSHOT</version>
<version>v1.0.0</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
@ -204,7 +161,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
@ -254,23 +211,6 @@
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
<github.global.server>githubo</github.global.server>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<branch>
master
</branch> <!-- Should be master if building ButtonCore locally - the CI will overwrite it (see below) -->
<noprefix.version>1.0.0</noprefix.version>
</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>

View file

@ -9,7 +9,7 @@ import buttondevteam.lib.player.TBMCPlayerBase;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@PlayerClass(pluginname = "Button1Chat")
@PlayerClass(pluginname = "Chroma-Chat")
public class ChatPlayer extends TBMCPlayerBase {
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
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!");
return true;
}

View file

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

View file

@ -40,6 +40,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
private UnlolCommand command;
private TBMCSystemChatEvent.BroadcastTarget unlolTarget;
private TBMCSystemChatEvent.BroadcastTarget fTarget;
private final Random random = new Random();
/**
* The strings that count as laughs, see unlol.
@ -66,7 +67,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
val pc = new PressCommand();
registerCommand(pc);
registerListener(pc);
registerCommand(command=new UnlolCommand(unlolTarget));
registerCommand(command = new UnlolCommand(unlolTarget));
registerListener(this);
registerCommand(new FTopCommand());
registerCommand(new OpmeCommand());
@ -106,7 +107,7 @@ public class FunComponent extends Component<PluginMain> implements Listener {
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
// 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 = () -> {
if (ActiveF) {
ActiveF = false;

View file

@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
"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 colors will split the name evenly but residents can override that with /u ncolor.", //
}) // TODO: /u u when annotation not present
})
@RequiredArgsConstructor
public class TownColorCommand extends UCommandBase {
private final TownColorComponent component;

View file

@ -44,22 +44,22 @@ public class TownColorComponent extends Component<PluginMain> implements Listene
/**
* 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
*/
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.
*/
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.
* 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
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 colors will split the name evenly.", //
})
public class TownColorCommand extends AdminCommandBase { //TODO: Command path aliases
public class TownColorCommand extends AdminCommandBase {
@Command2.Subcommand
public boolean def(CommandSender sender, String town, String... colornames) {
if (!TownyComponent.dataSource.hasTown(town)) {

View file

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

View file

@ -31,7 +31,7 @@ public class PlayerListener implements Listener {
/**
* 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)
public void onPlayerChat(AsyncPlayerChatEvent event) {