forked from lokka30/PhantomWorlds
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aliases as an option to data.yml.
- Loading branch information
1 parent
1266cdf
commit 301d3cc
Showing
12 changed files
with
336 additions
and
42 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
42 changes: 42 additions & 0 deletions
42
...lokka30/phantomworlds/commands/phantomworlds/parameters/resolvers/AliasWorldResolver.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,42 @@ | ||
package me.lokka30.phantomworlds.commands.phantomworlds.parameters.resolvers; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import me.lokka30.phantomworlds.PhantomWorlds; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.jetbrains.annotations.NotNull; | ||
import revxrsal.commands.process.ValueResolver; | ||
|
||
/** | ||
* AliasWorldResolver | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public class AliasWorldResolver implements ValueResolver<World> { | ||
|
||
@Override | ||
public World resolve(@NotNull ValueResolverContext context) throws Throwable { | ||
final String value = context.arguments().pop(); | ||
|
||
final String name = PhantomWorlds.worldManager().aliases.getOrDefault(value, value); | ||
|
||
return Bukkit.getWorld(name); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../lokka30/phantomworlds/commands/phantomworlds/parameters/resolvers/GameRulesResolver.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,49 @@ | ||
package me.lokka30.phantomworlds.commands.phantomworlds.parameters.resolvers; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import me.lokka30.phantomworlds.commands.phantomworlds.utils.WorldFolder; | ||
import me.lokka30.phantomworlds.commands.phantomworlds.utils.WorldRule; | ||
import org.bukkit.GameRule; | ||
import org.jetbrains.annotations.NotNull; | ||
import revxrsal.commands.process.ValueResolver; | ||
|
||
import java.util.ArrayList; | ||
import java.util.ListIterator; | ||
|
||
/** | ||
* GameRulesResolver | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public class GameRulesResolver implements ValueResolver<WorldRule[]> { | ||
|
||
@Override | ||
public WorldRule[] resolve(@NotNull ValueResolverContext context) throws Throwable { | ||
final WorldRule[] rules = new WorldRule[context.arguments().size()]; | ||
final ListIterator<String> it = context.arguments().listIterator(); | ||
|
||
while(it.hasNext()) { | ||
final String value = it.next(); | ||
|
||
|
||
} | ||
return rules; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...ka30/phantomworlds/commands/phantomworlds/parameters/suggestion/AliasWorldSuggestion.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,51 @@ | ||
package me.lokka30.phantomworlds.commands.phantomworlds.parameters.suggestion; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import me.lokka30.phantomworlds.PhantomWorlds; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.jetbrains.annotations.NotNull; | ||
import revxrsal.commands.autocomplete.SuggestionProvider; | ||
import revxrsal.commands.command.CommandActor; | ||
import revxrsal.commands.command.ExecutableCommand; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* AliasWorldSuggestion | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public class AliasWorldSuggestion implements SuggestionProvider { | ||
|
||
@Override | ||
public @NotNull Collection<String> getSuggestions(@NotNull List<String> list, @NotNull CommandActor commandActor, @NotNull ExecutableCommand executableCommand) throws Throwable { | ||
|
||
final List<String> worlds = new ArrayList<>(PhantomWorlds.worldManager().aliases.keySet()); | ||
|
||
for(final World world : Bukkit.getWorlds()) { | ||
worlds.add(world.getName()); | ||
} | ||
return worlds; | ||
} | ||
} |
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
Oops, something went wrong.