Search in sources :

Example 16 with ConcurrencyManager

use of net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager in project FunnyGuilds by FunnyGuilds.

the class Manager method start.

public void start() {
    if (FunnyGuilds.getInstance().isDisabling()) {
        return;
    }
    if (this.task != null) {
        return;
    }
    FunnyGuilds funnyGuilds = FunnyGuilds.getInstance();
    ConcurrencyManager concurrencyManager = funnyGuilds.getConcurrencyManager();
    long interval = this.getSettings().dataInterval * 60 * 20;
    DataSaveRequest saveRequest = new DataSaveRequest();
    this.task = Bukkit.getScheduler().runTaskTimerAsynchronously(funnyGuilds, () -> concurrencyManager.postRequests(saveRequest), interval, interval);
}
Also used : FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) DataSaveRequest(net.dzikoysk.funnyguilds.concurrency.requests.DataSaveRequest)

Example 17 with ConcurrencyManager

use of net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager in project FunnyGuilds by FunnyGuilds.

the class PlayerJoin method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    User user = User.get(player);
    PluginConfig config = Settings.getConfig();
    if (config.playerlistEnable && !AbstractTablist.hasTablist(player)) {
        AbstractTablist.createTablist(config.playerList, config.playerListHeader, config.playerListFooter, config.playerListPing, player);
    }
    user.getScoreboard();
    /*
        IndependentThread.actions(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
        IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, user);
        IndependentThread.actions(ActionType.RANK_UPDATE_USER, user);
         */
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player), new DummyGlobalUpdateUserRequest(user), new RankUpdateUserRequest(user));
    this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, () -> {
        PacketExtension.registerPlayer(player);
        Version.isNewAvailable(player, false);
        Region region = RegionUtils.getAt(player.getLocation());
        if (region == null || region.getGuild() == null) {
            return;
        }
        if (config.createEntityType != null) {
            EntityUtil.spawn(region.getGuild(), player);
        }
    }, 30L);
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) Player(org.bukkit.entity.Player) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) User(net.dzikoysk.funnyguilds.basic.User) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) RankUpdateUserRequest(net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateUserRequest) Region(net.dzikoysk.funnyguilds.basic.Region) DummyGlobalUpdateUserRequest(net.dzikoysk.funnyguilds.concurrency.requests.dummy.DummyGlobalUpdateUserRequest) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)17 Guild (net.dzikoysk.funnyguilds.basic.Guild)11 User (net.dzikoysk.funnyguilds.basic.User)11 Player (org.bukkit.entity.Player)10 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)9 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)6 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)6 Region (net.dzikoysk.funnyguilds.basic.Region)4 PrefixGlobalUpdatePlayer (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer)4 ConcurrencyTask (net.dzikoysk.funnyguilds.concurrency.ConcurrencyTask)3 ConcurrencyTaskBuilder (net.dzikoysk.funnyguilds.concurrency.ConcurrencyTaskBuilder)3 PrefixGlobalAddPlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest)3 PrefixGlobalRemovePlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemovePlayerRequest)3 RankUpdateUserRequest (net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateUserRequest)3 DummyGlobalUpdateUserRequest (net.dzikoysk.funnyguilds.concurrency.requests.dummy.DummyGlobalUpdateUserRequest)2 PrefixGlobalUpdateRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdateRequest)2 PrefixUpdateGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixUpdateGuildRequest)2 GuildMemberJoinEvent (net.dzikoysk.funnyguilds.event.guild.member.GuildMemberJoinEvent)2 GuildMemberKickEvent (net.dzikoysk.funnyguilds.event.guild.member.GuildMemberKickEvent)2 Block (org.bukkit.block.Block)2