Skip to content

Commit

Permalink
Forgot to check if the treasure has been spawned in the location befo…
Browse files Browse the repository at this point in the history
…re giving rewards.
  • Loading branch information
Smudgge committed Jul 26, 2024
1 parent bcdf1c8 commit c9c3dfc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.cozyplugins</groupId>
<artifactId>CozyTreasureHunt</artifactId>
<version>1.3.1</version>
<version>1.3.4</version>
<packaging>jar</packaging>
<name>CozyTreasureHunt</name>

Expand Down Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import com.github.cozyplugins.cozytreasurehunt.storage.DataStorage;
import com.github.cozyplugins.cozytreasurehunt.storage.LocationStorage;
import com.github.cozyplugins.cozytreasurehunt.storage.TreasureStorage;
import org.bukkit.Raid;
import org.checkerframework.checker.units.qual.A;
import org.jetbrains.annotations.NotNull;

import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Objects;

/**
Expand Down Expand Up @@ -59,15 +58,15 @@ public class SetCommand implements CommandType {

@Override
public @Nullable CommandStatus onPlayer(@NotNull PlayerUser user, @NotNull ConfigurationSection section, @NotNull CommandArguments arguments) {

// Check if there is no treasure specified.
if (arguments.getArguments().isEmpty() || Objects.equals(arguments.getArguments().get(0), "")) {
user.sendMessage(section.getString("invalid_treasure", "&7Treasure type does not exist."));
return new CommandStatus();
}

// Get the treasure type.
List<String> treasureNameList = arguments.getArguments().subList(1, arguments.getArguments().size());
String treasureName = String.join(" ", treasureNameList);
String treasureName = String.join(" ", arguments.getArguments());
Treasure treasure = TreasureStorage.getFirst(treasureName);

// Check if the treasure exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ private void setPage0() {
.setAction((value, user) -> {
if (value != null) {
try {
System.out.println(value.toUpperCase());
Particle particle = Particle.valueOf(value.toUpperCase());
treasure.setParticleType(particle);
treasure.save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,23 @@ public class EventListener implements Listener {

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onClick(PlayerInteractEvent event) {

// Check if a treasure is clicked in the most efficient way.
// Did the player click a block.
if (event.getClickedBlock() == null) return;

// Check if the location is in storage.
if (!LocationStorage.contains(event.getClickedBlock().getLocation())) return;

// Get the treasure location.
TreasureLocation treasureLocation = LocationStorage.get(event.getClickedBlock().getLocation());
if (treasureLocation == null) return;

// Is the treasure spawned?
if (!treasureLocation.isSpawned()) return;

// Check if the player is in the map.
// Meaning they have clicked most recently
// Meaning they have clicked most recently.
if (playerMap.containsKey(event.getPlayer().getUniqueId())) {
long lastTimeStamp = playerMap.get(event.getPlayer().getUniqueId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.checkerframework.checker.units.qual.A;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

/**
* Represents the treasure location storage.
Expand Down

0 comments on commit c9c3dfc

Please sign in to comment.