-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Made By IToncek
committed
Apr 2, 2024
1 parent
7edcb72
commit 1688eac
Showing
10 changed files
with
321 additions
and
11 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
MP-TEST/src/main/java/space/itoncek/mptest/ImportWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package space.itoncek.mptest; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static space.itoncek.mptest.MP_TEST.pl; | ||
|
||
public class ImportWorld implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
World world = WorldCreator.name(args[0]).environment(World.Environment.NORMAL).createWorld(); | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
((Player) sender).teleportAsync(world.getHighestBlockAt(0,0).getLocation().add(0,1,0)); | ||
} | ||
}.runTaskLater(pl,20L); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ main: space.itoncek.mptest.MP_TEST | |
api-version: '1.20' | ||
commands: | ||
tptest: | ||
importw: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 46 additions & 2 deletions
48
MSG/src/main/java/space/itoncek/msg/MultiSurvivalGames.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 55 additions & 2 deletions
57
MSG/src/main/java/space/itoncek/msg/commands/StartRoundCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,69 @@ | ||
package space.itoncek.msg.commands; | ||
|
||
import com.github.puregero.multilib.MultiLib; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.TextColor; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.*; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import space.itoncek.msg.generic.Team; | ||
import space.itoncek.msg.protocol.GCRequests; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
import static space.itoncek.msg.MultiSurvivalGames.dbmgr; | ||
import static space.itoncek.msg.MultiSurvivalGames.isMaster; | ||
|
||
public class StartRoundCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (sender.hasPermission("msg.command.startround") || sender.isOp()) { | ||
if ((sender.hasPermission("msg.command.startround") || sender.isOp()) && sender instanceof Player p) { | ||
// CLAIM BEING THE MASTER | ||
if (!isMaster) { | ||
try { | ||
dbmgr.setConfigEntry("master", MultiLib.getLocalServerName()); | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} finally { | ||
MultiLib.notify("msg:gc", GCRequests.MASTER_SYNC.name()); | ||
} | ||
} | ||
|
||
try { | ||
List<Location> spawns = dbmgr.getSpawns(p.getWorld()); | ||
List<Team> teams = dbmgr.getAllTeams(); | ||
if(spawns.size() >= teams.size()) { | ||
for (int i = 0; i < teams.size(); i++) { | ||
Team team = teams.get(i); | ||
Location spawn = spawns.get(i); | ||
for (int j = 0; j < team.players.size(); j++) { | ||
Location location = spawn.clone().add(0,j*3,0); | ||
createBoxForSpawn(location); | ||
team.players.get(j).teleportAsync(location); | ||
} | ||
} | ||
} else { | ||
sender.sendMessage(Component.text("Nedostatek míst pro týmy", TextColor.color(255,0,0))); | ||
} | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
private void createBoxForSpawn(Location loc) { | ||
//FLOOR | ||
loc.clone().subtract(0,1,0).getBlock().setType(Material.GLASS); | ||
//SIDES | ||
loc.clone().add(1,1,0).getBlock().setType(Material.GLASS); | ||
loc.clone().add(-1,1,0).getBlock().setType(Material.GLASS); | ||
loc.clone().add(0,1,-1).getBlock().setType(Material.GLASS); | ||
loc.clone().add(0,1,1).getBlock().setType(Material.GLASS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
MSG/src/main/java/space/itoncek/msg/exceptions/ConfigEntryNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package space.itoncek.msg.exceptions; | ||
|
||
public class ConfigEntryNotFoundException extends Throwable { | ||
public ConfigEntryNotFoundException(String key) { | ||
super("Unable to find config entry " + key); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package space.itoncek.msg.protocol; | ||
|
||
public enum GCRequests { | ||
MASTER_SYNC, | ||
} |
Oops, something went wrong.