Skip to content

Commit

Permalink
change dispozitions of all files
Browse files Browse the repository at this point in the history
  • Loading branch information
ZetaMap authored May 3, 2021
1 parent a7af05b commit 676216a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 24 deletions.
25 changes: 25 additions & 0 deletions src/main/java/functions/PlayerFunctions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package functions;

import mindustry.gen.Player;


public class PlayerFunctions {
public static void err(Player player, String fmt, Object... msg) {
player.sendMessage("[scarlet]Error: " + String.format(fmt, msg));
}
public static void info(Player player, String fmt, Object... msg) {
player.sendMessage("Info: " + String.format(fmt, msg));
}
public static void warn(Player player, String fmt, Object... msg) {
player.sendMessage("[gold]Warning: []" + String.format(fmt, msg));
}

//check the player if admin
public static boolean adminCheck(Player player) {
if(!player.admin()){
player.sendMessage("[scarlet]This command is only for admins!");
return false;
} else return true;
}

}
26 changes: 26 additions & 0 deletions src/main/java/functions/TempPlayerData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package functions;

import java.io.Serializable;
import java.util.HashMap;

@SuppressWarnings("serial")
public class TempPlayerData implements Serializable {
public static HashMap<String, TempPlayerData> tempPlayerDatas = new HashMap<>(); // uuid, data
public Integer hue;
public String realName;
public String nameNotSpace;
public String nameNotColor;
public int id;

public TempPlayerData(Integer hue, String name, int id){
this.hue = hue;
this.realName = name;
this.nameNotSpace = name.replaceAll("\\s+", "_");
this.nameNotColor = name.replaceAll("\\[", "[[");
this.id = id;
}
public void setHue(int i) {
this.hue = i;
}
}

34 changes: 10 additions & 24 deletions src/main/java/moreCommandsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Arrays;
import java.util.HashSet;

import arc.Core;
import arc.Events;
import arc.math.Mathf;
import arc.struct.ObjectMap;
Expand All @@ -32,12 +31,13 @@
import mindustry.gen.Player;
import mindustry.maps.Map;
import mindustry.mod.Plugin;
import mindustry.net.Administration.ChatFilter;
import mindustry.net.Administration.PlayerInfo;
import mindustry.net.NetConnection;
import mindustry.net.Packets.KickReason;
import mindustry.world.Block;
import mindustry.world.Tile;

import functions.PlayerFunctions;
import functions.TempPlayerData;


public class moreCommandsPlugin extends Plugin {
Expand All @@ -49,7 +49,7 @@ public class moreCommandsPlugin extends Plugin {
private boolean confirm = false, autoPause = false, tchat = true;

public void init() { netServer.admins.addChatFilter((player, message) -> null); } //delete the tchat
public moreCommandsPlugin() {
public moreCommandsPlugin() {
Events.on(PlayerJoin.class, e -> TempPlayerData.tempPlayerDatas.put(e.player.uuid(), new TempPlayerData(0, e.player.name, e.player.id))); // add player in TempPlayerData
Events.on(PlayerLeave.class, e -> TempPlayerData.tempPlayerDatas.remove(e.player.uuid())); // remove player in TempPlayerData

Expand Down Expand Up @@ -767,25 +767,11 @@ public void run() {
});
*/
}


public void err(Player player, String fmt, Object... msg) {
player.sendMessage("[scarlet]Error: " + String.format(fmt, msg));
}
public void info(Player player, String fmt, Object... msg) {
player.sendMessage("Info: " + String.format(fmt, msg));
}
public void warn(Player player, String fmt, Object... msg) {
player.sendMessage("[gold]Warning: []" + String.format(fmt, msg));
}

//check the player if admin
public boolean adminCheck(Player player) {
if(!player.admin()){
player.sendMessage("[scarlet]This command is only for admins!");
return false;
} else return true;
}

private void err(Player player, String fmt, Object... msg) { PlayerFunctions.err(player, fmt, msg); }
private void info(Player player, String fmt, Object... msg) { PlayerFunctions.info(player, fmt, msg); }
private void warn(Player player, String fmt, Object... msg) { PlayerFunctions.warn(player, fmt, msg); }
private boolean adminCheck(Player player) { return PlayerFunctions.adminCheck(player); }

//search a possible team
private Team getPosTeam(Player p){
Expand Down Expand Up @@ -818,4 +804,4 @@ public coreTeamReturn(Team _t){
}
}

}
}

0 comments on commit 676216a

Please sign in to comment.