diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 37cac7c..884a60b 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index c0e9255..00f03ca 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.4.1c +version: 3.4.2 commands: money: description: Tells the player the amount of money they are holding. @@ -47,8 +47,13 @@ commands: usage: /log permission: TwosideKeeper.log permission-message: No permissions! + servertype: + description: Sets the server type to another type. + usage: /servertype + permission: TwosideKeeper.servertype + permission-message: No permissions! fix: - description: Does many things depending on what you item is being held. Typically if it's broken, typing this will help. + description: Does many things depending on what item is being held. Typically if it's broken, typing this will help. usage: /fix permission: TwosideKeeper.fix permission-message: No permissions! \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ServerType.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ServerType.java new file mode 100644 index 0000000..ce90f58 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ServerType.java @@ -0,0 +1,34 @@ +package sig.plugin.TwosideKeeper.HelperStructures; + +public enum ServerType { + MAIN(0,""), //The main server. All announcements are made to Discord. + TEST(1,"Test"), //The test server. Reload and shutdown announcements are not made to Discord. Only restarts will be announced. + QUIET(2,"Private"); //No announcements to Discord are made. + + int val; + String name; + + ServerType(int val, String name) { + this.val=val; + this.name=name; + } + + public int GetValue() { + return this.val; + } + public static ServerType GetTypeFromValue(int val) { + for (int i=0;i0) { + return this.name+" "; + } else { + return this.name; + } + } +} diff --git a/src/sig/plugin/TwosideKeeper/SpleefManager.java b/src/sig/plugin/TwosideKeeper/SpleefManager.java index 64902a2..e382026 100644 --- a/src/sig/plugin/TwosideKeeper/SpleefManager.java +++ b/src/sig/plugin/TwosideKeeper/SpleefManager.java @@ -37,12 +37,12 @@ public class SpleefManager { public void SetupSpleefArena(SpleefArena id,Location corner1,Location corner2,Location shovel_block, Location register_sign) { SpleefGame newGame = new SpleefGame(plugin, id, corner1,corner2,shovel_block,register_sign); spleef_game_list.add(newGame); - TwosideKeeper.log("Added new SpleefGame: "+newGame.toString(),3); + TwosideKeeper.log("Added new SpleefGame: "+newGame.toString(),4); } public void SetupSpleefArena(SpleefArena id, Location corner1, Location corner2, Location shovel_block, Location shovel_block2, Location register_sign) { SpleefGame newGame = new SpleefGame(plugin, id, corner1,corner2,shovel_block,shovel_block2,register_sign); spleef_game_list.add(newGame); - TwosideKeeper.log("Added new SpleefGame: "+newGame.toString(),3); + TwosideKeeper.log("Added new SpleefGame: "+newGame.toString(),4); } public void PassEvent(Event e) { //Passes events in the world to all Spleef Games. diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index e55814c..2829e5f 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -96,6 +96,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.vehicle.VehicleCreateEvent; import org.bukkit.event.vehicle.VehicleExitEvent; @@ -131,6 +132,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.MalleableBaseQuest; import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; import sig.plugin.TwosideKeeper.HelperStructures.MonsterType; import sig.plugin.TwosideKeeper.HelperStructures.QuestStatus; +import sig.plugin.TwosideKeeper.HelperStructures.ServerType; import sig.plugin.TwosideKeeper.HelperStructures.SessionState; import sig.plugin.TwosideKeeper.HelperStructures.SpleefArena; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; @@ -169,6 +171,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static int WORLD_SHOP_ID=0; //The shop ID number we are on. public static int LOGGING_LEVEL=0; //The logging level the server will output in for the console. 0 = No Debug Messages. Toggled with /log. public static double ARTIFACT_RARITY=1.5; //The multiplier of artifact drops. + public static ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on. public static File filesave; public static HashMap playerdata; public static SpleefManager TwosideSpleefGames; @@ -273,12 +276,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //Announce the server has restarted soon after. - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - DiscordMessageSender.sendItalicizedRawMessageDiscord("The server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs."); - } - },100); + if (SERVER_TYPE!=ServerType.QUIET) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + DiscordMessageSender.sendItalicizedRawMessageDiscord(SERVER_TYPE.GetServerName()+"Server has been restarted.\nRunning v."+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+" of TwosideKeeper\nRunning v"+Bukkit.getPluginManager().getPlugin("aPlugin").getDescription().getVersion()+" of Jobs."); + } + },100); + } //This is the constant timing method. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ @@ -400,7 +405,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double old_buffdmg = pd.prev_buffdmg; double old_partydmg = pd.prev_partydmg; double old_armordef = pd.prev_armordef; - double store1=CalculateDamageReduction(1,p,p),store2=CalculateWeaponDamage(p,null); + double store1=CalculateDamageReduction(1,p,p); + + double store2=old_weapondmg; + if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { + store2 = CalculateWeaponDamage(p,null); + } if (store1!=pd.damagereduction || store2!=pd.damagedealt) { log("Values: "+old_weapondmg+"," +old_buffdmg+"," @@ -488,7 +498,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { TwosideSpleefGames.TickEvent(); }}, 20l, 20l); } - @Override public void onDisable() { // TODO Insert logic to be performed when the plugin is disabled @@ -497,17 +506,25 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "scoreboard objectives remove Party"+i); } saveOurData(); //Saves all of our server variables and closes down. - DiscordMessageSender.sendItalicizedRawMessageDiscord("Server is shutting down and restarting..."); } - @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("log")) { LOGGING_LEVEL = (LOGGING_LEVEL+1) % 6; sender.sendMessage("Debugging Log Level is now "+ChatColor.RED+LOGGING_LEVEL+"."); return true; - } + } else + if (cmd.getName().equalsIgnoreCase("servertype")) { + if (args.length==1) { + if (ServerType.valueOf(args[0].toUpperCase())!=null) { + SERVER_TYPE = ServerType.valueOf(args[0].toUpperCase()); + return true; + } + } else { + sender.sendMessage("Wrong arguments!"); + } + } else if (sender instanceof Player) { DecimalFormat df = new DecimalFormat("0.00"); if (cmd.getName().equalsIgnoreCase("fix")) { @@ -527,13 +544,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (args.length==2) { p.getEquipment().getItemInMainHand().addUnsafeEnchantment(Enchantment.getById(Integer.parseInt(args[0])), Integer.parseInt(args[1])); sender.sendMessage("Enchantment applied!"); + return true; } else { sender.sendMessage("Wrong arguments!"); } } else { sender.sendMessage("Cannot enchant nothing!"); + return true; } - return true; } else if (cmd.getName().equalsIgnoreCase("harden_armor")) { //sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+getPlayerMoney((Player)sender)); @@ -556,13 +574,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } item.setItemMeta(meta); p.getEquipment().setItemInMainHand(item); + return true; } else { sender.sendMessage("Wrong arguments!"); } } else { sender.sendMessage("Cannot harden nothing!"); + return true; } - return true; } else if (cmd.getName().equalsIgnoreCase("item_cube")) { //sender.sendMessage("You are currently holding "+ChatColor.GREEN+"$"+getPlayerMoney((Player)sender)); @@ -591,13 +610,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } item.setItemMeta(meta); p.getEquipment().setItemInMainHand(item); + return true; } else { sender.sendMessage("Wrong arguments!"); } } else { sender.sendMessage("Cannot convert nothing!"); + return true; } - return true; } else if (cmd.getName().equalsIgnoreCase("artifact")) { Player p = (Player)sender; @@ -605,9 +625,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemStack newartifact = Artifact.createArtifactItem(ArtifactItem.valueOf(args[0])); newartifact.setAmount(Integer.parseInt((args[1]))); p.getInventory().addItem(newartifact); + return true; } else if (args.length==1) { p.getInventory().addItem(Artifact.createArtifactItem(ArtifactItem.valueOf(args[0]))); + return true; } else { sender.sendMessage("Wrong arguments!"); } @@ -647,6 +669,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } return false; } + + @EventHandler(priority=EventPriority.LOW) + public void onServerCommand(ServerCommandEvent ev) { + log(ev.getSender().getName()+" is Executing Command: "+ev.getCommand(),3); + String msg = ""; + if (ev.getCommand().equalsIgnoreCase("stop") || ev.getCommand().equalsIgnoreCase("restart")) { + msg = "Server is shutting down..."; + }/* else + if (ev.getCommand().equalsIgnoreCase("reload")) { + msg = "Server plugins have been reloaded."; + }*/ // + if (!msg.equalsIgnoreCase("")) { + if (SERVER_TYPE==ServerType.MAIN) { + DiscordMessageSender.sendItalicizedRawMessageDiscord(SERVER_TYPE.GetServerName()+msg); + } + Bukkit.broadcastMessage(msg); + } + } @EventHandler(priority=EventPriority.LOW) public void onWorldSave(WorldSaveEvent ev) { @@ -1217,7 +1257,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); } else { - if (ev.getMessage().equalsIgnoreCase("()") || ev.getMessage().indexOf(" ()")>-1) { + if (ev.getMessage().equalsIgnoreCase("()") || ev.getMessage().indexOf(" ()")>-1 || (ev.getMessage().indexOf("() ")>-1 && ev.getMessage().indexOf("() ")==0)) { ev.setMessage(ev.getMessage().replace("()", "("+ev.getPlayer().getLocation().getBlockX()+","+ev.getPlayer().getLocation().getBlockY()+","+ev.getPlayer().getLocation().getBlockZ()+")")); } for (int i=0;i-1) { + if (ev.getMessage().equalsIgnoreCase("[]") || ev.getMessage().indexOf(" []")>-1 || (ev.getMessage().indexOf("[] ")>-1 && ev.getMessage().indexOf("[] ")==0)) { pos = ev.getMessage().indexOf("[]"); ev.setMessage(ev.getMessage().replace("[]", "")); log("pos is "+pos+" message is: {"+ev.getMessage()+"}",5); @@ -4310,6 +4350,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().set("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().set("LOGGING_LEVEL", LOGGING_LEVEL); getConfig().set("ARTIFACT_RARITY", ARTIFACT_RARITY); + getConfig().set("SERVER_TYPE", SERVER_TYPE.GetValue()); //getConfig().set("MOTD", MOTD); //It makes no sense to save the MOTD as it will never be modified in-game. saveConfig(); @@ -4358,6 +4399,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { getConfig().addDefault("WORLD_SHOP_ID", WORLD_SHOP_ID); getConfig().addDefault("LOGGING_LEVEL", LOGGING_LEVEL); getConfig().addDefault("ARTIFACT_RARITY", ARTIFACT_RARITY); + getConfig().addDefault("SERVER_TYPE", SERVER_TYPE.GetValue()); getConfig().options().copyDefaults(true); saveConfig(); SERVERTICK = getConfig().getLong("SERVERTICK"); @@ -4386,23 +4428,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener { WORLD_SHOP_ID = getConfig().getInt("WORLD_SHOP_ID"); LOGGING_LEVEL = getConfig().getInt("LOGGING_LEVEL"); ARTIFACT_RARITY = getConfig().getDouble("ARTIFACT_RARITY"); + SERVER_TYPE = ServerType.GetTypeFromValue(getConfig().getInt("SERVER_TYPE")); getMOTD(); //Informational reports to the console. - getLogger().info("[CONFIG] SERVERTICK set to "+SERVERTICK+"."); - getLogger().info("[CONFIG] SPEED of Day/Night Cycles are x"+DAYMULT); - getLogger().info("[CONFIG] Server will auto-save configs every "+SERVERCHECKERTICKS+" ticks."); - getLogger().info("[CONFIG] Withdraw/Deposit terminals can be used for "+TERMINALTIME+" ticks."); - getLogger().info("[CONFIG] Death Penalty is "+DEATHPENALTY+"% of holding money."); - getLogger().info("[CONFIG] Chance to Recycle an Item on Despawn: "+RECYCLECHANCE+"%. Decay AMT: "+RECYCLEDECAYAMT+"%."); - getLogger().info("[CONFIG] Item Cube ID is currently at "+ITEMCUBEID+". World Shop ID is at "+WORLD_SHOP_ID); - getLogger().info("[CONFIG] Health Regeneration Rate is "+HEALTH_REGENERATION_RATE+" ticks per heal."); - getLogger().info("[CONFIG] Food healing amount is "+FOOD_HEAL_AMT+" health per food item."); - getLogger().info("[CONFIG] Enemy Damage Multiplier x"+ENEMY_DMG_MULT+". Explosion Damage Multiplier x"+EXPLOSION_DMG_MULT); - getLogger().info("[CONFIG] Headshots have to be "+(HEADSHOT_ACC*100)+"% accurate."); - getLogger().info("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%. Artifact Drop Rarity is x"+ARTIFACT_RARITY); - getLogger().info("[CONFIG] Party Chunk Size Detection is set to "+(PARTY_CHUNK_SIZE)+" chunks."); - getLogger().info("[CONFIG] XP Conversion rate is $"+XP_CONVERSION_RATE+" per XP Point."); + log("[CONFIG] Server Type is set to "+SERVER_TYPE+".",2); + log("[CONFIG] SERVERTICK set to "+SERVERTICK+".",3); + log("[CONFIG] SPEED of Day/Night Cycles are x"+DAYMULT,3); + log("[CONFIG] Server will auto-save configs every "+SERVERCHECKERTICKS+" ticks.",3); + log("[CONFIG] Withdraw/Deposit terminals can be used for "+TERMINALTIME+" ticks.",4); + log("[CONFIG] Death Penalty is "+DEATHPENALTY+"% of holding money.",4); + log("[CONFIG] Chance to Recycle an Item on Despawn: "+RECYCLECHANCE+"%. Decay AMT: "+RECYCLEDECAYAMT+"%.",4); + log("[CONFIG] Item Cube ID is currently at "+ITEMCUBEID+". World Shop ID is at "+WORLD_SHOP_ID,5); + log("[CONFIG] Health Regeneration Rate is "+HEALTH_REGENERATION_RATE+" ticks per heal.",4); + log("[CONFIG] Enemy Damage Multiplier x"+ENEMY_DMG_MULT+". Explosion Damage Multiplier x"+EXPLOSION_DMG_MULT,3); + log("[CONFIG] Headshots have to be "+(HEADSHOT_ACC*100)+"% accurate.",4); + log("[CONFIG] Rare Drop Rate is currently "+(RARE_DROP_RATE*100)+"%. Artifact Drop Rarity is x"+ARTIFACT_RARITY,5); + log("[CONFIG] Party Chunk Size Detection is set to "+(PARTY_CHUNK_SIZE)+" chunks.",5); + log("[CONFIG] XP Conversion rate is $"+XP_CONVERSION_RATE+" per XP Point.",5); getLogger().info("[CONFIG] Console Logging Level set to "+LOGGING_LEVEL+"."); log("----------TwosideKeeper----------",5); log("You are running version _"+Bukkit.getPluginManager().getPlugin("TwosideKeeper").getDescription().getVersion()+"_ of TwosideKeeper.",5); @@ -5449,4 +5492,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } + public static ServerType getServerType() { + return SERVER_TYPE; + } } \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index a0c847d..0d92eba 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactItem; import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; import sig.plugin.TwosideKeeper.HelperStructures.MonsterType; +import sig.plugin.TwosideKeeper.HelperStructures.ServerType; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; public final class TwosideKeeperAPI { @@ -60,6 +61,9 @@ public final class TwosideKeeperAPI { } //Artifact Commands. + public static boolean isArtifactItem(ItemStack item) { + return Artifact.isArtifact(item); + } public static ItemStack dropArtifactItem(ArtifactItem type) { return Artifact.createArtifactItem(type); } @@ -82,6 +86,11 @@ public final class TwosideKeeperAPI { public static ItemStack breakHardenedItem(ItemStack i, Player p) { return GenericFunctions.breakHardenedItem(i,p); } + + //Server COMMANDS. + public static ServerType getServerType() { + return TwosideKeeper.getServerType(); + } //Combat COMMANDS. public static double getModifiedDamage(double dmg_amt, LivingEntity p) {