Skip to content

Commit

Permalink
🌓 Day time configurable in ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
nkomarn committed Mar 15, 2020
1 parent 3166780 commit ebdfb17
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 28 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --settings settings.xml deploy
- name: Upload Artifact
uses: actions/upload-artifact@v2-preview
with:
name: Harbor
path: target/
#- name: Upload Artifact
# uses: actions/upload-artifact@v2-preview
# with:
# name: Harbor
# path: target/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/.idea
*.iml
/target
settings.json
dependency-reduced-pom.xml
80 changes: 80 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>

<head>
<title>Harbor - A Sleep Enhancement Plugin for Spigot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style>
@import url('https://fonts.googleapis.com/css?family=Karla:400,700&display=swap');

* {
font-family: 'Karla', sans-serif;
}

body {
background-color: #F5F5F5;
padding: 4em 0;
}

.logo {
width: 7em;
padding-right: 1em;
padding-bottom: 1em;
float: left;
}

.beta-builds {
font-weight: 700;
padding: 0;
margin: 0;
}

.heading {
padding-bottom: 4em;
}

.code-block {
padding: 1em;
margin: 0 auto;
display: block;
}
</style>
</head>

<body>
<div class="container">
<div class="heading">
<img class="logo" src="https://github.com/nkomarn/SpigotImages/blob/master/Harbor/Icon.png?raw=true">
<h3 style="padding: 0; margin: 0; padding-top: 0.3em;">Harbor</h3>
<h3 class="beta-builds">Beta Builds</h3>
</div>

<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">Build</th>
<th scope="col">Released</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://pkg.githubusercontent.com/150201575/13dfbd80-618b-11ea-89f4-eed0e81592cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200308%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200308T225714Z&X-Amz-Expires=300&X-Amz-Signature=62046650b9a50d50e3dd5a0cf48c076a44bebe3924e226fd0eae839dd3611e25&X-Amz-SignedHeaders=host&actor_id=22900187&response-content-disposition=filename%3DHarbor-1.6.2.jar&response-content-type=application%2Foctet-stream">Harbor 1.6.2 Beta 2</a></td>
<td>3/8/2020</td>
</tr>
</tbody>
</table>
</div>

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.nkomarn</groupId>
<artifactId>Harbor</artifactId>
<version>1.6.2</version>
<version>1.6.2-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/xyz/nkomarn/Harbor/Harbor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.earth2me.essentials.Essentials;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.nkomarn.Harbor.command.HarborCommand;
import xyz.nkomarn.Harbor.listener.AfkListener;
Expand All @@ -22,9 +23,10 @@ public void onEnable() {
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this,
new Checker(), 0L, Config.getInteger("values.timer") * 20);

final PluginManager pluginManager = getServer().getPluginManager();
getCommand("harbor").setExecutor(new HarborCommand());
getServer().getPluginManager().registerEvents(new JoinListener(), this);
getServer().getPluginManager().registerEvents(new BedListener(), this);
pluginManager.registerEvents(new JoinListener(), this);
pluginManager.registerEvents(new BedListener(), this);

// bStats
new Metrics(this);
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/xyz/nkomarn/Harbor/command/HarborCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
Expand All @@ -33,11 +28,6 @@ public boolean onCommand(final CommandSender sender, final Command command, fina
if (args.length < 1) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "&7Harbor version "
+ Harbor.version + " by TechToolbox (@nkomarn)."));

BossBar bar = Bukkit.createBossBar("AAAAAAAAAAAA", BarColor.BLUE, BarStyle.SOLID);
bar.setProgress(1);
bar.addPlayer((Player) sender); // TODO remove

return true;
}

Expand All @@ -46,7 +36,8 @@ public boolean onCommand(final CommandSender sender, final Command command, fina
+ Config.getString("messages.miscellaneous.permission")));
return true;
}
else if (args[0].equalsIgnoreCase("reload")) {

if (args[0].equalsIgnoreCase("reload")) {
Harbor.instance.reloadConfig();
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix
+ "&7Reloaded configuration."));
Expand All @@ -69,8 +60,6 @@ else if (args[0].equalsIgnoreCase("forceskip")) {
return true;
}
else if (args[0].equalsIgnoreCase("update")) {

// Fancy actionbar stuff
if (sender instanceof Player) {
Player player = (Player) sender;
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public AccelerateNightTask(final World world) {
@Override
public void run() {
final long time = world.getTime();
if (!(time >= 450 && time <= 1000)) {
world.setTime(time + Config.getInteger("values.interval"));
final int interval = Config.getInteger("values.interval");
final int dayTime = Config.getInteger("values.day-time");

if (!(time >= (dayTime - interval * 2) && time <= dayTime)) {
world.setTime(time + interval);
} else {
// Announce night skip and clear queue
Messages.sendRandomChatMessage(world, "messages.chat.skipped");
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/xyz/nkomarn/Harbor/task/Checker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;

import xyz.nkomarn.Harbor.Harbor;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/xyz/nkomarn/Harbor/util/Afk.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.nkomarn.Harbor.util;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import xyz.nkomarn.Harbor.Harbor;

Expand Down
1 change: 0 additions & 1 deletion src/main/java/xyz/nkomarn/Harbor/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import xyz.nkomarn.Harbor.Harbor;
import xyz.nkomarn.Harbor.task.Checker;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ values:
timer: 2 # How often (in seconds) to run the clock task (used to detect sleep, AFK players, time actionbar, etc.)
percent: 50 # Percent of players that need to sleep to skip night (must be between 0 to 100)
interval: 60 # Time skip interval that is added when the night is accelerated.
day-time: 1000 # Time (in ticks) that Harbor considers as day
timeout: 15 # Time (in minutes) until a player is considered AFK (for internal AFK detection system only- when Essentials isn't present)

features:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Harbor
description: Harbor is a Spigot plugin that redefines how sleep works in your server, making it easier for all the online players to get in bed quickly and skip through the night!
main: xyz.nkomarn.Harbor.Harbor
version: 1.6.2
version: 1.6.2-SNAPSHOT
author: TechToolbox (@nkomarn)
website: https://nkomarn.xyz
softdepend: [Essentials, PlaceholderAPI]
Expand Down

0 comments on commit ebdfb17

Please sign in to comment.