-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add version comparison * Fetch latest version * Send update message to opped players * Move player listeners to a separate class (#30) * add an options container to ApolloPlatform * Fix conflicts * Add registerOptions method * Remove gson * give saveOptions the list of option keys * Fix no such method call on older velocity versions * Check the updater config key on join --------- Co-authored-by: connorhartley <[email protected]>
- Loading branch information
1 parent
a86119b
commit 7494ae4
Showing
11 changed files
with
569 additions
and
119 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
86 changes: 86 additions & 0 deletions
86
bukkit/src/main/java/com/lunarclient/apollo/listener/ApolloPlayerListener.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,86 @@ | ||
/* | ||
* This file is part of Apollo, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2023 Moonsworth | ||
* | ||
* 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. | ||
*/ | ||
package com.lunarclient.apollo.listener; | ||
|
||
import com.lunarclient.apollo.Apollo; | ||
import com.lunarclient.apollo.ApolloManager; | ||
import com.lunarclient.apollo.player.ApolloPlayerManagerImpl; | ||
import com.lunarclient.apollo.version.ApolloVersionManager; | ||
import com.lunarclient.apollo.wrapper.BukkitApolloPlayer; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.event.player.PlayerRegisterChannelEvent; | ||
import org.bukkit.event.player.PlayerUnregisterChannelEvent; | ||
|
||
/** | ||
* Handles registration and un-registration of Apollo players. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public final class ApolloPlayerListener implements Listener { | ||
|
||
@EventHandler | ||
private void onRegisterChannel(PlayerRegisterChannelEvent event) { | ||
if (!event.getChannel().equalsIgnoreCase(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { | ||
return; | ||
} | ||
|
||
((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).addPlayer(new BukkitApolloPlayer(event.getPlayer())); | ||
} | ||
|
||
@EventHandler | ||
private void onUnregisterChannel(PlayerUnregisterChannelEvent event) { | ||
if (!event.getChannel().equalsIgnoreCase(ApolloManager.PLUGIN_MESSAGE_CHANNEL)) { | ||
return; | ||
} | ||
|
||
((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).removePlayer(event.getPlayer().getUniqueId()); | ||
} | ||
|
||
@EventHandler | ||
private void onPlayerQuit(PlayerQuitEvent event) { | ||
((ApolloPlayerManagerImpl) Apollo.getPlayerManager()).removePlayer(event.getPlayer().getUniqueId()); | ||
} | ||
|
||
@EventHandler | ||
private void onPlayerJoin(PlayerJoinEvent event) { | ||
if (!Apollo.getPlatform().getOptions().get(ApolloVersionManager.SEND_UPDATE_MESSAGE)) { | ||
return; | ||
} | ||
|
||
if (!ApolloManager.getVersionManager().isNeedsUpdate()) { | ||
return; | ||
} | ||
|
||
Player player = event.getPlayer(); | ||
if (player.isOp()) { | ||
player.sendMessage(ChatColor.YELLOW + ApolloVersionManager.UPDATE_MESSAGE); | ||
} | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
bukkit/src/main/java/com/lunarclient/apollo/listener/ApolloWorldListener.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 @@ | ||
/* | ||
* This file is part of Apollo, licensed under the MIT License. | ||
* | ||
* Copyright (c) 2023 Moonsworth | ||
* | ||
* 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. | ||
*/ | ||
package com.lunarclient.apollo.listener; | ||
|
||
import com.lunarclient.apollo.Apollo; | ||
import com.lunarclient.apollo.world.ApolloWorldManagerImpl; | ||
import com.lunarclient.apollo.wrapper.BukkitApolloWorld; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.WorldLoadEvent; | ||
import org.bukkit.event.world.WorldUnloadEvent; | ||
|
||
/** | ||
* Handles registration and un-registration of Apollo worlds. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public final class ApolloWorldListener implements Listener { | ||
|
||
@EventHandler | ||
private void onWorldLoad(WorldLoadEvent event) { | ||
((ApolloWorldManagerImpl) Apollo.getWorldManager()).addWorld(new BukkitApolloWorld(event.getWorld())); | ||
} | ||
|
||
@EventHandler | ||
private void onWorldUnload(WorldUnloadEvent event) { | ||
((ApolloWorldManagerImpl) Apollo.getWorldManager()).removeWorld(event.getWorld().getName()); | ||
} | ||
|
||
} |
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.