-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: backup item tag before warping to lifetown
- Loading branch information
1 parent
ccff0d0
commit ef6a9db
Showing
10 changed files
with
122 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/mori01231/lifecore/command/TownServerCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.github.mori01231.lifecore.command | ||
|
||
import com.github.mori01231.lifecore.LifeCore | ||
import com.github.mori01231.lifecore.util.ItemUtil | ||
import com.github.mori01231.lifecore.util.JoinFilterUtil | ||
import org.bukkit.command.Command | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.entity.Player | ||
|
||
class TownServerCommand(private val plugin: LifeCore) : TransferCommand(plugin, "lifetown") { | ||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean { | ||
val player = sender as? Player ?: return false | ||
if (plugin.config.getBoolean("enable-backup-item-tag", true)) { | ||
val size = player.inventory.size | ||
for (i in 0..<size) { | ||
player.inventory.setItem(i, ItemUtil.restoreTag(player.inventory.getItem(i))) | ||
player.inventory.setItem(i, ItemUtil.backupTag(player.inventory.getItem(i))) | ||
} | ||
} | ||
JoinFilterUtil.addPlayerWithExpire(player.uniqueId, "lifetown", 1) | ||
super.onCommand(sender, command, label, args) | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/github/mori01231/lifecore/util/JoinFilterUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.github.mori01231.lifecore.util; | ||
|
||
import com.github.mori01231.lifecore.util.external.JoinFilterBridge; | ||
import org.bukkit.Bukkit; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public class JoinFilterUtil { | ||
public static boolean addPlayerWithExpire(@NotNull UUID uuid, @NotNull String server, long expireSeconds) { | ||
if (Bukkit.getPluginManager().isPluginEnabled("JoinFilter")) { | ||
JoinFilterBridge.addPlayerWithExpire(uuid, server, expireSeconds); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/github/mori01231/lifecore/util/external/JoinFilterBridge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.github.mori01231.lifecore.util.external; | ||
|
||
import net.azisaba.joinfilter.JoinFilter; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public class JoinFilterBridge { | ||
public static void addPlayerWithExpire(@NotNull UUID uuid, @NotNull String server, long expireSeconds) { | ||
JoinFilter.getPlugin(JoinFilter.class).addPlayerWithExpire(uuid, server, expireSeconds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ softdepend: | |
- Towny | ||
- MythicMobs | ||
- ItemStash | ||
- JoinFilter | ||
api-version: 1.13 | ||
|
||
commands: | ||
|