Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tfm5.1 mc1.10 #5

Open
wants to merge 50 commits into
base: 1.11.2DEV
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ad78aaf
Create FHistory.java
lemonsked Aug 28, 2016
31a1172
Create History.java
lemonsked Aug 28, 2016
c4388bb
Create UUIDFetcher.java
lemonsked Aug 28, 2016
6035a6f
Create Command_namehistory
lemonsked Aug 28, 2016
33b7eca
Rename Command_namehistory to Command_namehistory.java
lemonsked Aug 28, 2016
777b06d
Formatting
lemonsked Aug 28, 2016
0049df9
Update History.java
lemonsked Oct 12, 2016
ed32538
Update History.java
lemonsked Oct 12, 2016
1ed0f91
Update History.java
lemonsked Oct 12, 2016
895f1cc
Update History.java
lemonsked Oct 12, 2016
068a379
Update UUIDFetcher.java
lemonsked Oct 12, 2016
867b67a
Update FSync.java
lemonsked Oct 13, 2016
981fe92
Update History.java
lemonsked Oct 13, 2016
d249aae
Update UUIDFetcher.java
lemonsked Oct 13, 2016
bbcbdda
Update History.java
lemonsked Oct 13, 2016
a5e9e52
Update History.java
lemonsked Oct 13, 2016
2ea923f
Update UUIDFetcher.java
lemonsked Oct 21, 2016
541317f
Update FSync.java
lemonsked Oct 21, 2016
cc2207c
Update History.java
lemonsked Oct 21, 2016
31684d0
Delete FHistory.java
lemonsked Oct 21, 2016
cc8d8ad
Don't need import -> Same package.
lemonsked Oct 21, 2016
be8203a
Added /unloadchunks. Resolves #1779 (#674)
ChargedCreeper Nov 13, 2016
475b299
Fixed a typo in announcements (#911)
Telesphoreo Nov 13, 2016
0eb0c7a
Remove /invis smite, add /invis clear. Resolves #959 (#1011)
LegendIsAwesomes Nov 13, 2016
28142a6
Update to Spigot 1.11-R1
JeromSar Nov 17, 2016
6e6842d
Update compile version to v1_11_R1
JeromSar Nov 17, 2016
1bc81ca
:boom::camel: Added .gitattributes & .gitignore files
Apr 9, 2017
45defe6
TFM massive patches
Apr 9, 2017
e716433
Csnnot be private
May 13, 2017
ef69258
Cannot be private
May 13, 2017
5ffbc9e
Update compile version to v1_12_R1
JeromSar May 22, 2017
baf73df
Added /adventure, removed /spectator
JeromSar May 22, 2017
db569b4
Updated
May 24, 2017
24d1393
Updated again
May 24, 2017
85fe415
Stuff that marco changed...
StevenLawson May 29, 2017
159a948
Make httpd players module only show active admins.
StevenLawson May 29, 2017
ed4583a
Fix a concurrent modification exception & logviewer removals.
StevenLawson May 29, 2017
c6a2496
Fixed Module_players to include only active admins. Closes #1852 (#2036)
May 29, 2017
0b0ff56
Convert to nested static class
May 29, 2017
7a9177c
Update History.java
May 29, 2017
3a34000
Update UUIDFetcher.java
May 29, 2017
f3b3a91
Update History.java
May 30, 2017
293a876
Update UUIDFetcher.java
May 30, 2017
c74c281
Fixed logviewer deactivate on setActive(true).
StevenLawson May 31, 2017
a32d6db
Merge branch 'server' into tfm5.1-mc1.10
May 31, 2017
9ec6d27
evert
lemonsked May 31, 2017
3d22b88
Merge branch 'tfm5.1-mc1.12' into tfm5.1-mc1.10
May 31, 2017
cc71270
Update UUIDFetcher.java
Sep 23, 2017
2bd2ad1
This worked using Postman.... It shouldn't be erroring.
Sep 24, 2017
9c435db
fix npe
Oct 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.10</version>
<artifactId>spigot-server</artifactId>
<version>1.12</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/Spigot-1.10.jar</systemPath>
<systemPath>${project.basedir}/lib/Spigot-1.12.jar</systemPath>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import java.util.List;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.MinecraftServer;
import net.minecraft.server.v1_10_R1.PropertyManager;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.MinecraftServer;
import net.minecraft.server.v1_12_R1.PropertyManager;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;

public class ServerInterface extends FreedomService
{

public static final String COMPILE_NMS_VERSION = "v1_10_R1";
public static final String COMPILE_NMS_VERSION = "v1_12_R1";

public ServerInterface(TotalFreedomMod plugin)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package me.totalfreedom.totalfreedommod.command;

import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Quickly change your own gamemode to adventure, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", aliases = "gma")
public class Command_adventure extends FreedomCommand
{

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
{
if (isConsole())
{
sender.sendMessage("When used from the console, you must define a target player.");
return true;
}

playerSender.setGameMode(GameMode.ADVENTURE);
msg("Gamemode set to adventure.");
return true;
}

if (args[0].equals("-a"))
{
for (Player targetPlayer : server.getOnlinePlayers())
{
targetPlayer.setGameMode(GameMode.ADVENTURE);
}

FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
return true;
}

Player player = getPlayer(args[0]);

if (player == null)
{
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}

msg("Setting " + player.getName() + " to game mode adventure");
msg(player, sender.getName() + " set your game mode to adventure");
player.setGameMode(GameMode.ADVENTURE);

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
import org.bukkit.potion.PotionEffectType;

@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
@CommandParameters(description = "Shows (and optionally clears) invisisible players", usage = "/<command> [clear]")
public class Command_invis extends FreedomCommand
{

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
boolean clear = false;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("smite"))
if (args[0].equalsIgnoreCase("clear"))
{
FUtil.adminAction(sender.getName(), "Smiting all invisible players", true);
smite = true;
FUtil.adminAction(sender.getName(), "Clearing invisibility for all players", false);
clear = true;
}
else
{
Expand All @@ -33,17 +33,17 @@ public boolean run(CommandSender sender, Player playerSender, Command cmd, Strin
}

List<String> players = new ArrayList<>();
int smites = 0;
int clears = 0;

for (Player player : server.getOnlinePlayers())
{
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(player.getName());
if (smite && !plugin.al.isAdmin(player))
if (clear && !plugin.al.isAdmin(player))
{
player.setHealth(0.0);
smites++;
player.removePotionEffect(PotionEffectType.INVISIBILITY);
clears++;
}
}
}
Expand All @@ -54,9 +54,9 @@ public boolean run(CommandSender sender, Player playerSender, Command cmd, Strin
return true;
}

if (smite)
if (clear)
{
msg("Smitten " + smites + " players");
msg("Cleared invisibility effect from " + clears + " players");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.totalfreedom.totalfreedommod.command;

import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import me.totalfreedom.totalfreedommod.util.History;

@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Check name history of username.", usage = "/<command> <username>")
public class Command_namehistory extends FreedomCommand
{

@Override
public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
History.reportHistory(sender, args[0]);
return true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package me.totalfreedom.totalfreedommod.command;

import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;

@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Unloads chunks not currently in use", usage = "/<command>", aliases = "rc")
public class Command_unloadchunks extends FreedomCommand {

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
FUtil.adminAction(sender.getName(), "Unloading unused chunks", false);

int numChunks = 0;

for (World world : server.getWorlds()) {
numChunks += unloadUnusedChunks(world);
}

FUtil.playerMsg(sender, numChunks + " chunks unloaded.");
return true;
}

private int unloadUnusedChunks(World world) {
int numChunks = 0;

for (Chunk loadedChunk : world.getLoadedChunks()) {
if (!world.isChunkInUse(loadedChunk.getX(), loadedChunk.getZ())) {
if (world.unloadChunk(loadedChunk)) {
numChunks++;
}
}
}

return numChunks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public NanoHTTPD.Response getResponse()
}

// Admins
for (Admin admin : plugin.al.getAllAdmins().values())
for (Admin admin : plugin.al.getActiveAdmins())
{
final String username = admin.getName();

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/me/totalfreedom/totalfreedommod/util/FSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ public void run()
}.runTask(plugin);
}

public static void playerMsg(final CommandSender sender, final String message)
{
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
new BukkitRunnable()
{

@Override
public void run()
{
sender.sendMessage(message);
}

}.runTask(plugin);
}

public static void playerKick(final Player player, final String reason)
{
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
Expand Down
104 changes: 104 additions & 0 deletions src/main/java/me/totalfreedom/totalfreedommod/util/History.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package me.totalfreedom.totalfreedommod.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;

public class History
{

public static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

public static void reportHistory(final CommandSender sender, final String username)
{
new BukkitRunnable()
{
@Override
public void run()
{
UUID uuid = UUIDFetcher.fetch(username);
if (uuid != null)
{
Gson gson = new GsonBuilder().create();
String compactUuid = uuid.toString().replace("-", "");
try
{
URL url = new URL("https://api.mojang.com/user/profiles/" + compactUuid + "/names");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
FName[] oldNames = gson.fromJson(reader, FName[].class);
if (oldNames == null)
{
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
return;
}
reader.close();
conn.disconnect();
Arrays.sort(oldNames);
printHistory(sender, oldNames);
}
catch (Exception ex)
{
FSync.playerMsg(sender, ChatColor.RED + "Error, see logs for more details.");
FLog.severe(ex);
}
}
else
{
FSync.playerMsg(sender, ChatColor.RED + "Player not found!");
}
}
}.runTaskAsynchronously(TotalFreedomMod.plugin());
}

private static void printHistory(CommandSender sender, FName[] oldNames)
{
if (oldNames.length == 1)
{
FSync.playerMsg(sender, ChatColor.GREEN + oldNames[0].getName() + ChatColor.GOLD + " has never changed their name.");
return;
}
FSync.playerMsg(sender, ChatColor.GOLD + "Original name: " + ChatColor.GREEN + oldNames[0].getName());
for (int i = 1; i < oldNames.length; i++)
{
Date date = new Date(oldNames[i].getChangedToAt());
String formattedDate = df.format(date);
FSync.playerMsg(sender, ChatColor.BLUE + formattedDate + ChatColor.GOLD + " changed to " + ChatColor.GREEN + oldNames[i].getName());
}
}

private static class FName implements Comparable<FName>
{

private String name;
private long changedToAt;

@Override
public int compareTo(FName other)
{
return Long.compare(this.changedToAt, other.changedToAt);
}

public String getName()
{
return name;
}

public long getChangedToAt()
{
return changedToAt;
}
}
}
Loading