renamed MCchatbotyt to YouTubeBot
This commit is contained in:
25
pom.xml
25
pom.xml
@@ -35,28 +35,13 @@
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client</artifactId>
|
||||
<version>1.44.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.http-client</groupId>
|
||||
<artifactId>google-http-client-jackson2</artifactId>
|
||||
<version>1.44.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client</artifactId>
|
||||
<version>1.35.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-youtube</artifactId>
|
||||
<version>v3-rev222-1.25.0</version>
|
||||
</dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-youtube</artifactId>
|
||||
<version>v3-rev222-1.25.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
8
src/main/java/MainClass.java
Normal file
8
src/main/java/MainClass.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public class MainClass {
|
||||
public static void main(String[] args) {
|
||||
String apiKey = "AIzaSyA-wQ8i8vj_GKRuGJmtP-igFVNwaKrymIo"; // Replace with your actual YouTube API key
|
||||
YouTubeBot bot = new YouTubeBot(apiKey);
|
||||
|
||||
// Your bot logic goes here
|
||||
}
|
||||
}
|
@@ -1,50 +1,47 @@
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.services.youtube.YouTube;
|
||||
import com.google.api.services.youtube.model.VideoListResponse;
|
||||
import com.google.api.services.youtube.model.Video;
|
||||
|
||||
public class YouTubeBot {
|
||||
private Server server;
|
||||
private YouTube youtube;
|
||||
|
||||
public YouTubeBot(String apiKey) {
|
||||
try {
|
||||
this.server = Bukkit.getServer();
|
||||
this.youtube = new YouTube.Builder(
|
||||
GoogleNetHttpTransport.newTrustedTransport(),
|
||||
JacksonFactory.getDefaultInstance(),
|
||||
null)
|
||||
.setApplicationName("Crafty MC")
|
||||
.setYouTubeApiKey()
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getOnlinePlayersCount() {
|
||||
return server.getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
public void handleCommand(String command) {
|
||||
if (command.equalsIgnoreCase("!stats")) {
|
||||
String stats = getServerStatistics();
|
||||
// Send stats to YouTube chat or log for testing
|
||||
System.out.println(stats); // For testing, replace with actual sending to YouTube chat
|
||||
}
|
||||
}
|
||||
|
||||
private String getServerStatistics() {
|
||||
// Use Spigot API or other methods to get server stats
|
||||
int onlinePlayers = server.getOnlinePlayers().size();
|
||||
// Construct and return server stats message
|
||||
return "Online Players: " + onlinePlayers;
|
||||
}
|
||||
|
||||
// Other methods and bot logic
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.services.youtube.YouTube;
|
||||
|
||||
public class YouTubeBot {
|
||||
private Server server;
|
||||
private YouTube youtube;
|
||||
|
||||
public YouTubeBot(String apiKey) {
|
||||
try {
|
||||
this.server = Bukkit.getServer();
|
||||
this.youtube = new YouTube.Builder(
|
||||
GoogleNetHttpTransport.newTrustedTransport())
|
||||
.setApplicationName("Crafty MC")
|
||||
.build();
|
||||
|
||||
// API Key
|
||||
youtube.setApiKey(apiKey);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getOnlinePlayersCount() {
|
||||
return server.getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
public void handleCommand(String command) {
|
||||
if (command.equalsIgnoreCase("!stats")) {
|
||||
String stats = getServerStatistics();
|
||||
// Send stats to YouTube chat or log for testing
|
||||
System.out.println(stats); // For testing, replace with actual sending to YouTube chat
|
||||
}
|
||||
}
|
||||
|
||||
private String getServerStatistics() {
|
||||
// Use Spigot API or other methods to get server stats
|
||||
int onlinePlayers = server.getOnlinePlayers().size();
|
||||
// Construct and return server stats message
|
||||
return "Online Players: " + onlinePlayers;
|
||||
}
|
||||
|
||||
// Other methods and bot logic
|
||||
}
|
@@ -1 +1,2 @@
|
||||
C:\Users\hbmann\Documents\Projects\_MCbotYT\MCyoutube_bot\src\main\java\MCchatbotyt.java
|
||||
C:\Users\hbmann\Documents\Projects\_MCbotYT\MCyoutube_bot\src\main\java\YouTubeBot.java
|
||||
C:\Users\hbmann\Documents\Projects\_MCbotYT\MCyoutube_bot\src\main\java\MainClass.java
|
||||
|
Reference in New Issue
Block a user