Skip to content

Commit

Permalink
Changed project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMAVA committed Jun 25, 2020
1 parent 922b9ae commit b34ce40
Show file tree
Hide file tree
Showing 49 changed files with 1,925 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

.idea/

*.iml

v1_15_2/target/
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class StartMatchCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender theSender, Command command, String label, String[] args) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions v1_16_1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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>

<groupId>me.PauMAVA</groupId>
<artifactId>TheTowersRemastered</artifactId>
<version>1.1</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<includes>
<include>**/*.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib</classpathPrefix>
<mainClass>me.PauMAVA.TTR.TTRCore</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<inherited>false</inherited>
<configuration>
<target>
<echo>Copying .jar to Development Server....</echo>
<copy todir="C:\Users\Pau\Desktop\Servers\1.15.2\TestServer\plugins" overwrite="true">
<fileset dir="target" includes="*.jar">
<include name="TheTowersRemastered.jar"/>
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>PauMAVen</id>
<url>https://raw.githubusercontent.com/PauMAVA/PauMAVen/master</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>me.PauMAVA</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.16.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
127 changes: 127 additions & 0 deletions v1_16_1/src/main/java/me/PauMAVA/TTR/TTRCore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.PauMAVA.TTR;

import me.PauMAVA.TTR.commands.EnableDisableCommand;
import me.PauMAVA.TTR.commands.StartMatchCommand;
import me.PauMAVA.TTR.config.TTRConfigManager;
import me.PauMAVA.TTR.match.AutoStarter;
import me.PauMAVA.TTR.match.LootSpawner;
import me.PauMAVA.TTR.match.MatchStatus;
import me.PauMAVA.TTR.match.TTRMatch;
import me.PauMAVA.TTR.teams.TTRTeamHandler;
import me.PauMAVA.TTR.ui.TTRCustomTab;
import me.PauMAVA.TTR.ui.TTRScoreboard;
import me.PauMAVA.TTR.util.EventListener;
import me.PauMAVA.TTR.world.TTRWorldHandler;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;

public class TTRCore extends JavaPlugin {

private static TTRCore instance;
private boolean enabled = false;
private TTRMatch match;
private TTRTeamHandler teamHandler;
private TTRConfigManager configManager;
private TTRWorldHandler worldHandler;
private TTRCustomTab customTab;
private TTRScoreboard scoreboard;
private AutoStarter autoStarter;

private boolean isCounting = false;

@Override
public void onEnable() {
instance = this;
if (this.getConfig().getBoolean("enable_on_start")) {
enabled = true;
} else {
getLogger().warning("TTR is disabled on server start. Use /ttrenable to enable it on start. Make sure to be using the desired map.");
}
this.configManager = new TTRConfigManager(this.getConfig());
if(enabled) {
this.customTab = new TTRCustomTab();
this.scoreboard = new TTRScoreboard();
this.match = new TTRMatch(MatchStatus.PREGAME);
this.customTab.runTaskTimer(this, 0L, 20L);
this.teamHandler = new TTRTeamHandler();
this.teamHandler.setUpDefaultTeams();
this.worldHandler = new TTRWorldHandler(this, this.getServer().getWorlds().get(0));
this.worldHandler.setUpWorld();
this.getServer().getPluginManager().registerEvents(new EventListener(), this);
} else {
this.match = new TTRMatch(MatchStatus.DISABLED);
}

this.getCommand("ttrstart").setExecutor(new StartMatchCommand());
EnableDisableCommand enableDisableCommand = new EnableDisableCommand(this);
this.getCommand("ttrenable").setExecutor(enableDisableCommand);
this.getCommand("ttrdisable").setExecutor(enableDisableCommand);
this.autoStarter = new AutoStarter(this, this.getConfig());
}

@Override
public void onDisable() {
try {
this.customTab.cancel();
this.scoreboard.removeScoreboard();
} catch (NullPointerException ignored) {}
}

public static TTRCore getInstance() {
return instance;
}

public boolean enabled() {
return this.enabled;
}

public TTRMatch getCurrentMatch() {
return this.match;
}

public TTRTeamHandler getTeamHandler() {
return this.teamHandler;
}

public TTRConfigManager getConfigManager() {
return this.configManager;
}

public TTRWorldHandler getWorldHandler() {
return worldHandler;
}

public TTRScoreboard getScoreboard() {
return scoreboard;
}

public boolean isCounting() {
return isCounting;
}

public void setCounting(boolean counting) {
isCounting = counting;
}

public AutoStarter getAutoStarter() {
return autoStarter;
}
}
56 changes: 56 additions & 0 deletions v1_16_1/src/main/java/me/PauMAVA/TTR/chat/TTRChatManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package me.PauMAVA.TTR.chat;

import me.PauMAVA.TTR.TTRCore;
import me.PauMAVA.TTR.teams.TTRTeam;
import me.PauMAVA.TTR.util.TTRPrefix;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

public class TTRChatManager {

public static void sendMessage(Player sender, String originalMessage) {
if(originalMessage.startsWith("!")) {
dispatchGlobalMessage(originalMessage);
} else {
dispatchTeamMessage(originalMessage, sender);
}
}

private static void dispatchGlobalMessage(String string) {
for(Player p: Bukkit.getServer().getOnlinePlayers()) {
p.sendMessage(TTRPrefix.TTR_GLOBAL + "" + ChatColor.GRAY + string);
}
}

private static void dispatchTeamMessage(String string, Player sender) {
TTRTeam playerTeam = TTRCore.getInstance().getTeamHandler().getPlayerTeam(sender);
if(playerTeam == null) {
return;
}
for(Player p: playerTeam.getPlayers()) {
p.sendMessage(TTRPrefix.TTR_TEAM + "" + ChatColor.GRAY + string);
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package me.PauMAVA.TTR.commands;

import me.PauMAVA.TTR.TTRCore;
import me.PauMAVA.TTR.util.TTRPrefix;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class EnableDisableCommand implements CommandExecutor {

private TTRCore plugin;

public EnableDisableCommand(TTRCore plugin) {
this.plugin = plugin;
}

@Override
public boolean onCommand(CommandSender theSender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("ttrenable")) {
plugin.getConfigManager().setEnableOnStart(true);
theSender.sendMessage(TTRPrefix.TTR_GAME + "" + ChatColor.GREEN + "Plugin enabled on server start. /reload or restart server to apply changes! Players should rejoin...");
} else if (label.equalsIgnoreCase("ttrdisable")) {
plugin.getConfigManager().setEnableOnStart(false);
theSender.sendMessage(TTRPrefix.TTR_GAME + "" + ChatColor.RED + "Plugin disabled on server start. /reload or restart server to apply changes!");
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package me.PauMAVA.TTR.commands;

import me.PauMAVA.TTR.TTRCore;
import me.PauMAVA.TTR.util.TTRPrefix;
import me.PauMAVA.TTR.util.XPBarTimer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class StartMatchCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender theSender, Command command, String label, String[] args) {
if(TTRCore.getInstance().enabled() && !TTRCore.getInstance().getCurrentMatch().isOnCourse()) {
int timer;
if (args == null || args.length == 0) {
timer = 10;
} else {
try {
timer = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
theSender.sendMessage(TTRPrefix.TTR_GAME + "" + ChatColor.GRAY + "You must input an integer!");
return false;
}
}
try {
new XPBarTimer(timer, TTRCore.getInstance().getCurrentMatch().getClass().getMethod("startMatch")).runTaskTimer(TTRCore.getInstance(), 0L, 20L);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
return false;
}
}
Loading

0 comments on commit b34ce40

Please sign in to comment.