Significant progress

This commit is contained in:
Michael Ziluck 2019-05-30 19:24:56 -05:00
parent d22f155fb3
commit fe87356388
8 changed files with 124 additions and 10 deletions

30
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>com.alttd</groupId>
<artifactId>AltitudeTag</artifactId>
<version>0.0.1</version>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@ -28,9 +28,35 @@
<artifactId>mariadb-java-client</artifactId>
<version>2.4.1</version>
</dependency>
<!-- Power Mock JUnit -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.7.4</version>
<scope>test</scope>
</dependency>
<!-- Power Mockito -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>1.7.4</version>
<scope>test</scope>
</dependency>
<!-- Holographic Displays -->
<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>filoghost-repo</id>
<url>https://ci.filoghost.me/plugin/repository/everything/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>

View File

@ -3,6 +3,7 @@ package com.alttd.altitudetag;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class AltitudeTag extends JavaPlugin
@ -17,6 +18,21 @@ public class AltitudeTag extends JavaPlugin
public void onEnable()
{
instance = this;
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays"))
{
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
getLogger().severe("*** This plugin will be disabled. ***");
this.setEnabled(false);
return;
}
Bukkit.getScheduler().runTaskTimerAsynchronously(this, this::updateLeaderboard, 20, 10);
}
private void updateLeaderboard()
{
}
/**
@ -30,6 +46,10 @@ public class AltitudeTag extends JavaPlugin
{
UUID prev = instance.tagger;
instance.tagger = tagger;
// announce that a new person is it
Bukkit.getOnlinePlayers().stream().filter(player -> !player.getUniqueId().equals(tagger)).forEach(player -> player.sendMessage());
return prev;
}

View File

@ -52,6 +52,7 @@ public class Leaderboard
else
{
sql = "INSERT INTO Players (PlayerUuidMost, PlayerUuidLeast) VALUES (?, ?);";
}
// prepare the statement
try (PreparedStatement ps = TagConnection.getConnection().prepareStatement(sql))

View File

@ -69,6 +69,9 @@ public final class Config
updateValue(config, save, "database.timeout", DATABASE_TIMEOUT);
updateValue(config, save, "database.description", DATABASE_CONNECTION_DESCRIPTION);
// Notification information
if (save.getValue())
{
AltitudeTag.getInstance().saveConfig();

View File

@ -54,8 +54,18 @@ public enum Lang
* When the console tries to run a player-only command.
*/
ONLY_PLAYERS("only_players", "Only players can run that command."),
/**
* Sent to someone when they become it
*/
YOURE_IT("youre-it", "You're it! Try to tag someone!"),
TAGGED("tagged", "Nice tag! You're up to {tags} tags!");
/**
* When you tag someone
*/
TAGGED("tagged", "&7Nice tag! You're not it anymore. You're up to &b{tags}&7 tags!"),
/**
* Broadcast to the server when a new person becomes it.
*/
NEW_TAGGER("new_tagger", "Uh oh, {player} is it! Run!!");
private String[] message;

View File

@ -1,9 +1,12 @@
package com.alttd.altitudetag.listeners;
import com.alttd.altitudeapi.utils.CollectionUtils;
import java.util.Optional;
import java.util.UUID;
import com.alttd.altitudetag.AltitudeTag;
import com.alttd.altitudetag.configuration.Lang;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
@ -26,10 +29,21 @@ public class ConnectionListener implements Listener
{
if (event.getPlayer().getUniqueId().equals(AltitudeTag.getTagger()))
{
AltitudeTag.setTagger(CollectionUtils.randomValue(Bukkit.getOnlinePlayers()).getUniqueId());
Lang.YOURE_IT.send(event.getPlayer());
if (Bukkit.getOnlinePlayers().size() == 1)
{
AltitudeTag.setTagger(null);
}
else
{
Optional<? extends Player> optional = Bukkit.getOnlinePlayers().stream().filter(p -> p != event.getPlayer()).findAny();
if (!optional.isPresent())
{
throw new IllegalStateException("There is more than one player on but for some reason they are all: " + event.getPlayer().getUniqueId());
}
UUID uuid = optional.get().getUniqueId();
AltitudeTag.setTagger(uuid);
Lang.YOURE_IT.send(event.getPlayer());
}
}
}
}

View File

@ -5,4 +5,43 @@ database:
password: password
database: AltitudeTag
timeout: 100
description: 'Altitude Connection'
description: 'Altitude Connection'
leaderboard:
enabled: true
title: '&b&lAltitude Tag Leaderboard'
format: '&6{rank}. &e{player} &7- &e{tags}'
top: 10
location:
world: world
x: 10.0
y: 50.0
z: 10.0
notification:
sound:
enabled: false
type: ITEM_BREAK
join-delay:
enabled: true
length: 60
actionbar:
enabled: true
message: "&eTag: You're it - tag someone!"
duration: -1
title:
enabled: true
message: '&6Tag'
duration: 100
sub-title:
enabled: true
message: "&eYou're it!"
join-delay:
enabled: true
length: 60
boss-bar:
# Options: 0, 6, 10, 12, 20
segments: 0
percent: 0
message: "&eTag: You're it - tag someone!"
chat:
enabled: false
message: "&eTag: You're it - tag someone!"

View File

@ -1,4 +1,5 @@
main: com.alttd.altitudetag.AltitudeTag
name: AltitudeTag
version: ${project.version}
author: Michael Ziluck
author: Michael Ziluck
softdepend: [HolographicDisplays]