lbr = new ArrayList<>();
27 |
28 | public RSWLeaderboard() {
29 | }
30 |
31 | public void addRow(UUID uuid, String name, int o) {
32 | this.lbr.add(new RSWLeaderboardRow(uuid, name, o));
33 | }
34 |
35 | public String getIndex(int i) {
36 | if (i <= this.lbr.size()) {
37 | RSWLeaderboardRow lbr = this.lbr.get(i - 1);
38 | lbr.setPlace(i);
39 | return lbr.getText();
40 | } else {
41 | return new RSWLeaderboardRow().setPlace(i).getText();
42 | }
43 | }
44 |
45 | public enum RSWLeaderboardCategories {
46 | SOLO_WINS, SOLO_RANKED_WINS, TEAMS_WINS, TEAMS_RANKED_WINS,
47 | KILLS, DEATHS, KILLS_RANKED, DEATHS_RANKED;
48 |
49 | public String getDBName() {
50 | switch (this) {
51 | case SOLO_WINS:
52 | return "stats_wins_solo";
53 | case KILLS:
54 | return "kills";
55 | case DEATHS:
56 | return "deaths";
57 | case KILLS_RANKED:
58 | return "ranked_kills";
59 | case TEAMS_WINS:
60 | return "stats_wins_teams";
61 | case TEAMS_RANKED_WINS:
62 | return "stats_wins_ranked_teams";
63 | case DEATHS_RANKED:
64 | return "ranked_deaths";
65 | case SOLO_RANKED_WINS:
66 | return "stats_wins_ranked_solo";
67 | default:
68 | return "err";
69 | }
70 | }
71 |
72 | public int getValue(PlayerDataRow p) {
73 | switch (this) {
74 | case SOLO_WINS:
75 | return p.getStats_wins_solo();
76 | case KILLS:
77 | return p.getKills();
78 | case DEATHS:
79 | return p.getDeaths();
80 | case KILLS_RANKED:
81 | return p.getRanked_kills();
82 | case TEAMS_WINS:
83 | return p.getStats_wins_teams();
84 | case TEAMS_RANKED_WINS:
85 | return p.getStats_wins_ranked_teams();
86 | case DEATHS_RANKED:
87 | return p.getRanked_deaths();
88 | case SOLO_RANKED_WINS:
89 | return p.getStats_wins_ranked_solo();
90 | default:
91 | return -1;
92 | }
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/realskywars-api/src/main/java/joserodpt/realskywars/api/utils/CountdownTimer.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.api.utils;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.plugin.java.JavaPlugin;
5 |
6 | import java.util.function.Consumer;
7 |
8 | /**
9 | * A simple countdown timer using the Runnable interface in seconds! Great
10 | * for minigames and other shiz?
11 | *
12 | * Project created by
13 | *
14 | * @author ExpDev
15 | */
16 | public class CountdownTimer implements Runnable {
17 |
18 | // Main class for bukkit scheduling
19 | private final JavaPlugin plugin;
20 | // Seconds and shiz
21 | private final int seconds;
22 | // Actions to perform while counting down, before and after
23 | private final Consumer everySecond;
24 | private final Runnable beforeTimer;
25 | private final Runnable afterTimer;
26 | // Our scheduled task's assigned id, needed for canceling
27 | private Integer assignedTaskId;
28 | private int secondsLeft;
29 |
30 | // Construct a timer, you could create multiple so for example if
31 | // you do not want these "actions"
32 | public CountdownTimer(JavaPlugin plugin, int seconds, Runnable beforeTimer, Runnable afterTimer, Consumer everySecond) {
33 | // Initializing fields
34 | this.plugin = plugin;
35 |
36 | this.seconds = seconds;
37 | this.secondsLeft = seconds;
38 |
39 | this.beforeTimer = beforeTimer;
40 | this.afterTimer = afterTimer;
41 | this.everySecond = everySecond;
42 | }
43 |
44 | /**
45 | * Runs the timer once, decrements seconds etc... Really wish we could make it
46 | * protected/private so you couldn't access it
47 | */
48 | @Override
49 | public void run() {
50 | // Is the timer up?
51 | if (this.secondsLeft < 1) {
52 | // Do what was supposed to happen after the timer
53 | this.afterTimer.run();
54 |
55 | // Cancel timer
56 | if (this.assignedTaskId != null) Bukkit.getScheduler().cancelTask(this.assignedTaskId);
57 | return;
58 | }
59 |
60 | // Are we just starting?
61 | if (this.secondsLeft == this.seconds) this.beforeTimer.run();
62 |
63 | // Do what's supposed to happen every second
64 | this.everySecond.accept(this);
65 |
66 | // Decrement the seconds left
67 | --this.secondsLeft;
68 | }
69 |
70 | /**
71 | * Gets the total seconds this timer was set to run for
72 | *
73 | * @return Total seconds timer should run
74 | */
75 | public int getTotalSeconds() {
76 | return this.seconds;
77 | }
78 |
79 | public int getPassedSeconds() {
80 | return this.getTotalSeconds() - this.secondsLeft;
81 | }
82 |
83 | /**
84 | * Gets the seconds left this timer should run
85 | *
86 | * @return Seconds left timer should run
87 | */
88 | public int getSecondsLeft() {
89 | return this.secondsLeft;
90 | }
91 |
92 | public void killTask() {
93 | Bukkit.getScheduler().cancelTask(this.assignedTaskId);
94 | }
95 |
96 | /**
97 | * Schedules this instance to "run" every second
98 | */
99 | public void scheduleTimer() {
100 | // Initialize our assigned task's id, for later use so we can cancel
101 | this.assignedTaskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this, 0L, 20L);
102 | }
103 | }
--------------------------------------------------------------------------------
/realskywars-api/src/main/java/joserodpt/realskywars/api/map/RSWSign.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.api.map;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import joserodpt.realskywars.api.RealSkywarsAPI;
19 | import joserodpt.realskywars.api.utils.Text;
20 | import org.bukkit.Bukkit;
21 | import org.bukkit.Location;
22 | import org.bukkit.Material;
23 | import org.bukkit.block.Block;
24 | import org.bukkit.block.BlockFace;
25 | import org.bukkit.block.Sign;
26 | import org.bukkit.block.data.type.WallSign;
27 |
28 | public class RSWSign {
29 |
30 | private final RSWMap game;
31 | private final Block b;
32 |
33 | public RSWSign(RSWMap gm, Block b) {
34 | this.game = gm;
35 | this.b = b;
36 |
37 | this.update();
38 | }
39 |
40 | public void update() {
41 | if (this.game == null || RealSkywarsAPI.getInstance().getMapManagerAPI().shutdown) {
42 | return;
43 | }
44 |
45 | Bukkit.getScheduler().scheduleSyncDelayedTask(RealSkywarsAPI.getInstance().getPlugin(), () -> {
46 | if (this.getBlock().getType().name().contains("SIGN")) {
47 | Sign s = (Sign) this.getBlock().getState();
48 |
49 | s.setLine(0, RealSkywarsAPI.getInstance().getLanguageManagerAPI().getPrefix());
50 | s.setLine(1, Text.color("&b" + this.getGame().getName()));
51 | s.setLine(2, Text.color("&f" + this.getGame().getGameMode().getDefaultTranslation() + "&r&f | " + this.getGame().getPlayerCount() + "&7/&f" + this.getGame().getMaxPlayers()));
52 | s.setLine(3, Text.color("&b&l" + this.getGame().getState().getDefaultTranslation()));
53 | s.update();
54 |
55 | this.b.getWorld().getBlockAt(this.getBehindBlock().getLocation()).setType(this.getGame().getState().getStateMaterial(this.getGame().isRanked()));
56 | }
57 | });
58 | }
59 |
60 | private Block getGlass(Block b) {
61 | if (b.getState().getBlockData() instanceof WallSign) {
62 | WallSign signData = (WallSign) b.getState().getBlockData();
63 | BlockFace attached = signData.getFacing().getOppositeFace();
64 |
65 | return b.getRelative(attached);
66 | } else {
67 | return b.getRelative(BlockFace.DOWN);
68 | }
69 | }
70 |
71 | public Block getBlock() {
72 | return this.b;
73 | }
74 |
75 | public RSWMap getGame() {
76 | return this.game;
77 | }
78 |
79 | public Block getBehindBlock() {
80 | return this.getGlass(this.b);
81 | }
82 |
83 | public Location getLocation() {
84 | return this.b.getLocation();
85 | }
86 |
87 | public String getLocationSerialized() {
88 | return this.getLocation().getWorld().getName() + "<" +
89 | this.getLocation().getBlockX() + "<" +
90 | this.getLocation().getBlockY() + "<" +
91 | this.getLocation().getBlockZ();
92 | }
93 |
94 | public void delete() {
95 | Bukkit.getScheduler().scheduleSyncDelayedTask(RealSkywarsAPI.getInstance().getPlugin(), () -> {
96 | if (this.b.getType().name().contains("SIGN")) {
97 | this.b.setType(Material.AIR);
98 | }
99 | });
100 | }
101 | }
--------------------------------------------------------------------------------
/realskywars-plugin/src/main/resources/kits.yml:
--------------------------------------------------------------------------------
1 | Kits:
2 | Default:
3 | Display-Name: Default
4 | Price: 0.0
5 | Icon: LEATHER_CHESTPLATE
6 | Permission: RealSkywars.Kit
7 | Contents:
8 | - AMOUNT: 1
9 | SLOT: 0
10 | MATERIAL: WOODEN_SWORD
11 | - AMOUNT: 1
12 | SLOT: 1
13 | MATERIAL: WOODEN_SHOVEL
14 | - AMOUNT: 1
15 | SLOT: 2
16 | MATERIAL: WOODEN_PICKAXE
17 | - AMOUNT: 1
18 | SLOT: 3
19 | MATERIAL: WOODEN_AXE
20 | Ecologist:
21 | Display-Name: Ecologist
22 | Price: 10.0
23 | Icon: OAK_SAPLING
24 | Permission: RealSkywars.Kit
25 | Contents:
26 | - AMOUNT: 8
27 | SLOT: 0
28 | MATERIAL: STRIPPED_OAK_WOOD
29 | - AMOUNT: 1
30 | SLOT: 1
31 | MATERIAL: IRON_AXE
32 | - AMOUNT: 32
33 | SLOT: 2
34 | MATERIAL: OAK_SAPLING
35 | - AMOUNT: 32
36 | SLOT: 3
37 | MATERIAL: BONE_MEAL
38 | Life:
39 | Display-Name: '&aLife'
40 | Price: 10.0
41 | Icon: TOTEM_OF_UNDYING
42 | Permission: RealSkywars.Kit
43 | Contents:
44 | - AMOUNT: 1
45 | SLOT: 0
46 | MATERIAL: TOTEM_OF_UNDYING
47 | Enderman:
48 | Display-Name: '&5Enderman'
49 | Price: 10.0
50 | Icon: ENDER_EYE
51 | Permission: RealSkywars.Kit
52 | Perks:
53 | - ENDER
54 | Contents:
55 | - AMOUNT: 1
56 | SLOT: 0
57 | MATERIAL: ENDER_EYE
58 | - AMOUNT: 1
59 | SLOT: 1
60 | MATERIAL: ENDERMAN_SPAWN_EGG
61 | - AMOUNT: 1
62 | SLOT: 2
63 | MATERIAL: ENDER_CHEST
64 | - AMOUNT: 32
65 | SLOT: 3
66 | MATERIAL: END_STONE
67 | - AMOUNT: 1
68 | SLOT: 4
69 | MATERIAL: CLOCK
70 | - AMOUNT: 1
71 | SLOT: 39
72 | MATERIAL: DRAGON_HEAD
73 | Warrior:
74 | Display-Name: '&9Warrior'
75 | Price: 10.0
76 | Icon: IRON_SWORD
77 | Permission: RealSkywars.Kit
78 | Contents:
79 | - AMOUNT: 1
80 | SLOT: 0
81 | MATERIAL: IRON_SWORD
82 | - AMOUNT: 1
83 | SLOT: 1
84 | MATERIAL: BOW
85 | - AMOUNT: 32
86 | SLOT: 8
87 | MATERIAL: ARROW
88 | - AMOUNT: 1
89 | SLOT: 36
90 | MATERIAL: IRON_BOOTS
91 | - AMOUNT: 1
92 | SLOT: 37
93 | MATERIAL: GOLDEN_LEGGINGS
94 | - AMOUNT: 1
95 | SLOT: 38
96 | MATERIAL: GOLDEN_CHESTPLATE
97 | - AMOUNT: 1
98 | SLOT: 39
99 | MATERIAL: IRON_HELMET
100 | - AMOUNT: 32
101 | SLOT: 40
102 | MATERIAL: ARROW
103 | DJ:
104 | Display-Name: '&eDJ'
105 | Price: 20.0
106 | Icon: JUKEBOX
107 | Permission: RealSkywars.Kit
108 | Contents:
109 | - AMOUNT: 1
110 | SLOT: 0
111 | MATERIAL: JUKEBOX
112 | - AMOUNT: 1
113 | SLOT: 1
114 | MATERIAL: MUSIC_DISC_CAT
115 | - AMOUNT: 1
116 | SLOT: 2
117 | MATERIAL: MUSIC_DISC_BLOCKS
118 | - AMOUNT: 1
119 | SLOT: 3
120 | MATERIAL: MUSIC_DISC_CHIRP
121 | - AMOUNT: 1
122 | SLOT: 4
123 | MATERIAL: MUSIC_DISC_FAR
124 | - AMOUNT: 1
125 | SLOT: 5
126 | MATERIAL: MUSIC_DISC_MALL
127 | - AMOUNT: 1
128 | SLOT: 6
129 | MATERIAL: MUSIC_DISC_MELLOHI
130 | - AMOUNT: 1
131 | SLOT: 7
132 | MATERIAL: MUSIC_DISC_STAL
133 | - AMOUNT: 1
134 | SLOT: 8
135 | MATERIAL: MUSIC_DISC_STRAD
136 | - AMOUNT: 1
137 | SLOT: 9
138 | MATERIAL: MUSIC_DISC_WARD
139 | - AMOUNT: 1
140 | SLOT: 10
141 | MATERIAL: MUSIC_DISC_11
142 | - AMOUNT: 1
143 | SLOT: 11
144 | MATERIAL: MUSIC_DISC_WAIT
145 | - AMOUNT: 1
146 | SLOT: 12
147 | MATERIAL: MUSIC_DISC_13
--------------------------------------------------------------------------------
/realskywars-plugin/src/main/java/joserodpt/realskywars/plugin/managers/AchievementsManager.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.plugin.managers;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import joserodpt.realskywars.api.RealSkywarsAPI;
19 | import joserodpt.realskywars.api.achievements.RSWAchievement;
20 | import joserodpt.realskywars.api.achievements.types.RSWAchievementRCoin;
21 | import joserodpt.realskywars.api.config.RSWAchievementsConfig;
22 | import joserodpt.realskywars.api.managers.AchievementsManagerAPI;
23 | import joserodpt.realskywars.api.player.RSWPlayer;
24 |
25 | import java.util.ArrayList;
26 | import java.util.HashMap;
27 | import java.util.List;
28 | import java.util.Map;
29 | import java.util.Optional;
30 | import java.util.stream.Collectors;
31 |
32 | public class AchievementsManager extends AchievementsManagerAPI {
33 | private final RealSkywarsAPI rs;
34 |
35 | public AchievementsManager(RealSkywarsAPI rs) {
36 | this.rs = rs;
37 | }
38 |
39 | public Map> achievements = new HashMap<>();
40 |
41 | @Override
42 | public void loadAchievements() {
43 | int cats = 0, achi = 0;
44 | this.achievements.clear();
45 | //load coin achievements
46 | for (String dir : RSWAchievementsConfig.file().getSection("Coins").getRoutesAsStrings(false).stream()
47 | .map(Object::toString)
48 | .collect(Collectors.toSet())) {
49 | ++cats;
50 | RSWPlayer.PlayerStatistics t = null;
51 |
52 | switch (dir) {
53 | case "Kills":
54 | t = RSWPlayer.PlayerStatistics.KILLS;
55 | break;
56 | case "Wins-Solo":
57 | t = RSWPlayer.PlayerStatistics.WINS_SOLO;
58 | break;
59 | case "Wins-Teams":
60 | t = RSWPlayer.PlayerStatistics.WINS_TEAMS;
61 | break;
62 | case "Games-Played":
63 | t = RSWPlayer.PlayerStatistics.GAMES_PLAYED;
64 | break;
65 | }
66 |
67 | List achiv = new ArrayList<>();
68 |
69 | String path = "Coins." + dir;
70 | for (String meta : RSWAchievementsConfig.file().getSection(path).getRoutesAsStrings(false)) {
71 | ++achi;
72 | Double value = RSWAchievementsConfig.file().getDouble(path + "." + meta);
73 | achiv.add(new RSWAchievementRCoin(t, Integer.parseInt(meta), value));
74 | }
75 |
76 | this.achievements.put(t, achiv);
77 | }
78 |
79 | rs.getLogger().info("Loaded " + achi + " rewards for " + cats + " coin categories.");
80 | }
81 |
82 | @Override
83 | public List getAchievements(RSWPlayer.PlayerStatistics ds) {
84 | return this.achievements.get(ds);
85 | }
86 |
87 | @Override
88 | public RSWAchievement getAchievement(RSWPlayer.PlayerStatistics ps, int meta) {
89 | List list = this.achievements.get(ps);
90 | if (list != null) {
91 | Optional o = list.stream().filter(c -> c.getGoal() == meta).findFirst();
92 | if (o.isPresent()) {
93 | return o.get();
94 | }
95 | }
96 | return null;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/realskywars-api/src/main/java/joserodpt/realskywars/api/managers/world/engines/SWWorldDefaultEngine.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.api.managers.world.engines;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import joserodpt.realskywars.api.Debugger;
19 | import joserodpt.realskywars.api.RealSkywarsAPI;
20 | import joserodpt.realskywars.api.managers.WorldManagerAPI;
21 | import joserodpt.realskywars.api.managers.world.RSWWorld;
22 | import joserodpt.realskywars.api.managers.world.SWWorldEngine;
23 | import joserodpt.realskywars.api.map.RSWMap;
24 | import org.bukkit.World;
25 | import org.bukkit.WorldBorder;
26 |
27 | import java.util.Objects;
28 |
29 | public class SWWorldDefaultEngine implements SWWorldEngine {
30 |
31 | private final WorldManagerAPI wm = RealSkywarsAPI.getInstance().getWorldManagerAPI();
32 | private World world;
33 | private final RSWMap gameRoom;
34 | private final String worldName;
35 |
36 | public SWWorldDefaultEngine(World w, RSWMap gameMode) {
37 | this.worldName = w.getName();
38 | this.world = w;
39 | this.world.setAutoSave(false);
40 | this.gameRoom = gameMode;
41 | }
42 |
43 | @Override
44 | public World getWorld() {
45 | return this.world;
46 | }
47 |
48 | @Override
49 | public void resetWorld(RSWMap.OperationReason rr) {
50 | Debugger.print(SWWorldDefaultEngine.class, "Resetting " + this.getName() + " - type: " + this.getType().name());
51 |
52 | if (Objects.requireNonNull(rr) == RSWMap.OperationReason.SHUTDOWN) {//delete world
53 | this.deleteWorld(RSWMap.OperationReason.SHUTDOWN);
54 | } else {
55 | this.deleteWorld(RSWMap.OperationReason.RESET);
56 | //Copy world
57 | this.wm.copyWorld(this.getName(), WorldManagerAPI.CopyTo.ROOT);
58 |
59 | //Load world
60 | this.world = this.wm.createEmptyWorld(this.getName(), World.Environment.NORMAL);
61 | if (this.world != null) {
62 | this.world.setTime(0);
63 | this.world.setStorm(false);
64 | WorldBorder wb = this.world.getWorldBorder();
65 |
66 | wb.setCenter(this.gameRoom.getMapCuboid().getCenter());
67 | wb.setSize(this.gameRoom.getBorderSize());
68 |
69 | this.gameRoom.setState(RSWMap.MapState.AVAILABLE);
70 | } else {
71 | RealSkywarsAPI.getInstance().getLogger().severe("ERROR! Could not load " + this.getName());
72 | }
73 | }
74 | }
75 |
76 | @Override
77 | public void deleteWorld(RSWMap.OperationReason rr) {
78 | switch (rr) {
79 | case LOAD:
80 | break;
81 | case SHUTDOWN:
82 | case RESET:
83 | this.wm.deleteWorld(this.getName(), true);
84 | break;
85 | }
86 | }
87 |
88 | @Override
89 | public void setTime(long l) {
90 | this.world.setTime(l);
91 | }
92 |
93 | @Override
94 | public String getName() {
95 | return this.world != null ? this.world.getName() : this.worldName;
96 | }
97 |
98 | @Override
99 | public RSWWorld.WorldType getType() {
100 | return RSWWorld.WorldType.DEFAULT;
101 | }
102 |
103 | @Override
104 | public void save() {
105 | this.world.save();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/realskywars-api/src/main/java/joserodpt/realskywars/api/RealSkywarsAPI.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.api;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import com.google.common.base.Preconditions;
19 | import joserodpt.realskywars.api.currency.CurrencyAdapterAPI;
20 | import joserodpt.realskywars.api.managers.AchievementsManagerAPI;
21 | import joserodpt.realskywars.api.managers.DatabaseManagerAPI;
22 | import joserodpt.realskywars.api.managers.HologramManagerAPI;
23 | import joserodpt.realskywars.api.managers.KitManagerAPI;
24 | import joserodpt.realskywars.api.managers.LanguageManagerAPI;
25 | import joserodpt.realskywars.api.managers.LeaderboardManagerAPI;
26 | import joserodpt.realskywars.api.managers.LobbyManagerAPI;
27 | import joserodpt.realskywars.api.managers.MapManagerAPI;
28 | import joserodpt.realskywars.api.managers.PartiesManagerAPI;
29 | import joserodpt.realskywars.api.managers.PlayerManagerAPI;
30 | import joserodpt.realskywars.api.managers.ShopManagerAPI;
31 | import joserodpt.realskywars.api.managers.WorldManagerAPI;
32 | import joserodpt.realskywars.api.nms.RSWnms;
33 | import net.milkbowl.vault.economy.Economy;
34 | import org.bukkit.plugin.java.JavaPlugin;
35 |
36 | import java.util.Random;
37 | import java.util.logging.Logger;
38 |
39 | public abstract class RealSkywarsAPI {
40 |
41 | private static RealSkywarsAPI instance;
42 |
43 | /**
44 | * Gets instance of this API
45 | *
46 | * @return RealSkywarsAPI API instance
47 | */
48 | public static RealSkywarsAPI getInstance() {
49 | return instance;
50 | }
51 |
52 | /**
53 | * Sets the RealMinesAPI instance.
54 | * Note! This method may only be called once
55 | *
56 | * @param instance the new instance to set
57 | */
58 | public static void setInstance(RealSkywarsAPI instance) {
59 | Preconditions.checkNotNull(instance, "instance");
60 | Preconditions.checkArgument(RealSkywarsAPI.instance == null, "Instance already set");
61 | RealSkywarsAPI.instance = instance;
62 | }
63 |
64 | public abstract Logger getLogger();
65 |
66 | public abstract String getVersion();
67 |
68 | public abstract RSWnms getNMS();
69 |
70 | public abstract WorldManagerAPI getWorldManagerAPI();
71 |
72 | public abstract RSWEventsAPI getEventsAPI();
73 |
74 | public abstract LanguageManagerAPI getLanguageManagerAPI();
75 |
76 | public abstract PlayerManagerAPI getPlayerManagerAPI();
77 |
78 | public abstract MapManagerAPI getMapManagerAPI();
79 |
80 | public abstract LobbyManagerAPI getLobbyManagerAPI();
81 |
82 | public abstract ShopManagerAPI getShopManagerAPI();
83 |
84 | public abstract KitManagerAPI getKitManagerAPI();
85 |
86 | public abstract PartiesManagerAPI getPartiesManagerAPI();
87 |
88 | public abstract Random getRandom();
89 |
90 | public abstract DatabaseManagerAPI getDatabaseManagerAPI();
91 |
92 | public abstract LeaderboardManagerAPI getLeaderboardManagerAPI();
93 |
94 | public abstract AchievementsManagerAPI getAchievementsManagerAPI();
95 |
96 | public abstract HologramManagerAPI getHologramManagerAPI();
97 |
98 | public abstract CurrencyAdapterAPI getCurrencyAdapterAPI();
99 |
100 | public abstract JavaPlugin getPlugin();
101 |
102 | public abstract String getServerVersion();
103 |
104 | public abstract String getSimpleServerVersion();
105 |
106 | public abstract boolean hasNewUpdate();
107 |
108 | public abstract void reload();
109 |
110 | public abstract Economy getVaultEconomy();
111 | }
112 |
--------------------------------------------------------------------------------
/realskywars-plugin/src/main/java/joserodpt/realskywars/plugin/managers/LobbyManager.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.plugin.managers;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import joserodpt.realskywars.api.RealSkywarsAPI;
19 | import joserodpt.realskywars.api.config.RSWConfig;
20 | import joserodpt.realskywars.api.config.TranslatableLine;
21 | import joserodpt.realskywars.api.managers.LobbyManagerAPI;
22 | import joserodpt.realskywars.api.player.RSWPlayer;
23 | import joserodpt.realskywars.api.player.RSWPlayerItems;
24 | import org.bukkit.Bukkit;
25 | import org.bukkit.Location;
26 | import org.bukkit.World;
27 | import org.bukkit.entity.Player;
28 |
29 | public class LobbyManager extends LobbyManagerAPI {
30 |
31 | public RealSkywarsAPI rsa;
32 |
33 | public LobbyManager(RealSkywarsAPI rsa) {
34 | this.rsa = rsa;
35 | }
36 |
37 | private Location lobbyLOC;
38 | private Boolean loginTP = true;
39 |
40 | @Override
41 | public void loadLobby() {
42 | this.loginTP = RSWConfig.file().getBoolean("Config.Auto-Teleport-To-Lobby");
43 | if (RSWConfig.file().isSection("Lobby")) {
44 | double x = RSWConfig.file().getDouble("Lobby.X");
45 | double y = RSWConfig.file().getDouble("Lobby.Y");
46 | double z = RSWConfig.file().getDouble("Lobby.Z");
47 | float yaw = RSWConfig.file().getFloat("Lobby.Yaw");
48 | float pitch = RSWConfig.file().getFloat("Lobby.Pitch");
49 | World world = Bukkit.getServer().getWorld(RSWConfig.file().getString("Lobby.World"));
50 | this.lobbyLOC = new Location(world, x, y, z, yaw, pitch);
51 | }
52 | }
53 |
54 | @Override
55 | public void tpToLobby(Player player) {
56 | if (this.lobbyLOC != null && player != null) {
57 | try {
58 | player.teleport(this.lobbyLOC);
59 | } catch (Exception e) {
60 | rsa.getLogger().warning("Error while teleporting player to lobby: " + e.getMessage());
61 | }
62 | }
63 | }
64 |
65 | @Override
66 | public void tpToLobby(RSWPlayer p) {
67 | if (this.lobbyLOC != null && p != null) {
68 | tpToLobby(p.getPlayer());
69 | TranslatableLine.LOBBY_TELEPORT.send(p, true);
70 | RSWPlayerItems.LOBBY.giveSet(p);
71 | } else {
72 | TranslatableLine.LOBBY_NOT_SET.send(p, true);
73 | }
74 | }
75 |
76 | @Override
77 | public Location getLobbyLocation() {
78 | return this.lobbyLOC;
79 | }
80 |
81 | @Override
82 | public boolean scoreboardInLobby() {
83 | return RSWConfig.file().getBoolean("Config.Scoreboard-In-Lobby");
84 | }
85 |
86 | @Override
87 | public void setLobbyLoc(Location location) {
88 | this.lobbyLOC = location;
89 | //give everyone items again
90 |
91 | for (Player p : location.getWorld().getPlayers()) {
92 | RSWPlayer rswPlayer = rsa.getPlayerManagerAPI().getPlayer(p);
93 | if (rswPlayer != null) {
94 | RSWPlayerItems.LOBBY.giveSet(rswPlayer);
95 | }
96 | }
97 | }
98 |
99 | @Override
100 | public boolean tpLobbyOnJoin() {
101 | return loginTP && this.lobbyLOC != null;
102 | }
103 |
104 | @Override
105 | public boolean isInLobby(World w) {
106 | if (w == null || this.lobbyLOC == null || this.lobbyLOC.getWorld() == null) {
107 | return false;
108 | }
109 | return this.lobbyLOC != null && this.lobbyLOC.getWorld().equals(w);
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/realskywars-api/src/main/java/joserodpt/realskywars/api/nms/NMS114R1tov116R3.java:
--------------------------------------------------------------------------------
1 | package joserodpt.realskywars.api.nms;
2 |
3 | /*
4 | * _____ _ _____ _
5 | * | __ \ | |/ ____| |
6 | * | |__) |___ __ _| | (___ | | ___ ___ ____ _ _ __ ___
7 | * | _ // _ \/ _` | |\___ \| |/ / | | \ \ /\ / / _` | '__/ __|
8 | * | | \ \ __/ (_| | |____) | <| |_| |\ V V / (_| | | \__ \
9 | * |_| \_\___|\__,_|_|_____/|_|\_\\__, | \_/\_/ \__,_|_| |___/
10 | * __/ |
11 | * |___/
12 | *
13 | * Licensed under the MIT License
14 | * @author José Rodrigues © 2019-2025
15 | * @link https://github.com/joserodpt/RealSkywars
16 | */
17 |
18 | import joserodpt.realskywars.api.RealSkywarsAPI;
19 | import org.bukkit.Location;
20 | import org.bukkit.Material;
21 | import org.bukkit.block.Block;
22 | import org.bukkit.inventory.ItemStack;
23 |
24 | import java.lang.reflect.InvocationTargetException;
25 | import java.lang.reflect.Method;
26 |
27 | public class NMS114R1tov116R3 implements RSWnms {
28 | private final Class> world = ReflectionHelper.getNMSClass("World");
29 | private final Class> craft_world = ReflectionHelper.getCraftBukkitClass("CraftWorld");
30 | private final Class> block_pos = ReflectionHelper.getNMSClass("BlockPosition");
31 | private final Class> i_block_data = ReflectionHelper.getNMSClass("IBlockData");
32 | private final Class> block_class = ReflectionHelper.getNMSClass("Block");
33 |
34 | @Override
35 | public void playChestAnimation(Block block, boolean open) {
36 | final Location location = block.getLocation();
37 | try {
38 | final Object invoke = craft_world.getMethod("getHandle").invoke(location.getWorld());
39 | assert block_pos != null;
40 | final Object instance = block_pos.getConstructor(Double.TYPE, Double.TYPE, Double.TYPE).newInstance(location.getX(), location.getY(), location.getZ());
41 | assert world != null;
42 | assert i_block_data != null;
43 | world.getMethod("playBlockAction", block_pos, block_class, Integer.TYPE, Integer.TYPE).invoke(invoke, instance, i_block_data.getMethod("getBlock").invoke(world.getMethod("getType", block_pos).invoke(invoke, instance)), 1, open ? 1 : 0);
44 | } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException |
45 | InstantiationException ex) {
46 | RealSkywarsAPI.getInstance().getLogger().severe("Error while executing chest animation nms.");
47 | RealSkywarsAPI.getInstance().getLogger().severe(ex.toString());
48 | }
49 | }
50 |
51 | private final Class> craft_item_stack = ReflectionHelper.getCraftBukkitClass("inventory.CraftItemStack");
52 | private final Class> nms_item_stack = ReflectionHelper.getNMSClass("ItemStack");
53 | private final Class> locale_language = ReflectionHelper.getNMSClass("LocaleLanguage");
54 | private final Class> i_chat_base_component = ReflectionHelper.getNMSClass("IChatBaseComponent");
55 | private final Class> chat_serializer = ReflectionHelper.getNMSClass("IChatBaseComponent$ChatSerializer");
56 |
57 | @Override
58 | public String getItemName(Material mat) {
59 | try {
60 | Object nmsStack = craft_item_stack.getMethod("asNMSCopy", ItemStack.class).invoke(null, new ItemStack(mat));
61 | Object itemName = nms_item_stack.getMethod("getItem").invoke(nmsStack);
62 |
63 | Method getNameMethod = locale_language.getMethod("a", i_chat_base_component);
64 |
65 | Object json = nms_item_stack.getMethod("C").invoke(itemName);
66 | Object localeLanguageInstance = locale_language.getMethod("a").invoke(null);
67 |
68 | String jsonString = chat_serializer.getMethod("a", i_chat_base_component).invoke(null, json).toString();
69 | return (String) getNameMethod.invoke(localeLanguageInstance, jsonString);
70 | } catch (Exception ex) {
71 | RealSkywarsAPI.getInstance().getLogger().severe("Error while executing getItemName nms.");
72 | RealSkywarsAPI.getInstance().getLogger().severe(ex.toString());
73 | return "-";
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/realskywars-plugin/src/main/resources/config.yml:
--------------------------------------------------------------------------------
1 | Version: 13
2 | Debug-Mode: false
3 | Config:
4 | Prefix: "&fReal&bSkywars &7> &r"
5 | Languages:
6 | Default-Language: en_us
7 | Strings:
8 | Events:
9 | REFILL: "&aRefill"
10 | TNTRAIN: "&cTNT &fRain"
11 | BORDERSHRINK: "&5End"
12 | Boss-Bar:
13 | Wait: "&fWaiting players."
14 | End: "&fThe match ended."
15 | DeathMatch: "&5Deathmatch"
16 | Run-Time: "&fTime left : &b%time%"
17 | Starting: "&fStarting in &b%time% &fsecond(s)"
18 | Admin-Shutdown: "&cAn admin shutdown all games."
19 | BungeeCord:
20 | Full: "&cThis map is full. &7Please try another one."
21 | No-Available-Maps: "&cThere are currently no available maps. &7Please try again later."
22 | Kick-Message: "&7Connecting to the lobby..."
23 | Resetting: "&cThis map is resetting. &7Please try again later."
24 | Search:
25 | Not-Found: "&aEmpty"
26 | Menus:
27 | Filter-Button:
28 | Title: "&bFilter"
29 | Description: "&fClick here to filter itens on this page."
30 | Next-Button:
31 | Title: "&aNext"
32 | Description: "&fClick here to go next."
33 | Back-Button:
34 | Title: "&ePrevious"
35 | Description: "&fClick here to go back."
36 | Main-Menu-Button:
37 | Title: "&9Menu"
38 | Description: "&fClick here to go to the main menu."
39 | Bungeecord:
40 | Enabled: false
41 | Kick-Player: true
42 | Lobby-Server: lobby
43 | Map-State-As-Motd: false
44 | Use-Vault-As-Currency: false
45 | Invincibility-Seconds: 3
46 | Auto-Teleport-To-Lobby: true
47 | Scoreboard-In-Lobby: true
48 | Enable-Tab-Formatting: true
49 | Enable-Chat-Per-Map: false
50 | Disable-Chest-Animation: false
51 | Shops:
52 | Enable-Shop: true
53 | Enable-Spectator-Shop: true
54 | Enable-Kit-Shop: true
55 | Only-Buy-Kits-Per-Match: false
56 | Enable-Cage-Block-Shop: true
57 | Enable-Win-Block-Shop: true
58 | Enable-Bow-Particles-Shop: true
59 | Right-Click-Player-Info: true
60 | PlaceholderAPI-In-Scoreboard: false
61 | PlaceholderAPI-In-Tab: false
62 | Disable-Player-Reset: false
63 | Disable-Language-Selection: false
64 | Disable-Lobby-Items: false
65 | Disable-Lobby-Void-Teleport: false
66 | Disable-Map-Starting-Countdown:
67 | Message: false
68 | Actionbar: false
69 | Item-Slots:
70 | Lobby:
71 | Profile: 0
72 | Maps: 4
73 | Shop: 8
74 | Cage:
75 | Kit: 1
76 | Vote: 4
77 | Leave: 7
78 | Spectator:
79 | Spectate: 1
80 | Play-Again: 2
81 | Shop: 4
82 | Leave: 7
83 | Setup:
84 | Cage: 1
85 | Chest1: 3
86 | Chest2: 4
87 | Settings: 6
88 | Save: 7
89 | # Time in seconds
90 | Time:
91 | Formatting: dd-MM-yyyy HH:mm:ss
92 | Offset: 0
93 | Time-To-Start: 10
94 | Min-Players-ToStart: 2
95 | Time-EndGame: 10
96 | Refresh-Leaderboards: 600
97 | Vote-Before-Seconds: 3
98 | Death-Match-Shrink-Factor: 2
99 | Maximum-Game-Time:
100 | Solo: 300
101 | Teams: 500
102 | Shuffle-Items-In-Chest: true
103 | Kits:
104 | Ender-Pearl-Perk-Give-Interval: 120
105 | Default-Refill-Time: 180
106 | # Events: REFILL, TNTRAIN
107 | # REFILL refills the chests.
108 | # TNTRAIN, when executed, summons a TNT above all game players.
109 | # Event Config: @