Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Nuke plugin API
https://media.giphy.com/media/oe33xf3B50fsc/giphy.gif
Dieser Commit ist enthalten in:
Ursprung
313228abde
Commit
e38322a3ec
20
api/pom.xml
20
api/pom.xml
@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.geysermc</groupId>
|
|
||||||
<artifactId>geyser-parent</artifactId>
|
|
||||||
<version>parent</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>api</artifactId>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<version>2.8.2</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api;
|
|
||||||
|
|
||||||
import org.geysermc.api.command.CommandMap;
|
|
||||||
import org.geysermc.api.logger.Logger;
|
|
||||||
import org.geysermc.api.plugin.PluginManager;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
public interface Connector {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the logger
|
|
||||||
*
|
|
||||||
* @return the logger
|
|
||||||
*/
|
|
||||||
Logger getLogger();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the command map
|
|
||||||
*
|
|
||||||
* @return the command map
|
|
||||||
*/
|
|
||||||
CommandMap getCommandMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the plugin manager
|
|
||||||
*
|
|
||||||
* @return the plugin manager
|
|
||||||
*/
|
|
||||||
PluginManager getPluginManager();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the general thread pool
|
|
||||||
*
|
|
||||||
* @return the general thread pool
|
|
||||||
*/
|
|
||||||
ScheduledExecutorService getGeneralThreadPool();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a collection of the connected players
|
|
||||||
*
|
|
||||||
* @return a collection of the connected players
|
|
||||||
*/
|
|
||||||
Collection<? extends Player> getConnectedPlayers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shuts down the connector
|
|
||||||
*/
|
|
||||||
void shutdown();
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api;
|
|
||||||
|
|
||||||
public class ConsoleColors {
|
|
||||||
public static final String RESET = "\u001b[0m";
|
|
||||||
|
|
||||||
public static final String BOLD = "\u001b[1m";
|
|
||||||
public static final String BLINK = "\u001b[5m";
|
|
||||||
|
|
||||||
public static final String WHITE = "\u001b[30m";
|
|
||||||
public static final String RED = "\u001b[31m";
|
|
||||||
public static final String GREEN = "\u001b[32m";
|
|
||||||
public static final String YELLOW = "\u001b[33m";
|
|
||||||
public static final String BLUE = "\u001b[34m";
|
|
||||||
public static final String MAGENTA = "\u001b[35m";
|
|
||||||
public static final String CYAN = "\u001b[36m";
|
|
||||||
public static final String LIGHT_GRAY = "\u001b[37m";
|
|
||||||
|
|
||||||
public static final String DARK_GRAY = "\u001b[90m";
|
|
||||||
public static final String BRIGHT_RED = "\u001b[91m";
|
|
||||||
public static final String BRIGHT_GREEN = "\u001b[92m";
|
|
||||||
public static final String BRIGHT_YELLOW = "\u001b[93m";
|
|
||||||
public static final String BRIGHT_BLUE = "\u001b[94m";
|
|
||||||
public static final String BRIGHT_MAGENTA = "\u001b[95m";
|
|
||||||
public static final String BRIGHT_CYAN = "\u001b[96m";
|
|
||||||
public static final String BLACK = "\u001b[97m";
|
|
||||||
|
|
||||||
public static final String BLACK_BACKGROUND = "\u001b[30m";
|
|
||||||
public static final String RED_BACKGROUND = "\u001b[31m";
|
|
||||||
public static final String GREEN_BACKGROUND = "\u001b[32m";
|
|
||||||
public static final String YELLOW_BACKGROUND = "\u001b[33m";
|
|
||||||
public static final String BLUE_BACKGROUND = "\u001b[34m";
|
|
||||||
public static final String MAGENTA_BACKGROUND = "\u001b[35m";
|
|
||||||
public static final String CYAN_BACKGROUND = "\u001b[36m";
|
|
||||||
public static final String WHITE_BACKGROUND = "\u001b[37m";
|
|
||||||
|
|
||||||
/*public static final String BLACK_BACKGROUND = "\u001b[30m";
|
|
||||||
public static final String RED_BACKGROUND = "\u001b[31m";
|
|
||||||
public static final String GREEN_BACKGROUND = "\u001b[32m";
|
|
||||||
public static final String YELLOW_BACKGROUND = "\u001b[33m";
|
|
||||||
public static final String BLUE_BACKGROUND = "\u001b[34m";
|
|
||||||
public static final String MAGENTA_BACKGROUND = "\u001b[35m";
|
|
||||||
public static final String CYAN_BACKGROUND = "\u001b[36m";
|
|
||||||
public static final String WHITE_BACKGROUND = "\u001b[37m";*/
|
|
||||||
}
|
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api;
|
|
||||||
|
|
||||||
import org.geysermc.api.command.CommandMap;
|
|
||||||
import org.geysermc.api.logger.Logger;
|
|
||||||
import org.geysermc.api.plugin.PluginManager;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
|
|
||||||
public class Geyser {
|
|
||||||
|
|
||||||
private static Connector connector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the connector instance for Geyser
|
|
||||||
*
|
|
||||||
* @return the connector instance for Geyser
|
|
||||||
*/
|
|
||||||
public static Connector getConnector() {
|
|
||||||
return connector;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the connector instance for Geyser
|
|
||||||
*
|
|
||||||
* @param connector the connector instance
|
|
||||||
*/
|
|
||||||
public static void setConnector(Connector connector) {
|
|
||||||
Geyser.connector = connector;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the logger
|
|
||||||
*
|
|
||||||
* @return the logger
|
|
||||||
*/
|
|
||||||
public static Logger getLogger() {
|
|
||||||
return connector.getLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the plugin manager
|
|
||||||
*
|
|
||||||
* @return the plugin manager
|
|
||||||
*/
|
|
||||||
public static PluginManager getPluginManager() {
|
|
||||||
return connector.getPluginManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the command map
|
|
||||||
*
|
|
||||||
* @return the command map
|
|
||||||
*/
|
|
||||||
public static CommandMap getCommandMap() {
|
|
||||||
return connector.getCommandMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScheduledExecutorService getGeneralThreadPool() {
|
|
||||||
return connector.getGeneralThreadPool();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the amount of online players
|
|
||||||
*/
|
|
||||||
public static int getPlayerCount() {
|
|
||||||
return connector.getConnectedPlayers().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a collection of the connected players
|
|
||||||
*
|
|
||||||
* @return a collection of the connected players
|
|
||||||
*/
|
|
||||||
public static Collection<? extends Player> getConnectedPlayers() {
|
|
||||||
return connector.getConnectedPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api;
|
|
||||||
|
|
||||||
import org.geysermc.api.command.CommandSender;
|
|
||||||
import org.geysermc.api.session.AuthData;
|
|
||||||
import org.geysermc.api.window.FormWindow;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
public interface Player extends CommandSender {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects the player to the remote server
|
|
||||||
*
|
|
||||||
* @param remoteServer the remote server to connect to
|
|
||||||
*/
|
|
||||||
void connect(RemoteServer remoteServer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnect the player for the specified reason
|
|
||||||
*
|
|
||||||
* @param reason the reason to disconnect the player for
|
|
||||||
*/
|
|
||||||
void disconnect(String reason);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the authentication data of the player. This is not the
|
|
||||||
* player's Minecraft credentials; it's simply what is given to the server
|
|
||||||
* (Name, UUID, Xbox UUID) to verify the player can/actually exists.
|
|
||||||
*
|
|
||||||
* @return the authentication data of the player
|
|
||||||
*/
|
|
||||||
AuthData getAuthenticationData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a form window
|
|
||||||
*
|
|
||||||
* @param window the window form to send
|
|
||||||
*/
|
|
||||||
void sendForm(FormWindow window);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a form window with the given ID
|
|
||||||
*
|
|
||||||
* @param window the window to send
|
|
||||||
* @param id the id of the window
|
|
||||||
*/
|
|
||||||
void sendForm(FormWindow window, int id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current hostname and port the player is connected with.
|
|
||||||
*
|
|
||||||
* @return player's socket address.
|
|
||||||
*/
|
|
||||||
InetSocketAddress getSocketAddress();
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.command;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface Command {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of this command
|
|
||||||
*
|
|
||||||
* @return the name of this command
|
|
||||||
*/
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the description of this command
|
|
||||||
*
|
|
||||||
* @return the description of this command
|
|
||||||
*/
|
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the aliases of this command
|
|
||||||
*
|
|
||||||
* @return the aliases of this command
|
|
||||||
*/
|
|
||||||
List<String> getAliases();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the aliases of this command
|
|
||||||
*
|
|
||||||
* @param aliases the a liases of the command
|
|
||||||
*/
|
|
||||||
void setAliases(List<String> aliases);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes the command
|
|
||||||
*
|
|
||||||
* @param sender the sender of the command
|
|
||||||
* @param args the arguments of the command
|
|
||||||
*/
|
|
||||||
void execute(CommandSender sender, String[] args);
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.command;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface CommandMap {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a new command
|
|
||||||
*
|
|
||||||
* @param command the command to register
|
|
||||||
*/
|
|
||||||
void registerCommand(Command command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a command for the given command sender
|
|
||||||
*
|
|
||||||
* @param sender the sender to run the command for
|
|
||||||
* @param command the command to run
|
|
||||||
*/
|
|
||||||
void runCommand(CommandSender sender, String command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a map of the commands
|
|
||||||
*
|
|
||||||
* @return a map of the commands
|
|
||||||
*/
|
|
||||||
Map<String, Command> getCommands();
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.command;
|
|
||||||
|
|
||||||
public interface CommandSender {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of the sender
|
|
||||||
*
|
|
||||||
* @return the name of the sender
|
|
||||||
*/
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a message to the command sender
|
|
||||||
*
|
|
||||||
* @param message the message to be sent
|
|
||||||
*/
|
|
||||||
void sendMessage(String message);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends multiple messages to the command sender
|
|
||||||
*
|
|
||||||
* @param messages the messages to be sent
|
|
||||||
*/
|
|
||||||
void sendMessage(String[] messages);
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.command;
|
|
||||||
|
|
||||||
public interface ConsoleCommandSender extends CommandSender {
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.events;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The annotation to put on all methods that are events.
|
|
||||||
*/
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface EventHandler {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the order to execute events.
|
|
||||||
* @see EventPriority
|
|
||||||
*/
|
|
||||||
EventPriority value() default EventPriority.NORMAL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When an eventHandler should be run.
|
|
||||||
* The names mostly explain.
|
|
||||||
*/
|
|
||||||
enum EventPriority {
|
|
||||||
FIRST,
|
|
||||||
NORMAL,
|
|
||||||
LAST,
|
|
||||||
READ_ONLY;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A marker class which says that a specific class uses events.
|
|
||||||
* @see EventHandler
|
|
||||||
*/
|
|
||||||
public interface Listener {
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.events;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class PingEvent {
|
|
||||||
|
|
||||||
public PingEvent(InetSocketAddress address) {
|
|
||||||
this.address = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
private InetSocketAddress address;
|
|
||||||
|
|
||||||
private String edition;
|
|
||||||
private String motd;
|
|
||||||
private int protocolVersion;
|
|
||||||
private String version;
|
|
||||||
private int playerCount;
|
|
||||||
private int maximumPlayerCount;
|
|
||||||
private long serverId;
|
|
||||||
private String subMotd;
|
|
||||||
private String gameType;
|
|
||||||
private boolean nintendoLimited;
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.events.player;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.api.Player;
|
|
||||||
|
|
||||||
public class PlayerEvent {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
public PlayerEvent(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.events.player;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.api.Player;
|
|
||||||
import org.geysermc.api.window.FormWindow;
|
|
||||||
import org.geysermc.api.window.response.FormResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a player interacts with a form
|
|
||||||
*/
|
|
||||||
public class PlayerFormResponseEvent extends PlayerEvent {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int formID;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private FormWindow window;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new PlayerFormResponseEvent instance
|
|
||||||
*
|
|
||||||
* @param player the player interacting with the form
|
|
||||||
* @param formID the id of the form
|
|
||||||
* @param window the window
|
|
||||||
*/
|
|
||||||
public PlayerFormResponseEvent(Player player, int formID, FormWindow window) {
|
|
||||||
super(player);
|
|
||||||
|
|
||||||
this.formID = formID;
|
|
||||||
this.window = window;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the response of the window, can be null
|
|
||||||
* if the player closed the window
|
|
||||||
*
|
|
||||||
* @return the response of the window
|
|
||||||
*/
|
|
||||||
public FormResponse getResponse() {
|
|
||||||
return window.getResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the window is closed
|
|
||||||
*
|
|
||||||
* @return if the window is closed
|
|
||||||
*/
|
|
||||||
public boolean isClosed() {
|
|
||||||
return window.isClosed();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.plugin;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The class that any main plugin class should extend.
|
|
||||||
* The first init point is the constructor, followed by onLoad, and finally onEnable.
|
|
||||||
*/
|
|
||||||
public class Plugin {
|
|
||||||
protected String name;
|
|
||||||
protected String version;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the plugin is enabled
|
|
||||||
*
|
|
||||||
* @return if the plugin is enabled
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean enabled = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a plugin is enabled
|
|
||||||
*/
|
|
||||||
public void onEnable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a plugin is disabled
|
|
||||||
*/
|
|
||||||
public void onDisable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a plugin is loaded
|
|
||||||
*/
|
|
||||||
public void onLoad() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server is reloaded
|
|
||||||
*/
|
|
||||||
public void onReload() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final String toString() {
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.plugin;
|
|
||||||
|
|
||||||
import org.geysermc.api.events.Listener;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface PluginManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a plugin and all its class files
|
|
||||||
*
|
|
||||||
* @param plugin the plugin to load
|
|
||||||
*/
|
|
||||||
void loadPlugin(Plugin plugin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables a plugin
|
|
||||||
*
|
|
||||||
* @param plugin the plugin to enable
|
|
||||||
*/
|
|
||||||
void enablePlugin(Plugin plugin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables a plugin
|
|
||||||
*
|
|
||||||
* @param plugin the plugin to disable
|
|
||||||
*/
|
|
||||||
void disablePlugin(Plugin plugin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unloads a plugin
|
|
||||||
*
|
|
||||||
* @param plugin the plugin to unload
|
|
||||||
*/
|
|
||||||
void unloadPlugin(Plugin plugin);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a set of the loaded plugins
|
|
||||||
*
|
|
||||||
* @return a set of the loaded plugins
|
|
||||||
*/
|
|
||||||
Set<Plugin> getPlugins();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name The name of the plugin you want to get.
|
|
||||||
* @return The plugin with the String name in the parameters.
|
|
||||||
*/
|
|
||||||
Plugin getPluginByName(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a listener to be run when an event is executed
|
|
||||||
* @param plugin the plugin registering the listener
|
|
||||||
* @param listener the listener which will contain the event methods
|
|
||||||
*/
|
|
||||||
void registerEventListener(Plugin plugin, Listener listener);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run an event
|
|
||||||
* @param o the event object.
|
|
||||||
*/
|
|
||||||
void runEvent(Object o);
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.api.session;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface AuthData {
|
|
||||||
|
|
||||||
String getName();
|
|
||||||
|
|
||||||
UUID getUUID();
|
|
||||||
|
|
||||||
String getXboxUUID();
|
|
||||||
}
|
|
@ -25,10 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.platform.bukkit;
|
package org.geysermc.platform.bukkit;
|
||||||
|
|
||||||
|
import org.geysermc.common.logger.IGeyserLogger;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class GeyserBukkitLogger implements org.geysermc.api.logger.Logger {
|
public class GeyserBukkitLogger implements IGeyserLogger {
|
||||||
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private boolean debugMode;
|
private boolean debugMode;
|
||||||
|
@ -49,7 +49,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
|
|||||||
|
|
||||||
geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
|
geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
|
|
||||||
GeyserConnector.start(this, false);
|
GeyserConnector.start(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,10 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.platform.bungeecord;
|
package org.geysermc.platform.bungeecord;
|
||||||
|
|
||||||
|
import org.geysermc.common.logger.IGeyserLogger;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class GeyserBungeeLogger implements org.geysermc.api.logger.Logger {
|
public class GeyserBungeeLogger implements IGeyserLogger {
|
||||||
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private boolean debugMode;
|
private boolean debugMode;
|
||||||
|
@ -86,7 +86,7 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
|
|||||||
|
|
||||||
geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
|
|
||||||
GeyserConnector.start(this, false);
|
GeyserConnector.start(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +62,7 @@ public class GeyserBootstrap implements IGeyserBootstrap {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeyserConnector connector = GeyserConnector.start(this, false);
|
GeyserConnector connector = GeyserConnector.start(this);
|
||||||
|
|
||||||
ConsoleCommandReader consoleReader = new ConsoleCommandReader(connector);
|
ConsoleCommandReader consoleReader = new ConsoleCommandReader(connector);
|
||||||
consoleReader.startConsole();
|
consoleReader.startConsole();
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.platform.standalone.console;
|
package org.geysermc.platform.standalone.console;
|
||||||
|
|
||||||
import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
||||||
import org.geysermc.api.command.ConsoleCommandSender;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.command.GeyserConsoleCommandSender;
|
import org.geysermc.connector.command.GeyserConsoleCommandSender;
|
||||||
import org.jline.reader.EndOfFileException;
|
import org.jline.reader.EndOfFileException;
|
||||||
@ -82,7 +82,7 @@ public class ConsoleCommandReader {
|
|||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
ConsoleCommandSender sender = new GeyserConsoleCommandSender();
|
GeyserConsoleCommandSender sender = new GeyserConsoleCommandSender();
|
||||||
connector.getCommandMap().runCommand(sender, line);
|
connector.getCommandMap().runCommand(sender, line);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -26,14 +26,16 @@
|
|||||||
package org.geysermc.platform.standalone.console;
|
package org.geysermc.platform.standalone.console;
|
||||||
|
|
||||||
import io.sentry.Sentry;
|
import io.sentry.Sentry;
|
||||||
import org.geysermc.api.ChatColor;
|
|
||||||
|
import org.geysermc.common.ChatColor;
|
||||||
|
import org.geysermc.common.logger.IGeyserLogger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
public class GeyserLogger implements org.geysermc.api.logger.Logger {
|
public class GeyserLogger implements IGeyserLogger {
|
||||||
|
|
||||||
private boolean colored = true;
|
private boolean colored = true;
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geysermc</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>2.8.2</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api;
|
package org.geysermc.common;
|
||||||
|
|
||||||
public class ChatColor {
|
public class ChatColor {
|
||||||
|
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
package org.geysermc.common.bootstrap;
|
package org.geysermc.common.bootstrap;
|
||||||
|
|
||||||
import org.geysermc.api.logger.Logger;
|
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
|
import org.geysermc.common.logger.IGeyserLogger;
|
||||||
|
|
||||||
public interface IGeyserBootstrap {
|
public interface IGeyserBootstrap {
|
||||||
|
|
||||||
@ -36,5 +36,5 @@ public interface IGeyserBootstrap {
|
|||||||
|
|
||||||
IGeyserConfiguration getGeyserConfig();
|
IGeyserConfiguration getGeyserConfig();
|
||||||
|
|
||||||
Logger getGeyserLogger();
|
IGeyserLogger getGeyserLogger();
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.logger;
|
package org.geysermc.common.logger;
|
||||||
|
|
||||||
public interface Logger {
|
public interface IGeyserLogger {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a severe message to console
|
* Logs a severe message to console
|
@ -23,12 +23,13 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window;
|
package org.geysermc.common.window;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.window.button.FormImage;
|
import org.geysermc.common.window.CustomFormWindow;
|
||||||
import org.geysermc.api.window.component.FormComponent;
|
import org.geysermc.common.window.button.FormImage;
|
||||||
import org.geysermc.api.window.response.CustomFormResponse;
|
import org.geysermc.common.window.component.FormComponent;
|
||||||
|
import org.geysermc.common.window.response.CustomFormResponse;
|
||||||
|
|
||||||
public class CustomFormBuilder {
|
public class CustomFormBuilder {
|
||||||
|
|
@ -23,22 +23,16 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window;
|
package org.geysermc.common.window;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.window.button.FormImage;
|
import org.geysermc.common.window.button.FormImage;
|
||||||
import org.geysermc.api.window.component.DropdownComponent;
|
import org.geysermc.common.window.component.*;
|
||||||
import org.geysermc.api.window.component.FormComponent;
|
import org.geysermc.common.window.response.CustomFormResponse;
|
||||||
import org.geysermc.api.window.component.InputComponent;
|
import org.geysermc.common.window.response.FormResponseData;
|
||||||
import org.geysermc.api.window.component.LabelComponent;
|
|
||||||
import org.geysermc.api.window.component.SliderComponent;
|
|
||||||
import org.geysermc.api.window.component.StepSliderComponent;
|
|
||||||
import org.geysermc.api.window.component.ToggleComponent;
|
|
||||||
import org.geysermc.api.window.response.CustomFormResponse;
|
|
||||||
import org.geysermc.api.window.response.FormResponseData;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -23,11 +23,11 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window;
|
package org.geysermc.common.window;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.window.response.FormResponse;
|
import org.geysermc.common.window.response.FormResponse;
|
||||||
|
|
||||||
public abstract class FormWindow {
|
public abstract class FormWindow {
|
||||||
|
|
@ -23,12 +23,12 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window;
|
package org.geysermc.common.window;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.window.response.ModalFormResponse;
|
import org.geysermc.common.window.response.ModalFormResponse;
|
||||||
|
|
||||||
public class ModalFormWindow extends FormWindow {
|
public class ModalFormWindow extends FormWindow {
|
||||||
|
|
@ -23,13 +23,13 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window;
|
package org.geysermc.common.window;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.window.button.FormButton;
|
import org.geysermc.common.window.button.FormButton;
|
||||||
import org.geysermc.api.window.response.SimpleFormResponse;
|
import org.geysermc.common.window.response.SimpleFormResponse;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.button;
|
package org.geysermc.common.window.button;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.button;
|
package org.geysermc.common.window.button;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -54,7 +54,7 @@ public class SliderComponent extends FormComponent {
|
|||||||
super("slider");
|
super("slider");
|
||||||
|
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.min = min < 0f ? 0f : min;
|
this.min = Math.max(min, 0f);
|
||||||
this.max = max > this.min ? max : this.min;
|
this.max = max > this.min ? max : this.min;
|
||||||
if (step != -1f && step > 0)
|
if (step != -1f && step > 0)
|
||||||
this.step = step;
|
this.step = step;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.component;
|
package org.geysermc.common.window.component;
|
||||||
|
|
||||||
public class ToggleComponent extends FormComponent {
|
public class ToggleComponent extends FormComponent {
|
||||||
|
|
@ -23,10 +23,12 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.response;
|
package org.geysermc.common.window.response;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.geysermc.common.window.response.FormResponse;
|
||||||
|
import org.geysermc.common.window.response.FormResponseData;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.response;
|
package org.geysermc.common.window.response;
|
||||||
|
|
||||||
public interface FormResponse {
|
public interface FormResponse {
|
||||||
}
|
}
|
@ -23,7 +23,7 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.response;
|
package org.geysermc.common.window.response;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
@ -23,10 +23,11 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.response;
|
package org.geysermc.common.window.response;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.geysermc.common.window.response.FormResponse;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
@ -23,11 +23,12 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api.window.response;
|
package org.geysermc.common.window.response;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.window.button.FormButton;
|
import org.geysermc.common.window.button.FormButton;
|
||||||
|
import org.geysermc.common.window.response.FormResponse;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
@ -30,29 +30,21 @@ import com.nukkitx.protocol.bedrock.BedrockServer;
|
|||||||
import com.nukkitx.protocol.bedrock.v388.Bedrock_v388;
|
import com.nukkitx.protocol.bedrock.v388.Bedrock_v388;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.Connector;
|
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.api.Player;
|
|
||||||
import org.geysermc.api.command.CommandMap;
|
|
||||||
import org.geysermc.api.logger.Logger;
|
|
||||||
import org.geysermc.api.plugin.Plugin;
|
|
||||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||||
|
import org.geysermc.common.logger.IGeyserLogger;
|
||||||
import org.geysermc.connector.command.GeyserCommandMap;
|
import org.geysermc.connector.command.GeyserCommandMap;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.metrics.Metrics;
|
import org.geysermc.connector.metrics.Metrics;
|
||||||
import org.geysermc.connector.network.ConnectorServerEventHandler;
|
import org.geysermc.connector.network.ConnectorServerEventHandler;
|
||||||
import org.geysermc.connector.network.remote.RemoteJavaServer;
|
import org.geysermc.connector.network.remote.RemoteServer;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
import org.geysermc.connector.plugin.GeyserPluginLoader;
|
|
||||||
import org.geysermc.connector.plugin.GeyserPluginManager;
|
|
||||||
import org.geysermc.connector.thread.PingPassthroughThread;
|
import org.geysermc.connector.thread.PingPassthroughThread;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
import org.geysermc.connector.utils.Toolbox;
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -60,7 +52,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserConnector implements Connector {
|
public class GeyserConnector {
|
||||||
|
|
||||||
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC;
|
public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC;
|
||||||
public static final int BEDROCK_1_14_PROTOCOL_VERSION = 389;
|
public static final int BEDROCK_1_14_PROTOCOL_VERSION = 389;
|
||||||
@ -72,14 +64,12 @@ public class GeyserConnector implements Connector {
|
|||||||
|
|
||||||
private static GeyserConnector instance;
|
private static GeyserConnector instance;
|
||||||
|
|
||||||
private RemoteJavaServer remoteServer;
|
private RemoteServer remoteServer;
|
||||||
|
|
||||||
private Logger logger;
|
|
||||||
|
|
||||||
private CommandMap commandMap;
|
|
||||||
|
|
||||||
|
private IGeyserLogger logger;
|
||||||
private IGeyserConfiguration config;
|
private IGeyserConfiguration config;
|
||||||
private GeyserPluginManager pluginManager;
|
|
||||||
|
private GeyserCommandMap commandMap;
|
||||||
|
|
||||||
private boolean shuttingDown = false;
|
private boolean shuttingDown = false;
|
||||||
|
|
||||||
@ -88,13 +78,12 @@ public class GeyserConnector implements Connector {
|
|||||||
|
|
||||||
private Metrics metrics;
|
private Metrics metrics;
|
||||||
|
|
||||||
private GeyserConnector(IGeyserConfiguration config, Logger logger, boolean loadPlugins) {
|
private GeyserConnector(IGeyserConfiguration config, IGeyserLogger logger) {
|
||||||
long startupTime = System.currentTimeMillis();
|
long startupTime = System.currentTimeMillis();
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
GeyserLogger.setLogger(logger);
|
|
||||||
|
|
||||||
logger.info("******************************************");
|
logger.info("******************************************");
|
||||||
logger.info("");
|
logger.info("");
|
||||||
@ -103,7 +92,6 @@ public class GeyserConnector implements Connector {
|
|||||||
logger.info("******************************************");
|
logger.info("******************************************");
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool());
|
this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool());
|
||||||
|
|
||||||
logger.setDebug(config.isDebugMode());
|
logger.setDebug(config.isDebugMode());
|
||||||
@ -112,13 +100,7 @@ public class GeyserConnector implements Connector {
|
|||||||
TranslatorsInit.start();
|
TranslatorsInit.start();
|
||||||
|
|
||||||
commandMap = new GeyserCommandMap(this);
|
commandMap = new GeyserCommandMap(this);
|
||||||
remoteServer = new RemoteJavaServer(config.getRemote().getAddress(), config.getRemote().getPort());
|
remoteServer = new RemoteServer(config.getRemote().getAddress(), config.getRemote().getPort());
|
||||||
|
|
||||||
Geyser.setConnector(this);
|
|
||||||
|
|
||||||
pluginManager = new GeyserPluginManager(new GeyserPluginLoader(this));
|
|
||||||
if (loadPlugins)
|
|
||||||
pluginManager.getLoader().loadPlugins();
|
|
||||||
|
|
||||||
passthroughThread = new PingPassthroughThread(this);
|
passthroughThread = new PingPassthroughThread(this);
|
||||||
if (config.isPingPassthrough())
|
if (config.isPingPassthrough())
|
||||||
@ -136,9 +118,9 @@ public class GeyserConnector implements Connector {
|
|||||||
}).join();
|
}).join();
|
||||||
|
|
||||||
if (config.getMetrics().isEnabled()) {
|
if (config.getMetrics().isEnabled()) {
|
||||||
metrics = new Metrics("GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
|
metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
|
||||||
metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1));
|
metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1));
|
||||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", Geyser::getPlayerCount));
|
metrics.addCustomChart(new Metrics.SingleLineChart("players", players::size));
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("authMode", config.getRemote()::getAuthType));
|
metrics.addCustomChart(new Metrics.SimplePie("authMode", config.getRemote()::getAuthType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,40 +128,34 @@ public class GeyserConnector implements Connector {
|
|||||||
logger.info(String.format("Done (%ss)! Run /help for help!", new DecimalFormat("#.###").format(completeTime)));
|
logger.info(String.format("Done (%ss)! Run /help for help!", new DecimalFormat("#.###").format(completeTime)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<? extends Player> getConnectedPlayers() {
|
|
||||||
return players.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
logger.info("Shutting down connector.");
|
logger.info("Shutting down connector.");
|
||||||
for (Plugin plugin : pluginManager.getPlugins()) {
|
|
||||||
pluginManager.disablePlugin(plugin);
|
|
||||||
pluginManager.unloadPlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
shuttingDown = true;
|
shuttingDown = true;
|
||||||
|
|
||||||
generalThreadPool.shutdown();
|
generalThreadPool.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(GeyserSession player) {
|
public void addPlayer(GeyserSession player) {
|
||||||
players.put(player.getAuthenticationData().getName(), player);
|
players.put(player.getAuthData().getName(), player);
|
||||||
players.put(player.getAuthenticationData().getUUID(), player);
|
players.put(player.getAuthData().getUUID(), player);
|
||||||
players.put(player.getSocketAddress(), player);
|
players.put(player.getSocketAddress(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(GeyserSession player) {
|
public void removePlayer(GeyserSession player) {
|
||||||
players.remove(player.getAuthenticationData().getName());
|
players.remove(player.getAuthData().getName());
|
||||||
players.remove(player.getAuthenticationData().getUUID());
|
players.remove(player.getAuthData().getUUID());
|
||||||
players.remove(player.getSocketAddress());
|
players.remove(player.getSocketAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GeyserConnector start(IGeyserBootstrap bootstrap, boolean loadPlugins) {
|
public static GeyserConnector start(IGeyserBootstrap bootstrap) {
|
||||||
return new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger(), loadPlugins);
|
return new GeyserConnector(bootstrap.getGeyserConfig(), bootstrap.getGeyserLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stop() {
|
public static void stop() {
|
||||||
instance.shutdown();
|
instance.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GeyserConnector getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.geysermc.connector.command;
|
||||||
|
|
||||||
|
public interface CommandSender {
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
default void sendMessage(String[] messages) {
|
||||||
|
for (String message : messages) {
|
||||||
|
sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendMessage(String message);
|
||||||
|
}
|
@ -25,18 +25,24 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.command;
|
package org.geysermc.connector.command;
|
||||||
|
|
||||||
import org.geysermc.api.command.Command;
|
import lombok.AccessLevel;
|
||||||
import org.geysermc.api.command.CommandSender;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class GeyserCommand implements Command {
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public abstract class GeyserCommand {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@Setter(AccessLevel.NONE)
|
||||||
private GeyserCommandMap commandMap;
|
private GeyserCommandMap commandMap;
|
||||||
|
|
||||||
private List<String> aliases;
|
private List<String> aliases = new ArrayList<>();
|
||||||
|
|
||||||
public GeyserCommand(String name) {
|
public GeyserCommand(String name) {
|
||||||
this(name, "A geyser command.");
|
this(name, "A geyser command.");
|
||||||
@ -47,38 +53,5 @@ public abstract class GeyserCommand implements Command {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getAliases() {
|
|
||||||
return aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAliases(List<String> aliases) {
|
|
||||||
this.aliases = aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract void execute(CommandSender sender, String[] args);
|
public abstract void execute(CommandSender sender, String[] args);
|
||||||
|
|
||||||
public GeyserCommandMap getCommandMap() {
|
|
||||||
return commandMap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,6 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.command;
|
package org.geysermc.connector.command;
|
||||||
|
|
||||||
import org.geysermc.api.command.Command;
|
|
||||||
import org.geysermc.api.command.CommandMap;
|
|
||||||
import org.geysermc.api.command.CommandSender;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.command.defaults.HelpCommand;
|
import org.geysermc.connector.command.defaults.HelpCommand;
|
||||||
import org.geysermc.connector.command.defaults.StopCommand;
|
import org.geysermc.connector.command.defaults.StopCommand;
|
||||||
@ -36,9 +33,9 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GeyserCommandMap implements CommandMap {
|
public class GeyserCommandMap {
|
||||||
|
|
||||||
private final Map<String, Command> commandMap = Collections.synchronizedMap(new HashMap<String, Command>());
|
private final Map<String, GeyserCommand> commandMap = Collections.synchronizedMap(new HashMap<>());
|
||||||
private GeyserConnector connector;
|
private GeyserConnector connector;
|
||||||
|
|
||||||
public GeyserCommandMap(GeyserConnector connector) {
|
public GeyserCommandMap(GeyserConnector connector) {
|
||||||
@ -52,11 +49,11 @@ public class GeyserCommandMap implements CommandMap {
|
|||||||
registerCommand(new StopCommand(connector, "stop", "Shut down Geyser."));
|
registerCommand(new StopCommand(connector, "stop", "Shut down Geyser."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand(Command command) {
|
public void registerCommand(GeyserCommand command) {
|
||||||
commandMap.put(command.getName(), command);
|
commandMap.put(command.getName(), command);
|
||||||
connector.getLogger().debug("Registered command " + command.getName());
|
connector.getLogger().debug("Registered command " + command.getName());
|
||||||
|
|
||||||
if (command.getAliases() == null || command.getAliases().isEmpty())
|
if (command.getAliases().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (String alias : command.getAliases())
|
for (String alias : command.getAliases())
|
||||||
@ -64,25 +61,24 @@ public class GeyserCommandMap implements CommandMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runCommand(CommandSender sender, String command) {
|
public void runCommand(CommandSender sender, String command) {
|
||||||
String trim = command.trim();
|
if (!command.startsWith("/geyser "))
|
||||||
String label = null;
|
return;
|
||||||
String[] args = null;
|
|
||||||
|
|
||||||
if (!trim.contains(" ")) {
|
command = command.trim();
|
||||||
label = trim.toLowerCase();
|
command = command.replace("geyser ", "");
|
||||||
|
String label;
|
||||||
|
String[] args;
|
||||||
|
|
||||||
|
if (!command.contains(" ")) {
|
||||||
|
label = command.toLowerCase();
|
||||||
args = new String[0];
|
args = new String[0];
|
||||||
} else {
|
} else {
|
||||||
label = trim.substring(0, trim.indexOf(" ")).toLowerCase();
|
label = command.substring(0, command.indexOf(" ")).toLowerCase();
|
||||||
String argLine = trim.substring(trim.indexOf(" " + 1));
|
String argLine = command.substring(command.indexOf(" " + 1));
|
||||||
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
|
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label == null) {
|
GeyserCommand cmd = commandMap.get(label);
|
||||||
connector.getLogger().warning("Invalid Command! Try /help for a list of commands.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Command cmd = commandMap.get(label);
|
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
connector.getLogger().warning("Invalid Command! Try /help for a list of commands.");
|
connector.getLogger().warning("Invalid Command! Try /help for a list of commands.");
|
||||||
return;
|
return;
|
||||||
@ -91,7 +87,7 @@ public class GeyserCommandMap implements CommandMap {
|
|||||||
cmd.execute(sender, args);
|
cmd.execute(sender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Command> getCommands() {
|
public Map<String, GeyserCommand> getCommands() {
|
||||||
return commandMap;
|
return commandMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,9 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.command;
|
package org.geysermc.connector.command;
|
||||||
|
|
||||||
import org.geysermc.api.command.ConsoleCommandSender;
|
import org.geysermc.common.ChatColor;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
|
|
||||||
public class GeyserConsoleCommandSender implements ConsoleCommandSender {
|
public class GeyserConsoleCommandSender implements CommandSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -37,13 +36,6 @@ public class GeyserConsoleCommandSender implements ConsoleCommandSender {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
System.out.println(GeyserLogger.printConsole(message, true));
|
System.out.println(ChatColor.toANSI(message + ChatColor.RESET));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(String[] messages) {
|
|
||||||
for (String message : messages) {
|
|
||||||
sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,12 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.command.defaults;
|
package org.geysermc.connector.command.defaults;
|
||||||
|
|
||||||
import org.geysermc.api.ChatColor;
|
import org.geysermc.common.ChatColor;
|
||||||
import org.geysermc.api.command.Command;
|
|
||||||
import org.geysermc.api.command.CommandSender;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.command.CommandSender;
|
||||||
import org.geysermc.connector.command.GeyserCommand;
|
import org.geysermc.connector.command.GeyserCommand;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class HelpCommand extends GeyserCommand {
|
public class HelpCommand extends GeyserCommand {
|
||||||
|
|
||||||
@ -45,15 +40,15 @@ public class HelpCommand extends GeyserCommand {
|
|||||||
super(name, description);
|
super(name, description);
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
|
|
||||||
this.setAliases(Arrays.asList("?"));
|
this.setAliases(Collections.singletonList("?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
sender.sendMessage("---- Showing Help For: Geyser (Page 1/1) ----");
|
sender.sendMessage("---- Showing Help For: Geyser (Page 1/1) ----");
|
||||||
Map<String, Command> cmds = connector.getCommandMap().getCommands();
|
Map<String, GeyserCommand> cmds = connector.getCommandMap().getCommands();
|
||||||
|
|
||||||
List<String> commands = new ArrayList<String>(cmds.keySet());
|
List<String> commands = new ArrayList<>(cmds.keySet());
|
||||||
Collections.sort(commands);
|
Collections.sort(commands);
|
||||||
|
|
||||||
for (String cmd : commands) {
|
for (String cmd : commands) {
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
|
|
||||||
package org.geysermc.connector.command.defaults;
|
package org.geysermc.connector.command.defaults;
|
||||||
|
|
||||||
import org.geysermc.api.command.CommandSender;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.command.CommandSender;
|
||||||
import org.geysermc.connector.command.GeyserCommand;
|
import org.geysermc.connector.command.GeyserCommand;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class StopCommand extends GeyserCommand {
|
public class StopCommand extends GeyserCommand {
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class StopCommand extends GeyserCommand {
|
|||||||
super(name, description);
|
super(name, description);
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
|
|
||||||
this.setAliases(Arrays.asList("shutdown"));
|
this.setAliases(Collections.singletonList("shutdown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,147 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.connector.console;
|
|
||||||
|
|
||||||
import io.sentry.Sentry;
|
|
||||||
import org.geysermc.api.ChatColor;
|
|
||||||
import org.geysermc.api.logger.Logger;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.logging.*;
|
|
||||||
|
|
||||||
public class GeyserLogger {
|
|
||||||
|
|
||||||
public static Logger DEFAULT;
|
|
||||||
|
|
||||||
/*
|
|
||||||
private boolean colored = true;
|
|
||||||
private boolean debug = false;
|
|
||||||
|
|
||||||
private GeyserLogger() {
|
|
||||||
ConsoleHandler consoleHandler = new ConsoleHandler();
|
|
||||||
consoleHandler.setLevel(Level.INFO);
|
|
||||||
consoleHandler.setFormatter(new SimpleFormatter() {
|
|
||||||
private static final String format = "[%1$tT][%2$-5s] %3$s %n";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized String format(LogRecord lr) {
|
|
||||||
return String.format(format,
|
|
||||||
new Date(lr.getMillis()),
|
|
||||||
lr.getLevel().getLocalizedName(),
|
|
||||||
lr.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
File logDir = new File("logs");
|
|
||||||
logDir.mkdir();
|
|
||||||
File logFile = new File(logDir, "latest.log");
|
|
||||||
int maxLogFileSize = 20;//Mo
|
|
||||||
if (logFile.exists() && (logFile.length()) > maxLogFileSize * 1024L * 1024L)
|
|
||||||
this.warning("Your log file is larger than " + maxLogFileSize + "Mo, you should backup and clean it !");
|
|
||||||
FileHandler fileHandler = new FileHandler(logFile.getCanonicalPath(), true);
|
|
||||||
fileHandler.setLevel(Level.INFO);
|
|
||||||
fileHandler.setFormatter(new SimpleFormatter() {
|
|
||||||
private static final String format = "[%1$tF %1$tT][%2$-5s] %3$s %n";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized String format(LogRecord lr) {
|
|
||||||
return String.format(format,
|
|
||||||
new Date(lr.getMillis()),
|
|
||||||
lr.getLevel().getLocalizedName(),
|
|
||||||
lr.getMessage()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (IOException | SecurityException ex) {
|
|
||||||
Logger.getLogger(GeyserLogger.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.getenv().containsKey("DP_SENTRY_CLIENT_KEY")) {
|
|
||||||
Handler sentryHandler = new io.sentry.jul.SentryHandler();
|
|
||||||
sentryHandler.setLevel(Level.SEVERE);
|
|
||||||
Sentry.init(System.getenv().get("DP_SENTRY_CLIENT_KEY"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void severe(String message) {
|
|
||||||
System.out.println(printConsole(ChatColor.DARK_RED + message, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void severe(String message, Throwable error) {
|
|
||||||
System.out.println(printConsole(ChatColor.DARK_RED + message + "\n" + error.getMessage(), colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String message) {
|
|
||||||
System.out.println(printConsole(ChatColor.RED + message, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String message, Throwable error) {
|
|
||||||
System.out.println(printConsole(ChatColor.RED + message + "\n" + error, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warning(String message) {
|
|
||||||
System.out.println(printConsole(ChatColor.YELLOW + message, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String message) {
|
|
||||||
System.out.println(printConsole(ChatColor.WHITE + message, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String message) {
|
|
||||||
if (debug)
|
|
||||||
System.out.println(printConsole(ChatColor.GRAY + message, colored));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String printConsole(String message, boolean colors) {
|
|
||||||
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDebug(boolean debug) {
|
|
||||||
this.debug = debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String printConsole(String message, boolean colors) {
|
|
||||||
return colors ? ChatColor.toANSI(message + ChatColor.RESET) : ChatColor.stripColors(message + ChatColor.RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setLogger(Logger logger) {
|
|
||||||
DEFAULT = logger;
|
|
||||||
}
|
|
||||||
}
|
|
@ -34,11 +34,13 @@ import com.nukkitx.protocol.bedrock.data.EntityDataDictionary;
|
|||||||
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
import com.nukkitx.protocol.bedrock.data.EntityFlag;
|
||||||
import com.nukkitx.protocol.bedrock.data.EntityFlags;
|
import com.nukkitx.protocol.bedrock.data.EntityFlags;
|
||||||
import com.nukkitx.protocol.bedrock.packet.*;
|
import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.entity.attribute.Attribute;
|
import org.geysermc.connector.entity.attribute.Attribute;
|
||||||
import org.geysermc.connector.entity.attribute.AttributeType;
|
import org.geysermc.connector.entity.attribute.AttributeType;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
@ -115,7 +117,7 @@ public class Entity {
|
|||||||
valid = true;
|
valid = true;
|
||||||
session.getUpstream().sendPacket(addEntityPacket);
|
session.getUpstream().sendPacket(addEntityPacket);
|
||||||
|
|
||||||
GeyserLogger.DEFAULT.debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
|
session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +27,11 @@ package org.geysermc.connector.entity;
|
|||||||
|
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
import com.nukkitx.protocol.bedrock.packet.AddPaintingPacket;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.utils.PaintingType;
|
import org.geysermc.connector.utils.PaintingType;
|
||||||
@ -58,7 +59,7 @@ public class PaintingEntity extends Entity {
|
|||||||
|
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
GeyserLogger.DEFAULT.debug("Spawned painting on " + position);
|
session.getConnector().getLogger().debug("Spawned painting on " + position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3f fixOffset(boolean toBedrock) {
|
public Vector3f fixOffset(boolean toBedrock) {
|
||||||
|
@ -29,9 +29,11 @@ import com.github.steveice10.mc.auth.data.GameProfile;
|
|||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.AddPlayerPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.utils.SkinUtils;
|
import org.geysermc.connector.utils.SkinUtils;
|
||||||
@ -105,7 +107,7 @@ public class PlayerEntity extends LivingEntity {
|
|||||||
|
|
||||||
if (!playerList) {
|
if (!playerList) {
|
||||||
// remove from playerlist if player isn't on playerlist
|
// remove from playerlist if player isn't on playerlist
|
||||||
Geyser.getGeneralThreadPool().execute(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
|
||||||
PlayerListPacket playerList = new PlayerListPacket();
|
PlayerListPacket playerList = new PlayerListPacket();
|
||||||
playerList.setType(PlayerListPacket.Type.REMOVE);
|
playerList.setType(PlayerListPacket.Type.REMOVE);
|
||||||
playerList.getEntries().add(new PlayerListPacket.Entry(uuid));
|
playerList.getEntries().add(new PlayerListPacket.Entry(uuid));
|
||||||
|
@ -2,7 +2,6 @@ package org.geysermc.connector.metrics;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@ -47,15 +46,19 @@ public class Metrics {
|
|||||||
// A list with all custom charts
|
// A list with all custom charts
|
||||||
private final List<CustomChart> charts = new ArrayList<>();
|
private final List<CustomChart> charts = new ArrayList<>();
|
||||||
|
|
||||||
|
private GeyserConnector connector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor.
|
* Class constructor.
|
||||||
*
|
*
|
||||||
|
* @param connector The GeyserConnector instance
|
||||||
* @param name The name of the server software.
|
* @param name The name of the server software.
|
||||||
* @param serverUUID The uuid of the server.
|
* @param serverUUID The uuid of the server.
|
||||||
* @param logFailedRequests Whether failed requests should be logged or not.
|
* @param logFailedRequests Whether failed requests should be logged or not.
|
||||||
* @param logger The logger for the failed requests.
|
* @param logger The logger for the failed requests.
|
||||||
*/
|
*/
|
||||||
public Metrics(String name, String serverUUID, boolean logFailedRequests, Logger logger) {
|
public Metrics(GeyserConnector connector, String name, String serverUUID, boolean logFailedRequests, Logger logger) {
|
||||||
|
this.connector = connector;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.serverUUID = serverUUID;
|
this.serverUUID = serverUUID;
|
||||||
Metrics.logFailedRequests = logFailedRequests;
|
Metrics.logFailedRequests = logFailedRequests;
|
||||||
@ -81,7 +84,7 @@ public class Metrics {
|
|||||||
* Starts the Scheduler which submits our data every 30 minutes.
|
* Starts the Scheduler which submits our data every 30 minutes.
|
||||||
*/
|
*/
|
||||||
private void startSubmitting() {
|
private void startSubmitting() {
|
||||||
Geyser.getGeneralThreadPool().scheduleAtFixedRate(this::submitData, 1, 30, TimeUnit.MINUTES);
|
connector.getGeneralThreadPool().scheduleAtFixedRate(this::submitData, 1, 30, TimeUnit.MINUTES);
|
||||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||||
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
||||||
// WARNING: Just don't do it!
|
// WARNING: Just don't do it!
|
||||||
@ -119,7 +122,7 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private JsonObject getServerData() {
|
private JsonObject getServerData() {
|
||||||
// OS specific data
|
// OS specific data
|
||||||
int playerAmount = Geyser.getPlayerCount();
|
int playerAmount = connector.getPlayers().size();
|
||||||
|
|
||||||
String osName = System.getProperty("os.name");
|
String osName = System.getProperty("os.name");
|
||||||
String osArch = System.getProperty("os.arch");
|
String osArch = System.getProperty("os.arch");
|
||||||
|
@ -29,10 +29,9 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
|
|||||||
import com.nukkitx.protocol.bedrock.BedrockPong;
|
import com.nukkitx.protocol.bedrock.BedrockPong;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
|
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||||
import org.geysermc.api.events.PingEvent;
|
|
||||||
import org.geysermc.common.IGeyserConfiguration;
|
import org.geysermc.common.IGeyserConfiguration;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.utils.MessageUtils;
|
import org.geysermc.connector.utils.MessageUtils;
|
||||||
|
|
||||||
@ -48,50 +47,35 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
|
public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
|
||||||
GeyserLogger.DEFAULT.info(inetSocketAddress + " tried to connect!");
|
connector.getLogger().info(inetSocketAddress + " tried to connect!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
|
||||||
GeyserLogger.DEFAULT.debug(inetSocketAddress + " has pinged you!");
|
connector.getLogger().debug(inetSocketAddress + " has pinged you!");
|
||||||
|
|
||||||
IGeyserConfiguration config = connector.getConfig();
|
IGeyserConfiguration config = connector.getConfig();
|
||||||
PingEvent pongEvent = new PingEvent(inetSocketAddress);
|
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
|
||||||
pongEvent.setEdition("MCPE");
|
|
||||||
pongEvent.setGameType("Default");
|
|
||||||
pongEvent.setNintendoLimited(false);
|
|
||||||
pongEvent.setProtocolVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion());
|
|
||||||
pongEvent.setVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
|
||||||
|
|
||||||
connector.getPluginManager().runEvent(pongEvent);
|
|
||||||
if (connector.getConfig().isPingPassthrough()) {
|
|
||||||
ServerStatusInfo serverInfo = connector.getPassthroughThread().getInfo();
|
|
||||||
|
|
||||||
if (serverInfo != null) {
|
|
||||||
pongEvent.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
|
||||||
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
|
||||||
pongEvent.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
|
||||||
pongEvent.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pongEvent.setPlayerCount(1);
|
|
||||||
pongEvent.setMaximumPlayerCount(config.getMaxPlayers());
|
|
||||||
pongEvent.setMotd(config.getBedrock().getMotd1());
|
|
||||||
pongEvent.setSubMotd(config.getBedrock().getMotd2());
|
|
||||||
}
|
|
||||||
|
|
||||||
BedrockPong pong = new BedrockPong();
|
BedrockPong pong = new BedrockPong();
|
||||||
pong.setEdition(pongEvent.getEdition());
|
pong.setEdition("MCPE");
|
||||||
pong.setGameType(pongEvent.getGameType());
|
pong.setGameType("Default");
|
||||||
pong.setNintendoLimited(pongEvent.isNintendoLimited());
|
pong.setNintendoLimited(false);
|
||||||
pong.setProtocolVersion(pongEvent.getProtocolVersion());
|
pong.setProtocolVersion(GeyserConnector.BEDROCK_1_14_PROTOCOL_VERSION);
|
||||||
pong.setVersion(pongEvent.getVersion());
|
pong.setVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
|
||||||
pong.setMotd(pongEvent.getMotd());
|
|
||||||
pong.setSubMotd(pongEvent.getSubMotd());
|
|
||||||
pong.setPlayerCount(pongEvent.getPlayerCount());
|
|
||||||
pong.setMaximumPlayerCount(pongEvent.getMaximumPlayerCount());
|
|
||||||
pong.setIpv4Port(config.getBedrock().getPort());
|
pong.setIpv4Port(config.getBedrock().getPort());
|
||||||
|
if (connector.getConfig().isPingPassthrough()) {
|
||||||
|
pong.setMotd(MessageUtils.getBedrockMessage(serverInfo.getDescription()));
|
||||||
|
pong.setSubMotd(config.getBedrock().getMotd2());
|
||||||
|
pong.setPlayerCount(serverInfo.getPlayerInfo().getOnlinePlayers());
|
||||||
|
pong.setMaximumPlayerCount(serverInfo.getPlayerInfo().getMaxPlayers());
|
||||||
|
} else {
|
||||||
|
pong.setPlayerCount(connector.getPlayers().size());
|
||||||
|
pong.setMaximumPlayerCount(config.getMaxPlayers());
|
||||||
|
pong.setMotd(config.getBedrock().getMotd1());
|
||||||
|
pong.setMotd(config.getBedrock().getMotd2());
|
||||||
|
}
|
||||||
return pong;
|
return pong;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +84,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||||||
bedrockServerSession.setLogging(true);
|
bedrockServerSession.setLogging(true);
|
||||||
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
|
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
|
||||||
bedrockServerSession.addDisconnectHandler(disconnectReason -> {
|
bedrockServerSession.addDisconnectHandler(disconnectReason -> {
|
||||||
GeyserLogger.DEFAULT.info("Bedrock user with ip: " + bedrockServerSession.getAddress().getAddress() + " has disconnected for reason " + disconnectReason);
|
connector.getLogger().info("Bedrock user with ip: " + bedrockServerSession.getAddress().getAddress() + " has disconnected for reason " + disconnectReason);
|
||||||
|
|
||||||
GeyserSession player = connector.getPlayers().get(bedrockServerSession.getAddress());
|
GeyserSession player = connector.getPlayers().get(bedrockServerSession.getAddress());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
@ -66,7 +66,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||||||
switch (packet.getStatus()) {
|
switch (packet.getStatus()) {
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
session.connect(connector.getRemoteServer());
|
session.connect(connector.getRemoteServer());
|
||||||
connector.getLogger().info("Player connected with username " + session.getAuthenticationData().getName());
|
connector.getLogger().info("Player connected with username " + session.getAuthData().getName());
|
||||||
break;
|
break;
|
||||||
case HAVE_ALL_PACKS:
|
case HAVE_ALL_PACKS:
|
||||||
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
ResourcePackStackPacket stack = new ResourcePackStackPacket();
|
||||||
@ -93,7 +93,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||||||
IGeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername);
|
IGeyserConfiguration.IUserAuthenticationInfo info = connector.getConfig().getUserAuths().get(bedrockUsername);
|
||||||
|
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
connector.getLogger().info("using stored credentials for bedrock user " + session.getAuthenticationData().getName());
|
connector.getLogger().info("using stored credentials for bedrock user " + session.getAuthData().getName());
|
||||||
session.authenticate(info.getEmail(), info.getPassword());
|
session.authenticate(info.getEmail(), info.getPassword());
|
||||||
|
|
||||||
// TODO send a message to bedrock user telling them they are connected (if nothing like a motd
|
// TODO send a message to bedrock user telling them they are connected (if nothing like a motd
|
||||||
@ -109,7 +109,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||||||
public boolean handle(MovePlayerPacket packet) {
|
public boolean handle(MovePlayerPacket packet) {
|
||||||
if (!session.isLoggedIn() && !session.isLoggingIn()) {
|
if (!session.isLoggedIn() && !session.isLoggingIn()) {
|
||||||
// TODO it is safer to key authentication on something that won't change (UUID, not username)
|
// TODO it is safer to key authentication on something that won't change (UUID, not username)
|
||||||
if (!couldLoginUserByName(session.getAuthenticationData().getName())) {
|
if (!couldLoginUserByName(session.getAuthData().getName())) {
|
||||||
LoginEncryptionUtils.showLoginWindow(session);
|
LoginEncryptionUtils.showLoginWindow(session);
|
||||||
}
|
}
|
||||||
// else we were able to log the user in
|
// else we were able to log the user in
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.connector.network.remote;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.api.RemoteServer;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class RemoteJavaServer implements RemoteServer {
|
|
||||||
|
|
||||||
private String address;
|
|
||||||
private int port;
|
|
||||||
}
|
|
@ -23,21 +23,15 @@
|
|||||||
* @link https://github.com/GeyserMC/Geyser
|
* @link https://github.com/GeyserMC/Geyser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.geysermc.api;
|
package org.geysermc.connector.network.remote;
|
||||||
|
|
||||||
public interface RemoteServer {
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
@Getter
|
||||||
* Returns the IP address of the remote server
|
@AllArgsConstructor
|
||||||
*
|
public class RemoteServer {
|
||||||
* @return the IP address of the remote server
|
|
||||||
*/
|
|
||||||
String getAddress();
|
|
||||||
|
|
||||||
/**
|
private String address;
|
||||||
* Returns the port of the remote server
|
private int port;
|
||||||
*
|
|
||||||
* @return the port of the remote server
|
|
||||||
*/
|
|
||||||
int getPort();
|
|
||||||
}
|
}
|
@ -45,15 +45,17 @@ import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
|||||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||||
import com.nukkitx.protocol.bedrock.data.GameRule;
|
import com.nukkitx.protocol.bedrock.data.GameRule;
|
||||||
import com.nukkitx.protocol.bedrock.packet.*;
|
import com.nukkitx.protocol.bedrock.packet.*;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.geysermc.api.Player;
|
|
||||||
import org.geysermc.api.RemoteServer;
|
import org.geysermc.common.window.FormWindow;
|
||||||
import org.geysermc.api.session.AuthData;
|
|
||||||
import org.geysermc.api.window.FormWindow;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
import org.geysermc.connector.command.CommandSender;
|
||||||
import org.geysermc.connector.entity.PlayerEntity;
|
import org.geysermc.connector.entity.PlayerEntity;
|
||||||
import org.geysermc.connector.inventory.PlayerInventory;
|
import org.geysermc.connector.inventory.PlayerInventory;
|
||||||
|
import org.geysermc.connector.network.remote.RemoteServer;
|
||||||
|
import org.geysermc.connector.network.session.auth.AuthData;
|
||||||
import org.geysermc.connector.network.session.cache.*;
|
import org.geysermc.connector.network.session.cache.*;
|
||||||
import org.geysermc.connector.network.translators.Registry;
|
import org.geysermc.connector.network.translators.Registry;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
@ -63,13 +65,13 @@ import java.net.InetSocketAddress;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GeyserSession implements Player {
|
public class GeyserSession implements CommandSender {
|
||||||
|
|
||||||
private final GeyserConnector connector;
|
private final GeyserConnector connector;
|
||||||
private final UpstreamSession upstream;
|
private final UpstreamSession upstream;
|
||||||
private RemoteServer remoteServer;
|
private RemoteServer remoteServer;
|
||||||
private Client downstream;
|
private Client downstream;
|
||||||
private AuthData authenticationData;
|
private AuthData authData;
|
||||||
|
|
||||||
private PlayerEntity playerEntity;
|
private PlayerEntity playerEntity;
|
||||||
private PlayerInventory inventory;
|
private PlayerInventory inventory;
|
||||||
@ -123,7 +125,7 @@ public class GeyserSession implements Player {
|
|||||||
this.remoteServer = remoteServer;
|
this.remoteServer = remoteServer;
|
||||||
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
|
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
|
||||||
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
|
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
|
||||||
authenticate(authenticationData.getName());
|
authenticate(authData.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f pos = Vector3f.ZERO;
|
Vector3f pos = Vector3f.ZERO;
|
||||||
@ -182,7 +184,7 @@ public class GeyserSession implements Player {
|
|||||||
public void connected(ConnectedEvent event) {
|
public void connected(ConnectedEvent event) {
|
||||||
loggingIn = false;
|
loggingIn = false;
|
||||||
loggedIn = true;
|
loggedIn = true;
|
||||||
connector.getLogger().info(authenticationData.getName() + " (logged in as: " + protocol.getProfile().getName() + ")" + " has connected to remote java server on address " + remoteServer.getAddress());
|
connector.getLogger().info(authData.getName() + " (logged in as: " + protocol.getProfile().getName() + ")" + " has connected to remote java server on address " + remoteServer.getAddress());
|
||||||
playerEntity.setUuid(protocol.getProfile().getId());
|
playerEntity.setUuid(protocol.getProfile().getId());
|
||||||
playerEntity.setUsername(protocol.getProfile().getName());
|
playerEntity.setUsername(protocol.getProfile().getName());
|
||||||
}
|
}
|
||||||
@ -191,7 +193,7 @@ public class GeyserSession implements Player {
|
|||||||
public void disconnected(DisconnectedEvent event) {
|
public void disconnected(DisconnectedEvent event) {
|
||||||
loggingIn = false;
|
loggingIn = false;
|
||||||
loggedIn = false;
|
loggedIn = false;
|
||||||
connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
|
connector.getLogger().info(authData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
|
||||||
upstream.disconnect(event.getReason());
|
upstream.disconnect(event.getReason());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,12 +236,12 @@ public class GeyserSession implements Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthenticationData(AuthData authData) {
|
public void setAuthenticationData(AuthData authData) {
|
||||||
authenticationData = authData;
|
this.authData = authData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return authenticationData.getName();
|
return authData.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -255,18 +257,10 @@ public class GeyserSession implements Player {
|
|||||||
upstream.sendPacket(textPacket);
|
upstream.sendPacket(textPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(String[] messages) {
|
|
||||||
for (String message : messages) {
|
|
||||||
sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendForm(FormWindow window, int id) {
|
public void sendForm(FormWindow window, int id) {
|
||||||
windowCache.showWindow(window, id);
|
windowCache.showWindow(window, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public InetSocketAddress getSocketAddress() {
|
public InetSocketAddress getSocketAddress() {
|
||||||
return this.upstream.getAddress();
|
return this.upstream.getAddress();
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@ package org.geysermc.connector.network.session.auth;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.session.AuthData;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class BedrockAuthData implements AuthData {
|
public class AuthData {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private UUID UUID;
|
private UUID UUID;
|
@ -26,14 +26,14 @@
|
|||||||
package org.geysermc.connector.network.session.cache;
|
package org.geysermc.connector.network.session.cache;
|
||||||
|
|
||||||
import com.nukkitx.protocol.bedrock.packet.ModalFormRequestPacket;
|
import com.nukkitx.protocol.bedrock.packet.ModalFormRequestPacket;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
|
||||||
import org.geysermc.api.window.FormWindow;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import lombok.Getter;
|
||||||
import java.util.Map;
|
|
||||||
|
import org.geysermc.common.window.FormWindow;
|
||||||
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
public class WindowCache {
|
public class WindowCache {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators;
|
|||||||
|
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -55,7 +55,7 @@ public class Registry<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
GeyserLogger.DEFAULT.error("Could not translate packet " + packet.getClass().getSimpleName(), ex);
|
GeyserConnector.getInstance().getLogger().error("Could not translate packet " + packet.getClass().getSimpleName(), ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@ package org.geysermc.connector.network.translators.bedrock;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
|
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
|
|
||||||
@ -36,8 +37,8 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
|||||||
@Override
|
@Override
|
||||||
public void translate(CommandRequestPacket packet, GeyserSession session) {
|
public void translate(CommandRequestPacket packet, GeyserSession session) {
|
||||||
String command = packet.getCommand().replace("/", "");
|
String command = packet.getCommand().replace("/", "");
|
||||||
if (Geyser.getConnector().getCommandMap().getCommands().containsKey(command)) {
|
if (GeyserConnector.getInstance().getCommandMap().getCommands().containsKey(command)) {
|
||||||
Geyser.getConnector().getCommandMap().runCommand(session, command);
|
GeyserConnector.getInstance().getCommandMap().runCommand(session, command);
|
||||||
} else {
|
} else {
|
||||||
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
|
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
|
||||||
session.getDownstream().getSession().send(chatPacket);
|
session.getDownstream().getSession().send(chatPacket);
|
||||||
|
@ -30,7 +30,8 @@ import com.nukkitx.math.vector.Vector3f;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
||||||
import org.geysermc.api.ChatColor;
|
|
||||||
|
import org.geysermc.common.ChatColor;
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.entity.PlayerEntity;
|
import org.geysermc.connector.entity.PlayerEntity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
|
@ -41,7 +41,8 @@ import com.github.steveice10.opennbt.tag.builtin.ShortTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.utils.MessageUtils;
|
import org.geysermc.connector.utils.MessageUtils;
|
||||||
import org.geysermc.connector.utils.Toolbox;
|
import org.geysermc.connector.utils.Toolbox;
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ public class ItemTranslator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GeyserLogger.DEFAULT.debug("Missing mapping for bedrock item " + data.getId() + ":" + data.getDamage());
|
GeyserConnector.getInstance().getLogger().debug("Missing mapping for bedrock item " + data.getId() + ":" + data.getDamage());
|
||||||
return ItemEntry.AIR;
|
return ItemEntry.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ package org.geysermc.connector.network.translators.java;
|
|||||||
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
|
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||||
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.utils.MessageUtils;
|
import org.geysermc.connector.utils.MessageUtils;
|
||||||
@ -39,7 +40,7 @@ public class JavaChatTranslator extends PacketTranslator<ServerChatPacket> {
|
|||||||
TextPacket textPacket = new TextPacket();
|
TextPacket textPacket = new TextPacket();
|
||||||
textPacket.setPlatformChatId("");
|
textPacket.setPlatformChatId("");
|
||||||
textPacket.setSourceName("");
|
textPacket.setSourceName("");
|
||||||
textPacket.setXuid(session.getAuthenticationData().getXboxUUID());
|
textPacket.setXuid(session.getAuthData().getXboxUUID());
|
||||||
switch (packet.getType()) {
|
switch (packet.getType()) {
|
||||||
case CHAT:
|
case CHAT:
|
||||||
textPacket.setType(TextPacket.Type.CHAT);
|
textPacket.setType(TextPacket.Type.CHAT);
|
||||||
|
@ -30,7 +30,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.Serv
|
|||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -66,7 +66,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
|||||||
session.getUpstream().sendPacket(movePlayerPacket);
|
session.getUpstream().sendPacket(movePlayerPacket);
|
||||||
session.setSpawned(true);
|
session.setSpawned(true);
|
||||||
|
|
||||||
GeyserLogger.DEFAULT.info("Spawned player at " + packet.getX() + " " + packet.getY() + " " + packet.getZ());
|
session.getConnector().getLogger().info("Spawned player at " + packet.getX() + " " + packet.getY() + " " + packet.getZ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.java.entity.spawn;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -47,7 +47,7 @@ public class JavaSpawnMobTranslator extends PacketTranslator<ServerSpawnMobPacke
|
|||||||
|
|
||||||
EntityType type = EntityUtils.toBedrockEntity(packet.getType());
|
EntityType type = EntityUtils.toBedrockEntity(packet.getType());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
GeyserLogger.DEFAULT.warning("Entity type " + packet.getType() + " was null.");
|
session.getConnector().getLogger().warning("Entity type " + packet.getType() + " was null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.java.entity.spawn;
|
|||||||
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
|
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.entity.Entity;
|
import org.geysermc.connector.entity.Entity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -51,7 +51,7 @@ public class JavaSpawnObjectTranslator extends PacketTranslator<ServerSpawnObjec
|
|||||||
|
|
||||||
EntityType type = EntityUtils.toBedrockEntity(packet.getType());
|
EntityType type = EntityUtils.toBedrockEntity(packet.getType());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
GeyserLogger.DEFAULT.warning("Entity type " + packet.getType() + " was null.");
|
session.getConnector().getLogger().warning("Entity type " + packet.getType() + " was null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ package org.geysermc.connector.network.translators.java.entity.spawn;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.entity.PaintingEntity;
|
import org.geysermc.connector.entity.PaintingEntity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
@ -39,7 +40,7 @@ public class JavaSpawnPaintingTranslator extends PacketTranslator<ServerSpawnPai
|
|||||||
public void translate(ServerSpawnPaintingPacket packet, GeyserSession session) {
|
public void translate(ServerSpawnPaintingPacket packet, GeyserSession session) {
|
||||||
Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
||||||
|
|
||||||
Geyser.getGeneralThreadPool().execute(() -> { // #slowdownbrother, just don't execute it directly
|
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> { // #slowdownbrother, just don't execute it directly
|
||||||
PaintingEntity entity = new PaintingEntity(
|
PaintingEntity entity = new PaintingEntity(
|
||||||
packet.getEntityId(),
|
packet.getEntityId(),
|
||||||
session.getEntityCache().getNextEntityId().incrementAndGet(),
|
session.getEntityCache().getNextEntityId().incrementAndGet(),
|
||||||
|
@ -27,7 +27,8 @@ package org.geysermc.connector.network.translators.java.entity.spawn;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.entity.PlayerEntity;
|
import org.geysermc.connector.entity.PlayerEntity;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -43,7 +44,7 @@ public class JavaSpawnPlayerTranslator extends PacketTranslator<ServerSpawnPlaye
|
|||||||
|
|
||||||
PlayerEntity entity = session.getEntityCache().getPlayerEntity(packet.getUuid());
|
PlayerEntity entity = session.getEntityCache().getPlayerEntity(packet.getUuid());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
Geyser.getLogger().error("Haven't received PlayerListEntry packet before spawning player! We ignore the player " + packet.getUuid());
|
GeyserConnector.getInstance().getLogger().error("Haven't received PlayerListEntry packet before spawning player! We ignore the player " + packet.getUuid());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
package org.geysermc.connector.network.translators.java.scoreboard;
|
package org.geysermc.connector.network.translators.java.scoreboard;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.scoreboard.Scoreboard;
|
import org.geysermc.connector.scoreboard.Scoreboard;
|
||||||
@ -41,7 +42,7 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerTeamPacket packet, GeyserSession session) {
|
public void translate(ServerTeamPacket packet, GeyserSession session) {
|
||||||
Geyser.getLogger().debug("Team packet " + packet.getTeamName() + " " + packet.getAction()+" "+ Arrays.toString(packet.getPlayers()));
|
GeyserConnector.getInstance().getLogger().debug("Team packet " + packet.getTeamName() + " " + packet.getAction()+" "+ Arrays.toString(packet.getPlayers()));
|
||||||
|
|
||||||
Scoreboard scoreboard = session.getScoreboardCache().getScoreboard();
|
Scoreboard scoreboard = session.getScoreboardCache().getScoreboard();
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
|
@ -27,7 +27,8 @@ package org.geysermc.connector.network.translators.java.scoreboard;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardAction;
|
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardAction;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.scoreboard.Objective;
|
import org.geysermc.connector.scoreboard.Objective;
|
||||||
@ -42,7 +43,7 @@ public class JavaUpdateScoreTranslator extends PacketTranslator<ServerUpdateScor
|
|||||||
|
|
||||||
Objective objective = scoreboard.getObjective(packet.getObjective());
|
Objective objective = scoreboard.getObjective(packet.getObjective());
|
||||||
if (objective == null && packet.getAction() != ScoreboardAction.REMOVE) {
|
if (objective == null && packet.getAction() != ScoreboardAction.REMOVE) {
|
||||||
Geyser.getLogger().info("Tried to update score without the existence of its requested objective '" + packet.getObjective() + '\'');
|
GeyserConnector.getInstance().getLogger().info("Tried to update score without the existence of its requested objective '" + packet.getObjective() + '\'');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ import com.nukkitx.math.vector.Vector3f;
|
|||||||
import com.nukkitx.network.VarInts;
|
import com.nukkitx.network.VarInts;
|
||||||
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
|
import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.utils.ChunkUtils;
|
import org.geysermc.connector.utils.ChunkUtils;
|
||||||
@ -18,8 +20,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerChunkDataPacket packet, GeyserSession session) {
|
public void translate(ServerChunkDataPacket packet, GeyserSession session) {
|
||||||
// Not sure if this is safe or not, however without this the client usually times out
|
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
|
||||||
Geyser.getConnector().getGeneralThreadPool().execute(() -> {
|
|
||||||
Vector2i chunkPos = session.getLastChunkPosition();
|
Vector2i chunkPos = session.getLastChunkPosition();
|
||||||
Vector3f position = session.getPlayerEntity().getPosition();
|
Vector3f position = session.getPlayerEntity().getPosition();
|
||||||
Vector2i newChunkPos = Vector2i.from(position.getFloorX() >> 4, position.getFloorZ() >> 4);
|
Vector2i newChunkPos = Vector2i.from(position.getFloorX() >> 4, position.getFloorZ() >> 4);
|
||||||
|
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.connector.plugin;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
|
||||||
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler;
|
|
||||||
import org.geysermc.api.Connector;
|
|
||||||
import org.geysermc.api.plugin.Plugin;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
|
|
||||||
public class GeyserPluginLoader extends ClassLoader {
|
|
||||||
|
|
||||||
private Connector connector;
|
|
||||||
|
|
||||||
public GeyserPluginLoader(Connector connector) {
|
|
||||||
this.connector = connector;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadPlugins() {
|
|
||||||
File dir = new File("plugins");
|
|
||||||
|
|
||||||
if (!dir.exists()) {
|
|
||||||
dir.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (File f : dir.listFiles()) {
|
|
||||||
if (!f.getName().toLowerCase().endsWith(".jar"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
try {
|
|
||||||
ZipFile file = new ZipFile(f);
|
|
||||||
ZipEntry e = file.getEntry("plugin.yml");
|
|
||||||
|
|
||||||
if (e == null || e.isDirectory()) {
|
|
||||||
connector.getLogger().severe("Plugin " + f.getName() + " has no valid plugin.yml!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.stream().forEach((x) -> {
|
|
||||||
if (x.getName().endsWith(".class")) {
|
|
||||||
try {
|
|
||||||
InputStream is = file.getInputStream(x);
|
|
||||||
byte[] b = new byte[is.available()];
|
|
||||||
is.read(b);
|
|
||||||
this.defineClass(x.getName().replace(".class", "").replaceAll("/", "."), b, 0, b.length);
|
|
||||||
is.close();
|
|
||||||
} catch (Exception e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
|
|
||||||
InputStream is = file.getInputStream(e);
|
|
||||||
|
|
||||||
PluginYML yml = mapper.readValue(is, PluginYML.class);
|
|
||||||
is.close();
|
|
||||||
Plugin plugin = (Plugin) Class.forName(yml.main, true, this).newInstance();
|
|
||||||
|
|
||||||
Class cl = Plugin.class;
|
|
||||||
|
|
||||||
Field name = cl.getDeclaredField("name");
|
|
||||||
name.setAccessible(true);
|
|
||||||
|
|
||||||
Field version = cl.getDeclaredField("version");
|
|
||||||
version.setAccessible(true);
|
|
||||||
|
|
||||||
name.set(plugin, yml.name);
|
|
||||||
|
|
||||||
version.set(plugin, yml.version);
|
|
||||||
|
|
||||||
connector.getLogger().info("Loading plugin " + yml.name + " version " + yml.version);
|
|
||||||
connector.getPluginManager().loadPlugin(plugin);
|
|
||||||
} catch (Exception e) {
|
|
||||||
connector.getLogger().severe("Error loading plugin " + f.getName());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Plugin plugin : connector.getPluginManager().getPlugins()) {
|
|
||||||
connector.getPluginManager().enablePlugin(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadPlugin(Plugin plugin) {
|
|
||||||
plugin.onLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enablePlugin(Plugin plugin) {
|
|
||||||
plugin.setEnabled(true);
|
|
||||||
plugin.onEnable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disablePlugin(Plugin plugin) {
|
|
||||||
plugin.setEnabled(false);
|
|
||||||
plugin.onDisable();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.connector.plugin;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.api.events.EventHandler;
|
|
||||||
import org.geysermc.api.events.Listener;
|
|
||||||
import org.geysermc.api.plugin.Plugin;
|
|
||||||
import org.geysermc.api.plugin.PluginManager;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GeyserPluginManager implements PluginManager {
|
|
||||||
private final List<PluginListener> EVENTS = new ArrayList<>();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private GeyserPluginLoader loader;
|
|
||||||
|
|
||||||
private Map<String, Plugin> plugins = new HashMap<>();
|
|
||||||
|
|
||||||
public GeyserPluginManager(GeyserPluginLoader loader) {
|
|
||||||
this.loader = loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadPlugin(Plugin plugin) {
|
|
||||||
loader.loadPlugin(plugin);
|
|
||||||
plugins.put(plugin.getName(), plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unloadPlugin(Plugin plugin) {
|
|
||||||
plugins.remove(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enablePlugin(Plugin plugin) {
|
|
||||||
loader.enablePlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disablePlugin(Plugin plugin) {
|
|
||||||
loader.disablePlugin(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Plugin> getPlugins() {
|
|
||||||
return new HashSet<>(plugins.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerEventListener(Plugin p, Listener l) {
|
|
||||||
try {
|
|
||||||
Class<? extends Listener> clazz = l.getClass();
|
|
||||||
|
|
||||||
for(Method m : clazz.getMethods()) {
|
|
||||||
if(m.getAnnotation(EventHandler.class) != null) {
|
|
||||||
PluginListener listener = new PluginListener();
|
|
||||||
|
|
||||||
listener.plugin = p;
|
|
||||||
listener.listener = l;
|
|
||||||
listener.clazz = m.getParameterTypes()[0];
|
|
||||||
listener.priority = m.getAnnotation(EventHandler.class).value();
|
|
||||||
listener.run = m;
|
|
||||||
EVENTS.add(listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void runEvent(Object o) {
|
|
||||||
for(EventHandler.EventPriority p : EventHandler.EventPriority.values()) {
|
|
||||||
for (PluginListener listener : EVENTS) {
|
|
||||||
listener.runIfNeeded(p, o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin getPluginByName(String name) {
|
|
||||||
return plugins.get(name);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package org.geysermc.connector.plugin;
|
|
||||||
|
|
||||||
import org.geysermc.api.events.EventHandler;
|
|
||||||
import org.geysermc.api.events.Listener;
|
|
||||||
import org.geysermc.api.plugin.Plugin;
|
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class PluginListener {
|
|
||||||
Method run;
|
|
||||||
Plugin plugin;
|
|
||||||
Listener listener;
|
|
||||||
Class clazz;
|
|
||||||
EventHandler.EventPriority priority;
|
|
||||||
|
|
||||||
void runIfNeeded(EventHandler.EventPriority p, Object o) {
|
|
||||||
if(p.equals(priority) && clazz.isInstance(o)) {
|
|
||||||
try {
|
|
||||||
run.invoke(listener, o);
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
GeyserLogger.DEFAULT.severe("Exception while trying to run event! Contact the maintainer of " + plugin.getName());
|
|
||||||
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2019 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* @author GeyserMC
|
|
||||||
* @link https://github.com/GeyserMC/Geyser
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.connector.plugin;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
public class PluginYML {
|
|
||||||
|
|
||||||
@JsonProperty("name")
|
|
||||||
String name;
|
|
||||||
|
|
||||||
@JsonProperty("version")
|
|
||||||
String version;
|
|
||||||
|
|
||||||
@JsonProperty("main")
|
|
||||||
String main;
|
|
||||||
}
|
|
@ -31,7 +31,7 @@ import com.nukkitx.protocol.bedrock.packet.RemoveObjectivePacket;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket;
|
import com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
|
import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -77,7 +77,7 @@ public class Scoreboard {
|
|||||||
|
|
||||||
public Team registerNewTeam(String teamName, Set<String> players) {
|
public Team registerNewTeam(String teamName, Set<String> players) {
|
||||||
if (teams.containsKey(teamName)) {
|
if (teams.containsKey(teamName)) {
|
||||||
Geyser.getLogger().info("Ignoring team " + teamName + ". It overrides without removing old team.");
|
session.getConnector().getLogger().info("Ignoring team " + teamName + ". It overrides without removing old team.");
|
||||||
return getTeam(teamName);
|
return getTeam(teamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ public class Scoreboard {
|
|||||||
for (String objectiveId : new ArrayList<>(objectives.keySet())) {
|
for (String objectiveId : new ArrayList<>(objectives.keySet())) {
|
||||||
Objective objective = objectives.get(objectiveId);
|
Objective objective = objectives.get(objectiveId);
|
||||||
if (objective.isTemp()) {
|
if (objective.isTemp()) {
|
||||||
Geyser.getLogger().debug("Ignoring temp Scoreboard Objective '"+ objectiveId +'\'');
|
session.getConnector().getLogger().debug("Ignoring temp Scoreboard Objective '"+ objectiveId +'\'');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import com.github.steveice10.packetlib.packet.Packet;
|
|||||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
|
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
|
||||||
import org.geysermc.api.Geyser;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.inventory.Inventory;
|
import org.geysermc.connector.inventory.Inventory;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.TranslatorsInit;
|
import org.geysermc.connector.network.translators.TranslatorsInit;
|
||||||
@ -51,7 +51,7 @@ public class InventoryUtils {
|
|||||||
|
|
||||||
InventoryTranslator translator = TranslatorsInit.getInventoryTranslator();
|
InventoryTranslator translator = TranslatorsInit.getInventoryTranslator();
|
||||||
translator.prepareInventory(session, inventory);
|
translator.prepareInventory(session, inventory);
|
||||||
Geyser.getGeneralThreadPool().schedule(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
||||||
List<Packet> packets = session.getInventoryCache().getCachedPackets().get(inventory.getId());
|
List<Packet> packets = session.getInventoryCache().getCachedPackets().get(inventory.getId());
|
||||||
packets.forEach(itemPacket -> {
|
packets.forEach(itemPacket -> {
|
||||||
if (itemPacket != null) {
|
if (itemPacket != null) {
|
||||||
|
@ -9,17 +9,18 @@ import com.nukkitx.network.util.Preconditions;
|
|||||||
import com.nukkitx.protocol.bedrock.packet.LoginPacket;
|
import com.nukkitx.protocol.bedrock.packet.LoginPacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
|
import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
|
||||||
import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
|
import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
|
||||||
|
|
||||||
import net.minidev.json.JSONObject;
|
import net.minidev.json.JSONObject;
|
||||||
import org.geysermc.api.events.player.PlayerFormResponseEvent;
|
|
||||||
import org.geysermc.api.window.CustomFormBuilder;
|
import org.geysermc.common.window.CustomFormBuilder;
|
||||||
import org.geysermc.api.window.CustomFormWindow;
|
import org.geysermc.common.window.CustomFormWindow;
|
||||||
import org.geysermc.api.window.FormWindow;
|
import org.geysermc.common.window.FormWindow;
|
||||||
import org.geysermc.api.window.component.InputComponent;
|
import org.geysermc.common.window.component.InputComponent;
|
||||||
import org.geysermc.api.window.component.LabelComponent;
|
import org.geysermc.common.window.component.LabelComponent;
|
||||||
import org.geysermc.api.window.response.CustomFormResponse;
|
import org.geysermc.common.window.response.CustomFormResponse;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.session.auth.BedrockAuthData;
|
import org.geysermc.connector.network.session.auth.AuthData;
|
||||||
import org.geysermc.connector.network.session.cache.WindowCache;
|
import org.geysermc.connector.network.session.cache.WindowCache;
|
||||||
|
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
@ -86,7 +87,7 @@ public class LoginEncryptionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONObject extraData = (JSONObject) jwt.getPayload().toJSONObject().get("extraData");
|
JSONObject extraData = (JSONObject) jwt.getPayload().toJSONObject().get("extraData");
|
||||||
session.setAuthenticationData(new BedrockAuthData(extraData.getAsString("displayName"), UUID.fromString(extraData.getAsString("identity")), extraData.getAsString("XUID")));
|
session.setAuthenticationData(new AuthData(extraData.getAsString("displayName"), UUID.fromString(extraData.getAsString("identity")), extraData.getAsString("XUID")));
|
||||||
|
|
||||||
if (payload.get("identityPublicKey").getNodeType() != JsonNodeType.STRING) {
|
if (payload.get("identityPublicKey").getNodeType() != JsonNodeType.STRING) {
|
||||||
throw new RuntimeException("Identity Public Key was not found!");
|
throw new RuntimeException("Identity Public Key was not found!");
|
||||||
@ -140,17 +141,13 @@ public class LoginEncryptionUtils {
|
|||||||
FormWindow window = windowCache.getWindows().remove(AUTH_FORM_ID);
|
FormWindow window = windowCache.getWindows().remove(AUTH_FORM_ID);
|
||||||
window.setResponse(formData.trim());
|
window.setResponse(formData.trim());
|
||||||
|
|
||||||
if (session.isLoggedIn()) {
|
if (!session.isLoggedIn()) {
|
||||||
PlayerFormResponseEvent event = new PlayerFormResponseEvent(session, AUTH_FORM_ID, window);
|
|
||||||
connector.getPluginManager().runEvent(event);
|
|
||||||
} else {
|
|
||||||
if (window instanceof CustomFormWindow) {
|
if (window instanceof CustomFormWindow) {
|
||||||
CustomFormWindow customFormWindow = (CustomFormWindow) window;
|
CustomFormWindow customFormWindow = (CustomFormWindow) window;
|
||||||
if (!customFormWindow.getTitle().equals("Login"))
|
if (!customFormWindow.getTitle().equals("Login"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CustomFormResponse response = (CustomFormResponse) customFormWindow.getResponse();
|
CustomFormResponse response = (CustomFormResponse) customFormWindow.getResponse();
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
String email = response.getInputResponses().get(2);
|
String email = response.getInputResponses().get(2);
|
||||||
String password = response.getInputResponses().get(3);
|
String password = response.getInputResponses().get(3);
|
||||||
@ -158,7 +155,6 @@ public class LoginEncryptionUtils {
|
|||||||
session.authenticate(email, password);
|
session.authenticate(email, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should we clear the window cache in all cases or just if not already logged in?
|
|
||||||
// Clear windows so authentication data isn't accidentally cached
|
// Clear windows so authentication data isn't accidentally cached
|
||||||
windowCache.getWindows().clear();
|
windowCache.getWindows().clear();
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@ package org.geysermc.connector.utils;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -19,7 +19,7 @@ import java.util.concurrent.*;
|
|||||||
|
|
||||||
public class SkinProvider {
|
public class SkinProvider {
|
||||||
public static final Gson GSON = new GsonBuilder().create();
|
public static final Gson GSON = new GsonBuilder().create();
|
||||||
public static final boolean ALLOW_THIRD_PARTY_CAPES = ((GeyserConnector)Geyser.getConnector()).getConfig().isAllowThirdPartyCapes();
|
public static final boolean ALLOW_THIRD_PARTY_CAPES = GeyserConnector.getInstance().getConfig().isAllowThirdPartyCapes();
|
||||||
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(ALLOW_THIRD_PARTY_CAPES ? 21 : 14);
|
private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(ALLOW_THIRD_PARTY_CAPES ? 21 : 14);
|
||||||
|
|
||||||
public static final byte[] STEVE_SKIN = new ProvidedSkin("bedrock/skin/skin_steve.png").getSkin();
|
public static final byte[] STEVE_SKIN = new ProvidedSkin("bedrock/skin/skin_steve.png").getSkin();
|
||||||
@ -58,7 +58,7 @@ public class SkinProvider {
|
|||||||
getOrDefault(requestCape(capeUrl, false), EMPTY_CAPE, 5)
|
getOrDefault(requestCape(capeUrl, false), EMPTY_CAPE, 5)
|
||||||
);
|
);
|
||||||
|
|
||||||
Geyser.getLogger().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId);
|
GeyserConnector.getInstance().getLogger().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId);
|
||||||
return skinAndCape;
|
return skinAndCape;
|
||||||
}, EXECUTOR_SERVICE);
|
}, EXECUTOR_SERVICE);
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ public class SkinProvider {
|
|||||||
|
|
||||||
private static byte[] requestImage(String imageUrl, boolean cape) throws Exception {
|
private static byte[] requestImage(String imageUrl, boolean cape) throws Exception {
|
||||||
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
BufferedImage image = ImageIO.read(new URL(imageUrl));
|
||||||
Geyser.getLogger().debug("Downloaded " + imageUrl);
|
GeyserConnector.getInstance().getLogger().debug("Downloaded " + imageUrl);
|
||||||
|
|
||||||
if (cape) {
|
if (cape) {
|
||||||
image = image.getWidth() > 64 ? scale(image) : image;
|
image = image.getWidth() > 64 ? scale(image) : image;
|
||||||
@ -173,8 +173,7 @@ public class SkinProvider {
|
|||||||
image = newImage;
|
image = newImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(image.getWidth() * 4 + image.getHeight() * 4);
|
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(image.getWidth() * 4 + image.getHeight() * 4)) {
|
||||||
try {
|
|
||||||
for (int y = 0; y < image.getHeight(); y++) {
|
for (int y = 0; y < image.getHeight(); y++) {
|
||||||
for (int x = 0; x < image.getWidth(); x++) {
|
for (int x = 0; x < image.getWidth(); x++) {
|
||||||
int rgba = image.getRGB(x, y);
|
int rgba = image.getRGB(x, y);
|
||||||
@ -186,10 +185,6 @@ public class SkinProvider {
|
|||||||
}
|
}
|
||||||
image.flush();
|
image.flush();
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
outputStream.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,10 @@ import com.google.gson.JsonObject;
|
|||||||
import com.nukkitx.protocol.bedrock.data.ImageData;
|
import com.nukkitx.protocol.bedrock.data.ImageData;
|
||||||
import com.nukkitx.protocol.bedrock.data.SerializedSkin;
|
import com.nukkitx.protocol.bedrock.data.SerializedSkin;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.api.Geyser;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.entity.PlayerEntity;
|
import org.geysermc.connector.entity.PlayerEntity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
@ -96,8 +97,8 @@ public class SkinUtils {
|
|||||||
|
|
||||||
return new GameProfileData(skinUrl, capeUrl, isAlex);
|
return new GameProfileData(skinUrl, capeUrl, isAlex);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
if (!((GeyserConnector) Geyser.getConnector()).getConfig().getRemote().getAuthType().equals("offline")) {
|
if (!GeyserConnector.getInstance().getConfig().getRemote().getAuthType().equals("offline")) {
|
||||||
Geyser.getLogger().debug("Got invalid texture data for " + profile.getName() + " " + exception.getMessage());
|
GeyserConnector.getInstance().getLogger().debug("Got invalid texture data for " + profile.getName() + " " + exception.getMessage());
|
||||||
}
|
}
|
||||||
// return default skin with default cape when texture data is invalid
|
// return default skin with default cape when texture data is invalid
|
||||||
return new GameProfileData(SkinProvider.EMPTY_SKIN.getTextureUrl(), SkinProvider.EMPTY_CAPE.getTextureUrl(), false);
|
return new GameProfileData(SkinProvider.EMPTY_SKIN.getTextureUrl(), SkinProvider.EMPTY_CAPE.getTextureUrl(), false);
|
||||||
@ -107,7 +108,7 @@ public class SkinUtils {
|
|||||||
|
|
||||||
public static void requestAndHandleSkinAndCape(PlayerEntity entity, GeyserSession session,
|
public static void requestAndHandleSkinAndCape(PlayerEntity entity, GeyserSession session,
|
||||||
Consumer<SkinProvider.SkinAndCape> skinAndCapeConsumer) {
|
Consumer<SkinProvider.SkinAndCape> skinAndCapeConsumer) {
|
||||||
Geyser.getGeneralThreadPool().execute(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().execute(() -> {
|
||||||
GameProfileData data = GameProfileData.from(entity.getProfile());
|
GameProfileData data = GameProfileData.from(entity.getProfile());
|
||||||
|
|
||||||
SkinProvider.requestSkinAndCape(entity.getUuid(), data.getSkinUrl(), data.getCapeUrl())
|
SkinProvider.requestSkinAndCape(entity.getUuid(), data.getSkinUrl(), data.getCapeUrl())
|
||||||
@ -151,7 +152,7 @@ public class SkinUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Geyser.getLogger().error("Failed getting skin for " + entity.getUuid(), e);
|
GeyserConnector.getInstance().getLogger().error("Failed getting skin for " + entity.getUuid(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skinAndCapeConsumer != null) skinAndCapeConsumer.accept(skinAndCape);
|
if (skinAndCapeConsumer != null) skinAndCapeConsumer.accept(skinAndCape);
|
||||||
|
@ -9,8 +9,8 @@ import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.console.GeyserLogger;
|
|
||||||
import org.geysermc.connector.network.translators.block.BlockEntry;
|
import org.geysermc.connector.network.translators.block.BlockEntry;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
import org.geysermc.connector.world.GlobalBlockPalette;
|
import org.geysermc.connector.world.GlobalBlockPalette;
|
||||||
@ -40,7 +40,7 @@ public class Toolbox {
|
|||||||
blocksTag = (ListTag<CompoundTag>) nbtInputStream.readTag();
|
blocksTag = (ListTag<CompoundTag>) nbtInputStream.readTag();
|
||||||
nbtInputStream.close();
|
nbtInputStream.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
GeyserLogger.DEFAULT.warning("Failed to get blocks from runtime block states, please report this error!");
|
GeyserConnector.getInstance().getLogger().warning("Failed to get blocks from runtime block states, please report this error!");
|
||||||
throw new AssertionError(ex);
|
throw new AssertionError(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class Toolbox {
|
|||||||
int blockIndex = 0;
|
int blockIndex = 0;
|
||||||
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
|
for (Map.Entry<String, Map<String, Object>> itemEntry : blocks.entrySet()) {
|
||||||
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
|
if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
|
||||||
GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
|
GeyserConnector.getInstance().getLogger().debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
|
||||||
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
|
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
|
||||||
} else {
|
} else {
|
||||||
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
|
BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
|
||||||
|
1
pom.xml
1
pom.xml
@ -31,7 +31,6 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>api</module>
|
|
||||||
<module>bootstrap</module>
|
<module>bootstrap</module>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
<module>connector</module>
|
<module>connector</module>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren