Skip to content

Commit 4d9c58b

Browse files
committed
3.2.4修复更新:
·修复 #24 建立的传送点会失效 的问题
1 parent 1e6b953 commit 4d9c58b

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

latest.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.3
1+
3.2.4

pom.xml

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

77
<groupId>top.craft_hello.tpa</groupId>
88
<artifactId>TPA</artifactId>
9-
<version>3.2.3</version>
9+
<version>3.2.4</version>
1010
<packaging>jar</packaging>
1111

1212
<name>TPA</name>

src/main/java/top/craft_hello/tpa/abstracts/Configuration.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ protected void loadConfiguration(boolean isReplace){
6363
}
6464

6565
protected void saveConfiguration(CommandSender sender) {
66-
if (!ErrorException.trySaveConfiguration(sender, configuration, configurationFile)) {
67-
reloadConfiguration();
68-
}
66+
ErrorException.trySaveConfiguration(sender, configuration, configurationFile);
67+
reloadConfiguration();
6968
}
7069

7170
protected Location loadLocation(String index) {

src/main/java/top/craft_hello/tpa/objects/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ private void updateConfiguration() {
158158
ConfigurationSection keySection;
159159
ConfigurationSection keySection2;
160160
switch (configVersion) {
161+
case "3.2.3":
161162
case "3.2.2":
162163
case "3.2.1":
163164
case "3.2.0":
164165
configurationFile.renameTo(new File(PLUGIN.getDataFolder(), "backup/" + configVersion + "/" + configurationFile.getName()));
165166
configuration.set("version", VERSION);
167+
offUpdateConfiguration();
166168
break;
167169
case "3.1.3":
168170
case "3.1.2":

src/main/java/top/craft_hello/tpa/objects/LanguageConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ private void updateConfiguration() {
7777
Files.move(oldLanguageFolder.toPath(), backupFolder.toPath(), StandardCopyOption.REPLACE_EXISTING);
7878
} catch (Exception ignored) {}
7979
}
80+
default:
81+
break;
8082
}
8183
}
8284

src/main/java/top/craft_hello/tpa/objects/PlayerDataConfig.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,23 +403,37 @@ public void setLanguage(String languageStr) {
403403
SendMessageUtil.setLangCommandSuccess(player, this.languageStr);
404404
}
405405

406-
public void setDefaultHomeName(String homeName) {
407-
if (isNull(homeName) || !containsHomeLocation(homeName)) throw new ErrorHomeNotFoundException(player, homeName);
408-
if (homeName.equalsIgnoreCase(defaultHomeName)) throw new ErrorDefaultHomeAlreadySetException(player, homeName);
406+
public void setDefaultHomeName(String homeName, boolean force) {
407+
if (!force){
408+
if (isNull(homeName) || !containsHomeLocation(homeName)) throw new ErrorHomeNotFoundException(player, homeName);
409+
if (homeName.equalsIgnoreCase(defaultHomeName)) throw new ErrorDefaultHomeAlreadySetException(player, homeName);
410+
}
409411
defaultHomeName = homeName;
412+
configuration.set("default_home", defaultHomeName);
410413
SendMessageUtil.setDefaultHomeSuccess(player, homeName);
411414
}
412415

413416
public void setHomeLocation(Location location) {
414417
String defaultHomeName = "default";
415418
if (containsDefaultHome()) defaultHomeName = this.defaultHomeName;
416-
setHomeLocation(defaultHomeName, location);
419+
if (!containsHomeLocation(defaultHomeName)) {
420+
checkHomeAmountIsMax();
421+
setDefaultHomeName(defaultHomeName, true);
422+
}
423+
HOMES.put(defaultHomeName, location);
424+
setLocation("homes." + defaultHomeName, location);
425+
saveConfiguration(null);
426+
SendMessageUtil.setHomeSuccess(player, defaultHomeName);
427+
//setHomeLocation(defaultHomeName, location);
417428
}
418429

419430
public void setHomeLocation(String homeName, Location location) {
420431
if (isNull(homeName) || isNull(location)) return;
421432
if (!containsHomeLocation(homeName)) checkHomeAmountIsMax();
422-
if (isNull(defaultHomeName)) defaultHomeName = homeName;
433+
if (isNull(defaultHomeName)) {
434+
defaultHomeName = homeName;
435+
setDefaultHomeName(defaultHomeName, true);
436+
}
423437
HOMES.put(homeName, location);
424438
setLocation("homes." + homeName, location);
425439
saveConfiguration(null);

src/main/java/top/craft_hello/tpa/utils/ErrorCheckUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public static void executeCommand(CommandSender sender, String[] args, String co
243243
if (args.length != 1) throw new ErrorSyntaxHomeException(executorPlayer, command);
244244
targetName = args[args.length - 1];
245245
playerDataConfig = PlayerDataConfig.getPlayerData(executorPlayer);
246-
playerDataConfig.setDefaultHomeName(targetName);
246+
playerDataConfig.setDefaultHomeName(targetName, false);
247247
break;
248248
case DEL_HOME:
249249
if (!(sender instanceof Player)) throw new ErrorConsoleRestrictedException(sender);

0 commit comments

Comments
 (0)