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

replacing all System.out.println statements with Bukkit.getLogger().info #99

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import org.apache.tools.ant.filters.ReplaceTokens

buildscript {
repositories {
jcenter()
gradlePluginPortal()
}

dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:5.1.0'
classpath 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
}
}

Expand All @@ -32,11 +32,11 @@ allprojects {
}
maven {
// WorldEdit
url = 'http://maven.sk89q.com/repo/'
url = 'https://maven.enginehub.org/repo/'
}
maven {
// ProtocolLib
url "http://repo.dmulloy2.net/nexus/repository/public/"
url "https://repo.dmulloy2.net/repository/public/"
}
// PaperLib
maven {
Expand All @@ -52,7 +52,7 @@ allprojects {
}

processResources {
from(sourceSets.main.resources.srcDirs) {
filesMatching("plugin.yml") {
filter ReplaceTokens, tokens: [version: version]
}
}
Expand All @@ -69,18 +69,18 @@ dependencies {
//shadow 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
shadow 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
shadow 'com.github.MilkBowl:VaultAPI:1.7'
shadow 'net.wesjd:anvilgui:1.5.3-SNAPSHOT'
compile name: 'BiomeMapping-1.3'
compile "io.papermc:paperlib:1.0.5"
shadow 'com.comphenix.protocol:ProtocolLib:4.4.0'
compile project('Support-WorldEdit-6')
compile project('Support-WorldEdit-7')
implementation 'net.wesjd:anvilgui:1.5.3-SNAPSHOT'
implementation name: 'BiomeMapping-1.3'
implementation "io.papermc:paperlib:1.0.5"
shadow 'com.comphenix.protocol:ProtocolLib:4.7.0'
implementation project('Support-WorldEdit-6')
implementation project('Support-WorldEdit-7')
}

shadowJar {
classifier = ''
configurations = [project.configurations.compile]
relocate 'io.papermc.lib', 'com.gmail.val59000mc.paperlib'
relocate 'net.wesjd.anvilgui', 'com.gmail.val59000mc.anvilgui'
}

build.dependsOn(shadowJar)
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void loadKits(){
// IllegalArgumentException, Thrown by builder.build() when kit has no items.
}catch(ParseException | IllegalArgumentException ex){
Bukkit.getLogger().severe("[UhcCore] Kit "+kitKey+" was disabled because of an error of syntax.");
System.out.println(ex.getMessage());
Bukkit.getLogger().severe(ex.getMessage());
ex.printStackTrace();
}
}
Expand Down
48 changes: 0 additions & 48 deletions src/main/java/com/gmail/val59000mc/game/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -175,53 +174,6 @@ public void setGameState(GameState gameState){

// Call UhcGameStateChangedEvent
Bukkit.getPluginManager().callEvent(new UhcGameStateChangedEvent(oldGameState, gameState));

// Update MOTD
switch(gameState){
case ENDED:
setMotd(Lang.DISPLAY_MOTD_ENDED);
break;
case LOADING:
setMotd(Lang.DISPLAY_MOTD_LOADING);
break;
case DEATHMATCH:
setMotd(Lang.DISPLAY_MOTD_PLAYING);
break;
case PLAYING:
setMotd(Lang.DISPLAY_MOTD_PLAYING);
break;
case STARTING:
setMotd(Lang.DISPLAY_MOTD_STARTING);
break;
case WAITING:
setMotd(Lang.DISPLAY_MOTD_WAITING);
break;
default:
setMotd(Lang.DISPLAY_MOTD_ENDED);
break;
}
}

private void setMotd(String motd){
if (config.get(MainConfig.DISABLE_MOTD)){
return; // No motd support
}

if (motd == null){
return; // Failed to load lang.yml so motd is null.
}

try {
Class<?> craftServerClass = NMSUtils.getNMSClass("CraftServer");
Object craftServer = craftServerClass.cast(Bukkit.getServer());
Object dedicatedPlayerList = NMSUtils.getHandle(craftServer);
Object dedicatedServer = NMSUtils.getServer(dedicatedPlayerList);

Method setMotd = NMSUtils.getMethod(dedicatedServer.getClass(), "setMotd");
setMotd.invoke(dedicatedServer, motd);
}catch (ReflectiveOperationException | NullPointerException ex){
ex.printStackTrace();
}
}

public void loadNewGame() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public void execute(Listener listener, Event event){
return;
}

System.out.println("event!");

if (type == Type.ACHIEVEMENTS){
addHeart(((PlayerEvent) event).getPlayer());
}else{
Expand Down Expand Up @@ -113,7 +111,6 @@ private void addHeart(Player player){
private static boolean isValidAdvancement(PlayerEvent event){
org.bukkit.event.player.PlayerAdvancementDoneEvent advancementEvent = (org.bukkit.event.player.PlayerAdvancementDoneEvent) event;
NamespacedKey key = advancementEvent.getAdvancement().getKey();
System.out.println(key.getKey());
return key.getKey().startsWith("story/");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gmail.val59000mc.scenarios.ScenarioListener;
import com.gmail.val59000mc.utils.RandomUtils;
import com.gmail.val59000mc.utils.VersionUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -51,7 +52,7 @@ private void addHeroesEffect(UhcPlayer uhcPlayer, int effect){
player.setHealth(maxHealth);
break;
default:
System.out.println("No effect for: " + effect);
Bukkit.getLogger().info("No effect for: " + effect);
break;
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/gmail/val59000mc/utils/NMSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ public static Object getHandle(Object craftObject){
}
}

@Nullable
public static Object getServer(Object o){
try{
return getMethod(o.getClass(), "getServer").invoke(o);
}catch (ReflectiveOperationException | IllegalArgumentException ex){
return null;
}
}

public static Method getMethod(Class<?> c, String name) throws ReflectiveOperationException{
return getMethod(c, name, -1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void removeRecipe(ItemStack item, Recipe r){
Recipe recipe = (Recipe) toBukkitRecipe.invoke(value);

if (recipe.getResult().isSimilar(item)){
System.out.println("Found recipe in map! Removing ...");
Bukkit.getLogger().info("Found recipe in map! Removing ...");
map.remove(value);
break;
}
Expand All @@ -227,7 +227,7 @@ public void removeRecipe(ItemStack item, Recipe r){

Recipe recipe = (Recipe) toBukkitRecipe.invoke(mcRecipe);
if (recipe.getResult().isSimilar(item)){
System.out.println("Found recipe in array! Removing ...");
Bukkit.getLogger().info("Found recipe in array! Removing ...");
array[i] = null;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: UhcCore
main: com.gmail.val59000mc.UhcCore
version: @version@
version: "@version@"
description: Automates UHC games on a dedicated server
author: val59000mc, Mezy
softdepend: [WorldEdit,Vault,ProtocolLib]
Expand Down