Skip to content

Commit

Permalink
feat: Added proxy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pixkk committed Jul 16, 2024
1 parent e24540f commit a60b733
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'com.tigerhix'
version = '4.0.3-RELEASE'
version = '4.0.5-RELEASE'

repositories {
mavenCentral()
Expand Down
56 changes: 32 additions & 24 deletions src/main/java/com/tigerhix/vampirez/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import com.tigerhix.vampirez.lib.ItemMessage;
import com.tigerhix.vampirez.lib.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.bukkit.scoreboard.ScoreboardManager;

import java.io.BufferedReader;
Expand All @@ -25,7 +27,7 @@
import java.util.List;
import java.util.Map;

public class Main extends JavaPlugin
public class Main extends JavaPlugin implements PluginMessageListener
{
public ScoreboardManager sm;
public ItemMessage messenger;
Expand Down Expand Up @@ -108,24 +110,25 @@ public static boolean isVersionNewer(String version1, String version2) {
}

public void onEnable() {

Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage("§c Enabling VAMPIREZ ");
Bukkit.getConsoleSender().sendMessage("§c========================================");
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Enabling VAMPIREZ ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
PluginDescriptionFile file = this.getDescription();
try {
String version1 = file.getVersion().replace("-RELEASE", "");
String version2 = getSpigotVersion().replace("-RELEASE", "");

boolean isNewer = isVersionNewer(version2, version1);
// Bukkit.getConsoleSender().sendMessage("§c" + version2);
// Bukkit.getConsoleSender().sendMessage("§c" + version1);
// Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "" + version2);
// Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "" + version1);

if (isNewer) {
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage("§c VAMPIREZ UPDATE FOUND: ");
Bukkit.getConsoleSender().sendMessage("§c NEW VERSION: "+version2+" ");
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " VAMPIREZ UPDATE FOUND: ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " NEW VERSION: "+version2+" ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
}

} catch (IOException e) {
Expand All @@ -148,17 +151,15 @@ public void onEnable() {
try {
Metrics metrics = new Metrics(this, pluginId);

metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> {
return Bukkit.getOnlinePlayers().size();
}));
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));

} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("bStats failed, maybe it disabled.");
}


String version_server = Utils.getServerVersion();
Bukkit.getConsoleSender().sendMessage("§cDetected server version: " + version_server);
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Detected server version: " + version_server);
// Check if messages.yml is empty

if(!message.disabled) {
Expand All @@ -180,12 +181,12 @@ public void onEnable() {
for (final Player player : this.getServer().getOnlinePlayers()) {
this.gamers.put(player.getName(), new Gamer(this, player.getName()));
}
Bukkit.getConsoleSender().sendMessage("§cEnabled arenas:");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Enabled arenas:");
int i = 1;
for (final String name : this.getConfig().getStringList("arenas.enabled-arenas")) {
Arena arena = new Arena(this, name);
this.arenas.put(name, arena);
Bukkit.getConsoleSender().sendMessage("§c" + i+". " +name+ "");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "" + i+". " +name+ "");
i++;
}

Expand All @@ -200,15 +201,22 @@ public void onEnable() {

}
public void onDisable() {
//make sure to unregister the registered channels in case of a reload
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this);
this.getServer().getMessenger().unregisterIncomingPluginChannel(this);
this.reloadConfig();
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage("§c Disabling VAMPIREZ ");
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " Disabling VAMPIREZ ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
if (isCurrentlyReloading()) {
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage("§c DON`T USE /RELOAD COMMAND! ");
Bukkit.getConsoleSender().sendMessage("§c YOU CAN GET UNEXPECTED ERRORS. ");
Bukkit.getConsoleSender().sendMessage("§c========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " DON`T USE /RELOAD COMMAND! ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + " YOU CAN GET UNEXPECTED ERRORS. ");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "========================================");
}
}

@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
}
}
34 changes: 24 additions & 10 deletions src/main/java/com/tigerhix/vampirez/configs/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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

public class Config
{
Expand Down Expand Up @@ -42,23 +43,36 @@ public Config(final Main plugin) {
plugin.saveConfig();
}

plugin.getConfig().addDefault("proxy-mode", false);
plugin.getConfig().addDefault("proxy-main-server", "hub");

Config.minSeconds = plugin.getConfig().getInt("general.seconds.min");
Config.maxSeconds = plugin.getConfig().getInt("general.seconds.max");
Config.signStyle = 2;
Config.waitingText = ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "- "+plugin.message.get().get("sign-waiting") + " -";
Config.startedText = ChatColor.DARK_RED + "" + ChatColor.BOLD + "- "+plugin.message.get().get("sign-started") + " -";
Config.waitingText = ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "- " + plugin.message.get().get("sign-waiting") + " -";
Config.startedText = ChatColor.DARK_RED + "" + ChatColor.BOLD + "- " + plugin.message.get().get("sign-started") + " -";
Config.roomText = ChatColor.BOLD + "- %id% -";
(Config.survivorEffects = new ArrayList<>()).add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0));
Config.survivorEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 0));
Config.survivorEffects.add(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 0));
(Config.waveEffects = new ArrayList<>()).add(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
Config.waveEffects.add(new PotionEffect(PotionEffectType.CONFUSION, 300, 0));
(Config.vampireEffects = new ArrayList<>()).add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
Config.vampireEffects.add(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0));
Config.vampireEffects.add(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));

List<PotionEffect> survivorEffects = new ArrayList<>();
survivorEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0));
survivorEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 0));
survivorEffects.add(new PotionEffect(PotionEffectType.BLINDNESS, Integer.MAX_VALUE, 0));
Config.survivorEffects = survivorEffects;

List<PotionEffect> waveEffects = new ArrayList<>();
waveEffects.add(new PotionEffect(PotionEffectType.REGENERATION, 100, 1));
waveEffects.add(new PotionEffect(PotionEffectType.CONFUSION, 300, 0));
Config.waveEffects = waveEffects;

List<PotionEffect> vampireEffects = new ArrayList<>();
vampireEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
vampireEffects.add(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0));
vampireEffects.add(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
Config.vampireEffects = vampireEffects;
Config.punch = false;



plugin.getConfig().addDefault("mysql.enabled", false);
plugin.getConfig().addDefault("mysql.ip", "127.0.0.1");
plugin.getConfig().addDefault("mysql.port", "3306");
Expand Down

0 comments on commit a60b733

Please sign in to comment.