mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-04 06:28:51 +00:00
Cleanup
This commit is contained in:
1 parent
575c00242c
commit
9c80c5d0a2
4 files changed
+67
-24
No files matched your search
@@ -97,7 +97,7 @@ public class Main extends JavaPlugin {
|
|||||||
new RaidCommands(this);
|
new RaidCommands(this);
|
||||||
getCommand("war").setTabCompleter(new WarTabCompletion());
|
getCommand("war").setTabCompleter(new WarTabCompletion());
|
||||||
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
|
getCommand("siege").setTabCompleter(new SiegeTabCompletion());
|
||||||
//getCommand("raid").setTabCompleter(new RaidTabCompletion());
|
getCommand("raid").setTabCompleter(new RaidTabCompletion());
|
||||||
getServer().getPluginManager().registerEvents((Listener) new KillsListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents((Listener) new KillsListener(), (Plugin) this);
|
||||||
getServer().getPluginManager().registerEvents((Listener) new CommandsListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents((Listener) new CommandsListener(), (Plugin) this);
|
||||||
getServer().getPluginManager().registerEvents((Listener) new JoinListener(), (Plugin) this);
|
getServer().getPluginManager().registerEvents((Listener) new JoinListener(), (Plugin) this);
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ v/ Raiders on death are teleported to their town spawn.
|
|||||||
*/
|
*/
|
||||||
public class Raid {
|
public class Raid {
|
||||||
|
|
||||||
|
//Ticks between activity, this is lower than siege because more activity is occuring in a raid
|
||||||
private static final int incremental = 40;
|
private static final int incremental = 40;
|
||||||
private War war;
|
private War war;
|
||||||
private final String name;
|
private final String name;
|
||||||
@@ -88,7 +89,14 @@ public class Raid {
|
|||||||
public ArrayList<String> defenderPlayers;
|
public ArrayList<String> defenderPlayers;
|
||||||
public Map<WorldCoord, LootBlock> lootedChunks;
|
public Map<WorldCoord, LootBlock> lootedChunks;
|
||||||
|
|
||||||
// Constructs raid for staging phase
|
/** Constructs raid for staging phase
|
||||||
|
*
|
||||||
|
* @param war
|
||||||
|
* @param raidedTown
|
||||||
|
* @param gatherTown
|
||||||
|
* @param side1AreRaiders
|
||||||
|
* @param raidTicks
|
||||||
|
*/
|
||||||
public Raid(final War war, final Town raidedTown, final Town gatherTown,
|
public Raid(final War war, final Town raidedTown, final Town gatherTown,
|
||||||
final boolean side1AreRaiders, final int raidTicks) {
|
final boolean side1AreRaiders, final int raidTicks) {
|
||||||
|
|
||||||
@@ -105,6 +113,16 @@ public class Raid {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IDK why this constructor exists but it does
|
||||||
|
* @param war
|
||||||
|
* @param raidedTown
|
||||||
|
* @param gatherTown
|
||||||
|
* @param side1AreRaiders
|
||||||
|
* @param raidTicks
|
||||||
|
* @param activeRaiders
|
||||||
|
* @param phase
|
||||||
|
*/
|
||||||
public Raid(final War war, final Town raidedTown, final Town gatherTown, final boolean side1AreRaiders, final int raidTicks, ArrayList<String> activeRaiders, RaidPhase phase) {
|
public Raid(final War war, final Town raidedTown, final Town gatherTown, final boolean side1AreRaiders, final int raidTicks, ArrayList<String> activeRaiders, RaidPhase phase) {
|
||||||
this(war, raidedTown, gatherTown, side1AreRaiders, raidTicks);
|
this(war, raidedTown, gatherTown, side1AreRaiders, raidTicks);
|
||||||
this.activeRaiders = activeRaiders;
|
this.activeRaiders = activeRaiders;
|
||||||
@@ -112,6 +130,13 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial Constructor
|
||||||
|
* @param war
|
||||||
|
* @param raidedTown
|
||||||
|
* @param gatherTown
|
||||||
|
* @param side1AreRaiders
|
||||||
|
*/
|
||||||
public Raid(final War war, final Town raidedTown, final Town gatherTown,
|
public Raid(final War war, final Town raidedTown, final Town gatherTown,
|
||||||
final boolean side1AreRaiders) {
|
final boolean side1AreRaiders) {
|
||||||
this.bukkitId = new int[1];
|
this.bukkitId = new int[1];
|
||||||
@@ -125,6 +150,9 @@ public class Raid {
|
|||||||
this.lootedChunks = new HashMap<>();
|
this.lootedChunks = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run when raid starts
|
||||||
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
//start
|
//start
|
||||||
@@ -459,7 +487,9 @@ public class Raid {
|
|||||||
}, 0L, incremental);
|
}, 0L, incremental);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of raid
|
/**
|
||||||
|
* End of raid
|
||||||
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
this.phase = RaidPhase.END;
|
this.phase = RaidPhase.END;
|
||||||
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
||||||
@@ -468,7 +498,7 @@ public class Raid {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* do loot logic for a chunk, synchronized in case multiple players are looting at once and something breaks
|
* Do loot logic for a chunk, synchronized in case multiple players are looting at once and something breaks
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* @param wc
|
* @param wc
|
||||||
@@ -546,7 +576,7 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to add call to KillsListener (defined seperate from Siege)
|
* Raider killed in combat
|
||||||
*/
|
*/
|
||||||
public void raiderKilledInCombat(PlayerDeathEvent event) {
|
public void raiderKilledInCombat(PlayerDeathEvent event) {
|
||||||
|
|
||||||
@@ -578,7 +608,7 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to add call to KillsListener (defined seperate from Siege)
|
* Defender killed in combat
|
||||||
*/
|
*/
|
||||||
public void defenderKilledInCombat(PlayerDeathEvent event) {
|
public void defenderKilledInCombat(PlayerDeathEvent event) {
|
||||||
this.addPointsToRaidScore(20);
|
this.addPointsToRaidScore(20);
|
||||||
@@ -604,7 +634,7 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to add call to KillsListener (defined seperate from Siege)
|
* Raider killed outside of combat
|
||||||
*/
|
*/
|
||||||
public void raiderKilledOutofCombat(PlayerDeathEvent event) {
|
public void raiderKilledOutofCombat(PlayerDeathEvent event) {
|
||||||
|
|
||||||
@@ -635,7 +665,7 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to add call to KillsListener (defined seperate from Siege)
|
* Defender killed out of combat
|
||||||
*/
|
*/
|
||||||
public void defenderKilledOutofCombat(PlayerDeathEvent event) {
|
public void defenderKilledOutofCombat(PlayerDeathEvent event) {
|
||||||
for (final String playerName : this.getActiveRaiders()) {
|
for (final String playerName : this.getActiveRaiders()) {
|
||||||
@@ -659,6 +689,11 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raiders win, give payout and finalize raid
|
||||||
|
* @param owner
|
||||||
|
* @param raidScore
|
||||||
|
*/
|
||||||
public void raidersWin(final Player owner, int raidScore) {
|
public void raidersWin(final Player owner, int raidScore) {
|
||||||
//TODO finalize payout
|
//TODO finalize payout
|
||||||
|
|
||||||
@@ -724,6 +759,10 @@ public class Raid {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defenders win, payout, and finalize raid
|
||||||
|
* @param raidScore
|
||||||
|
*/
|
||||||
public void defendersWin(int raidScore) {
|
public void defendersWin(int raidScore) {
|
||||||
//TODO finalize payout
|
//TODO finalize payout
|
||||||
/*
|
/*
|
||||||
@@ -768,12 +807,20 @@ public class Raid {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Positively impact the raid score
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
public void addPointsToRaidScore(final int points) {
|
public void addPointsToRaidScore(final int points) {
|
||||||
this.raidScore += points;
|
this.raidScore += points;
|
||||||
//cap
|
//cap
|
||||||
if (raidScore > 1000) this.raidScore = 1000;
|
if (raidScore > 1000) this.raidScore = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Negatively impact the raid score
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
public void subtractPointsFromRaidScore(final int points) {
|
public void subtractPointsFromRaidScore(final int points) {
|
||||||
this.raidScore -= points;
|
this.raidScore -= points;
|
||||||
//cap
|
//cap
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.ShermansWorld.AlathraWar.data;
|
package me.ShermansWorld.AlathraWar.data;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.object.Coord;
|
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
import com.palmergames.bukkit.towny.object.metadata.CustomDataField;
|
import com.palmergames.bukkit.towny.object.metadata.CustomDataField;
|
||||||
@@ -36,6 +35,7 @@ public class RaidData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a raid with a specific name
|
* Gets a raid with a specific name
|
||||||
|
*
|
||||||
* @param name - Name to check
|
* @param name - Name to check
|
||||||
* @return Raid or Null
|
* @return Raid or Null
|
||||||
*/
|
*/
|
||||||
@@ -69,6 +69,7 @@ public class RaidData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a raid object from a provided HashMap
|
* Creates a raid object from a provided HashMap
|
||||||
|
*
|
||||||
* @param fileData
|
* @param fileData
|
||||||
* @return Raid object
|
* @return Raid object
|
||||||
*/
|
*/
|
||||||
@@ -116,9 +117,9 @@ public class RaidData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the war into files.
|
* Saves the war into files.
|
||||||
|
*
|
||||||
* @param raid - War to be saved.
|
* @param raid - War to be saved.
|
||||||
*/
|
*/
|
||||||
public static void saveRaid(Raid raid) {
|
public static void saveRaid(Raid raid) {
|
||||||
@@ -141,6 +142,7 @@ public class RaidData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a raid into a map
|
* Turns a raid into a map
|
||||||
|
*
|
||||||
* @param raid - Raid
|
* @param raid - Raid
|
||||||
* @return Map
|
* @return Map
|
||||||
*/
|
*/
|
||||||
@@ -180,6 +182,7 @@ public class RaidData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a map of raid maps
|
* Creates a map of raid maps
|
||||||
|
*
|
||||||
* @param war - War to map
|
* @param war - War to map
|
||||||
* @return Map of Maps
|
* @return Map of Maps
|
||||||
*/
|
*/
|
||||||
@@ -192,9 +195,8 @@ public class RaidData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Isaac this is for getting when the last raid was on a town
|
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
|
* @Isaac this is for getting when the last raid was on a town
|
||||||
*/
|
*/
|
||||||
public static long whenTownLastRaided(Town town) {
|
public static long whenTownLastRaided(Town town) {
|
||||||
if (town.hasMeta("lastRaided")) {
|
if (town.hasMeta("lastRaided")) {
|
||||||
@@ -212,10 +214,9 @@ public class RaidData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @return
|
||||||
* @Isaac this is for getting if a town can be raided, return (-1, 0, 1, 2) based on status
|
* @Isaac this is for getting if a town can be raided, return (-1, 0, 1, 2) based on status
|
||||||
* (24 hours town cooldown, 6 hour war cooldown, valid time to raid, town being raided already)
|
* (24 hours town cooldown, 6 hour war cooldown, valid time to raid, town being raided already)
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static int isValidRaid(War war, Town town) {
|
public static int isValidRaid(War war, Town town) {
|
||||||
long townTime = whenTownLastRaided(town);
|
long townTime = whenTownLastRaided(town);
|
||||||
|
|||||||
@@ -4,22 +4,15 @@ import me.ShermansWorld.AlathraWar.Helper;
|
|||||||
import me.ShermansWorld.AlathraWar.Raid;
|
import me.ShermansWorld.AlathraWar.Raid;
|
||||||
import me.ShermansWorld.AlathraWar.Siege;
|
import me.ShermansWorld.AlathraWar.Siege;
|
||||||
import me.ShermansWorld.AlathraWar.War;
|
import me.ShermansWorld.AlathraWar.War;
|
||||||
import me.ShermansWorld.AlathraWar.commands.RaidCommands;
|
|
||||||
import me.ShermansWorld.AlathraWar.commands.SiegeCommands;
|
|
||||||
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
import me.ShermansWorld.AlathraWar.data.RaidPhase;
|
||||||
import me.ShermansWorld.AlathraWar.data.WarData;
|
import me.ShermansWorld.AlathraWar.data.WarData;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public class CommandsListener implements Listener {
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommandsListener implements Listener
|
|
||||||
{
|
|
||||||
|
|
||||||
final static String[] prefixes = new String[]{
|
final static String[] prefixes = new String[]{
|
||||||
"", "towny", "essentials", "wild", "minecraft"
|
"", "towny", "essentials", "wild", "minecraft"
|
||||||
@@ -38,7 +31,6 @@ public class CommandsListener implements Listener
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onCommandSend(final PlayerCommandPreprocessEvent event) {
|
public void onCommandSend(final PlayerCommandPreprocessEvent event) {
|
||||||
|
|
||||||
@@ -74,9 +66,12 @@ public class CommandsListener implements Listener
|
|||||||
|| parse.equals("t spawn") || parse.equals("town spawn")
|
|| parse.equals("t spawn") || parse.equals("town spawn")
|
||||||
|| parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|
|| parse.equals("towny:n spawn") || parse.equals("towny:nat spawn") || parse.equals("towny:nation spawn")
|
||||||
|| parse.equals("towny:t spawn") || parse.equals("towny:town spawn")) {
|
|| parse.equals("towny:t spawn") || parse.equals("towny:town spawn")) {
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are stuck in spawn and allowed to teleport to your town or nation!");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are stuck in spawn and are allowed to teleport to your town or nation.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You are stuck in spawn and are allowed to teleport to your town or nation.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//else
|
//else
|
||||||
|
|||||||
Reference in new issue
Block a user