9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
Xiao-MoMi
2022-08-09 17:43:10 +08:00
parent 3b9d45c315
commit a78433cc47
3 changed files with 0 additions and 172 deletions

View File

@@ -1,93 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.competition;
import java.util.TreeSet;
public class Ranking {
private final TreeSet<CompetitionPlayer> competitionPlayers = new TreeSet<>();
public void addPlayer(String player, float score) {
CompetitionPlayer competitionPlayer = new CompetitionPlayer(player, score);
competitionPlayers.add(competitionPlayer);
}
public void addPlayer(CompetitionPlayer competitionPlayer) {
competitionPlayers.add(competitionPlayer);
}
public void removePlayer(CompetitionPlayer competitionPlayer) {
competitionPlayers.removeIf(e -> e == competitionPlayer);
}
public void clear() {
competitionPlayers.clear();
}
public boolean contains(CompetitionPlayer competitionPlayer) {
return competitionPlayers.contains(competitionPlayer);
}
public CompetitionPlayer getCompetitionPlayer(String player) {
for (CompetitionPlayer competitionPlayer : competitionPlayers) {
if (competitionPlayer.getPlayer().equals(player)) {
return competitionPlayer;
}
}
return null;
}
public String getPlayerRank(String player) {
int index = 1;
for (CompetitionPlayer competitionPlayer : competitionPlayers) {
if (competitionPlayer.getPlayer().equals(player)) {
return String.valueOf(index);
}else {
index++;
}
}
return null;
}
public CompetitionPlayer getFirst() {
return competitionPlayers.first();
}
public String getPlayerAt(int i) {
int count = 1;
for (CompetitionPlayer competitionPlayer : competitionPlayers) {
if (count == i) {
return competitionPlayer.getPlayer();
}
count++;
}
return null;
}
public float getScoreAt(int i) {
int count = 1;
for (CompetitionPlayer competitionPlayer : competitionPlayers) {
if (count == i) {
return competitionPlayer.getScore();
}
count++;
}
return -1.0f;
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.competition.reward;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.List;
public class Command implements Reward{
private final List<String> commands;
public Command(List<String> commands){
this.commands = commands;
}
@Override
public void giveReward(Player player) {
commands.forEach(command -> {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
});
}
}

View File

@@ -1,40 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.competition.reward;
import net.momirealms.customfishing.utils.AdventureManager;
import org.bukkit.entity.Player;
import java.util.List;
public class Message implements Reward{
private final List<String> messages;
public Message(List<String> messages){
this.messages = messages;
}
@Override
public void giveReward(Player player) {
if (!player.isOnline()) return;
messages.forEach(message -> {
AdventureManager.playerMessage(player, message);
});
}
}