Skip to content

Commit

Permalink
Fix #4, #5 and #6. Created ReflectionUtils class to access NMS resour…
Browse files Browse the repository at this point in the history
…ces.
  • Loading branch information
PauMAVA committed Jun 6, 2021
1 parent 1ed0892 commit 4c438d0
Show file tree
Hide file tree
Showing 52 changed files with 485 additions and 321 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

.idea/

*.iml

v1_15_2/target/

v1_16_1/target/

.idea/

*.iml

v1_15_2/target/

v1_16_1/target/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# TheTowersRemastered
A remsatered version of The Towers for 1.15.X
A remastered version of The Towers for 1.15.X - 1.16.X

## License (GNU v3)
````
TheTowersRemastered (TTR)
Copyright (c) 2019-2020 Pau Machetti Vallverdú
Copyright (c) 2019-2021 Pau Machetti Vallverdú
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
Expand Down
52 changes: 52 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ TheTowersRemastered (TTR)
~ Copyright (c) 2019-2021 Pau Machetti Vallverdú
~
~ 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/>.
-->

<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.2.1</version>

<packaging>pom</packaging>

<modules>
<module>v1_15_2</module>
<module>v1_16_1</module>
</modules>

<name>TheTowersRemastered [Parent]</name>
<url>https://github.com/PauMAVA/TheTowersRemastered</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>PauMAVen</id>
<url>https://raw.githubusercontent.com/PauMAVA/PauMAVen/master</url>
</repository>
</repositories>

</project>
41 changes: 31 additions & 10 deletions v1_15_2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ TheTowersRemastered (TTR)
~ Copyright (c) 2019-2021 Pau Machetti Vallverdú
~
~ 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/>.
-->

<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>
<artifactId>TheTowersRemastered.15</artifactId>

<parent>
<groupId>me.PauMAVA</groupId>
<artifactId>TheTowersRemastered</artifactId>
<version>1.2.1</version>
</parent>

<name>TheTowersRemastered [1.15.2]</name>

<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand Down Expand Up @@ -53,7 +78,7 @@
<configuration>
<target>
<echo>Copying .jar to Development Server....</echo>
<copy todir="C:\Users\Pau\Desktop\Servers\1.15.2\TestServer\plugins" overwrite="true">
<copy todir="${bukkit.server.plugins.1.15}" overwrite="true">
<fileset dir="target" includes="*.jar">
<include name="TheTowersRemastered.jar"/>
</fileset>
Expand All @@ -65,12 +90,7 @@
</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>
Expand All @@ -79,4 +99,5 @@
<scope>provided</scope>
</dependency>
</dependencies>

</project>
10 changes: 4 additions & 6 deletions v1_15_2/src/main/java/me/PauMAVA/TTR/TTRCore.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand All @@ -21,16 +21,13 @@
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 {
Expand All @@ -56,7 +53,7 @@ public void onEnable() {
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) {
if (enabled) {
this.customTab = new TTRCustomTab();
this.scoreboard = new TTRScoreboard();
this.match = new TTRMatch(MatchStatus.PREGAME);
Expand All @@ -82,7 +79,8 @@ public void onDisable() {
try {
this.customTab.cancel();
this.scoreboard.removeScoreboard();
} catch (NullPointerException ignored) {}
} catch (NullPointerException ignored) {
}
}

public static TTRCore getInstance() {
Expand Down
12 changes: 6 additions & 6 deletions v1_15_2/src/main/java/me/PauMAVA/TTR/chat/TTRChatManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand Down Expand Up @@ -29,26 +29,26 @@
public class TTRChatManager {

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

private static void dispatchGlobalMessage(String string) {
for(Player p: Bukkit.getServer().getOnlinePlayers()) {
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) {
if (playerTeam == null) {
return;
}
for(Player p: playerTeam.getPlayers()) {
p.sendMessage(TTRPrefix.TTR_TEAM + "" + ChatColor.GRAY + string);
for (Player p : playerTeam.getPlayers()) {
p.sendMessage(TTRPrefix.TTR_TEAM + "" + ChatColor.GRAY + string);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand All @@ -26,17 +26,13 @@
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()) {
if (TTRCore.getInstance().enabled() && !TTRCore.getInstance().getCurrentMatch().isOnCourse()) {
int timer;
if (args == null || args.length == 0) {
timer = 10;
timer = 10;
} else {
try {
timer = Integer.parseInt(args[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand All @@ -20,10 +20,11 @@

import me.PauMAVA.TTR.TTRCore;
import me.PauMAVA.TTR.teams.TTRTeam;
import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.Hash;

import java.io.File;
import java.util.*;
Expand All @@ -40,7 +41,7 @@ public class TTRConfigManager {
public TTRConfigManager(FileConfiguration configuration) {
this.configuration = configuration;
this.world = TTRCore.getInstance().getServer().getWorlds().get(0);
if(!new File(TTRCore.getInstance().getDataFolder() + "/config.yml").exists()) {
if (!new File(TTRCore.getInstance().getDataFolder() + "/config.yml").exists()) {
setUpFile();
saveConfig();
} else {
Expand Down Expand Up @@ -88,8 +89,8 @@ public Set<String> getTeamNames() {
}

private ConfigurationSection getTeam(String teamName) {
for(String key: this.teamsSection.getKeys(false)) {
if(key.equalsIgnoreCase(teamName)) {
for (String key : this.teamsSection.getKeys(false)) {
if (key.equalsIgnoreCase(teamName)) {
return this.teamsSection.getConfigurationSection(key);
}
}
Expand All @@ -110,8 +111,8 @@ public Location getTeamCage(String teamName) {

public HashMap<Location, TTRTeam> getTeamCages() {
HashMap<Location, TTRTeam> cages = new HashMap<Location, TTRTeam>();
for(String teamName: getTeamNames()) {
cages.put(getTeamCage(teamName), TTRCore.getInstance().getTeamHandler().getTeam(teamName ));
for (String teamName : getTeamNames()) {
cages.put(getTeamCage(teamName), TTRCore.getInstance().getTeamHandler().getTeam(teamName));
}
return cages;
}
Expand Down
4 changes: 2 additions & 2 deletions v1_15_2/src/main/java/me/PauMAVA/TTR/match/AutoStarter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand Down Expand Up @@ -72,7 +72,7 @@ private void removePlayerFromList(Player player) {
}

private boolean isPlayerInQueue(Player player) {
for (Player p: queue) {
for (Player p : queue) {
if (player.getUniqueId().equals(p.getUniqueId())) {
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions v1_15_2/src/main/java/me/PauMAVA/TTR/match/Cage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* TheTowersRemastered (TTR)
* Copyright (c) 2019-2020 Pau Machetti Vallverdu
* Copyright (c) 2019-2021 Pau Machetti Vallverdú
*
* 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
Expand All @@ -22,8 +22,6 @@
import org.bukkit.Location;
import org.bukkit.entity.Player;

import java.util.List;

public class Cage {

private Location location;
Expand Down
Loading

0 comments on commit 4c438d0

Please sign in to comment.