Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit e85e464

Browse files
committed
fix0.5
Fixed the issue where cPlayer could be null in certain situations and added a cPlayer check
1 parent 354c48f commit e85e464

File tree

4 files changed

+17
-74
lines changed

4 files changed

+17
-74
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = "fr.xyness"
9-
version = "1.4"
9+
version = "1.4.2"
1010

1111
java {
1212
toolchain {

src/main/java/fr/xyness/SCS/Commands/ClaimCommand.java

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,18 @@
5757
import fr.xyness.SCS.Guis.ClaimMembersGui;
5858
import fr.xyness.SCS.Guis.ClaimMainGui;
5959

60-
/**
61-
* Command executor and tab completer for the /claim command.
62-
*/
6360
public class ClaimCommand implements CommandExecutor, TabCompleter {
6461

6562

6663
// ***************
6764
// * Variables *
6865
// ***************
6966

70-
71-
/** A map of players currently in the process of creating a claim. */
67+
7268
public static Map<Player, Integer> isOnCreate = new HashMap<>();
73-
74-
/** A map of players currently in the process of adding a chunk. */
7569
public static Map<Player, String> isOnAdd = new HashMap<>();
76-
77-
/** A map of invitations */
7870
public static Map<Player, Map<Player,String>> invitations = new HashMap<>();
7971
public static Map<Player, Map<Player,LocalDateTime>> invitationsTime = new HashMap<>();
80-
81-
/** Instance of SimpleClaimSystem */
8272
private SimpleClaimSystem instance;
8373

8474
public static Set<String> commands = Set.of("settings", "add", "remove", "list", "setspawn", "setname", "members", "setdesc",
@@ -89,32 +79,13 @@ public class ClaimCommand implements CommandExecutor, TabCompleter {
8979
// ******************
9080
// * Constructors *
9181
// ******************
92-
93-
94-
/**
95-
* Constructor for ClaimCommand.
96-
*
97-
* @param instance The instance of the SimpleClaimSystem plugin.
98-
*/
9982
public ClaimCommand(SimpleClaimSystem instance) {
10083
this.instance = instance;
10184
}
102-
103-
10485
// ******************
10586
// * Tab Complete *
10687
// ******************
10788

108-
109-
/**
110-
* Handles tab completion for the /claim command.
111-
*
112-
* @param sender the sender of the command
113-
* @param cmd the command
114-
* @param alias the alias of the command
115-
* @param args the arguments provided to the command
116-
* @return a list of possible completions for the final argument, or an empty list if none are applicable
117-
*/
11889
@Override
11990
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
12091
if (!(sender instanceof Player)) {
@@ -158,31 +129,21 @@ public List<String> onTabComplete(CommandSender sender, Command cmd, String alia
158129
// * Main command *
159130
// ******************
160131

161-
162-
/**
163-
* Handles the execution of the /claim command.
164-
*
165-
* @param sender the command sender
166-
* @param command the command
167-
* @param label the command label
168-
* @param args the command arguments
169-
* @return true if the command was successful, false otherwise
170-
*/
171132
@Override
172133
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
173134

174-
// If the sender is not a player
175135
if (!(sender instanceof Player)) {
176136
sender.sendMessage(instance.getLanguage().getMessage("command-only-by-players"));
177137
return true;
178138
}
179139

180-
// Get data
181140
Player player = (Player) sender;
182141
String playerName = player.getName();
183142
CPlayer cPlayer = instance.getPlayerMain().getCPlayer(player.getUniqueId());
184-
185-
// Check if for desc (so there are many arguments)
143+
if (cPlayer == null) {
144+
player.sendMessage(instance.getLanguage().getMessage("error"));
145+
return true;
146+
}
186147
if (args.length > 1 && args[0].equals("setdesc")) {
187148
handleDesc(player, playerName, args);
188149
return true;

src/main/java/fr/xyness/SCS/Commands/ClaimsCommand.java

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,20 @@
1111
import fr.xyness.SCS.Guis.Bedrock.BClaimsGui;
1212
import fr.xyness.SCS.Types.CPlayer;
1313

14-
/**
15-
* Handles the /claims command, which opens a GUI for the player to view their claims.
16-
*/
14+
1715
public class ClaimsCommand implements CommandExecutor {
1816

1917

2018
// ***************
2119
// * Variables *
2220
// ***************
23-
24-
25-
/** Instance of SimpleClaimSystem */
21+
2622
private SimpleClaimSystem instance;
27-
28-
23+
2924
// ******************
3025
// * Constructors *
3126
// ******************
32-
33-
34-
/**
35-
* Constructor for ClaimsCommand.
36-
*
37-
* @param instance The instance of the SimpleClaimSystem plugin.
38-
*/
27+
3928
public ClaimsCommand(SimpleClaimSystem instance) {
4029
this.instance = instance;
4130
}
@@ -44,17 +33,7 @@ public ClaimsCommand(SimpleClaimSystem instance) {
4433
// ******************
4534
// * Main command *
4635
// ******************
47-
48-
49-
/**
50-
* Executes the given command, returning its success.
51-
*
52-
* @param sender Source of the command
53-
* @param command Command which was executed
54-
* @param label Alias of the command which was used
55-
* @param args Passed command arguments
56-
* @return true if a valid command, otherwise false
57-
*/
36+
5837
@Override
5938
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
6039

@@ -67,7 +46,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
6746
// Get data
6847
Player player = (Player) sender;
6948
CPlayer cPlayer = instance.getPlayerMain().getCPlayer(player.getUniqueId());
70-
49+
if (cPlayer == null) {
50+
player.sendMessage(instance.getLanguage().getMessage("error"));
51+
return true;
52+
}
7153
// Open the claims GUI for the player
7254
cPlayer.setGuiPage(1);
7355
if(instance.getSettings().getBooleanSetting("floodgate")) {

src/main/resources/plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: SimpleClaimSystem
2-
version: 1.4
2+
version: 1.4.2
33
main: fr.xyness.SCS.SimpleClaimSystem
4-
authors: [Xyness]
4+
authors: [Xyness,MingLi.]
55
softdepend: [PlaceholderAPI, WorldGuard, Vault, dynmap, BlueMap, pl3xmap, GriefPrevention, floodgate, ItemsAdder, CraftEngine]
66
api-version: 1.18
77
folia-supported: true

0 commit comments

Comments
 (0)