Skip to content

Commit

Permalink
XMerge branch 'Misat11-refactor/slib-2.0.3' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
boiscljo committed Sep 19, 2023
2 parents 7c65e32 + b7a9b3d commit b093ad9
Show file tree
Hide file tree
Showing 78 changed files with 418 additions and 1,040 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import lombok.Data;
import org.screamingsandals.bedwars.api.game.Game;
import org.screamingsandals.bedwars.api.game.GameStatus;
import org.screamingsandals.lib.tasker.DefaultThreads;
import org.screamingsandals.lib.tasker.Tasker;
import org.screamingsandals.lib.tasker.TaskerTime;
import org.screamingsandals.lib.tasker.task.TaskerTask;
import org.screamingsandals.lib.tasker.task.Task;

import java.util.UUID;

Expand All @@ -17,7 +18,7 @@ public abstract class BaseGameTask {
protected Game game;
private long duration;
private TaskerTime timeUnit;
private TaskerTask task;
private Task task;
private boolean started;

public BaseGameTask() {
Expand All @@ -32,7 +33,7 @@ public BaseGameTask start(IArena arena) {
if (task != null) {
task.cancel();
}
task = Tasker.build(this::loopLogic).repeat(duration, timeUnit).start();
task = Tasker.runRepeatedly(DefaultThreads.GLOBAL_THREAD, this::loopLogic, duration, timeUnit);
return this;
}

Expand Down
12 changes: 4 additions & 8 deletions api/src/main/java/io/github/pronze/sba/lang/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@
import io.github.pronze.sba.AddonAPI;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.minimessage.MiniMessage;

import org.screamingsandals.lib.spectator.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.lib.sender.CommandSenderWrapper;
import org.screamingsandals.lib.sender.CommandSenderWrapper.Type;
import org.screamingsandals.lib.sender.CommandSender;
import org.screamingsandals.lib.sender.CommandSender.Type;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.libs.kyori.adventure.text.ComponentLike;

@RequiredArgsConstructor(staticName = "of", access = AccessLevel.PRIVATE)
public class Message implements Cloneable {
Expand Down Expand Up @@ -237,7 +233,7 @@ public List<Component> toComponentList() {
.collect(Collectors.toList());
}

public void send(CommandSenderWrapper... wrapper) {
public void send(CommandSender... wrapper) {
// var message = toComponentList();
// for (var sender : wrapper) {
// message.forEach(sender::sendMessage);
Expand All @@ -252,7 +248,7 @@ public void send(CommandSenderWrapper... wrapper) {
}
}

public void send(List<CommandSenderWrapper> wrapperList) {
public void send(List<CommandSender> wrapperList) {

wrapperList.forEach(receiver -> {
Player target = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import lombok.Getter;
import lombok.Setter;
import org.screamingsandals.bedwars.Main;
import org.screamingsandals.lib.player.PlayerMapper;
import org.screamingsandals.lib.player.Players;
import org.screamingsandals.lib.spectator.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand All @@ -19,12 +19,12 @@

@Getter
@Setter
public class SBAPlayerWrapper extends org.screamingsandals.lib.player.ExtendablePlayerWrapper {
public class SBAPlayerWrapper extends org.screamingsandals.lib.player.ExtendablePlayer {
private int shoutCooldown;
private final ToggleableSetting<PlayerSetting> settings;

public SBAPlayerWrapper(Player player) {
super(org.screamingsandals.lib.player.PlayerMapper.wrapPlayer(player));
super(Players.wrapPlayer(player));

this.shoutCooldown = 0;
this.settings = ToggleableSetting.of(PlayerSetting.class);
Expand All @@ -50,7 +50,7 @@ public void shout(Component message) {
Collection<? extends Player> receivers = Bukkit.getOnlinePlayers();
if(Main.isPlayerInGame(as(Player.class)))
receivers=Main.getInstance().getGameOfPlayer(as(Player.class)).getConnectedPlayers();
receivers.forEach(receiver->PlayerMapper.wrapPlayer(receiver).sendMessage(message));
receivers.forEach(receiver->Players.wrapPlayer(receiver).sendMessage(message));
if (getInstance().hasPermission(Permissions.SHOUT_BYPASS.getKey()) || getDefaultShoutCoolDownTime() == 0) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ KYORI_ADVENTURE_VERSION=4.11.0
KYORI_ADVENTURE_TEXT_MINIMESSAGE_VERSION=4.11.0
KYORI_ADVENTURE_PLATFORM_BUKKIT_VERSION=4.11.0
PAPI_VERSION=2.11.1
SCREAMINGLIB_VERSION=2.0.2-SNAPSHOT
SIMPLEINVENTORIES_VERSION=2.0.2-SNAPSHOT
SCREAMINGLIB_VERSION=2.0.3-SNAPSHOT
SIMPLEINVENTORIES_VERSION=2.0.3-SNAPSHOT
SCREAMING_PLUGIN_BUILDER_VERSION=1.0.76
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
BUILDCONFIG_VERSION=3.0.2
Expand Down
1 change: 1 addition & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
implementation "cloud.commandframework:cloud-annotations:" + CLOUD_COMMANDS_VERSION, {
exclude group: 'net.kyori'
}
implementation 'org.spongepowered:configurate-yaml:4.1.2'
compileOnly "net.citizensnpcs:citizens-main:2.0.31-SNAPSHOT"
}
test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,25 @@
import io.github.pronze.lib.pronzelib.scoreboards.api.PlaceholderFunction;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import io.github.pronze.lib.pronzelib.scoreboards.animations.ScoreboardAnimator;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.Objects;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.Collections;
import java.util.HashMap;

import io.github.pronze.lib.pronzelib.scoreboards.builder.ScoreboardBuilder;
import io.github.pronze.lib.pronzelib.scoreboards.data.PlaceholderData;
import io.github.pronze.lib.pronzelib.scoreboards.scoreboardr.board.BoardPlayer;
import io.github.pronze.lib.pronzelib.scoreboards.scoreboardr.board.ConfigBoard;

import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;

import io.github.pronze.lib.pronzelib.scoreboards.api.UpdateCallback;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.lib.player.PlayerMapper;
import org.screamingsandals.lib.player.PlayerWrapper;
import org.screamingsandals.lib.sidebar.Sidebar;
import org.screamingsandals.lib.sidebar.SidebarImpl;
import org.screamingsandals.lib.utils.visual.TextEntry;

import io.github.pronze.sba.utils.Logger;
import me.clip.placeholderapi.PlaceholderAPI;
import org.screamingsandals.lib.spectator.Component;
import org.screamingsandals.lib.player.Players;

public class Scoreboard {
private ConfigBoard holder;
Expand All @@ -56,7 +41,7 @@ public class Scoreboard {
private List<String> animatedTitle;
private boolean updateTaskRunning;
private boolean animationTaskRunning;
private PlayerWrapper player;
private org.screamingsandals.lib.player.Player player;
private List<String> lines;
private PlaceholderFunction papiFunction;
private final HashMap<String, Object> persistentPlaceholders;
Expand All @@ -72,7 +57,7 @@ public Scoreboard(final Player player) {
if (ScoreboardManager.getPluginInstance() == null) {
throw new NullPointerException("Plugin instance not set! call ScoreboardManager.install() first");
}
this.player = PlayerMapper.wrapPlayer(player);
this.player = Players.wrapPlayer(player);
this.holder = new ConfigBoard(player.getName());
BoardPlayer.getBoardPlayer(player).attachConfigBoard(this.holder);
this.holder.runTaskTimerAsynchronously(ScoreboardManager.getPluginInstance(), 1, 1);
Expand Down Expand Up @@ -254,7 +239,7 @@ public void setOccupyMaxWidth(final boolean occupyMaxWidth) {
this.occupyMaxWidth = occupyMaxWidth;
}

public PlayerWrapper getPlayer() {
public org.screamingsandals.lib.player.Player getPlayer() {
return player;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
package io.github.pronze.lib.pronzelib.scoreboards.data;

import io.github.pronze.lib.pronzelib.scoreboards.Scoreboard;
import org.bukkit.entity.Player;
import org.screamingsandals.lib.player.PlayerWrapper;
import org.screamingsandals.lib.player.Player;

public class PlaceholderData
{
private final PlayerWrapper player;
private final Player player;
private final Scoreboard holder;
private final String line;

public PlaceholderData(final PlayerWrapper player, final Scoreboard holder, final String line) {
public PlaceholderData(final Player player, final Scoreboard holder, final String line) {
this.player = player;
this.holder = holder;
this.line = line;
}

public PlayerWrapper getPlayer() {
public Player getPlayer() {
return this.player;
}

Expand Down
11 changes: 3 additions & 8 deletions plugin/src/main/java/io/github/pronze/sba/SBA.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.bedwars.Main;
import io.github.pronze.sba.VersionInfo;
import org.screamingsandals.bedwars.api.BedwarsAPI;
import org.screamingsandals.bedwars.api.game.Game;
import org.screamingsandals.bedwars.lib.bstats.bukkit.Metrics;
Expand All @@ -59,20 +57,17 @@
import org.screamingsandals.lib.hologram.HologramManager;
import org.screamingsandals.lib.npc.NPCManager;
import org.screamingsandals.lib.packet.PacketMapper;
import org.screamingsandals.lib.player.PlayerMapper;
import org.screamingsandals.lib.player.Players;
import org.screamingsandals.lib.plugin.PluginContainer;
import org.screamingsandals.lib.sidebar.SidebarManager;
import org.screamingsandals.lib.tasker.Tasker;
import org.screamingsandals.lib.utils.PlatformType;
import org.screamingsandals.lib.utils.annotations.Init;
import org.screamingsandals.lib.utils.annotations.Plugin;
import org.screamingsandals.lib.utils.annotations.PluginDependencies;
import org.screamingsandals.lib.utils.reflect.Reflect;
import org.screamingsandals.simpleinventories.SimpleInventoriesCore;
import io.github.pronze.lib.pronzelib.scoreboards.ScoreboardManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -308,7 +303,7 @@ public Optional<IGameStorage> getGameStorage(Game game) {
@Override
public SBAPlayerWrapper getPlayerWrapper(Player player) {
return PlayerWrapperService.getInstance().get(player)
.orElseGet(() -> PlayerMapper.wrapPlayer(player).as(SBAPlayerWrapper.class));
.orElseGet(() -> Players.wrapPlayer(player).as(SBAPlayerWrapper.class));
}

@Override
Expand All @@ -323,7 +318,7 @@ public boolean isSnapshot() {

@Override
public String getVersion() {
return getPluginDescription().getVersion();
return getPluginDescription().version();
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions plugin/src/main/java/io/github/pronze/sba/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.lib.event.EventManager;
import org.screamingsandals.lib.event.player.SPlayerJoinEvent;
import org.screamingsandals.lib.plugin.ServiceManager;
import org.screamingsandals.lib.tasker.Tasker;
import org.screamingsandals.lib.utils.annotations.Service;
import org.screamingsandals.lib.utils.annotations.ServiceDependencies;
import org.screamingsandals.lib.utils.annotations.methods.OnPostEnable;
import org.screamingsandals.lib.utils.reflect.Reflect;

Expand All @@ -27,7 +25,8 @@
import java.net.URL;
import java.util.Scanner;

@Service(dependsOn = {
@Service
@ServiceDependencies(dependsOn = {
SBAConfig.class
})
public class UpdateChecker {
Expand Down
31 changes: 0 additions & 31 deletions plugin/src/main/java/io/github/pronze/sba/commands/AICommand.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
package io.github.pronze.sba.commands;

import cloud.commandframework.annotations.Argument;
import cloud.commandframework.annotations.CommandDescription;
import cloud.commandframework.annotations.CommandMethod;
import cloud.commandframework.annotations.CommandPermission;
import io.github.pronze.sba.MessageKeys;
import io.github.pronze.sba.Permissions;
import io.github.pronze.sba.SBA;
import io.github.pronze.sba.lib.lang.LanguageService;
import io.github.pronze.sba.service.AIService;
import io.github.pronze.sba.utils.Logger;
import io.github.pronze.sba.utils.citizens.Strategy;
import io.github.pronze.sba.wrapper.SBAPlayerWrapper;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.event.DespawnReason;
import net.citizensnpcs.api.event.SpawnReason;
import net.citizensnpcs.api.npc.MemoryNPCDataStore;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.Gravity;
import net.citizensnpcs.trait.SkinTrait;
import org.screamingsandals.lib.spectator.Component;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.bedwars.Main;
import org.screamingsandals.bedwars.api.events.BedwarsPlayerDeathMessageSendEvent;
import org.screamingsandals.bedwars.api.game.GameStatus;
import org.screamingsandals.bedwars.game.TeamColor;
import org.screamingsandals.bedwars.utils.FakeDeath;
import org.screamingsandals.lib.player.PlayerMapper;
import org.screamingsandals.lib.tasker.Tasker;
import org.screamingsandals.lib.tasker.TaskerTime;
import org.screamingsandals.lib.utils.annotations.Service;
import org.screamingsandals.lib.utils.annotations.methods.OnPostEnable;
import org.screamingsandals.lib.utils.annotations.methods.OnPreDisable;

import io.github.pronze.sba.config.SBAConfig;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;

@Service
public class AICommand implements Listener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.lib.plugin.ServiceManager;
import org.screamingsandals.lib.utils.annotations.Service;
import org.screamingsandals.lib.utils.annotations.ServiceDependencies;
import org.screamingsandals.lib.utils.annotations.methods.OnEnable;

import io.github.pronze.sba.utils.Logger;
import io.github.pronze.sba.utils.SBAUtil;

import java.util.function.Function;

@Service(initAnother = {
@Service
@ServiceDependencies(initAnother = {
SBACommand.class,
GamesInvNPCCommand.class,
ShoutCommand.class,
Expand Down
Loading

0 comments on commit b093ad9

Please sign in to comment.