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.
Refactor commands directory, add compatibility classes for older vers…
…ions.
- Loading branch information
1 parent
3ab0ecc
commit 35fbeb8
Showing
38 changed files
with
248 additions
and
105 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
61 changes: 61 additions & 0 deletions
61
src/main/java/me/lokka30/phantomworlds/comatibility/VersionCompatibility.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,61 @@ | ||
package me.lokka30.phantomworlds.comatibility; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 - 2024 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 org.bukkit.NamespacedKey; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* VersionCompatibility | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public interface VersionCompatibility { | ||
|
||
/** | ||
* Used to return a list of potion effects suggestions for our /pw set effects command. | ||
* @return The list containing the potion effects that exist. | ||
*/ | ||
default List<String> potionEffectSuggestions() { | ||
|
||
final List<String> effects = new ArrayList<>(); | ||
|
||
for(PotionEffectType value : PotionEffectType.values()) { | ||
|
||
if(value == null) { //for some reason there is a null value here | ||
continue; | ||
} | ||
effects.add(value.getKey() + ",duration,amplifier"); | ||
effects.add(value.getKey() + ",-1,1"); | ||
} | ||
return effects; | ||
} | ||
|
||
/** | ||
* Used to find an {@link PotionEffectType effect type} based on a string. | ||
* @param effectType The effect type. | ||
* @return The effect type if found, otherwise null | ||
*/ | ||
default PotionEffectType findType(final String effectType) { | ||
return PotionEffectType.getByKey(NamespacedKey.fromString(effectType)); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/me/lokka30/phantomworlds/comatibility/impl/OneSeventeenCompatibility.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,67 @@ | ||
package me.lokka30.phantomworlds.comatibility.impl; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 - 2024 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.comatibility.VersionCompatibility; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* OneSixteenCompatibility | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public class OneSeventeenCompatibility implements VersionCompatibility { | ||
|
||
/** | ||
* Used to return a list of potion effects suggestions for our /pw set effects command. | ||
* | ||
* @return The list containing the potion effects that exist. | ||
*/ | ||
@Override | ||
public List<String> potionEffectSuggestions() { | ||
|
||
final List<String> effects = new ArrayList<>(); | ||
|
||
for(PotionEffectType value : PotionEffectType.values()) { | ||
|
||
if(value == null) { //for some reason there is a null value here | ||
continue; | ||
} | ||
|
||
effects.add(value.getName() + ",duration,amplifier"); | ||
effects.add(value.getName() + ",-1,1"); | ||
} | ||
return effects; | ||
} | ||
|
||
/** | ||
* Used to find an {@link PotionEffectType effect type} based on a string. | ||
* | ||
* @param effectType The effect type. | ||
* | ||
* @return The effect type if found, otherwise null | ||
*/ | ||
@Override | ||
public PotionEffectType findType(String effectType) { | ||
return PotionEffectType.getByName(effectType); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/me/lokka30/phantomworlds/comatibility/impl/OneTwentyCompatibility.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,29 @@ | ||
package me.lokka30.phantomworlds.comatibility.impl; | ||
/* | ||
* Phantom Worlds | ||
* Copyright (C) 2023 - 2024 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.comatibility.VersionCompatibility; | ||
|
||
/** | ||
* OneTwentyCompatibility | ||
* | ||
* @author creatorfromhell | ||
* @since 2.0.5.0 | ||
*/ | ||
public class OneTwentyCompatibility implements VersionCompatibility { | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...sredux/handler/PWInvalidUsageHandler.java → ...mmands/handler/PWInvalidUsageHandler.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
2 changes: 1 addition & 1 deletion
2
...andsredux/params/AliasWorldParameter.java → .../commands/params/AliasWorldParameter.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
2 changes: 1 addition & 1 deletion
2
...mmandsredux/params/GamemodeParameter.java → ...ds/commands/params/GamemodeParameter.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
2 changes: 1 addition & 1 deletion
2
...commandsredux/params/PortalParameter.java → ...rlds/commands/params/PortalParameter.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
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
4 changes: 2 additions & 2 deletions
4
...ommandsredux/params/SettingParameter.java → ...lds/commands/params/SettingParameter.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
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
2 changes: 1 addition & 1 deletion
2
...rlds/commandsredux/sub/BackupCommand.java → ...tomworlds/commands/sub/BackupCommand.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
2 changes: 1 addition & 1 deletion
2
...mmandsredux/sub/CompatibilityCommand.java → ...ds/commands/sub/CompatibilityCommand.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
2 changes: 1 addition & 1 deletion
2
...rlds/commandsredux/sub/CreateCommand.java → ...tomworlds/commands/sub/CreateCommand.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
2 changes: 1 addition & 1 deletion
2
...orlds/commandsredux/sub/DebugCommand.java → ...ntomworlds/commands/sub/DebugCommand.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
Oops, something went wrong.