Update
This commit is contained in:
parent
6c4776f88a
commit
23e5740ee1
1
.gitignore
vendored
1
.gitignore
vendored
@ -152,3 +152,4 @@ fabric.properties
|
|||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
run/
|
8
.idea/.gitignore
vendored
8
.idea/.gitignore
vendored
@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
@ -21,15 +21,15 @@
|
|||||||
<option name="name" value="papermc-repo" />
|
<option name="name" value="papermc-repo" />
|
||||||
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="sonatype" />
|
|
||||||
<option name="name" value="sonatype" />
|
|
||||||
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="maven" />
|
<option name="id" value="maven" />
|
||||||
<option name="name" value="maven" />
|
<option name="name" value="maven" />
|
||||||
<option name="url" value="https://repo.rapture.pw/repository/maven-snapshots/" />
|
<option name="url" value="https://repo.rapture.pw/repository/maven-snapshots/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="sonatype" />
|
||||||
|
<option name="name" value="sonatype" />
|
||||||
|
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -9,7 +9,5 @@
|
|||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -22,7 +22,7 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
|
compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT'
|
||||||
compileOnly 'com.grinderwolf:slimeworldmanager-api:2.8.0-SNAPSHOT'
|
compileOnly 'com.grinderwolf:slimeworldmanager-api:2.10.0-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 17
|
def targetJavaVersion = 17
|
||||||
|
3
move.bat
Normal file
3
move.bat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@rem @echo off
|
||||||
|
call .\gradlew.bat build
|
||||||
|
copy /Y "x:\Java\Minecraft\BukkitBased\LetThemEatCake\build\libs\LetThemEatCake-1.0.0.jar" "x:\Java\Minecraft\BukkitBased\LetThemEatCake\run\plugins"
|
@ -2,6 +2,7 @@ package org.lunamc.letthemeatcake;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -11,10 +12,18 @@ public class Game {
|
|||||||
private boolean openStatus;
|
private boolean openStatus;
|
||||||
private List<Player> players;
|
private List<Player> players;
|
||||||
|
|
||||||
|
private BukkitTask queueTimer;
|
||||||
|
|
||||||
public Game(JavaPlugin plugin) {
|
public Game(JavaPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
openStatus = true;
|
openStatus = true;
|
||||||
players = new ArrayList<>();
|
players = new ArrayList<>();
|
||||||
|
startQueueTimer();
|
||||||
|
queueTimer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getPlayers() {
|
||||||
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,6 +32,10 @@ public class Game {
|
|||||||
* @return 0 if the player has been added, 1 if the game is full
|
* @return 0 if the player has been added, 1 if the game is full
|
||||||
*/
|
*/
|
||||||
public int addPlayer(Player player) {
|
public int addPlayer(Player player) {
|
||||||
|
if (players.size() >= 2 || queueTimer.isCancelled()) {
|
||||||
|
startQueueTimer();
|
||||||
|
}
|
||||||
|
|
||||||
players.add(player);
|
players.add(player);
|
||||||
if (players.size() == 8) {
|
if (players.size() == 8) {
|
||||||
openStatus = false;
|
openStatus = false;
|
||||||
@ -65,6 +78,17 @@ public class Game {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startQueueTimer() {
|
||||||
|
queueTimer = plugin.getServer().getScheduler().runTaskLater(
|
||||||
|
plugin,
|
||||||
|
() -> {
|
||||||
|
openStatus = false;
|
||||||
|
start();
|
||||||
|
},
|
||||||
|
200L
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
openStatus = false;
|
openStatus = false;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package org.lunamc.letthemeatcake;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GamesManager {
|
|
||||||
private static List<Game> games = new ArrayList<>();
|
|
||||||
|
|
||||||
public static void addToGame() {
|
|
||||||
for (Game game : games) {
|
|
||||||
if (game.isOpen()) {
|
|
||||||
switch (game.addPlayers()) {
|
|
||||||
case 0: {} // Success
|
|
||||||
case 1: {} // Full
|
|
||||||
case 2: {} // Success and Full
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,8 +7,14 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class JoinGameCommand implements CommandExecutor {
|
public class JoinGameCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private static List<Game> games = new ArrayList<>();
|
||||||
|
private static List<Player> playerQueue = new ArrayList<>();
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
|
|
||||||
public JoinGameCommand(JavaPlugin plugin) {
|
public JoinGameCommand(JavaPlugin plugin) {
|
||||||
@ -18,9 +24,12 @@ public class JoinGameCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (sender instanceof Player player) {
|
if (sender instanceof Player player) {
|
||||||
|
for (Game game : games) {
|
||||||
|
if (game.isOpen()) {
|
||||||
|
game.addPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package org.lunamc.letthemeatcake;
|
package org.lunamc.letthemeatcake;
|
||||||
|
|
||||||
import com.grinderwolf.swm.api.SlimePlugin;
|
import com.grinderwolf.swm.api.SlimePlugin;
|
||||||
import com.grinderwolf.swm.api.exceptions.CorruptedWorldException;
|
import com.grinderwolf.swm.api.exceptions.*;
|
||||||
import com.grinderwolf.swm.api.exceptions.NewerFormatException;
|
|
||||||
import com.grinderwolf.swm.api.exceptions.UnknownWorldException;
|
|
||||||
import com.grinderwolf.swm.api.exceptions.WorldInUseException;
|
|
||||||
import com.grinderwolf.swm.api.loaders.SlimeLoader;
|
import com.grinderwolf.swm.api.loaders.SlimeLoader;
|
||||||
import com.grinderwolf.swm.api.world.SlimeWorld;
|
import com.grinderwolf.swm.api.world.SlimeWorld;
|
||||||
import com.grinderwolf.swm.api.world.properties.SlimeProperties;
|
import com.grinderwolf.swm.api.world.properties.SlimeProperties;
|
||||||
@ -12,6 +9,7 @@ import com.grinderwolf.swm.api.world.properties.SlimePropertyMap;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public final class LetThemEatCake extends JavaPlugin {
|
public final class LetThemEatCake extends JavaPlugin {
|
||||||
@ -22,7 +20,8 @@ public final class LetThemEatCake extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
this.getCommand("join").setExecutor(new JoinGameCommand(this));
|
||||||
|
loadSWM();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,11 +37,18 @@ public final class LetThemEatCake extends JavaPlugin {
|
|||||||
|
|
||||||
swm = (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
|
swm = (SlimePlugin) Bukkit.getPluginManager().getPlugin("SlimeWorldManager");
|
||||||
swmLoader = swm.getLoader("file");
|
swmLoader = swm.getLoader("file");
|
||||||
|
|
||||||
|
File worldDir = new File(new File("").getAbsolutePath().replace('\\', '/') + "/import_worlds/");
|
||||||
|
worldDir.mkdirs();
|
||||||
|
System.out.println(worldDir.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
swmWorld = swm.loadWorld(swmLoader, "map", true, properties);
|
swm.importWorld(new File(worldDir.getAbsolutePath().replace('\\', '/') + "/steve"), "steve", swmLoader);
|
||||||
|
swmWorld = swm.loadWorld(swmLoader, "steve", true, properties);
|
||||||
swm.generateWorld(swmWorld);
|
swm.generateWorld(swmWorld);
|
||||||
} catch (UnknownWorldException | IOException | CorruptedWorldException | NewerFormatException | WorldInUseException e) {
|
} catch (UnknownWorldException | IOException | CorruptedWorldException | NewerFormatException | WorldInUseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (InvalidWorldException | WorldLoadedException | WorldAlreadyExistsException | WorldTooBigException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ name: LetThemEatCake
|
|||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: org.lunamc.letthemeatcake.LetThemEatCake
|
main: org.lunamc.letthemeatcake.LetThemEatCake
|
||||||
api-version: 1.19
|
api-version: 1.19
|
||||||
depend: [ slimeworldmanager ]
|
depend: [ SlimeWorldManager ]
|
||||||
authors: [ nevets, 5gi ]
|
authors: [ nevets, 5gi ]
|
||||||
description: Description
|
description: Description
|
||||||
website: https://lunamc.org
|
website: https://lunamc.org
|
||||||
|
commands:
|
||||||
|
join:
|
||||||
|
permission: ltec.join
|
||||||
|
Loading…
Reference in New Issue
Block a user