Refactor: tryClose() method
This commit is contained in:
parent
4e441493c1
commit
180998e5ca
@ -68,20 +68,8 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
tryClose(stream);
|
||||||
if (stream != null) {
|
tryClose(reader);
|
||||||
stream.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (reader != null) {
|
|
||||||
reader.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketsManager.init(this);
|
PacketsManager.init(this);
|
||||||
@ -149,24 +137,22 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
tryClose(input);
|
||||||
if (input != null) {
|
tryClose(reader);
|
||||||
input.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (reader != null) {
|
|
||||||
reader.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return toWrite;
|
return toWrite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void tryClose(Closeable input) {
|
||||||
|
if (input != null) {
|
||||||
|
try {
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume
|
* Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume
|
||||||
* for mob noises. As well as setting their watcher class and entity size.
|
* for mob noises. As well as setting their watcher class and entity size.
|
||||||
|
Loading…
Reference in New Issue
Block a user