mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-07-06 07:16:41 +00:00
Some stuff
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
package fns.fossil;
|
||||
|
||||
import fns.fossil.cmd.CakeCommand;
|
||||
import fns.fossil.reactions.ReactionSystem;
|
||||
import fns.fossil.trail.Trailer;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.command.CommandHandler;
|
||||
@ -33,6 +34,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class Fossil extends JavaPlugin
|
||||
{
|
||||
private final Trailer trailer = new Trailer();
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
|
@ -37,11 +37,17 @@ import net.kyori.adventure.bossbar.BossBar;
|
||||
public final class CopyCatReaction extends Reaction
|
||||
{
|
||||
private final long reward;
|
||||
private final BossBar bossBar;
|
||||
|
||||
public CopyCatReaction(final long reward)
|
||||
{
|
||||
super(ReactionType.COPYCAT);
|
||||
this.reward = reward;
|
||||
this.bossBar = BossBarDisplay.builder()
|
||||
.setName(getRandomCharacterString())
|
||||
.setProgress(0.0F)
|
||||
.setOverlay(BossBar.Overlay.NOTCHED_10)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,16 +59,16 @@ public final class CopyCatReaction extends Reaction
|
||||
@Override
|
||||
public void display(final Audience audience)
|
||||
{
|
||||
final BossBar bossBar = BossBarDisplay.builder()
|
||||
.setName(getRandomCharacterString())
|
||||
.setProgress(0.0F)
|
||||
.build();
|
||||
audience.showBossBar(bossBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReact(final EconomicEntity entity)
|
||||
{
|
||||
//
|
||||
entity.getEconomicData()
|
||||
.addToBalance(getReward());
|
||||
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
public String getRandomCharacterString()
|
||||
@ -79,4 +85,16 @@ public final class CopyCatReaction extends Reaction
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTimer()
|
||||
{
|
||||
if (bossBar.progress() >= 1.0F)
|
||||
{
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
bossBar.progress(bossBar.progress() + 0.1F);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of FreedomNetworkSuite - https://github.com/SimplexDevelopment/FreedomNetworkSuite
|
||||
* Copyright (C) 2023 Simplex Development and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package fns.fossil.reactions;
|
||||
|
||||
import fns.fossil.Fossil;
|
||||
import fns.patchwork.base.Registration;
|
||||
import fns.patchwork.base.Shortcuts;
|
||||
import fns.patchwork.provider.SubscriptionProvider;
|
||||
import fns.patchwork.service.Task;
|
||||
import fns.patchwork.service.TaskSubscription;
|
||||
import java.time.Duration;
|
||||
|
||||
public class ReactionSystem
|
||||
{
|
||||
public static void startCopyCat()
|
||||
{
|
||||
final Fossil fossil = Shortcuts.provideModule(Fossil.class);
|
||||
final TaskSubscription<CopyCatReaction> subscription =
|
||||
SubscriptionProvider.runSyncTask(fossil, new CopyCatReaction(25L));
|
||||
|
||||
Registration.getServiceTaskRegistry().registerTask(subscription);
|
||||
Registration.getServiceTaskRegistry().startTask(CopyCatReaction.class);
|
||||
}
|
||||
|
||||
private static final class SystemTask extends Task
|
||||
{
|
||||
private SystemTask()
|
||||
{
|
||||
super("sys-task", 0L, Duration.ofMinutes(15L));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
ReactionSystem.startCopyCat();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user