Compare commits
3 Commits
1.1-prerel
...
1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 66c6cb76c4 | |||
| e37b176a3e | |||
|
|
798841215e |
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Deutschich/User404
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,13 +15,15 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class InfiniteHomes extends JavaPlugin {
|
||||
public class InfiniteHomes extends JavaPlugin implements TabCompleter {
|
||||
|
||||
private Map<UUID, Map<String, Location>> homes;
|
||||
private Map<UUID, Long> cooldowns;
|
||||
@@ -45,6 +48,10 @@ public class InfiniteHomes extends JavaPlugin {
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
|
||||
// TabCompleter registrieren
|
||||
getCommand("home").setTabCompleter(this);
|
||||
getCommand("delhome").setTabCompleter(this);
|
||||
|
||||
getLogger().info("InfiniteHomes plugin enabled!");
|
||||
}
|
||||
|
||||
@@ -54,6 +61,43 @@ public class InfiniteHomes extends JavaPlugin {
|
||||
getLogger().info("InfiniteHomes plugin disabled!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> completions = new ArrayList<>();
|
||||
|
||||
// Nur für Spieler und für die Befehle home und delhome
|
||||
if (!(sender instanceof Player) || (!command.getName().equalsIgnoreCase("home") &&
|
||||
!command.getName().equalsIgnoreCase("delhome"))) {
|
||||
return completions;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
UUID playerUuid = player.getUniqueId();
|
||||
|
||||
// Wenn der Spieler keine Homes hat, leere Liste zurückgeben
|
||||
if (!homes.containsKey(playerUuid) || homes.get(playerUuid).isEmpty()) {
|
||||
return completions;
|
||||
}
|
||||
|
||||
// Home-Namen des Spielers holen
|
||||
Set<String> homeNames = homes.get(playerUuid).keySet();
|
||||
|
||||
// Wenn kein Argument vorhanden ist, alle Home-Namen zurückgeben
|
||||
if (args.length == 0 || args[0].isEmpty()) {
|
||||
completions.addAll(homeNames);
|
||||
} else {
|
||||
// Home-Namen filtern, die mit dem eingegebenen Text beginnen
|
||||
String input = args[0].toLowerCase();
|
||||
for (String home : homeNames) {
|
||||
if (home.toLowerCase().startsWith(input)) {
|
||||
completions.add(home);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return completions;
|
||||
}
|
||||
|
||||
private void setupHomesConfig() {
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
@@ -10,12 +10,15 @@ commands:
|
||||
delhome:
|
||||
description: Delete a home with the given name.
|
||||
usage: /delhome <name>
|
||||
aliases: [deletehome]
|
||||
home:
|
||||
description: Teleport to a home with the given name.
|
||||
usage: /home <name>
|
||||
aliases: [h]
|
||||
homes:
|
||||
description: List all your homes.
|
||||
usage: /homes
|
||||
aliases: [listhomes]
|
||||
homecount:
|
||||
description: Set the global home limit (OP only).
|
||||
usage: /homecount <number>
|
||||
|
||||
Reference in New Issue
Block a user