Skip to content

Commit

Permalink
Added plugin base structure
Browse files Browse the repository at this point in the history
  • Loading branch information
PauMAVA committed Dec 26, 2019
1 parent d347214 commit 04296bd
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 0 deletions.
82 changes: 82 additions & 0 deletions 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>pre-0.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>1.8</source>
<target>1.8</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/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.15</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
39 changes: 39 additions & 0 deletions src/me/PauMAVA/TTR/TTRCore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package me.PauMAVA.TTR;

import me.PauMAVA.TTR.match.TTRMatch;
import me.PauMAVA.TTR.util.EventListener;
import org.bukkit.plugin.java.JavaPlugin;

public class TTRCore extends JavaPlugin {

private static TTRCore instance;
private boolean enabled = false;
private TTRMatch match;

@Override
public void onEnable() {
instance = this;
if(this.getConfig().getBoolean("enableOnStart")) {
enabled = true;
}
this.match = new TTRMatch();
this.getServer().getPluginManager().registerEvents(new EventListener(), this);
}

@Override
public void onDisable() {

}

public static TTRCore getInstance() {
return instance;
}

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

public TTRMatch getCurrentMatch() {
return this.match;
}
}
23 changes: 23 additions & 0 deletions src/me/PauMAVA/TTR/match/TTRMatch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.PauMAVA.TTR.match;

public class TTRMatch {

private boolean isOnCourse;

public TTRMatch() {
isOnCourse = false;
}

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

public void startMatch() {

}

public void endMatch() {

}

}
46 changes: 46 additions & 0 deletions src/me/PauMAVA/TTR/teams/TTRTeam.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package me.PauMAVA.TTR.teams;

import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class TTRTeam {

private String identifier;
private List<Player> players = new ArrayList<Player>();
private int points = 0;

public TTRTeam(String identifier, List<Player> players) {
this.identifier = identifier;
this.players = players;
}

public TTRTeam(String identifier) {
this.identifier = identifier;
}

public String getIdentifier() {
return this.identifier;
}

public void addPlayer(Player player) {
this.players.add(player);
}

public void removePlayer(Player player) {
this.players.remove(player);
}

public List<Player> getPlayers() {
return this.players;
}

public void addPoints(int points) {
this.points += points;
}

public int getPoints() {
return this.points;
}
}
49 changes: 49 additions & 0 deletions src/me/PauMAVA/TTR/teams/TTRTeamHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package me.PauMAVA.TTR.teams;

import me.PauMAVA.TTR.match.TTRMatch;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class TTRTeamHandler {

private TTRMatch match = new TTRMatch();
private List<TTRTeam> teams = new ArrayList<TTRTeam>();

public void setUpDefaultTeams() {
teams.add(new TTRTeam("red"));
teams.add(new TTRTeam("blue"));
}

public void setUpCustomTeams(List<TTRTeam> customTeams) {
this.teams = customTeams;
}

public boolean addPlayerToTeam(Player player, String teamIdentifier) {
TTRTeam team = getTeam(teamIdentifier);
if(team == null) {
return false;
}
team.addPlayer(player);
return true;
}

public boolean removePlayerFromTeam(Player player, String teamIdentifier) {
TTRTeam team = getTeam(teamIdentifier);
if(team == null) {
return false;
}
team.removePlayer(player);
return true;
}

private TTRTeam getTeam(String teamIdentifier) {
for(TTRTeam team: this.teams) {
if(team.getIdentifier().equalsIgnoreCase(teamIdentifier)) {
return team;
}
}
return null;
}
}
56 changes: 56 additions & 0 deletions src/me/PauMAVA/TTR/ui/CustomUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package me.PauMAVA.TTR.ui;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;

public class CustomUI {

private Inventory inventory;
private String title;
private int size;

CustomUI(int size, String title) {
this.inventory = Bukkit.getServer().createInventory(null, size, title);
}

void openUI(Player player) {
player.openInventory(this.inventory);
}

void closeUI(Player player) {
if(player.getOpenInventory().equals(this.inventory)) {
player.closeInventory();
}
}

public void setSlot(int id, ItemStack item, @Nullable String title, @Nullable String lore) {
if(title == null) {
this.inventory.setItem(id, item);
return;
}
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(title);
if(lore != null) {
meta.setLore(new ArrayList<String>(Arrays.asList(lore)));
}
item.setItemMeta(meta);
this.inventory.setItem(id, item);
}

public void clearSlot(int id) {
this.inventory.clear(id);
}

public void clearUI() {
this.inventory.clear();
}

}
22 changes: 22 additions & 0 deletions src/me/PauMAVA/TTR/ui/TeamSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.PauMAVA.TTR.ui;

import org.bukkit.entity.Player;

public class TeamSelector extends CustomUI {

private Player owner;

public TeamSelector(Player player) {
super(27, "Team Selection");
this.owner = player;
}

public void openSelector() {
super.openUI(this.owner);
}

public void closeSelector() {
super.closeUI(this.owner);
}

}
Loading

0 comments on commit 04296bd

Please sign in to comment.