Skip to content

Commit

Permalink
release 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ewoutvans committed Jul 27, 2018
1 parent 0d95e4c commit 7c2e2d6
Show file tree
Hide file tree
Showing 36 changed files with 256 additions and 291 deletions.
Binary file modified .gradle/4.4.1/fileContent/fileContent.lock
Binary file not shown.
Binary file modified .gradle/4.4.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/4.4.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/4.4.1/taskHistory/taskHistory.bin
Binary file not shown.
Binary file modified .gradle/4.4.1/taskHistory/taskHistory.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Sun Jul 08 10:51:20 CEST 2018
gradle.version=4.6
#Fri Jul 27 20:00:08 CEST 2018
gradle.version=4.4.1
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
10 changes: 3 additions & 7 deletions .idea/libraries/Gradle__com_google_code_gson_gson_2_8_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions .idea/libraries/Gradle__com_google_guava_guava_21_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/GameSpleef_main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/GameSpleef_test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

445 changes: 184 additions & 261 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion GameSpleef.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="GameSpleef" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="cloud.zeroprox" external.system.module.version="1.2" type="JAVA_MODULE" version="4">
<module external.linked.project.id="GameSpleef" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="cloud.zeroprox" external.system.module.version="1.3" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/classes/java/main/cloud/zeroprox/gamespleef/GameSpleef.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion build/resources/main/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"modid": "gamespleef",
"name": "GameSpleef",
"version": "1.2",
"version": "1.3",
"description": "A spleef minigame",
"url": "https://zeroprox.cloud",
"authorList": [
Expand Down
2 changes: 1 addition & 1 deletion build/tmp/generateMetadata/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"modid": "gamespleef",
"name": "GameSpleef",
"version": "1.2",
"version": "1.3",
"description": "A spleef minigame",
"url": "https://zeroprox.cloud",
"authorList": [
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginGroup=cloud.zeroprox
pluginId=gamespleef
pluginVersion=1.2
pluginVersion=1.3
11 changes: 6 additions & 5 deletions src/main/java/cloud/zeroprox/gamespleef/GameSpleef.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ private void loadConfig() throws IOException, ObjectMappingException {
floors,
gameSerialize.spawn,
gameSerialize.lobby,
20,
2,
7,
5
gameSerialize.playerLimit,
gameSerialize.campRadius,
gameSerialize.campInterval,
gameSerialize.campPlayers,
gameSerialize.saveInv
);
}
getGameManager().iGames.add(iGame);
Expand Down Expand Up @@ -250,7 +251,7 @@ public enum GameType {
}

public enum AdminBuildTypes {
NAME, LOBBY, SPAWN, CORNER_FLOOR_1, CORNER_FLOOR_2, CORNER_AREA_1, CORNER_AREA_2, SAVE, STOP, TYPE
NAME, LOBBY, SPAWN, CORNER_FLOOR_1, CORNER_FLOOR_2, CORNER_AREA_1, CORNER_AREA_2, SAVE, STOP, TYPE, SAVE_INV
}

public class GameArgument extends CommandElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.service.pagination.PaginationList;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.action.TextActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
this.gameSerialize.gameType = GameSpleef.GameType.CLASSIC;
this.gameSerialize.name = name.orElse(new Random().nextLong() + "");
this.gameSerialize.floors = new ArrayList<>();
this.gameSerialize.campInterval = 7;
this.gameSerialize.campPlayers = 5;
this.gameSerialize.campRadius = 2;
this.gameSerialize.saveInv = true;
this.gameSerialize.playerLimit = 20;
showProgress(src);
return CommandResult.success();
}
Expand Down Expand Up @@ -105,6 +110,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
case CORNER_AREA_2:
gameSerialize.corner_area_2 = player.getLocation();
break;
case SAVE_INV:
gameSerialize.saveInv = !gameSerialize.saveInv;
break;
default:
}
showProgress(src);
Expand All @@ -118,6 +126,7 @@ private void showProgress(CommandSource src) {
} else {
textArray.add(Text.builder("Name: ").color(TextColors.GRAY).append(Text.builder(gameSerialize.name).color(TextColors.GREEN).build()).build());
textArray.add(Text.builder("Lobby: ").color(TextColors.GRAY).append(colorVariable(gameSerialize.lobby)).onClick(TextActions.runCommand("/spleef admin build LOBBY")).build());
textArray.add(Text.builder("Can join with items in inv: ").color(TextColors.GRAY).append(Text.of(TextColors.GREEN, gameSerialize.saveInv)).append(Text.of(" (disable this on modded)")).onClick(TextActions.runCommand("/spleef admin build SAVE_INV")).build());
textArray.add(Text.builder("Spawn: ").color(TextColors.GRAY).append(colorVariable(gameSerialize.spawn)).onClick(TextActions.runCommand("/spleef admin build SPAWN")).build());
if (gameSerialize.corner_area_1 != null && gameSerialize.corner_area_2 != null) {
textArray.add(Text.builder("Area: ").color(TextColors.GRAY).append(Text.builder("Okay").color(TextColors.GREEN).build()).build());
Expand Down
30 changes: 27 additions & 3 deletions src/main/java/cloud/zeroprox/gamespleef/game/GameClassic.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ public class GameClassic implements IGame {
private List<AABB> floors;
private Transform<World> spawn, lobby;
private int limit, lowestY, campRadius, campInterval, campPlayers;
private boolean saveInventories;
private HashMap<BlockSnapshot, UUID> brokenBlocks;
private Task countTask, campTask;
Map<UUID, PlayerStats> activePlayers = new HashMap<>();
Map<UUID, PlayerStats> inactivePlayers = new HashMap<>();
Map<UUID, Vector3i> playerPos = new HashMap<>();
Map<UUID, LinkedHashSet<Optional<ItemStack>>> inventories = new HashMap<>();
Map<UUID, List<Optional<ItemStack>>> inventories = new HashMap<>();
HashSet<UUID> campWarnings = new HashSet<>();

public GameClassic(String name, AABB area, List<AABB> floors, Transform<World> spawn, Transform<World> lobby, int limit, int campRadius, int campInterval, int campPlayers) {
public GameClassic(String name, AABB area, List<AABB> floors, Transform<World> spawn, Transform<World> lobby, int limit, int campRadius, int campInterval, int campPlayers, boolean saveInventories) {
this.name = name;
this.area = area;
this.floors = floors;
Expand All @@ -64,6 +65,7 @@ public GameClassic(String name, AABB area, List<AABB> floors, Transform<World> s
this.campRadius = campRadius;
this.campInterval = campInterval;
this.campPlayers = campPlayers;
this.saveInventories = saveInventories;
}

@Override
Expand Down Expand Up @@ -136,6 +138,10 @@ public void addPlayer(Player player) {
player.sendMessage(Text.of(TextColors.RED, "You can't join the game is already started."));
return;
}
if (this.saveInventories == false && player.getInventory().totalItems() != 0) {
player.sendMessage(Text.of(TextColors.RED, "You need a empty inventory to join."));
return;
}
player.health().set(20D);
player.maxHealth().set(20D);
player.foodLevel().set(20);
Expand All @@ -147,9 +153,17 @@ public void addPlayer(Player player) {
PotionEffect.builder().amplifier(1).duration(20 * 60 * 60 * 60).particles(false).potionType(PotionEffectTypes.SATURATION).build()));
player.sendMessage(Text.of(TextColors.GREEN, "You have joined the game"));

if (this.saveInventories) {
List<Optional<ItemStack>> items = new ArrayList<>();
for (Inventory slot : player.getInventory().slots()) {
items.add(slot.peek());
}
this.inventories.put(player.getUniqueId(), items);
}


((PlayerInventory) player.getInventory()).getHotbar().setSelectedSlotIndex(0);

player.getInventory().clear();
player.setTransform(this.getSpawn());

this.activePlayers.put(player.getUniqueId(), new PlayerStats(player.getUniqueId()));
Expand All @@ -170,6 +184,16 @@ public void leavePlayer(Player player, boolean resetStats) {
}
this.activePlayers.remove(player.getUniqueId());
player.getInventory().clear();

if (this.saveInventories) {
List<Optional<ItemStack>> items = this.inventories.get(player.getUniqueId());
int index = 0;
for (Inventory slot : player.getInventory().slots()) {
slot.set(items.get(index).orElse(ItemStack.empty()));
index++;
}
}

player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
player.offer(Keys.POTION_EFFECTS, new ArrayList<>());
player.setScoreboard(null);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/cloud/zeroprox/gamespleef/utils/GameSerialize.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ public class GameSerialize {
@Setting("gametype")
public GameSpleef.GameType gameType;

@Setting(value = "saveinv", comment = "experimental inventory save option DO NOT USE ON MODDED SERVER")
public boolean saveInv;

@Setting(value = "playerLimit", comment = "maximum player to join this arena")
public int playerLimit;

@Setting(value = "campRadius", comment = "radius to check every interval, if the player has not moved in that radius it will count as camping")
public int campRadius;

@Setting(value = "campInterval", comment = "how many seconds interval to check player are camping")
public int campInterval;

@Setting(value = "campPlayers", comment = "when player count is lower than campPlayers anticamping start checking")
public int campPlayers;

public Location corner_floor_1;
public Location corner_floor_2;
public Location corner_area_1;
Expand Down

0 comments on commit 7c2e2d6

Please sign in to comment.