Skip to content

Commit

Permalink
Add paste command and fix inventory handling issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite committed May 22, 2022
1 parent 08d9f7c commit 04fb5a0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>dev.efnilite</groupId>
<artifactId>IP</artifactId>
<packaging>pom</packaging>
<version>3.3.3</version>
<version>3.3.4</version>
<modules>
<module>witp</module>
</modules>
Expand Down
4 changes: 2 additions & 2 deletions witp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<artifactId>IP</artifactId>
<groupId>dev.efnilite</groupId>
<version>3.3.3</version>
<version>3.3.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>witp</artifactId>
<version>3.3.3</version>
<version>3.3.4</version>

<properties>
<maven.compiler.source>16</maven.compiler.source>
Expand Down
20 changes: 19 additions & 1 deletion witp/src/main/java/dev/efnilite/ip/ParkourCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import dev.efnilite.ip.player.ParkourPlayer;
import dev.efnilite.ip.player.ParkourUser;
import dev.efnilite.ip.player.data.InventoryData;
import dev.efnilite.ip.schematic.RotationAngle;
import dev.efnilite.ip.schematic.Schematic;
import dev.efnilite.ip.schematic.SchematicCache;
import dev.efnilite.ip.schematic.selection.Selection;
import dev.efnilite.ip.session.Session;
import dev.efnilite.ip.util.Util;
Expand Down Expand Up @@ -194,6 +196,7 @@ public boolean execute(CommandSender sender, String[] args) {
Message.send(player, "<red>/witp schematic pos1 <dark_gray>- &7Set the first position of your selection");
Message.send(player, "<red>/witp schematic pos2 <dark_gray>- &7Set the second position of your selection");
Message.send(player, "<red>/witp schematic save <dark_gray>- &7Save your selection to a schematic file");
Message.send(player, "<red>/witp schematic paste <file> <dark_gray>- &7Paste a schematic file");
Message.send(player, "");
Message.send(player, "<dark_gray>&nHave any questions or need help? Join the Discord!");
return true;
Expand Down Expand Up @@ -410,6 +413,21 @@ public boolean execute(CommandSender sender, String[] args) {

return true;
}
} else if (args.length == 3) {
if (args[0].equalsIgnoreCase("schematic") && player != null && player.hasPermission("witp.schematic")) {
if (args[1].equalsIgnoreCase("paste")) {
String name = args[2];
Schematic schematic = SchematicCache.getSchematic(name);
if (schematic == null) {
Message.send(sender, IP.PREFIX + "Couldn't find " + name);
return true;
}

schematic.paste(player.getLocation(), RotationAngle.ANGLE_0);
Message.send(sender, IP.PREFIX + "Pasted schematic " + name);
return true;
}
}
}
return true;
}
Expand Down Expand Up @@ -450,7 +468,7 @@ public List<String> tabComplete(CommandSender sender, String[] args) {
completions.add(pp.getName());
}
} else if (args[0].equalsIgnoreCase("schematic") && sender.hasPermission("witp.schematic")) {
completions.addAll(Arrays.asList("wand", "pos1", "pos2", "save"));
completions.addAll(Arrays.asList("wand", "pos1", "pos2", "save", "paste"));
} else if (args[0].equalsIgnoreCase("forcejoin") && sender.hasPermission("witp.forcejoin")) {
if (sender.hasPermission("witp.forcejoin.everyone")) {
completions.add("everyone");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public DefaultGenerator(@NotNull Session session, GeneratorOption... generatorOp

this.mostRecentBlock = player.getLocation().clone();
this.lastStandingPlayerLocation = mostRecentBlock.clone();
this.heading = Option.HEADING.get();
this.heading = Option.HEADING;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SchematicAdjuster {
Vector3D to = start.getRelativePosition();
adjustTo = adjustTo.subtract(to.toBukkitVector());

return schematic.pasteAdjusted(adjustTo, getAngle(Option.HEADING.get()));
return schematic.pasteAdjusted(adjustTo, getAngle(Option.HEADING));
}

/**
Expand All @@ -43,7 +43,7 @@ public class SchematicAdjuster {
*
* @return the associated angle
*/
private static RotationAngle getAngle(Direction heading) {
public static RotationAngle getAngle(Direction heading) {
return switch (heading) {
case SOUTH -> // south
RotationAngle.ANGLE_180;
Expand Down
4 changes: 2 additions & 2 deletions witp/src/main/java/dev/efnilite/ip/util/config/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Option {

public static List<Integer> POSSIBLE_LEADS;
// Advanced settings
public static ConfigOption<Direction> HEADING;
public static Direction HEADING;

public static ConfigOption<List<String>> LANGUAGES;
public static String DEFAULT_LANG;
Expand Down Expand Up @@ -149,7 +149,7 @@ public static void init(boolean init) {
BUNGEECORD = new ConfigOption<>(config, "bungeecord.enabled");

// Generation
HEADING = new ConfigOption<>(Util.getDirection(generation.getString("advanced.island.parkour.heading")));
HEADING = Util.getDirection(generation.getString("advanced.island.parkour.heading"));

// Scoring
ALL_POINTS = new ConfigOption<>(config, "scoring.all-points");
Expand Down
7 changes: 5 additions & 2 deletions witp/src/main/java/dev/efnilite/ip/world/WorldDivider.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,14 @@ public void setup(Location to, ParkourPlayer pp) {
Player player = pp.getPlayer();

pp.teleport(to);
player.setGameMode(GameMode.ADVENTURE);

// -= Inventory =-
player.setGameMode(GameMode.ADVENTURE);
if (Option.INVENTORY_HANDLING.get() && Option.OPTIONS_ENABLED.get()) {
if (Option.INVENTORY_HANDLING.get()) {
player.getInventory().clear();
}

if (Option.INVENTORY_HANDLING.get() && Option.OPTIONS_ENABLED.get()) {
ItemStack mat = IP.getConfiguration().getFromItemData(pp.getLocale(), "general.menu").build();
if (mat == null) {
IP.logging().error("Material for options in config is null - defaulting to compass");
Expand Down
2 changes: 1 addition & 1 deletion witp/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'WITP'
description: 'Infinitely automatically generating parkour plugin.'
author: Efnilite, Ice_Pancake
version: 3.3.3
version: 3.3.4
api-version: 1.16
main: dev.efnilite.ip.IP
depend: [vilib]
Expand Down

0 comments on commit 04fb5a0

Please sign in to comment.